emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/denote 8a8be90200 1/9: Relax conditionality for adding


From: ELPA Syncer
Subject: [elpa] externals/denote 8a8be90200 1/9: Relax conditionality for adding links
Date: Sat, 13 Aug 2022 03:57:29 -0400 (EDT)

branch: externals/denote
commit 8a8be90200bb90edff5149cd7153c40536864a5e
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Relax conditionality for adding links
    
    The idea is to be able to create a 'denote:' link to any file that has a
    Denote identifier and is in the 'denote-directory'.
    
    There still are some refinements to be made, though they belong to
    separate commits.
    
    Thanks to Peter Prevos for discussing this on the mailing list:
    <https://lists.sr.ht/~protesilaos/denote/%3C87fsi1m5ze.fsf@prevos.net%3E>.
---
 denote.el | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/denote.el b/denote.el
index 59ed2ad722..76cc843914 100644
--- a/denote.el
+++ b/denote.el
@@ -446,6 +446,11 @@ trailing hyphen."
          ;; Can this ever be t given the above?
          (not (string-match-p "[#~]\\'" file)))))
 
+(defun denote--file-has-identifier-p (file)
+  "Return non-nil if FILE has a Denote identifier."
+  (let ((file-name (file-name-nondirectory file)))
+    (string-match-p denote--id-regexp (format "\\`%s" file-name))))
+
 (defun denote--file-supported-extension-p (file)
   "Return non-nil if FILE has supported extension."
   (string-match-p (format "%s\\(.gpg\\)?\\'" denote--extension-regexp) file))
@@ -494,11 +499,11 @@ FILE must be an absolute path."
 
 (defun denote--directory-files-matching-regexp (regexp)
   "Return list of files matching REGEXP.
-The match is performed against the file name relative to the
-variable `denote-directory'."
+Files are those which satisfy `denote--file-has-identifier-p' and
+`denote--file-name-relative-to-denote-directory'."
   (seq-filter
    (lambda (f)
-     (and (denote--only-note-p f)
+     (and (denote--file-has-identifier-p f)
           (string-match-p regexp 
(denote--file-name-relative-to-denote-directory f))))
    (denote--directory-files)))
 
@@ -632,7 +637,7 @@ If optional KEY is non-nil, return the key instead."
   "Prompt for regular file in variable `denote-directory'."
   (read-file-name "Select note: " (denote-directory) nil nil nil
                   (lambda (f)
-                    (or (denote--only-note-p f)
+                    (or (denote--file-has-identifier-p f)
                         (file-directory-p f)))))
 
 (defun denote--retrieve-files-in-output (files)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]