emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/denote dc66c56cb1 3/8: Add user option 'denote-rename-n


From: ELPA Syncer
Subject: [elpa] externals/denote dc66c56cb1 3/8: Add user option 'denote-rename-no-confirm'
Date: Sat, 4 Nov 2023 00:57:50 -0400 (EDT)

branch: externals/denote
commit dc66c56cb1d5d5958b350f9654759a468dd22803
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Add user option 'denote-rename-no-confirm'
---
 README.org | 26 ++++++++++++++++++++++++++
 denote.el  | 30 +++++++++++++++++++++++++++---
 2 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/README.org b/README.org
index 49b5b6b766..d25a02adb1 100644
--- a/README.org
+++ b/README.org
@@ -1101,6 +1101,9 @@ old and new file names. For example:
 Rename sample.txt to 20220612T052900--my-sample-title__testing.txt? (y or n)
 #+end_example
 
+Do not ask for confirmation if the ~denote-rename-no-confirm~ option
+is set to a non-nil value ([[#h:a2ae9090-c49e-4b32-bcf5-eb8944241fd7][The 
~denote-rename-no-confirm~ option]]).
+
 Read the file type extension (like =.txt=) from the underlying file
 and preserve it through the renaming process. Files that have no
 extension are left without one.
@@ -1133,6 +1136,29 @@ non-note files (e.g. PDF) that can benefit from Denote's 
file-naming
 scheme. The latter is a convenience we provide, since we already have
 all the requisite mechanisms in place.
 
+*** The ~denote-rename-no-confirm~ option
+:PROPERTIES:
+:CUSTOM_ID: h:a2ae9090-c49e-4b32-bcf5-eb8944241fd7
+:END:
+
+[ Part of {{{development-version}}}. ]
+
+The default behaviour of the ~denote-rename-file~ command is to ask
+for an affirmative answer as a final step before changing the file
+name and, where relevant, inserting or updating the corresponding
+front matter ([[#h:7cc9e000-806a-48da-945c-711bbc7426b0][Rename a single 
file]]).
+
+Remember that ~denote-rename-file~ does not save the underlying buffer
+it modifies. It leaves it unsaved so that the user can review what
+happened, such as by invoking the command ~diff-buffer-with-file~.
+
+Specialised commands that build on top of ~denote-rename-file~ may
+internally bind this user option to a non-nil value in order to
+perform their operation (e.g. ~denote-dired-rename-files~ goes through
+each marked Dired file, prompting for the information to use, but
+carries out the renaming without asking for confirmation (buffers
+remain unsaved)).
+
 ** Rename a single file based on its front matter
 :PROPERTIES:
 :CUSTOM_ID: h:3ab08ff4-81fa-4d24-99cb-79f97c13a373
diff --git a/denote.el b/denote.el
index 0285c119c8..9c4cffe0a6 100644
--- a/denote.el
+++ b/denote.el
@@ -401,6 +401,28 @@ current note."
   :package-version '(denote . "1.2.0")
   :type 'boolean)
 
+(defcustom denote-rename-no-confirm nil
+  "When non-nil, `denote-rename-file' does not prompt for confirmation.
+The default behaviour of the `denote-rename-file' command is to
+ask for an affirmative answer as a final step before changing the
+file name and, where relevant, inserting or updating the
+corresponding front matter.
+
+Remember that `denote-rename-file' does not save the underlying
+buffer it modifies.  It leaves it unsaved so that the user can
+review what happened, such as by invoking the command
+`diff-buffer-with-file'.
+
+Specialised commands that build on top of `denote-rename-file'
+may internally bind this user option to a non-nil value in order
+to perform their operation (e.g. `denote-dired-rename-files' goes
+through each marked Dired file, prompting for the information to
+use, but carries out the renaming without asking for
+confirmation (buffers remain unsaved))."
+  :group 'denote
+  :package-version '(denote . "2.1.0")
+  :type 'boolean)
+
 (defcustom denote-excluded-directories-regexp nil
   "Regular expression of directories to exclude from all operations.
 Omit matching directories from file prompts and also exclude them
@@ -2407,7 +2429,9 @@ included in the new file name.
 
 As a final step after the FILE, TITLE, KEYWORDS, and SIGNATURE
 are collected, ask for confirmation, showing the difference
-between old and new file names.
+between old and new file names.  Do not ask for confirmation if
+the user option `denote-rename-no-confirm' is set to a non-nil
+value.
 
 Read the file type extension (like .txt) from the underlying file
 and preserve it through the renaming process.  Files that have no
@@ -2467,12 +2491,12 @@ place."
          (signature (or signature (denote-retrieve-filename-signature file)))
          (new-name (denote-format-file-name dir id keywords (denote-sluggify 
title 'title) extension signature))
          (max-mini-window-height denote-rename-max-mini-window-height))
-    (when (denote-rename-file-prompt file new-name)
+    (when (or denote-rename-no-confirm (denote-rename-file-prompt file 
new-name))
       (denote-rename-file-and-buffer file new-name)
       (denote-update-dired-buffers)
       (when (denote-file-is-writable-and-supported-p new-name)
         (if (denote--edit-front-matter-p new-name file-type)
-            (denote-rewrite-front-matter new-name title keywords file-type)
+            (denote-rewrite-front-matter new-name title keywords file-type 
denote-rename-no-confirm)
           (denote--add-front-matter new-name title keywords id file-type))))))
 
 ;;;###autoload



reply via email to

[Prev in Thread] Current Thread [Next in Thread]