branch: externals/denote
commit 34fd0bfc6404d952f390dee6095aaf9a4532103c
Author: Protesilaos Stavrou <i...@protesilaos.com>
Commit: Protesilaos Stavrou <i...@protesilaos.com>

    Add variable to inhibit front matter rewrite via a 'let'
    
    We discussed this with Jean-Philippe Gagné Guay in issue 589:
    <https://github.com/protesilaos/denote/issues/589>.
---
 README.org | 7 +++++++
 denote.el  | 9 ++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/README.org b/README.org
index 505300ca60..6a6d693b92 100644
--- a/README.org
+++ b/README.org
@@ -5545,6 +5545,13 @@ The following sections cover the specifics.
 :CUSTOM_ID: h:66d31f42-6092-493a-97db-83b217db9d96
 :END:
 
+#+vindex: denote-rename-rewrite-front-matter
+- Variable ~denote-rename-rewrite-front-matter~ :: When non-nil,
+  rewrite the front matter if appropriate. The purpose of this
+  variable is to be ~let~ bound to nil by a caller of the command
+  ~denote-rename-file~ or related. This will have the effect of not
+  rewriting the file's front matter [ Part of {{{development-version}}}. ]
+
 #+findex: denote-rename-file-prompt
 - Function ~denote-rename-file-prompt~ :: Prompt to rename file named
   =OLD-NAME= to =NEW-NAME=. If ~denote-rename-confirmations~ does not
diff --git a/denote.el b/denote.el
index 8861c4f5af..6afc344695 100644
--- a/denote.el
+++ b/denote.el
@@ -3739,6 +3739,12 @@ Respect `denote-generate-identifier-automatically'."
           (current-time))
     nil))
 
+(defvar denote-rename-rewrite-front-matter t
+  "When non-nil, rewrite the front matter if appropriate.
+The purpose of this variable is to be `let' bound to nil by a caller of
+the command `denote-rename-file' or related.  This will have the effect
+of not rewriting the file's front matter.")
+
 (defun denote--rename-file (file title keywords signature date)
   "Rename FILE according to the other parameters.
 Parameters TITLE, KEYWORDS, SIGNATURE and DATE are as described
@@ -3777,7 +3783,8 @@ Respect `denote-rename-confirmations', 
`denote-save-buffers' and
     (when (denote-rename-file-prompt file new-name)
       (denote-rename-file-and-buffer file new-name))
     ;; Handle front matter if new-name is of a supported type (rewrite or add 
front matter)
-    (when (and (denote-file-has-supported-extension-p file)
+    (when (and denote-rename-rewrite-front-matter
+               (denote-file-has-supported-extension-p file)
                (denote-file-is-writable-and-supported-p new-name))
       (if (denote--file-has-front-matter-p new-name file-type)
           (denote-rewrite-front-matter new-name title keywords signature date 
id file-type)

Reply via email to