feat(org): add ::SEARCH support to id: links
This commit is contained in:
parent
4eda9329aa
commit
aeef05bfd7
1 changed files with 23 additions and 0 deletions
|
@ -551,6 +551,29 @@ relative to `org-directory', unless it is an absolute path."
|
||||||
(+org-define-basic-link "doom-docs" 'doom-docs-dir)
|
(+org-define-basic-link "doom-docs" 'doom-docs-dir)
|
||||||
(+org-define-basic-link "doom-modules" 'doom-modules-dir)
|
(+org-define-basic-link "doom-modules" 'doom-modules-dir)
|
||||||
|
|
||||||
|
;; TODO PR this upstream
|
||||||
|
(defadvice! +org--follow-search-string-a (fn link arg)
|
||||||
|
"Support ::SEARCH syntax for id: links."
|
||||||
|
:around #'org-id-open
|
||||||
|
:around #'org-roam-id-open
|
||||||
|
(save-match-data
|
||||||
|
(cl-destructuring-bind (id &optional search)
|
||||||
|
(split-string link "::")
|
||||||
|
(prog1 (funcall fn id arg)
|
||||||
|
(cond ((null search))
|
||||||
|
((string-match-p "\\`[0-9]+\\'" search)
|
||||||
|
;; Move N lines after the ID (in case it's a heading), instead
|
||||||
|
;; of the start of the buffer.
|
||||||
|
(forward-line (string-to-number option)))
|
||||||
|
((string-match "^/\\([^/]+\\)/$" search)
|
||||||
|
(let ((match (match-string 1 search)))
|
||||||
|
(save-excursion (org-link-search search))
|
||||||
|
;; `org-link-search' only reveals matches. Moving the point
|
||||||
|
;; to the first match after point is a sensible change.
|
||||||
|
(when (re-search-forward match)
|
||||||
|
(goto-char (match-beginning 0)))))
|
||||||
|
((org-link-search search)))))))
|
||||||
|
|
||||||
;; Add "lookup" links for packages and keystrings; useful for Emacs
|
;; Add "lookup" links for packages and keystrings; useful for Emacs
|
||||||
;; documentation -- especially Doom's!
|
;; documentation -- especially Doom's!
|
||||||
(org-link-set-parameters
|
(org-link-set-parameters
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue