branch: externals/denote
commit b89d30de21c23de71f360b012a66481ed552f05f
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>

    Try a simpler implementation of denote--file-has-backlinks-p
    
    I discussed this with Yann Dutrieux in the follow-up to pull request
    637: <https://github.com/protesilaos/denote/pull/637>.
---
 denote.el | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/denote.el b/denote.el
index e6628f19fb..e6b90c05ce 100644
--- a/denote.el
+++ b/denote.el
@@ -6045,17 +6045,11 @@ Also see `denote-get-links'."
               (files (denote-directory-files nil :omit-current :text-only)))
     (catch 'has-backlinks
       (dolist (file files)
-        (when-let* ((file-type (denote-filetype-heuristics file))
-                    (link-regexp (denote--link-in-context-regexp file-type)))
-          (with-temp-buffer
-            (insert-file-contents file)
-            (goto-char (point-min))
-            (while (re-search-forward link-regexp nil t)
-              (when
-                  (string-equal
-                   (caar (denote--inside-link-regexp-p link-regexp (point)))
-                   id)
-                (throw 'has-backlinks t)))))))))
+        (with-temp-buffer
+          (insert-file-contents file)
+          (goto-char (point-min))
+          (when (search-forward (format "[denote:%s]" id) nil t)
+            (throw 'has-backlinks t)))))))
 
 ;;;###autoload
 (defun denote-find-backlink ()

Reply via email to