Last active
February 8, 2023 17:51
-
-
Save bdarcus/8fa0e45a5834a4e57e3781d2b6acafd3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
;;; citar-menu.el --- transient example for citar -*- lexical-binding: t; -*- | |
;; | |
;;; Code: | |
(require 'org-element) | |
(require 'transient) | |
(require 'citar) | |
(require 'citar-org) | |
(defun citar-hydra-open-entry () | |
"A hydra interface to 'citar-open-entry'." | |
(interactive) | |
(citar--open-entry (citar-key-at-point))) | |
(defun citar-hydra-open-note () | |
"A hydra interface to 'citar--open-note'." | |
(interactive) | |
(let ((key (citar-key-at-point))) | |
(citar-open-notes (list key)))) | |
(defun citar-menu-open-library-file () | |
"A hydra interface to 'citar--library-file-action'." | |
(interactive) | |
(let ((key (citar-key-at-point))) | |
(citar-open-files (list key)))) | |
(defun citar-menu-open () | |
"A hydra interface to 'citar-open'." | |
(interactive) | |
(let ((key (citar-key-at-point))) | |
(citar-open (list key)))) | |
(transient-define-prefix citar-menu-transient () | |
["Reference(s)\n" | |
["Open" | |
("f" "library files" citar-menu-open-library-file) | |
("e" "BibTeX entry" citar-menu-open-entry) | |
("n" "notes" citar-menu-open-note) | |
("o" "files or links" citar-menu-open)] | |
["Edit" | |
("i" "Insert or edit" citar-insert-edit) | |
("d" "Delete key/citation" citar-org-delete-citation)]]) | |
(defun citar-menu-follow (&optional datum _) | |
"Follow function to use a hydra for citar. | |
DATUM is the org element." | |
(interactive) | |
(when (null datum) (setq datum (org-element-context))) | |
(if (eq 'citation-reference (org-element-type datum)) | |
(citar-org-citation-reference/body))) | |
(defun citar-menu-transient-follow (&optional datum _) | |
"Follow function to use a hydra for citar. | |
DATUM is the org element." | |
(interactive) | |
(when (null datum) (setq datum (org-element-context))) | |
(if (eq 'citation-reference (org-element-type datum)) | |
(citar-menu-transient))) | |
;;;###autoload | |
(org-cite-register-processor 'citar-transient | |
:follow #'citar-menu-follow) | |
(org-cite-register-processor 'citar-transient | |
:follow #'citar-menu-transient-follow) | |
(provide 'citar-menu) | |
;;; citar-hydra.el ends here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment