emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/denote 71630b9510 08/14: Add denote-sequence-get-relati


From: ELPA Syncer
Subject: [elpa] externals/denote 71630b9510 08/14: Add denote-sequence-get-relative function
Date: Fri, 17 Jan 2025 03:58:15 -0500 (EST)

branch: externals/denote
commit 71630b951082379485372ea0337fff01f8046c78
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Add denote-sequence-get-relative function
    
    This foreshadows commands I will introduce shortly.
---
 denote-sequence.el | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/denote-sequence.el b/denote-sequence.el
index 8538b31b3b..f383b75f65 100644
--- a/denote-sequence.el
+++ b/denote-sequence.el
@@ -569,6 +569,23 @@ return value of `denote-sequence-get-all-sequences'."
     ('sibling (denote-sequence--get-new-sibling sequence sequences))
     (_ (error "The type `%s' is not among `denote-sequence-types'" type))))
 
+(defun denote-sequence-get-relative (sequence type &optional files)
+  "Get files of TYPE given the SEQUENCE.
+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)
+                   (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))
+      (_ (error "The type `%s' is not among the `denote-sequence-types'" 
type)))))
+
 (defvar denote-sequence-type-history nil
   "Minibuffer history of `denote-sequence-type-prompt'.")
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]