branch: externals/denote-sequence
commit 4150015376fef89ebd284e6850d7a95619de791a
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>
Expand denote-sequence-file-prompt to support list value for
denote-directory
---
denote-sequence.el | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/denote-sequence.el b/denote-sequence.el
index 2d2f502916..fdcf143035 100644
--- a/denote-sequence.el
+++ b/denote-sequence.el
@@ -859,14 +859,25 @@ With optional PROMPT-TEXT use it instead of a generic
prompt.
With optional FILES-WITH-SEQUENCES as a list of strings, use them as
completion candidates. Else use `denote-sequence-get-all-files'."
- (if-let* ((relative-files (mapcar
#'denote-get-file-name-relative-to-denote-directory
- (or files-with-sequences
(denote-sequence-get-all-files))))
+ (if-let* ((roots (denote-directories))
+ (single-dir-p (null (cdr roots)))
+ ;; Some external program may use `default-directory' with the
+ ;; relative file paths of the completion candidates.
+ (default-directory (if single-dir-p
+ (car roots)
+ (denote-directories-get-common-root roots)))
+ (files (or files-with-sequences (denote-sequence-get-all-files)))
+ (relative-files (if single-dir-p
+ (mapcar
#'denote-get-file-name-relative-to-denote-directory files)
+ files))
(prompt (format-prompt (or prompt-text "Select FILE with
sequence") nil))
(input (completing-read
prompt
(apply 'denote-get-completion-table relative-files
denote-sequence-file-prompt-extra-metadata)
nil t nil 'denote-sequence-file-history)))
- (expand-file-name input (car (denote-directories)))
+ (if single-dir-p
+ (expand-file-name input default-directory)
+ input)
(error "There are no sequence notes in the `denote-directory'")))
;;;###autoload