summaryrefslogtreecommitdiff
path: root/helm-org.el
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2014-12-14 12:35:00 +0100
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2014-12-14 12:35:00 +0100
commit168b97d5a300727e742a921c0f1ddb48c108af46 (patch)
tree921bbcaa2fe9d0531f600fb2c0223168dafcbab4 /helm-org.el
parente002743ed5929396df222a5de535329627667657 (diff)
Allow fontifying helm-org-headings.
* helm-org.el (helm-org-headings-fontify): New user var. (helm-get-org-candidates-in-file, helm-org-get-candidates): Use it.
Diffstat (limited to 'helm-org.el')
-rw-r--r--helm-org.el43
1 files changed, 23 insertions, 20 deletions
diff --git a/helm-org.el b/helm-org.el
index 85caab84..d51ed134 100644
--- a/helm-org.el
+++ b/helm-org.el
@@ -18,15 +18,26 @@
;;; Code:
(require 'cl-lib)
(require 'helm)
-(require 'helm-plugin)
(require 'org)
+(defgroup helm-org nil
+ "Org related functions for helm."
+ :group 'helm)
+
+(defcustom helm-org-headings-fontify nil
+ "Fontify org buffers before parsing them.
+This reflect fontification in helm-buffer when non--nil.
+NOTE: This will be slow on large org buffers."
+ :group 'helm-org
+ :type 'boolean)
+
;;; Org headings
;;
;;
(defun helm-org-goto-marker (marker)
(switch-to-buffer (marker-buffer marker))
(goto-char (marker-position marker))
+ (org-show-context)
(org-show-entry))
(cl-defun helm-source-org-headings-for-files (filenames
@@ -63,17 +74,20 @@
(apply #'append
(mapcar (lambda (filename)
(helm-get-org-candidates-in-file
- filename min-depth max-depth))
+ filename min-depth max-depth helm-org-headings-fontify))
filenames)))
-(defun helm-get-org-candidates-in-file (filename min-depth max-depth)
+(defun helm-get-org-candidates-in-file (filename min-depth max-depth
+ &optional fontify)
(with-current-buffer (find-file-noselect filename)
- (save-excursion
- (goto-char (point-min))
- (cl-loop while (re-search-forward org-complex-heading-regexp nil t)
- if (let ((num-stars (length (match-string-no-properties 1))))
- (and (>= num-stars min-depth) (<= num-stars max-depth)))
- collect `(,(match-string-no-properties 0) . ,(point-marker))))))
+ (and fontify (jit-lock-fontify-now))
+ (let ((match-fn (if fontify 'match-string 'match-string-no-properties)))
+ (save-excursion
+ (goto-char (point-min))
+ (cl-loop while (re-search-forward org-complex-heading-regexp nil t)
+ if (let ((num-stars (length (match-string-no-properties 1))))
+ (and (>= num-stars min-depth) (<= num-stars max-depth)))
+ collect `(,(funcall match-fn 0) . ,(point-marker)))))))
;;;###autoload
(defun helm-org-agenda-files-headings ()
@@ -90,17 +104,6 @@
:candidate-number-limit 99999
:buffer "*helm org inbuffer*"))
-;; (defvar helm-documentation-filecache nil)
-;; (defvar helm-documentation-directory "~/.emacs.d/helm-documentation/")
-;; (defun helm-documentation ()
-;; (interactive)
-;; (unless helm-documentation-filecache
-;; (setq helm-documentation-filecache
-;; (directory-files helm-documentation-directory t "\\.org\\'")))
-;; (helm :sources (helm-source-org-headings-for-files
-;; helm-documentation-filecache)
-;; :candidate-number-limit 99999
-;; :buffer "*helm org doc*"))
(provide 'helm-org)