5353
5454(defvar embark-keymap-alist )
5555(defvar embark-target-finders )
56+ (defvar embark-pre-action-hooks )
5657(defvar embark-general-map )
5758(defvar embark-meta-map )
5859(defvar citar-org-open-note-function )
@@ -191,16 +192,19 @@ If you use 'org-roam' and 'org-roam-bibtex', you can use
191192 '(((org-mode ) .
192193 ((local-bib-files . citar-org-local-bib-files)
193194 (insert-citation . citar-org-insert-citation)
195+ (insert-edit . citar-org-insert-edit)
194196 (key-at-point . citar-org-key-at-point)
195197 (citation-at-point . citar-org-citation-at-point)))
196198 ((latex-mode ) .
197199 ((local-bib-files . citar-latex-local-bib-files)
198200 (insert-citation . citar-latex-insert-citation)
201+ (insert-edit . citar-latex-insert-edit)
199202 (key-at-point . citar-latex-key-at-point)
200203 (citation-at-point . citar-latex-citation-at-point)))
201204 ((markdown-mode ) .
202205 ((insert-keys . citar-markdown-insert-keys)
203206 (insert-citation . citar-markdown-insert-citation)
207+ (insert-edit . citar-markdown-insert-edit)
204208 (key-at-point . citar-markdown-key-at-point)
205209 (citation-at-point . citar-markdown-citation-at-point)))
206210 (t .
@@ -223,6 +227,10 @@ insert-citation: the corresponding function should insert a
223227complete citation from a list of keys at point. If the point is
224228in a citation, new keys should be added to the citation.
225229
230+ insert-edit: the corresponding function should accept an optional
231+ prefix argument and interactively edit the citation or key at
232+ point.
233+
226234key-at-point: the corresponding function should return the
227235citation key at point or nil if there is none. The return value
228236should be (KEY . BOUNDS), where KEY is a string and BOUNDS is a
@@ -266,8 +274,9 @@ start and end of the citation."
266274 map)
267275 " Keymap for Embark minibuffer actions." )
268276
269- (defvar citar-buffer -map
277+ (defvar citar-citation -map
270278 (let ((map (make-sparse-keymap )))
279+ (define-key map (kbd " i" ) (cons " insert or edit" #'citar-insert-edit ))
271280 (define-key map (kbd " o" ) (cons " open source document" #'citar-open ))
272281 (define-key map (kbd " e" ) (cons " open bibtex entry" #'citar-open-entry ))
273282 (define-key map (kbd " l" ) (cons " open source URL or DOI" #'citar-open-link ))
@@ -716,7 +725,9 @@ FORMAT-STRING."
716725
717726(with-eval-after-load 'embark
718727 (add-to-list 'embark-keymap-alist '(citar-reference . citar-map))
719- (add-to-list 'embark-keymap-alist '(citar-key . citar-buffer-map)))
728+ (add-to-list 'embark-keymap-alist '(citar-key . citar-citation-map))
729+ (add-to-list 'embark-keymap-alist '(citar-citation . citar-citation-map))
730+ (add-to-list 'embark-pre-action-hooks '(citar-insert-edit embark--ignore-target)))
720731
721732; ;; Commands
722733
@@ -861,6 +872,15 @@ With prefix, rebuild the cache before offering candidates."
861872 (message " Citation insertion is not supported for %s " major-mode))
862873 (citar--extract-keys keys-entries)))
863874
875+ (defun citar-insert-edit (&optional arg )
876+ " Edit the citation at point."
877+ (interactive " P" )
878+ (citar--major-mode-function
879+ 'insert-edit
880+ (lambda (&rest _ )
881+ (message " Citation editing is not supported for %s " major-mode))
882+ arg))
883+
864884;;;### autoload
865885(defun citar-insert-reference (keys-entries )
866886 " Insert formatted reference(s) associated with the KEYS-ENTRIES.
0 commit comments