[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 1c772c4430 4/4: Make denote-rewrite-front-matter
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote 1c772c4430 4/4: Make denote-rewrite-front-matter accept optional NO-CONFIRM |
Date: |
Fri, 20 Oct 2023 00:58:02 -0400 (EDT) |
branch: externals/denote
commit 1c772c44305d3d052792dd3eb47e95e2348e99c3
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Make denote-rewrite-front-matter accept optional NO-CONFIRM
---
README.org | 5 ++++-
denote.el | 21 +++++++++++++--------
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/README.org b/README.org
index 2e3241f9f2..fb275244d6 100644
--- a/README.org
+++ b/README.org
@@ -3886,7 +3886,10 @@ might change them without further notice.
note after ~denote-rename-file~ (or related) The =FILE=, =TITLE=,
=KEYWORDS=, and =FILE-TYPE= arguments are given by the renaming
command and are used to construct new front matter values if
- appropriate.
+ appropriate. With optional =NO-CONFIRM=, do not prompt to confirm the
+ rewriting of the front matter. Otherwise produce a ~y-or-n-p~ prompt
+ to that effect. [ The =NO-CONFIRM= argument is part of
+ {{{development-version}}}. ]
#+findex: denote-rewrite-keywords
+ Function ~denote-rewrite-keywords~ :: Rewrite =KEYWORDS= in =FILE=
diff --git a/denote.el b/denote.el
index ec84e2e40f..3ac88ed0b9 100644
--- a/denote.el
+++ b/denote.el
@@ -2202,22 +2202,27 @@ This is for use in
`denote-keywords-add',`denote-keywords-remove',
'denote-rewrite-keywords
"2.0.0")
-(defun denote-rewrite-front-matter (file title keywords file-type)
+(defun denote-rewrite-front-matter (file title keywords file-type &optional
no-confirm)
"Rewrite front matter of note after `denote-rename-file'.
The FILE, TITLE, KEYWORDS, and FILE-TYPE are given by the
renaming command and are used to construct new front matter
-values if appropriate."
+values if appropriate.
+
+With optional NO-CONFIRM, do not prompt to confirm the rewriting
+of the front matter. Otherwise produce a `y-or-n-p' prompt to
+that effect."
(when-let ((old-title-line (denote-retrieve-title-line file file-type))
(old-keywords-line (denote-retrieve-keywords-line file file-type))
(new-title-line (denote--get-title-line-from-front-matter title
file-type))
(new-keywords-line (denote--get-keywords-line-from-front-matter
keywords file-type)))
(with-current-buffer (find-file-noselect file)
- (when (y-or-n-p (format
- "Replace front matter?\n-%s\n+%s\n\n-%s\n+%s?"
- (propertize old-title-line 'face 'error)
- (propertize new-title-line 'face 'success)
- (propertize old-keywords-line 'face 'error)
- (propertize new-keywords-line 'face 'success)))
+ (when (or no-confirm
+ (y-or-n-p (format
+ "Replace front matter?\n-%s\n+%s\n\n-%s\n+%s?"
+ (propertize old-title-line 'face 'error)
+ (propertize new-title-line 'face 'success)
+ (propertize old-keywords-line 'face 'error)
+ (propertize new-keywords-line 'face 'success))))
(save-excursion
(save-restriction
(widen)