[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 489e59e61c 08/12: Move denote-keywords-{add, re
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote 489e59e61c 08/12: Move denote-keywords-{add, remove} where the renaming commands are |
Date: |
Thu, 15 Feb 2024 00:58:21 -0500 (EST) |
branch: externals/denote
commit 489e59e61cf93d3dbd3ab574b1ff187c22e758ca
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Move denote-keywords-{add,remove} where the renaming commands are
---
denote.el | 124 +++++++++++++++++++++++++++++++-------------------------------
1 file changed, 63 insertions(+), 61 deletions(-)
diff --git a/denote.el b/denote.el
index 2d8b06e10f..a197b133f5 100644
--- a/denote.el
+++ b/denote.el
@@ -2386,67 +2386,6 @@ note's actual title. At the `denote-file-prompt' type
(find-file target)
(denote--command-with-features (denote-command-prompt)
:use-file-prompt-as-def-title nil nil nil))))
-;;;###autoload
-(defun denote-keywords-add (keywords)
- "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)))
- ;; 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))
- ((denote-file-is-note-p file))
- (file-type (denote-filetype-heuristics file)))
- (let* ((cur-keywords (denote-retrieve-front-matter-keywords-value file
file-type))
- (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 :auto-confirm)
- (when denote-rename-no-confirm (save-buffer))
- (run-hooks 'denote-after-rename-file-hook))
- (user-error "Buffer not visiting a Denote file")))
-
-(defun denote--keywords-delete-prompt (keywords)
- "Prompt for one or more KEYWORDS.
-In the case of multiple entries, those are separated by the
-`crm-sepator', which typically is a comma. In such a case, the
-output is sorted with `string-collate-lessp'."
- (let ((choice (denote--keywords-crm keywords "Keywords to remove")))
- (if denote-sort-keywords
- (sort choice #'string-collate-lessp)
- choice)))
-
-;;;###autoload
-(defun denote-keywords-remove ()
- "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."
- (declare (interactive-only t))
- (interactive)
- (if-let ((file (buffer-file-name))
- ((denote-file-is-note-p file))
- (file-type (denote-filetype-heuristics file)))
- (when-let ((cur-keywords (denote-retrieve-front-matter-keywords-value
file file-type))
- (del-keyword (denote--keywords-delete-prompt cur-keywords)))
- (denote-rewrite-keywords
- file
- (seq-difference cur-keywords del-keyword)
- file-type)
- (denote-rename-file-using-front-matter file :auto-confirm)
- (when denote-rename-no-confirm (save-buffer))9
- (run-hooks 'denote-after-rename-file-hook))
- (user-error "Buffer not visiting a Denote file")))
-
;;;; Note modification
;;;;; Common helpers for note modifications
@@ -3001,6 +2940,69 @@ cannot know if they have front matter and what that may
be."
(denote-update-dired-buffers))
(user-error "No marked Denote files; aborting")))
+;;;;;; Interactively modify keywords and rename accordingly
+
+;;;###autoload
+(defun denote-keywords-add (keywords)
+ "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)))
+ ;; 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))
+ ((denote-file-is-note-p file))
+ (file-type (denote-filetype-heuristics file)))
+ (let* ((cur-keywords (denote-retrieve-front-matter-keywords-value file
file-type))
+ (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 :auto-confirm)
+ (when denote-rename-no-confirm (save-buffer))
+ (run-hooks 'denote-after-rename-file-hook))
+ (user-error "Buffer not visiting a Denote file")))
+
+(defun denote--keywords-delete-prompt (keywords)
+ "Prompt for one or more KEYWORDS.
+In the case of multiple entries, those are separated by the
+`crm-sepator', which typically is a comma. In such a case, the
+output is sorted with `string-collate-lessp'."
+ (let ((choice (denote--keywords-crm keywords "Keywords to remove")))
+ (if denote-sort-keywords
+ (sort choice #'string-collate-lessp)
+ choice)))
+
+;;;###autoload
+(defun denote-keywords-remove ()
+ "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."
+ (declare (interactive-only t))
+ (interactive)
+ (if-let ((file (buffer-file-name))
+ ((denote-file-is-note-p file))
+ (file-type (denote-filetype-heuristics file)))
+ (when-let ((cur-keywords (denote-retrieve-front-matter-keywords-value
file file-type))
+ (del-keyword (denote--keywords-delete-prompt cur-keywords)))
+ (denote-rewrite-keywords
+ file
+ (seq-difference cur-keywords del-keyword)
+ file-type)
+ (denote-rename-file-using-front-matter file :auto-confirm)
+ (when denote-rename-no-confirm (save-buffer))9
+ (run-hooks 'denote-after-rename-file-hook))
+ (user-error "Buffer not visiting a Denote file")))
+
;;;;; Creation of front matter
;;;###autoload
- [elpa] externals/denote updated (127c9a38a8 -> b82da20d5d), ELPA Syncer, 2024/02/15
- [elpa] externals/denote edac33337c 01/12: Avoid keeping opened buffers in `denote-link-return-links`, ELPA Syncer, 2024/02/15
- [elpa] externals/denote 13a64f7709 02/12: Merge branch 'protesilaos:main' into main, ELPA Syncer, 2024/02/15
- [elpa] externals/denote 2f122d374f 03/12: Merge pull request #252 from mattyonweb/main, ELPA Syncer, 2024/02/15
- [elpa] externals/denote f978dd746d 04/12: Acknowledge mattyonweb for commit edac333, ELPA Syncer, 2024/02/15
- [elpa] externals/denote 969367db4b 06/12: Update the documentation of the user option denote-rename-no-confirm, ELPA Syncer, 2024/02/15
- [elpa] externals/denote 1646c43bc3 05/12: Make denote-keywords-{add, remove} honour denote-rename-no-confirm, ELPA Syncer, 2024/02/15
- [elpa] externals/denote 6035d777cd 07/12: Update the documentation of denote-after-new-note-hook, ELPA Syncer, 2024/02/15
- [elpa] externals/denote 489e59e61c 08/12: Move denote-keywords-{add, remove} where the renaming commands are,
ELPA Syncer <=
- [elpa] externals/denote 5a53344bbd 09/12: Make denote-save-buffer-after-creation a user option and document it, ELPA Syncer, 2024/02/15
- [elpa] externals/denote 79e5ec02d3 11/12: Update the documentation of denote-keywords-{add,remove}; group as "rename", ELPA Syncer, 2024/02/15
- [elpa] externals/denote b82da20d5d 12/12: Clarify that all convenience commands append to the denote-prompts, ELPA Syncer, 2024/02/15
- [elpa] externals/denote c6ef5ec335 10/12: Define aliases for denote-keywords-{add, remove}, ELPA Syncer, 2024/02/15