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

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

[elpa] externals/embark 5182b7e: Add outline and imenu TOC candidate col


From: ELPA Syncer
Subject: [elpa] externals/embark 5182b7e: Add outline and imenu TOC candidate collectors
Date: Sun, 14 Nov 2021 12:57:19 -0500 (EST)

branch: externals/embark
commit 5182b7eb2200a9245f1e5f73806672d6dcdd0356
Author: Omar Antolín <omar.antolin@gmail.com>
Commit: Omar Antolín <omar.antolin@gmail.com>

    Add outline and imenu TOC candidate collectors
    
    The outline collector is on by default.
---
 embark-consult.el | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/embark-consult.el b/embark-consult.el
index dc9f92f..ba7d18e 100644
--- a/embark-consult.el
+++ b/embark-consult.el
@@ -311,5 +311,24 @@ that is a Consult async command."
                (alist-get cmd embark-setup-action-hooks)))
  embark-consult-async-search-map)
 
+;;; Tables of contents for buffers: imenu and outline candidate collectors
+
+
+(defun embark-consult-toc-outline ()
+  "Collect all outline headings in the current buffer." 
+  (cons 'consult-location (consult--outline-candidates)))
+
+(defun embark-consult-toc-imenu ()
+  "Collect all imenu items in the current buffer." 
+  (cons 'consult-location
+        (mapcar (pcase-lambda (`(,item . ,pos))
+                  (propertize item 'consult-location
+                              (cons pos (line-number-at-pos pos))))
+                (consult-imenu--items))))
+
+(unless (memq 'embark-consult-toc-outline embark-candidate-collectors)
+  (setq embark-candidate-collectors
+        (append embark-candidate-collectors '(embark-consult-toc-outline))))
+
 (provide 'embark-consult)
 ;;; embark-consult.el ends here



reply via email to

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