[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote bcdae9266a 1/2: Make denote-dired-rename-marked-
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote bcdae9266a 1/2: Make denote-dired-rename-marked-files-with-keywords respect denote-rename-no-confirm |
Date: |
Wed, 14 Feb 2024 09:57:57 -0500 (EST) |
branch: externals/denote
commit bcdae9266ae4649992c9b54e66da8d65969aba37
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Make denote-dired-rename-marked-files-with-keywords respect
denote-rename-no-confirm
---
README.org | 24 +++++++++++++++---------
denote.el | 21 ++++++++++++++-------
2 files changed, 29 insertions(+), 16 deletions(-)
diff --git a/README.org b/README.org
index a23bebb00f..2ad7842e1b 100644
--- a/README.org
+++ b/README.org
@@ -1356,6 +1356,9 @@ check the command
~denote-dired-rename-marked-files-with-keywords~.
:CUSTOM_ID: h:f365ff7e-2140-4e14-a92f-666ae97382a4
:END:
+[ Revised as part of {{{development-version}}} to honour the value of
+ the user option ~denote-prompts~ where that makes sense
([[#h:f9204f1f-fcee-49b1-8081-16a08a338099][The ~denote-prompts~ option]]). ]
+
#+findex: denote-dired-rename-marked-files-with-keywords
The ~denote-dired-rename-marked-files-with-keywords~ command renames
marked files in Dired to conform with our file-naming scheme. It does
@@ -1380,11 +1383,12 @@ so by writing keywords to them. Specifically, it does
the following:
is recognized as a Denote note (per the ~denote-file-type~ user
option), such that it includes the new keywords.
-[ Note that the affected buffers are not saved. Users can thus check
- them to confirm that the new front matter does not cause any
- problems (e.g. with the ~diff-buffer-with-file~ command). Multiple
- buffers can be saved in one go with ~save-some-buffers~ (read its
- doc string). ]
+[ Note that the affected buffers are not saved, unless the user option
+ ~denote-rename-no-confirm~ is non-nil. Users can thus check them to
+ confirm that the new front matter does not cause any problems (e.g.
+ with the ~diff-buffer-with-file~ command). Multiple buffers can be
+ saved in one go with the command ~save-some-buffers~ (read its doc
+ string). ]
** Rename multiple files based on their front matter
:PROPERTIES:
@@ -4254,11 +4258,13 @@ might change them without further notice.
#+findex: denote-rewrite-keywords
+ Function ~denote-rewrite-keywords~ :: Rewrite =KEYWORDS= in =FILE=
- outright according to =FILE-TYPE=. Do the same as
+ outright according to =FILE-TYPE=. Do the same as
~denote-rewrite-front-matter~ for keywords, but do not ask for
- confirmation. This is for use in ~denote-keywords-add~,
- ~denote-keywords-remove~, ~denote-dired-rename-marked-files-with-keywords~,
- or related.
+ confirmation. With optional =SAVE-BUFFER=, save the buffer
+ corresponding to =FILE=. This function is for use in the commands
+ ~denote-keywords-add~, ~denote-keywords-remove~,
+ ~denote-dired-rename-files~, or related. [ The =SAVE-BUFFER= saves
+ the buffer as part of {{{development-version}}}. ]
#+findex: denote-update-dired-buffers
+ Function ~denote-update-dired-buffers~ :: Update Dired buffers of
diff --git a/denote.el b/denote.el
index 3ab4a57896..cac2b857e1 100644
--- a/denote.el
+++ b/denote.el
@@ -2535,14 +2535,17 @@ contains a title line, a keywords line or both."
(denote--regexp-in-file-p (denote--title-key-regexp file-type) file)
(denote--regexp-in-file-p (denote--keywords-key-regexp file-type)
file)))
-(defun denote-rewrite-keywords (file keywords file-type)
+(defun denote-rewrite-keywords (file keywords file-type &optional save-buffer)
"Rewrite KEYWORDS in FILE outright according to FILE-TYPE.
Do the same as `denote-rewrite-front-matter' for keywords,
but do not ask for confirmation.
-This is for use in `denote-keywords-add',`denote-keywords-remove',
-`denote-dired-rename-files', or related."
+With optional SAVE-BUFFER, save the buffer corresponding to FILE.
+
+This function is for use in the commands `denote-keywords-add',
+`denote-keywords-remove', `denote-dired-rename-files', or
+related."
(with-current-buffer (find-file-noselect file)
(save-excursion
(save-restriction
@@ -2551,7 +2554,8 @@ This is for use in
`denote-keywords-add',`denote-keywords-remove',
(when (re-search-forward (denote--keywords-key-regexp file-type) nil t
1)
(goto-char (line-beginning-position))
(insert (denote--get-keywords-line-from-front-matter keywords
file-type))
- (delete-region (point) (line-end-position)))))))
+ (delete-region (point) (line-end-position))
+ (when save-buffer (save-buffer)))))))
(define-obsolete-function-alias
'denote--rewrite-keywords
@@ -2867,7 +2871,10 @@ Specifically, do the following:
it is recognized as a Denote note (per `denote-file-type'),
such that it includes the new keywords.
-[ Note that the affected buffers are not saved. Users can thus
+Run the `denote-after-rename-file-hook' after renaming is done.
+
+[ Note that the affected buffers are not saved, unless the user
+ option `denote-rename-no-confirm' is non-nil. Users can thus
check them to confirm that the new front matter does not cause
any problems (e.g. with the `diff-buffer-with-file' command).
Multiple buffers can be saved in one go with the command
@@ -2891,8 +2898,8 @@ Specifically, do the following:
(denote-rename-file-and-buffer file new-name)
(when (denote-file-is-writable-and-supported-p new-name)
(if (denote--edit-front-matter-p new-name file-type)
- (denote-rewrite-keywords new-name keywords file-type)
- (denote--add-front-matter new-name title keywords id
file-type)))
+ (denote-rewrite-keywords new-name keywords file-type
denote-rename-no-confirm)
+ (denote--add-front-matter new-name title keywords id file-type
denote-rename-no-confirm)))
(when used-ids
(puthash id t used-ids))))
(denote-update-dired-buffers))