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

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

[elpa] externals/denote 6438bc7965 3/7: Check buffer file names in denot


From: ELPA Syncer
Subject: [elpa] externals/denote 6438bc7965 3/7: Check buffer file names in denote--id-exists-p
Date: Mon, 18 Jul 2022 01:57:39 -0400 (EDT)

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

    Check buffer file names in denote--id-exists-p
    
    Add function denote--buffer-file-names
---
 denote.el | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/denote.el b/denote.el
index 8eb5e2ebb5..c87f5aa141 100644
--- a/denote.el
+++ b/denote.el
@@ -825,6 +825,19 @@ is set to \\'(file-type title keywords)."
   "Return DATE if parsed by `date-to-time', else signal error."
   (date-to-time date))
 
+(defun denote--buffer-file-names ()
+  "Return file names of active buffers."
+  (mapcar
+   (lambda (name)
+     (file-name-nondirectory name))
+   (delq nil
+         (mapcar
+          (lambda (buf)
+            (buffer-file-name buf))
+          (buffer-list)))))
+
+(declare-function cl-some "cl-extra" (cl-pred cl-seq &rest cl-rest))
+
 ;; This should only be relevant for `denote-date', otherwise the
 ;; identifier is always unique (we trust that no-one writes multiple
 ;; notes within fractions of a second).
@@ -832,7 +845,11 @@ is set to \\'(file-type title keywords)."
   "Return non-nil if IDENTIFIER already exists.
 NO-CHECK-CURRENT passes the appropriate flag to
 `denote--directory-files-matching-regexp'."
-  (denote--directory-files-matching-regexp identifier no-check-current))
+  (or (cl-some (lambda (file)
+                 (string-match-p (concat "\\`" identifier) file))
+               (denote--buffer-file-names))
+      (denote--directory-files-matching-regexp
+       (concat "\\`" identifier) no-check-current)))
 
 (defun denote--barf-duplicate-id (identifier)
   "Throw a user-error if IDENTIFIER already exists else return t."



reply via email to

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