Skip to content

Instantly share code, notes, and snippets.

@juxtin
Created July 9, 2015 17:41
Show Gist options
  • Save juxtin/191c455f31da40ba0d0f to your computer and use it in GitHub Desktop.
Save juxtin/191c455f31da40ba0d0f to your computer and use it in GitHub Desktop.
helm-clojure-headlines
(defun helm-clojure-headlines ()
"Display headlines for the current Clojure file."
(interactive)
(setq helm-current-buffer (current-buffer)) ;; Fixes bug where the current buffer sometimes isn't used
(jit-lock-fontify-now) ;; https://groups.google.com/forum/#!topic/emacs-helm/YwqsyRRHjY4
(helm :sources (helm-build-in-buffer-source "Clojure Headlines"
:data (with-helm-current-buffer
(goto-char (point-min))
(cl-loop while (re-search-forward "^(\\|testing\\|^;.*[a-zA-Z]+" nil t)
for line = (buffer-substring (point-at-bol) (point-at-eol))
for pos = (line-number-at-pos)
collect (propertize line 'helm-realvalue pos)))
:get-line 'buffer-substring
:action (lambda (c) (helm-goto-line c)))
:buffer "helm-clojure-headlines"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment