update of packages
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
|
||||
;;; Code:
|
||||
(eval-and-compile (require 'org-macs))
|
||||
(eval-and-compile (require 'ol))
|
||||
(require 'hydra)
|
||||
|
||||
(defcustom org-ref-default-ref-type "ref"
|
||||
@@ -83,6 +84,7 @@ The label should always be in group 1.")
|
||||
("pageref" "to the page number a label is on")
|
||||
("nameref" "to the name associated with a label (e.g. a caption)")
|
||||
("autoref" "from hyperref, adds automatic prefixes")
|
||||
("Autoref" "from hyperref, capitalized version of autoref")
|
||||
("cref" "from cleveref, adds automatic prefixes, and condenses multiple refs")
|
||||
("Cref" "from cleveref, capitalized version of cref")
|
||||
("crefrange" "from cleveref, makes a range of refs from two refs with a prefix")
|
||||
@@ -113,11 +115,11 @@ The label should always be in group 1.")
|
||||
(path (org-element-property :path cite-link))
|
||||
(deltap (- (point) begin)))
|
||||
;; note this does not respect brackets
|
||||
(setf (buffer-substring begin end)
|
||||
(concat
|
||||
(if bracketp "[[" "")
|
||||
new-type ":" path
|
||||
(if bracketp "]]" "")))
|
||||
(cl--set-buffer-substring begin end
|
||||
(concat
|
||||
(if bracketp "[[" "")
|
||||
new-type ":" path
|
||||
(if bracketp "]]" "")))
|
||||
;; try to preserve the character the point is on.
|
||||
(goto-char (+ begin deltap (- (length new-type) (length old-type))))))
|
||||
|
||||
@@ -275,9 +277,10 @@ This is meant to be used with `apply-partially' in the link definitions."
|
||||
(concat refstyle ":" (completing-read "Label: " (org-ref-get-labels))))
|
||||
|
||||
|
||||
(defun org-ref-store-ref ()
|
||||
(defun org-ref-store-ref-link (&optional reftype)
|
||||
"Store a ref link to a label. The output will be a ref to that label."
|
||||
;; First we have to make sure we are on a label link.
|
||||
(unless reftype (setq reftype "ref"))
|
||||
(let* ((object (and (eq major-mode 'org-mode) (org-element-context)))
|
||||
(label (cond
|
||||
;; here literally on a label link.
|
||||
@@ -357,17 +360,16 @@ This is meant to be used with `apply-partially' in the link definitions."
|
||||
nil))))
|
||||
|
||||
(when label
|
||||
(cl-loop for (reftype _) in org-ref-ref-types do
|
||||
(org-link-store-props
|
||||
:type reftype
|
||||
:link (concat reftype ":" label)))
|
||||
(format (concat org-ref-default-ref-type ":" label)))))
|
||||
(org-link-store-props
|
||||
:type reftype
|
||||
:link (concat reftype ":" label))
|
||||
t)))
|
||||
|
||||
|
||||
;; ** ref link
|
||||
|
||||
(org-link-set-parameters "ref"
|
||||
:store #'org-ref-store-ref
|
||||
:store (defun org-ref-store-ref () (org-ref-store-ref-link "ref"))
|
||||
:complete (apply-partially #'org-ref-complete-link "ref")
|
||||
:activate-func #'org-ref-ref-activate
|
||||
:follow #'org-ref-ref-jump-to
|
||||
@@ -379,7 +381,7 @@ This is meant to be used with `apply-partially' in the link definitions."
|
||||
;;** pageref link
|
||||
|
||||
(org-link-set-parameters "pageref"
|
||||
:store #'org-ref-store-ref
|
||||
:store (defun org-ref-store-pageref () (org-ref-store-ref-link "pageref"))
|
||||
:complete (apply-partially #'org-ref-complete-link "pageref")
|
||||
:activate-func #'org-ref-ref-activate
|
||||
:follow #'org-ref-ref-jump-to
|
||||
@@ -392,7 +394,7 @@ This is meant to be used with `apply-partially' in the link definitions."
|
||||
;;** nameref link
|
||||
|
||||
(org-link-set-parameters "nameref"
|
||||
:store #'org-ref-store-ref
|
||||
:store (defun org-ref-store-nameref () (org-ref-store-ref-link "nameref"))
|
||||
:complete (apply-partially #'org-ref-complete-link "nameref")
|
||||
:activate-func #'org-ref-ref-activate
|
||||
:follow #'org-ref-ref-jump-to
|
||||
@@ -403,7 +405,7 @@ This is meant to be used with `apply-partially' in the link definitions."
|
||||
;;** eqref link
|
||||
|
||||
(org-link-set-parameters "eqref"
|
||||
:store #'org-ref-store-ref
|
||||
:store (defun org-ref-store-eqref () (org-ref-store-ref-link "eqref"))
|
||||
:complete (apply-partially #'org-ref-complete-link "eqref")
|
||||
:activate-func #'org-ref-ref-activate
|
||||
:follow #'org-ref-ref-jump-to
|
||||
@@ -414,7 +416,7 @@ This is meant to be used with `apply-partially' in the link definitions."
|
||||
;;** autoref link
|
||||
|
||||
(org-link-set-parameters "autoref"
|
||||
:store #'org-ref-store-ref
|
||||
:store (defun org-ref-store-autoref () (org-ref-store-ref-link "autoref"))
|
||||
:complete (apply-partially #'org-ref-complete-link "autoref")
|
||||
:activate-func #'org-ref-ref-activate
|
||||
:follow #'org-ref-ref-jump-to
|
||||
@@ -422,13 +424,23 @@ This is meant to be used with `apply-partially' in the link definitions."
|
||||
:face 'org-ref-ref-face
|
||||
:help-echo #'org-ref-ref-help-echo)
|
||||
|
||||
|
||||
(org-link-set-parameters "Autoref"
|
||||
:store (defun org-ref-store-Autoref () (org-ref-store-ref-link "Autoref"))
|
||||
:complete (apply-partially #'org-ref-complete-link "Autoref")
|
||||
:activate-func #'org-ref-ref-activate
|
||||
:follow #'org-ref-ref-jump-to
|
||||
:export (apply-partially #'org-ref-ref-export "Autoref")
|
||||
:face 'org-ref-ref-face
|
||||
:help-echo #'org-ref-ref-help-echo)
|
||||
|
||||
;;** cref link
|
||||
;; for LaTeX cleveref package:
|
||||
;; https://www.ctan.org/tex-archive/macros/latex/contrib/cleveref
|
||||
|
||||
|
||||
(org-link-set-parameters "cref"
|
||||
:store #'org-ref-store-ref
|
||||
:store (defun org-ref-store-cref () (org-ref-store-ref-link "cref"))
|
||||
:complete (apply-partially #'org-ref-complete-link "cref")
|
||||
:activate-func #'org-ref-ref-activate
|
||||
:follow #'org-ref-ref-jump-to
|
||||
@@ -438,7 +450,7 @@ This is meant to be used with `apply-partially' in the link definitions."
|
||||
|
||||
|
||||
(org-link-set-parameters "Cref"
|
||||
:store #'org-ref-store-ref
|
||||
:store (defun org-ref-store-Cref () (org-ref-store-ref-link "Cref"))
|
||||
:complete (apply-partially #'org-ref-complete-link "Cref")
|
||||
:activate-func #'org-ref-ref-activate
|
||||
:follow #'org-ref-ref-jump-to
|
||||
@@ -458,7 +470,7 @@ This is meant to be used with `apply-partially' in the link definitions."
|
||||
(pcase backend
|
||||
('latex
|
||||
(let ((labels (split-string path ",")))
|
||||
(format "\\crefrange{%s}{%s}" (cl-first labels) (cl-second labels))))))
|
||||
(format "\\Crefrange{%s}{%s}" (cl-first labels) (cl-second labels))))))
|
||||
|
||||
|
||||
(defun org-ref-crefrange-complete (cmd &optional _arg)
|
||||
@@ -487,6 +499,19 @@ This is meant to be used with `apply-partially' in the link definitions."
|
||||
:help-echo #'org-ref-ref-help-echo)
|
||||
|
||||
|
||||
;; ** remove store functions
|
||||
(defun org-ref-ref-remove-store ()
|
||||
"Remove the store functions from ref links.
|
||||
These tend to clobber the org store links. You can use C-u C-u
|
||||
C-c C-l to not use them, but if you prefer not to use them, this
|
||||
function removes the store functions from the links."
|
||||
(interactive)
|
||||
(cl-loop for reflink in '("ref" "pageref" "nameref" "eqref" "autoref" "Autoref"
|
||||
"cref" "Cref" "crefrange" "Crefrange")
|
||||
do
|
||||
(setf (cdr (assoc reflink org-link-parameters))
|
||||
(org-plist-delete (cdr (assoc reflink org-link-parameters)) :store))))
|
||||
|
||||
;; * Insert link
|
||||
(defvar org-ref-equation-environments
|
||||
'("equation"
|
||||
|
||||
Reference in New Issue
Block a user