branch: externals/denote-sequence
commit 4d603877579244ab65065737a5a2575261a14069
Author: Protesilaos Stavrou <i...@protesilaos.com>
Commit: Protesilaos Stavrou <i...@protesilaos.com>

    Define new command denote-sequence-rename-as-parent
    
    This is in response to issue 4 by Alex Carney:
    <https://github.com/protesilaos/denote-sequence/issues/4>.
---
 denote-sequence.el | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/denote-sequence.el b/denote-sequence.el
index 67b65b193d..68e521bc3d 100644
--- a/denote-sequence.el
+++ b/denote-sequence.el
@@ -1106,6 +1106,25 @@ the target sequence."
          (new-sequence (denote-sequence--get-new-child target-sequence)))
     (denote-rename-file current-file 'keep-current 'keep-current new-sequence 
'keep-current)))
 
+;;;###autoload
+(defun denote-sequence-rename-as-parent (current-file)
+  "Make CURRENT-FILE a new parent sequence.
+If CURRENT-FILE has a sequence abort the operation.
+
+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))))
+  (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)))
+    (denote-rename-file current-file 'keep-current 'keep-current new-sequence 
'keep-current)))
+
 ;;;###autoload
 (defun denote-sequence-convert (files)
   "Convert the sequence scheme of FILES to match `denote-sequence-scheme'.

Reply via email to