branch: master
commit 0028c8c9d47a35b9146c5b2dd6a72bfcdbac0a3d
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
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")