Skip to content

Instantly share code, notes, and snippets.

@kenoss
Created January 11, 2016 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenoss/365b6a12b3fe61164ebe to your computer and use it in GitHub Desktop.
Save kenoss/365b6a12b3fe61164ebe to your computer and use it in GitHub Desktop.
helm-occur for org headers
;;; helm in org
(defclass keu-helm-source-multi-occur-org-headers (helm-source-multi-occur)
((search :initform '(keu-helm-occur-org-headers-search))
; (search-strict :initform t)
(matchplugin :initform nil)))
;; Mimic of helm-occur. IT IS A MIMIC!
(defun keu-helm-occur-org-headers ()
"helm-occur for org headers."
(interactive)
(helm-occur-init-source)
;; Terrible!
(let1 helm-source-occur (helm-make-source "Occur org headers" 'keu-helm-source-multi-occur-org-headers)
(let ((bufs (list (buffer-name (current-buffer)))))
(helm-attrset 'moccur-buffers bufs helm-source-occur)
(helm-set-local-variable 'helm-multi-occur-buffer-list bufs)
(helm-set-local-variable
'helm-multi-occur-buffer-tick
(cl-loop for b in bufs
collect (buffer-chars-modified-tick (get-buffer b)))))
(helm :sources (list helm-source-occur)
:buffer "*helm occur*"
:history 'helm-grep-history
:preselect (and (memq 'helm-source-occur helm-sources-using-default-as-input)
(format "%s:%d:\t" (buffer-name) (line-number-at-pos (point))))
:truncate-lines t)))
(defun keu-helm-occur-org-headers-search (pattern)
(helm-candidates-in-buffer-search-default-fn (concat "^\\*+ .*" pattern)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment