branch: externals/denote commit 18f92264db57ce48a93d20ffb506da2474d996ff Author: Jean-Philippe Gagné Guay <jeanphilippe...@gmail.com> Commit: Jean-Philippe Gagné Guay <jeanphilippe...@gmail.com>
Make parameters of denote--rename-file accept a keep-current symbol --- README.org | 11 ++++++++--- denote.el | 19 +++++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/README.org b/README.org index 01d2dcfb43..1bd82c7551 100644 --- a/README.org +++ b/README.org @@ -1490,9 +1490,14 @@ separated by a comma, else the ~crm-separator~). For all prompts, the ~denote-rename-file~ interprets an empty input as an instruction to remove that file name component. For example, if a =TITLE= prompt is available and =FILE= is =20240211T093531--some-title__keyword1.org= -then it renames =FILE= to =20240211T093531__keyword1.org=. If a file -name component is present, but there is no entry for it in -~denote-prompts~, keep it as-is. +then it renames =FILE= to =20240211T093531__keyword1.org=. + +In interactive use, if there is no entry for a file name +component in `denote-prompts', keep it as-is. + +When called from Lisp, the special symbol `keep-current' can be +used for the TITLE, KEYWORDS, SIGNATURE and DATE parameters to +keep them as-is. [ NOTE: Please check with your minibuffer user interface how to provide an empty input. The Emacs default setup accepts the empty diff --git a/denote.el b/denote.el index 8986301a00..4f833ad725 100644 --- a/denote.el +++ b/denote.el @@ -2980,7 +2980,9 @@ If `denote-rename-confirmations' does not contain "Rename FILE according to the other parameters. Parameters TITLE, KEYWORDS, SIGNATURE and DATE are as described in `denote-rename-file' and are assumed to be valid (TITLE and -SIGNATURE are strings, KEYWORDS is a list, etc.). +SIGNATURE are strings, KEYWORDS is a list, etc.). The special +symbol `keep-current' can be used for the TITLE, KEYWORDS, +SIGNATURE and DATE parameters to keep the current value. This function only does the work necessary to rename a file according to its parameters. In particular, it does not prompt @@ -2994,7 +2996,12 @@ Respect `denote-rename-confirmations', `denote-save-buffers' and (file-type (denote-filetype-heuristics file)) (current-title (or (denote-retrieve-front-matter-title-value file file-type) "")) (current-keywords (denote-extract-keywords-from-path file)) - (keywords (denote-keywords-sort keywords)) + (current-signature (or (denote-retrieve-filename-signature file) "")) + (title (if (eq title 'keep-current) current-title title)) + (keywords (if (eq keywords 'keep-current) current-keywords (denote-keywords-sort keywords))) + (signature (if (eq signature 'keep-current) current-signature signature)) + ;; 'keep-current is the same as nil because we do not currently allow the modification of the identifier + (date (if (eq date 'keep-current) nil date)) (directory (file-name-directory file)) (extension (file-name-extension file :include-period)) ;; TODO: For now, we cannot change the identifier. We retrieve @@ -3118,8 +3125,12 @@ remove that file name component. For example, if a TITLE prompt is available and FILE is 20240211T093531--some-title__keyword1.org then rename FILE to 20240211T093531__keyword1.org. -If a file name component is present, but there is no entry for it in -`denote-prompts', keep it as-is. +In interactive use, if there is no entry for a file name +component in `denote-prompts', keep it as-is. + +When called from Lisp, the special symbol `keep-current' can be +used for the TITLE, KEYWORDS, SIGNATURE and DATE parameters to +keep them as-is. [ NOTE: Please check with your minibuffer user interface how to provide an empty input. The Emacs default setup accepts the