branch: externals/denote-sequence commit 59b5841a31cd87852eae17e6fe8752340b01161d Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
Define helper function to get the current file path of a rename operation --- denote-sequence.el | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/denote-sequence.el b/denote-sequence.el index 68e521bc3d..8e4b1508b7 100644 --- a/denote-sequence.el +++ b/denote-sequence.el @@ -1066,6 +1066,14 @@ Also see `denote-sequence-dired'." (user-error "The sequence `%s' has no relatives of type `%s'" sequence type)) (user-error "The current file has no sequence"))) +(defun denote-sequence--get-current-file-for-renaming () + "Return path to file for a rename operation. +The path is that of the special Org buffer (like `org-capture'), the +file at point in a Dired buffer, or the variable `buffer-file-name'." + (if (denote--file-type-org-extra-p) + denote-last-path-after-rename + (denote--rename-dired-file-or-current-file-or-prompt))) + ;; TODO 2025-01-14: We need to have an operation that reparents ;; recursively. This can be done inside of the `denote-sequence-reparent', ;; where if it finds that the current file has children, it prompts @@ -1092,9 +1100,7 @@ such (per `denote-sequence-p'). In both cases, what matters is to know the target sequence." (interactive (list - (if (denote--file-type-org-extra-p) - denote-last-path-after-rename - (denote--rename-dired-file-or-current-file-or-prompt)) + (denote-sequence--get-current-file-for-renaming) (denote-sequence-file-prompt (format "Reparent `%s' to be a child of" (propertize @@ -1115,11 +1121,7 @@ When called interactively, CURRENT-FILE is either the current file, or a special Org buffer (like those of `org-capture'), or the file at point in Dired. When called from Lisp, CURRENT-FILE is a string pointing to a file." - (interactive - (list - (if (denote--file-type-org-extra-p) - denote-last-path-after-rename - (denote--rename-dired-file-or-current-file-or-prompt)))) + (interactive (list (denote-sequence--get-current-file-for-renaming))) (when (denote-sequence-file-p current-file) (user-error "The `%s' already has a sequence; aborting" current-file)) (let ((new-sequence (denote-sequence--get-new-parent)))