branch: externals/denote
commit 14fc0197a2b34d64ba8a615d834f28478d49f6af
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>
Make denote-sequence-get-relative get parents more reliably
---
denote-sequence.el | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/denote-sequence.el b/denote-sequence.el
index bbd9e90073..e994d78179 100644
--- a/denote-sequence.el
+++ b/denote-sequence.el
@@ -574,21 +574,26 @@ return value of `denote-sequence-get-all-sequences'."
With optional FILES consider only those, otherwise operate on all files
returned by `denote-sequence-get-all-files'."
(let* ((depth (denote-sequence-depth sequence))
+ (scheme (cdr (denote-sequence-and-scheme-p sequence)))
(components (denote-sequence-split sequence))
(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)))))
+ (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 (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)))
+ (when-let* ((prefix (denote-sequence-join butlast scheme))
+ (parent (seq-find
+ (lambda (file)
+ (string=
(denote-retrieve-filename-signature file) prefix))
+ (denote-sequence-get-all-files
files))))
+ (push parent parents)
+ (setq butlast (butlast butlast))))
parents))
- ('sibling (funcall filter-common '= (denote-sequence-join (butlast
components) (cdr (denote-sequence-and-scheme-p sequence)))))
+ ('sibling (funcall filter-common '= (denote-sequence-join (butlast
components) scheme)))
('child (funcall filter-common '> sequence))
(_ (error "The type `%s' is not among the `denote-sequence-types'"
type)))))