-
Notifications
You must be signed in to change notification settings - Fork 54
Embark
To be able to run embark-act
at point within an org property drawer (where citations are not recognized as anything but plain text values), you can add a target finder like the below. The syntax here must be @citekey
:
(setf (alist-get
'key-at-point
(alist-get '(org-mode) citar-major-mode-functions nil nil #'equal))
#'my/citar-org-key-at-point)
(defun my/citar-org-key-at-point ()
"Return citekey at point, when in org property drawer.
Citkey must be formatted as `@key'."
(or (citar-org-key-at-point)
(when (and (equal (org-element-type (org-element-at-point)) 'node-property)
(org-in-regexp (concat "[[:space:]]" org-element-citation-key-re)))
(cons (substring (match-string 0) 2)
(cons (match-beginning 0)
(match-end 0))))))
Bind the keymap to embark-act
like so:
(add-to-list 'embark-keymap-alist '(bib-reference . citar-map))
This command allows you to take the input you use for one command, but pipe it to another.
That can be used to configure something similar to the "fallback" behavior you see in helm-bibtex
and ivy-bibtex
.
In order to configure that, you use a keymap, just as with embark-act
.
Here's an example for biblio
lookup services, which in this case will be available if you are using citar-open-files
:
;; define the keymap
(defvar my-citar-embark-become-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "f") 'citar-open-library-files)
(define-key map (kbd "x") 'biblio-arxiv-lookup)
(define-key map (kbd "c") 'biblio-crossref-lookup)
(define-key map (kbd "i") 'biblio-ieee-lookup)
(define-key map (kbd "h") 'biblio-hal-lookup)
(define-key map (kbd "s") 'biblio-dissemin-lookup)
(define-key map (kbd "b") 'biblio-dblp-lookup)
(define-key map (kbd "o") 'biblio-doi-insert-bibtex)
map)
"Citar Embark become keymap for biblio lookup.")
;; tell embark about the keymap
(add-to-list 'embark-become-keymaps 'my-citar-embark-become-map)
A flat list of standard Emacs commands plus Embark gives a lot of flexibility.
If you come from helm-bibtex
or ivy-bibtex
and crave a shorter entry point, however, the simple solution is to define an alias to what you'd like to be your default command; like:
(defalias 'my/cite 'citar-insert-citation)
For marking candidates in the embark-collect
buffer.
TODO Still need code to bind this to embark.
This allows you to bypass the embark-act
command and invoke actions directly within a collect buffer.