branch: externals/denote commit 890a3350927559608936344191117ff9a9b6779e Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
Add denote-dired-rename-expert user option --- README.org | 5 +++++ denote-dired.el | 29 ++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/README.org b/README.org index 6feb5359f4..0b6989b37f 100644 --- a/README.org +++ b/README.org @@ -300,6 +300,10 @@ before renaming the file at point, showing a message like: Rename sample.pdf to 20220612T052900--my-sample-title__testing.pdf? (y or n) #+end_example +#+vindex: denote-dired-rename-expert +However, if the user option ~denote-dired-rename-expert~ is non-nil, +conduct the renaming operation outright---no questions asked. + When operating on a file that has no identifier, such as =sample.pdf=, Denote reads the file properties to retrieve its last modification time. If the file was from a past date like 2000-11-31 it will get an @@ -802,6 +806,7 @@ Everything is in place to set up the package. (require 'denote-link) (require 'denote-dired) +(setq denote-dired-rename-expert nil) ;; We use different ways to specify a path for demo purposes. (setq denote-dired-directories diff --git a/denote-dired.el b/denote-dired.el index 1856e9e37c..cee702cff7 100644 --- a/denote-dired.el +++ b/denote-dired.el @@ -78,6 +78,13 @@ :type '(repeat directory) :group 'denote-dired) +(defcustom denote-dired-rename-expert nil + "If t, `denote-dired-rename-file' doesn't ask for confirmation. +The confiration is asked via a `y-or-n-p' prompt which shows the +old name followed by the new one." + :type 'boolean + :group 'denote-dired) + ;;;; Commands (defun denote-dired--file-attributes-time (file) @@ -97,16 +104,24 @@ ;;;###autoload (defun denote-dired-rename-file (file title keywords) "Rename FILE to include TITLE and KEYWORDS. -If in Dired consider FILE the one at point, else prompt with -completion. -If FILE has a Denote-style identifier, retain it while updating -the TITLE and KEYWORDS fields. Else create an identifier, -replacing the whole name. +If in Dired, consider FILE to be the one at point, else prompt +with completion. + +If FILE has a Denote-compliant identifier, retain it while +updating the TITLE and KEYWORDS fields of the file name. Else +create an identifier based on the file's attribute of last +modification time. If such attribute cannot be found, the +identifier falls back to the current time. + +As a final step, prompt for confirmation, showing the difference +between old and new file names. If `denote-dired-rename-expert' +is non-nil, conduct the renaming operation outright---no +questions asked! The file type extension (e.g. .pdf) is read from the underlying -file and is preserved in the renaming process. Files that have -no extension are simply left without one. +file and is preserved through the renaming process. Files that +have no extension are simply left without one. Renaming only occurs relative to the current directory. Files are not moved between directories.