branch: externals/denote
commit 47fbde671ab6b8e7e7d14a825bf1fcfb100ee87d
Author: Protesilaos Stavrou <i...@protesilaos.com>
Commit: Protesilaos Stavrou <i...@protesilaos.com>

    Make denote-sequence-get-relative correctly get the parents
---
 denote-sequence.el | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/denote-sequence.el b/denote-sequence.el
index f383b75f65..c3e32501ed 100644
--- a/denote-sequence.el
+++ b/denote-sequence.el
@@ -575,15 +575,21 @@ With optional FILES consider only those, otherwise 
operate on all files
 returned by `denote-sequence-get-all-files'."
   (let* ((depth (denote-sequence-depth sequence))
          (components (denote-sequence-split sequence))
-         (filter (lambda (comparison prefix)
+         (filter-common (lambda (comparison prefix)
                    (seq-filter
                     (lambda (file)
                       (funcall comparison (denote-sequence-depth 
(denote-retrieve-filename-signature file)) depth))
                     (denote-sequence-get-all-files-with-prefix prefix 
files)))))
     (pcase type
-      ('parent (funcall filter '< (car components)))
-      ('sibling (funcall filter '= (denote-sequence-join (butlast components) 
(cdr (denote-sequence-and-scheme-p sequence)))))
-      ('child (funcall filter '> sequence))
+      ('parent (let ((parents nil)
+                     (butlast (butlast components)))
+                 (while (>= (length butlast) 1)
+                   (let ((prefix (denote-sequence-join butlast (cdr 
(denote-sequence-and-scheme-p sequence)))))
+                     (push (car (denote-sequence-get-all-files-with-prefix 
prefix files)) parents))
+                   (setq butlast (butlast butlast)))
+                 parents))
+      ('sibling (funcall filter-common '= (denote-sequence-join (butlast 
components) (cdr (denote-sequence-and-scheme-p sequence)))))
+      ('child (funcall filter-common '> sequence))
       (_ (error "The type `%s' is not among the `denote-sequence-types'" 
type)))))
 
 (defvar denote-sequence-type-history nil

Reply via email to