branch: externals/denote-sequence
commit 39f8dc2d6492bfdd66378d407d97965a7aeaa111
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>

    Make stylistic tweaks to denote-sequence-reparent
    
    Thanks to Peter Prevos for contributing the original version of this
    in commit cfded6c. This was done in pull request 13:
    <https://github.com/protesilaos/denote-sequence/pull/13>.
---
 denote-sequence.el | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/denote-sequence.el b/denote-sequence.el
index 4962da1ca2..0cd1723d7d 100644
--- a/denote-sequence.el
+++ b/denote-sequence.el
@@ -1243,22 +1243,19 @@ the target sequence."
   (let* ((root-sequence (denote-retrieve-filename-signature current-file))
          (target-sequence (or (denote-sequence-file-p file-with-sequence)
                               (denote-sequence-p file-with-sequence)
-                              (user-error "No sequence of `denote-sequence-p' 
found in `%s'"
-                                          file-with-sequence)))
+                              (user-error "No sequence of `denote-sequence-p' 
found in `%s'" file-with-sequence)))
          (new-sequence (denote-sequence--get-new-child target-sequence))
          (descendants (when (and recursive root-sequence)
-                        (denote-sequence-get-relative root-sequence 
'all-children))))
-    ;; Reparent root file
-    (denote-rename-file current-file 'keep-current 'keep-current new-sequence
-                        'keep-current 'keep-current)
-    ;; Recursive reparenting only when requested
+                        (denote-sequence-get-relative root-sequence 
'all-children)))
+         (rename-fn (lambda (file sequence)
+                      (denote-rename-file file 'keep-current 'keep-current 
sequence 'keep-current 'keep-current))))
+    (funcall rename-fn current-file new-sequence)
     (when descendants
       (dolist (child descendants)
         (let* ((child-sequence (denote-retrieve-filename-signature child))
                (child-sequence-suffix (string-remove-prefix root-sequence 
child-sequence))
                (new-child-sequence (concat new-sequence 
child-sequence-suffix)))
-          (denote-rename-file child 'keep-current 'keep-current 
new-child-sequence
-                              'keep-current 'keep-current))))))
+          (funcall rename-fn child new-child-sequence))))))
 
 (defun denote-sequence-reparent-recursive (current-file file-with-sequence)
   "Re-parent CURRENT-FILE and all its descendants to FILE-WITH-SEQUENCE.

Reply via email to