diff --git a/consult-denote.el b/consult-denote.el index 135838e..76895a8 100644 --- a/consult-denote.el +++ b/consult-denote.el @@ -90,7 +90,7 @@ aforementioned function." (let* ((default-directory (denote-directory)) (common-parent-directory (let ((common-prefix (try-completion "" all-files))) - (if (> (length common-prefix) 0) + (if (length> common-prefix 0) (file-name-directory common-prefix)))) (cpd-length (length common-parent-directory)) (prompt-prefix (or prompt-text "Select FILE")) @@ -101,16 +101,16 @@ aforementioned function." (setq all-files (delete common-parent-directory all-files)) t)) - (substrings (mapcar (lambda (s) (substring s cpd-length)) all-files)) - (_ (when included-cpd - (setq substrings (cons "./" substrings)))) + (substrings (append + (if included-cpd '("./")) + (mapcar (lambda (s) (substring s cpd-length)) all-files))) (new-collection (denote--completion-table 'file substrings)) ;; We populate the history ourselves because we process the input. (input (consult--read new-collection :state (consult--file-preview) :prompt prompt)) - ;; FIXME 2024-05-08: Is there some elegant way to do this? + ;; FIXME 2024-05-08: Is there some elegant way to do this? what is "this" (filename (with-temp-buffer (insert input) (completion-in-region (point-min) (point-max) new-collection) @@ -164,14 +164,13 @@ aforementioned function." (defun consult-denote--buffers () "Return file names of Denote buffers." - (delq nil - (mapcar - (lambda (buffer) - (when-let ((file (buffer-file-name buffer)) - ((buffer-live-p buffer)) - ((denote-filename-is-note-p file))) - (buffer-name buffer))) - (buffer-list)))) + (mapcan ;or use `match-buffers' + (lambda (buffer) + (and-let* ((file (buffer-file-name buffer)) + ((buffer-live-p buffer)) + ((denote-filename-is-note-p file))) + (list (buffer-name buffer)))) + (buffer-list))) (defvar consult-denote--buffer-source `( :name "Denote buffers"