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

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

[elpa] externals/consult-denote 183a31d273 3/8: Add prototype consult-de


From: ELPA Syncer
Subject: [elpa] externals/consult-denote 183a31d273 3/8: Add prototype consult-denote-outline-prompt
Date: Wed, 3 Jul 2024 06:58:26 -0400 (EDT)

branch: externals/consult-denote
commit 183a31d27354b6cd840899d47c830746263ea4b4
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Add prototype consult-denote-outline-prompt
---
 consult-denote.el | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/consult-denote.el b/consult-denote.el
index 9afdc20789..ed113816c3 100644
--- a/consult-denote.el
+++ b/consult-denote.el
@@ -146,6 +146,23 @@ Return the absolute path to the matching file."
      :state (consult--file-preview)
      :history 'denote-link-find-file-history)))
 
+;; FIXME 2024-07-03: We need a :state function that previews the
+;; current line in the given buffer and then restores the window
+;; configuration.
+(defun consult-denote-outline-prompt (&optional file)
+  "Like `denote-org-extras-outline-prompt' with Consult preview.
+FILE has the same meaning as in `denote-org-extras-outline-prompt'."
+  (let ((current-file (or file buffer-file-name)))
+    (consult--read
+     (denote--completion-table-no-sort 'imenu (denote-org-extras--get-outline 
current-file))
+     :state (lambda (_action candidate)
+              (with-current-buffer (current-buffer)
+                (when-let ((_ candidate)
+                           (line (string-to-number (car (split-string 
candidate)))))
+                  (goto-line line (get-file-buffer current-file)))))
+     :prompt (format "Select heading inside `%s': " (propertize 
(file-name-nondirectory current-file) 'face 'denote-faces-prompt-current-name))
+     :require-match t)))
+
 ;;;; Commands
 
 ;;;###autoload
@@ -226,9 +243,6 @@ Return the absolute path to the matching file."
        :state ,#'consult--file-state
        :items ,denote-silo-extras-directories)))
 
-;; TODO 2024-03-30: Cover the `denote-org-extras--outline-prompt'.  It
-;; will be like `consult-outline' in presentation.
-
 ;; TODO 2024-03-30: Cover the `denote-silo-extras--directory-prompt'.
 ;; It is a regular directory prompt.  Preview the dired buffer.
 
@@ -244,10 +258,13 @@ Return the absolute path to the matching file."
           (add-to-list 'consult-buffer-sources source :append))
         (advice-add #'denote-file-prompt :override 
#'consult-denote-file-prompt)
         (advice-add #'denote-select-linked-file-prompt :override 
#'consult-denote-select-linked-file-prompt))
+        ;; See FIXME where this function is defined.
+        (advice-add #'denote-org-extras-outline-prompt :override 
#'consult-denote-outline-prompt)
     (dolist (source consult-denote-buffer-sources)
       (setq consult-buffer-sources (delq source consult-buffer-sources)))
     (advice-remove #'denote-file-prompt #'consult-denote-file-prompt)
     (advice-remove #'denote-select-linked-file-prompt 
#'consult-denote-select-linked-file-prompt)))
+    (advice-remove #'denote-org-extras-outline-prompt 
#'consult-denote-outline-prompt)
 
 (provide 'consult-denote)
 ;;; consult-denote.el ends here



reply via email to

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