branch: elpa/helm commit 09c61064a4d369bbf5b6e3cb34e904e79b9306b4 Author: Thierry Volpiatto <thie...@posteo.net> Commit: Thierry Volpiatto <thie...@posteo.net>
New command to navigate outline buffers --- helm-misc.el | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/helm-misc.el b/helm-misc.el index 104c9e41cd..b188eed52f 100644 --- a/helm-misc.el +++ b/helm-misc.el @@ -27,6 +27,8 @@ (declare-function jabber-chat-with "ext:jabber.el") (declare-function jabber-read-account "ext:jabber.el") (declare-function helm-comp-read "helm-mode") +(declare-function outline-back-to-heading "outline.el") +(declare-function outline-end-of-heading "outline.el") (defgroup helm-misc nil @@ -387,6 +389,36 @@ Default action change TZ environment variable locally to emacs." (delete-minibuffer-contents) (insert elm))) +;;;###autoload +(defun helm-outline () + "Basic helm navigation tool for outline buffers." + (interactive) + (cl-assert (buffer-local-value 'outline-minor-mode (current-buffer)) + nil "Not an outline enabled buffer") + (helm :sources (helm-build-sync-source "helm outline" + :candidates + (lambda () + (with-helm-current-buffer + (save-excursion + (goto-char (point-min)) + (cl-loop while (re-search-forward "^[*]+" nil t) + for beg = (match-beginning 0) + for end = (progn + (outline-end-of-heading) (point)) + do (jit-lock-fontify-now beg end) + and collect + (cons (buffer-substring beg end) beg))))) + :action (lambda (pos) + (goto-char pos) + (helm-highlight-current-line))) + :preselect (save-excursion + (when (condition-case _err + (outline-back-to-heading) + (error nil)) + (regexp-quote + (buffer-substring + (point) (progn (outline-end-of-heading) (point)))))) + :buffer "*helm outline*")) (provide 'helm-misc)