branch: externals/denote commit f6b5770b97e3a837e0f2356269cd1e07f5f6bdd0 Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
Add denote-sequence-find command and helper wrappers to get relatives --- denote-sequence.el | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/denote-sequence.el b/denote-sequence.el index e994d78179..1d7bcc606d 100644 --- a/denote-sequence.el +++ b/denote-sequence.el @@ -725,6 +725,39 @@ If the current file does not have a sequence, then behave exactly like (denote-use-signature new-sequence)) (call-interactively 'denote))) +;;;###autoload +(defun denote-sequence-find (type) + "Find relatives of the given TYPE using the current file's sequence. +Prompt for TYPE among `denote-sequence-types' and then prompt for a file +among the matching files." + (interactive (list (denote-sequence-type-prompt "Find relatives of TYPE"))) + (if-let* ((sequence (denote-sequence-file-p buffer-file-name))) + (if-let* ((relatives (delete buffer-file-name (denote-sequence-get-relative sequence type)))) + (find-file (denote-sequence-file-prompt "Select a relative" relatives)) + (user-error "The sequence `%s' has no relatives of type `%s'" sequence type)) + (user-error "The current file has no sequence"))) + +;;;###autoload +(defun denote-sequence-find-parent () + "Convenience wrapper of `denote-sequence-find' to select a parent." + (declare (interactive-only t)) + (interactive) + (denote-sequence-find 'parent)) + +;;;###autoload +(defun denote-sequence-find-sibling () + "Convenience wrapper of `denote-sequence-find' to select a sibling." + (declare (interactive-only t)) + (interactive) + (denote-sequence-find 'sibling)) + +;;;###autoload +(defun denote-sequence-find-child () + "Convenience wrapper of `denote-sequence-find' to select a child." + (declare (interactive-only t)) + (interactive) + (denote-sequence-find 'child)) + ;;;###autoload (defun denote-sequence-link (file &optional id-only) "Link to FILE with sequence.