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

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

[elpa] master 0028c8c 106/348: counsel.el (counsel-outline): New command


From: Oleh Krehel
Subject: [elpa] master 0028c8c 106/348: counsel.el (counsel-outline): New command
Date: Sat, 8 Apr 2017 11:03:37 -0400 (EDT)

branch: master
commit 0028c8c9d47a35b9146c5b2dd6a72bfcdbac0a3d
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    counsel.el (counsel-outline): New command
---
 counsel.el | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/counsel.el b/counsel.el
index 7782d4c..f4fb7a8 100644
--- a/counsel.el
+++ b/counsel.el
@@ -2159,6 +2159,29 @@ And insert it into the minibuffer. Useful during
     (ivy-read "tag: " tags
               :action 'counsel-semantic-action)))
 
+;;** `counsel-outline'
+(defun counsel-outline-candidates ()
+  (let (cands)
+    (save-excursion
+      (goto-char (point-min))
+      (while (re-search-forward outline-regexp nil t)
+        (skip-chars-forward " ")
+        (push (cons (buffer-substring-no-properties
+                     (point) (line-end-position))
+                    (line-beginning-position))
+              cands))
+      (nreverse cands))))
+
+(defun counsel-outline-action (x)
+  (with-ivy-window
+    (goto-char (cdr x))))
+
+(defun counsel-outline ()
+  "Jump to outline with completion."
+  (interactive)
+  (ivy-read "outline: " (counsel-outline-candidates)
+            :action #'counsel-outline-action))
+
 ;;* Misc OS
 ;;** `counsel-rhythmbox'
 (declare-function dbus-call-method "dbus")



reply via email to

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