Optimize doom/help-search

Yields a ~80% decrease in indexing time.
This commit is contained in:
Henrik Lissner 2019-10-26 01:55:16 -04:00
parent d0ae6c9bda
commit 9b3f21a9bc
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -110,24 +110,24 @@
(when (bound-and-true-p evil-local-mode) (when (bound-and-true-p evil-local-mode)
(evil-insert 1)))) (evil-insert 1))))
(defun +org--get-property (name &optional bound)
(save-excursion
(let ((re (format "^#\\+%s:[ \t]*\\([^\n]+\\)" (upcase name))))
(goto-char (point-min))
(when (re-search-forward re bound t)
(buffer-substring-no-properties (match-beginning 1) (match-end 1))))))
;;;###autoload ;;;###autoload
(defun +org-get-global-property (property &optional file) (defun +org-get-global-property (name &optional file bound)
"Get #+PROPERTY from an org FILE (defaults to current file)." "Get a document property named NAME (string) from an org FILE (defaults to
current file). Only scans first 2048 bytes of the document."
(unless bound
(setq bound 256))
(if file (if file
(let ((bound 256)) (with-temp-buffer
(with-temp-buffer (insert-file-contents-literally file nil 0 bound)
(insert-file-contents-literally file nil 0 bound) (+org--get-property name))
(goto-char (point-min)) (+org--get-property name bound)))
(and (re-search-forward (format "^#\\+%s:[ \t]*\\([^\n]+\\)" (upcase name))
bound t)
(buffer-substring-no-properties (match-beginning 1)
(match-end 1)))))
(org-element-property
:value
(car (org-element-map (org-element-parse-buffer) 'keyword
(lambda (el)
(and (string-match-p property (org-element-property :key el))
el)))))))
;;;###autoload ;;;###autoload
(defun +org-get-todo-keywords-for (&optional keyword) (defun +org-get-todo-keywords-for (&optional keyword)