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

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

[elpa] externals/denote ae53d463ad 4/4: Make denote-keywords-{add, remov


From: ELPA Syncer
Subject: [elpa] externals/denote ae53d463ad 4/4: Make denote-keywords-{add, remove} accept an optional SAVE-BUFFER argument
Date: Thu, 15 Feb 2024 03:58:04 -0500 (EST)

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

    Make denote-keywords-{add,remove} accept an optional SAVE-BUFFER argument
---
 README.org |  6 ++++--
 denote.el  | 30 ++++++++++++++++++++----------
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/README.org b/README.org
index 8215e076e5..9b7fa3865d 100644
--- a/README.org
+++ b/README.org
@@ -1489,8 +1489,10 @@ accordingly.
 
 [ The following are part of {{{development-version}}}. ]
 
-Both commands will automatically save the buffer if the user option
-~denote-rename-no-confirm~ is set to a non-nil value 
([[#h:a2ae9090-c49e-4b32-bcf5-eb8944241fd7][The ~denote-rename-no-confirm~ 
option]]).
+Both commands accept an optional prefix argument to automatically save
+the buffer. Similarly, they both interpret a non-nil value for the
+user option ~denote-rename-no-confirm~ the same as the prefix argument
+([[#h:a2ae9090-c49e-4b32-bcf5-eb8944241fd7][The ~denote-rename-no-confirm~ 
option]]).
 
 #+findex: denote-rename-add-keywords
 #+findex: denote-rename-remove-keywords
diff --git a/denote.el b/denote.el
index b58c59d11f..631d4b64b2 100644
--- a/denote.el
+++ b/denote.el
@@ -2971,16 +2971,21 @@ cannot know if they have front matter and what that may 
be."
 ;;;;;; Interactively modify keywords and rename accordingly
 
 ;;;###autoload
-(defun denote-keywords-add (keywords)
+(defun denote-keywords-add (keywords &optional save-buffer)
   "Prompt for KEYWORDS to add to the current note's front matter.
 When called from Lisp, KEYWORDS is a list of strings.
 
 Rename the file without further prompt so that its name reflects
 the new front matter, per `denote-rename-file-using-front-matter'.
 
-If the user option `denote-rename-no-confirm' is non-nil, save
-the buffer.  Otherwise, leave it unsaved for further review."
-  (interactive (list (denote-keywords-prompt)))
+With an optional SAVE-BUFFER (such as a prefix argument when
+called interactively), save the buffer outright.  Otherwise leave
+the buffer unsaved for further review.
+
+If the user option `denote-rename-no-confirm' is non-nil,
+interpret it the same way as SAVE-BUFFER, making SAVE-BUFFER
+reduntant."
+  (interactive (list (denote-keywords-prompt) current-prefix-arg))
   ;; A combination of if-let and let, as we need to take into account
   ;; the scenario in which there are no keywords yet.
   (if-let ((file (buffer-file-name))
@@ -2990,7 +2995,7 @@ the buffer.  Otherwise, leave it unsaved for further 
review."
              (new-keywords (denote-keywords-sort
                             (seq-uniq (append keywords cur-keywords)))))
         (denote-rewrite-keywords file new-keywords file-type)
-        (denote-rename-file-using-front-matter file :no-confirm 
denote-rename-no-confirm)
+        (denote-rename-file-using-front-matter file :no-confirm (or 
denote-rename-no-confirm save-buffer))
         (run-hooks 'denote-after-rename-file-hook))
     (user-error "Buffer not visiting a Denote file")))
 
@@ -3008,17 +3013,22 @@ output is sorted with `string-collate-lessp'."
       choice)))
 
 ;;;###autoload
-(defun denote-keywords-remove ()
+(defun denote-keywords-remove (&optional save-buffer)
   "Prompt for keywords in current note and remove them.
 Keywords are retrieved from the file's front matter.
 
 Rename the file without further prompt so that its name reflects
 the new front matter, per `denote-rename-file-using-front-matter'.
 
-If the user option `denote-rename-no-confirm' is non-nil, save
-the buffer.  Otherwise, leave it unsaved for further review."
+With an optional SAVE-BUFFER as a prefix argument, save the
+buffer outright.  Otherwise leave the buffer unsaved for further
+review.
+
+If the user option `denote-rename-no-confirm' is non-nil,
+interpret it the same way as SAVE-BUFFER, making SAVE-BUFFER
+reduntant."
   (declare (interactive-only t))
-  (interactive)
+  (interactive "P")
   (if-let ((file (buffer-file-name))
            ((denote-file-is-note-p file))
            (file-type (denote-filetype-heuristics file)))
@@ -3028,7 +3038,7 @@ the buffer.  Otherwise, leave it unsaved for further 
review."
          file
          (seq-difference cur-keywords del-keyword)
          file-type)
-        (denote-rename-file-using-front-matter file :no-confirm 
denote-rename-no-confirm)
+        (denote-rename-file-using-front-matter file :no-confirm (or 
denote-rename-no-confirm save-buffer))
         (run-hooks 'denote-after-rename-file-hook))
     (user-error "Buffer not visiting a Denote file")))
 



reply via email to

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