Skip to content

Commit

Permalink
* elisp-demos.el (elisp-demos--search): Avoid org-mode functions for …
Browse files Browse the repository at this point in the history
…speed.

This means Org headings with TODO keywords and tags are not supported.
  • Loading branch information
xuchunyang committed Jan 19, 2024
1 parent cdde3c4 commit 90bd2d6
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions elisp-demos.el
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,20 @@ If set, new notes are added to the first file in this list."
(when (file-exists-p file)
(with-temp-buffer
(insert-file-contents file)
(delay-mode-hooks (org-mode))
(let ((pos (org-find-exact-headline-in-buffer (symbol-name symbol))))
(when pos
(goto-char pos)
(forward-line)
(goto-char (point-min))
(when (re-search-forward
(format "^\\* %s$" (regexp-quote (symbol-name symbol)))
nil t)
(let (beg end)
(forward-line 1)
(setq beg (point))
(if (re-search-forward "^\\*" nil t)
(setq end (line-beginning-position))
(setq end (point-max)))
(push (propertize
(string-trim
(buffer-substring-no-properties
(point)
(org-end-of-subtree)))
(string-trim (buffer-substring-no-properties beg end))
'file file
'pos (marker-position pos))
'pos beg)
results))))))
(when results
(string-join (nreverse results) "\n\n"))))
Expand Down

0 comments on commit 90bd2d6

Please sign in to comment.