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

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

[elpa] externals/denote 3f51ba3b79 03/14: Rework denote--only-note-p


From: ELPA Syncer
Subject: [elpa] externals/denote 3f51ba3b79 03/14: Rework denote--only-note-p
Date: Sat, 9 Jul 2022 02:57:36 -0400 (EDT)

branch: externals/denote
commit 3f51ba3b79fbadaa5f1193e4a534511ef7f99cdf
Author: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>
Commit: Jean-Philippe Gagné Guay <jeanphilippe150@gmail.com>

    Rework denote--only-note-p
    
    A file is a Denote note if it starts with an id and ends with a
    supported extension.
---
 denote.el | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/denote.el b/denote.el
index f971fb4e6a..dd9e484469 100644
--- a/denote.el
+++ b/denote.el
@@ -242,6 +242,9 @@ are described in the doc string of `format-time-string'."
 (defconst denote--keywords-regexp "__\\([0-9A-Za-z_-]*\\)"
   "Regular expression to match keywords.")
 
+(defconst denote--extension-regexp "\\.\\(org\\|md\\|txt\\)"
+  "Regular expression to match supported Denote extensions.")
+
 (defconst denote--file-title-regexp
   (concat denote--id-regexp "\\(--\\)\\(.*\\)\\(__\\)")
   "Regular expression to match file names from `denote'.")
@@ -250,10 +253,6 @@ are described in the doc string of `format-time-string'."
   (concat denote--file-title-regexp "\\([0-9A-Za-z_-]*\\)\\(\\.?.*\\)")
   "Regular expression to match the entire file name'.")
 
-(defconst denote--file-only-note-regexp
-  (concat denote--file-regexp "\\.\\(org\\|md\\|txt\\)")
-  "Regular expression to match the entire file name of a note file.")
-
 (defconst denote--punctuation-regexp "[][{}!@#$%^&*()_=+'\"?,.\|;:~`‘’“”/]*"
   "Regular expression of punctionation that should be removed.
 We consider those characters illigal for our purposes.")
@@ -321,10 +320,13 @@ trailing hyphen."
 (defun denote--only-note-p (file)
   "Make sure FILE is an actual Denote note.
 FILE is relative to the variable `denote-directory'."
-  (and (not (file-directory-p file))
-       (file-regular-p file)
-       (string-match-p denote--file-only-note-regexp file)
-       (not (string-match-p "[#~]\\'" file))))
+  (let ((file-name (file-name-nondirectory file)))
+    (and (not (file-directory-p file))
+         (file-regular-p file)
+         (string-match-p (concat "\\`" denote--id-regexp
+                                 ".*" denote--extension-regexp "\\'")
+                         file-name)
+         (not (string-match-p "[#~]\\'" file)))))
 
 (defun denote--file-name-relative-to-denote-directory (file)
   "Return file name of FILE relative to the variable `denote-directory'.



reply via email to

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