Last active
February 24, 2024 01:49
-
-
Save jdtsmith/8602d998116b953725218224b77b8766 to your computer and use it in GitHub Desktop.
Insert link from consult-org-headings with embark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun my/org-link-heading-here (cand) | |
(when-let ((marker (get-text-property 0 'consult--candidate cand))) | |
(save-excursion | |
(with-current-buffer (marker-buffer marker) | |
(goto-char marker) | |
(org-store-link nil t))) | |
(org-insert-all-links 1 "" " "))) | |
(defvar-keymap embark-consult-org-heading-map | |
:doc "Keymap for operating on org headings" | |
:parent embark-general-map | |
"l" 'my/org-link-heading-here) | |
(add-to-list 'embark-keymap-alist '(consult-org-heading . embark-consult-org-heading-map)) | |
;; make sure it quits to restore point | |
(setf (alist-get 'my/org-link-heading-here embark-quit-after-action) t) |
The parentheses around ("l" 'my/org-link-heading-here)
should be removed.
Yep, thanks.
BTW, have you tried consult-org-agenda
? Basically it's consult-org-heading across all agenda files. A little slow for giant files but pretty good. I updated the function to correctly handle adding an :ID:
and linking to other files.
No I didn't, mostly because I use a single Org file per context. But good to know nevertheless.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Recently, embark has removed
embark-define-keymap
; updated.