update packages

This commit is contained in:
2025-11-25 19:52:03 +01:00
parent 14ba373378
commit dbbae92267
280 changed files with 13451 additions and 11207 deletions

View File

@@ -28,8 +28,8 @@
;; indicate the pre/post-note structure. They also have tooltips that show
;; information from the bibtex entry.
;;
;; Each link is functional, and clicking on one will open a hydra menu
;; `org-ref-citation-hydra/body' of actions that range from opening the bibtex
;; Each link is functional, and clicking on one will open a transient menu
;; `org-ref-citation-menu' of actions that range from opening the bibtex
;; entry, notes, pdf or associated URL, to searching the internet for related
;; articles.
;;
@@ -48,7 +48,7 @@
;;
;;; Code:
(require 'org-keys)
(require 'hydra)
(require 'transient)
(require 'xref)
(eval-when-compile (require 'subr-x))
@@ -340,14 +340,14 @@ to a path string."
(string-join (cl-loop for ref in (plist-get data :references) collect (plist-get ref :key)) ","))
(3
(concat
(when-let (prefix (plist-get data :prefix)) (concat prefix ";"))
(when-let* ((prefix (plist-get data :prefix))) (concat prefix ";"))
(string-join (cl-loop for ref in (plist-get data :references) collect
(concat
(plist-get ref :prefix)
"&" (plist-get ref :key)
(plist-get ref :suffix)))
";")
(when-let (suffix (plist-get data :suffix)) (concat ";" suffix))))))
(when-let* ((suffix (plist-get data :suffix))) (concat ";" suffix))))))
;; * Activating citation links
@@ -360,19 +360,6 @@ to a path string."
(defvar bibtex-completion-bibliography)
(defvar bibtex-completion-display-formats-internal)
;; (defun org-ref-valid-keys ()
;; "Return a list of valid bibtex keys for this buffer.
;; This is used a lot in `org-ref-cite-activate' so it needs to be
;; fast, but also up to date."
;; ;; this seems to be needed, but we don't want to do this every time
;; (unless bibtex-completion-display-formats-internal
;; (bibtex-completion-init))
;; (let ((bibtex-completion-bibliography (org-ref-find-bibliography)))
;; (cl-loop for entry in (bibtex-completion-candidates)
;; collect
;; (cdr (assoc "=key=" (cdr entry))))))
(defun org-ref-valid-keys ()
"Return a list of valid bibtex keys for this buffer.
@@ -380,6 +367,8 @@ This is used a lot in `org-ref-cite-activate' so it needs to be
fast, but also up to date."
;; this seems to be needed, but we don't want to do this every time
;; I found when bibtex-completion-display-formats-internal is nil
;; we have to run this init function
(unless bibtex-completion-display-formats-internal
(bibtex-completion-init))
@@ -394,7 +383,9 @@ fast, but also up to date."
for file in files
append (cddr (assoc file bibtex-completion-cache)))
collect (cdr (assoc "=key=" (cdr entry))))
;; you need to get a cache because one or more of the files was not in the cache.
;; you need to get a cache because one or more of the files was not in the
;; cache. The cache should be automatically made by
;; bibtex-completion-candidates
(let ((bibtex-completion-bibliography files))
(cl-loop for entry in (bibtex-completion-candidates)
collect
@@ -405,11 +396,15 @@ fast, but also up to date."
(defvar-local org-ref-valid-keys-cache nil)
(defun org-ref-valid-keys-cached ()
"Update `org-ref-valid-keys-cache` only when files changed."
"Update `org-ref-valid-keys-cache` only when files changed or it is empty.
Returns a hash-table you can use to test key validity.
(gethash key (org-ref-valid-keys-cached)"
(let ((local-hashes (cons bibtex-completion-bibliography
(mapcar 'cadr bibtex-completion-cache))))
(when (not (equal local-hashes org-ref-valid-keys-hashes))
(when (or (null org-ref-valid-keys-cache)
(not (equal local-hashes org-ref-valid-keys-hashes)))
(setq-local org-ref-valid-keys-hashes local-hashes)
(setq-local org-ref-valid-keys-cache (make-hash-table :test 'equal))
(cl-loop for entry in (org-ref-valid-keys)
@@ -427,7 +422,7 @@ PATH has the citations in it."
;; path containing @ which makes it likely to be an org-cite. Maybe
;; a text property is better, in case this is an issue in the
;; future.
(not (s-contains-p "@" path)))
(not (string-match-p (regexp-quote "@") path)))
(let* ((valid-keys (org-ref-valid-keys))
valid-key
substrings)
@@ -522,64 +517,67 @@ PATH has the citations in it."
(declare-function org-ref-get-bibtex-key-and-file "org-ref-core")
(defhydra org-ref-citation-hydra (:color blue :hint nil)
"Citation actions
"
("o" org-ref-open-citation-at-point "Bibtex" :column "Open")
("p" org-ref-open-pdf-at-point "PDF" :column "Open")
("n" org-ref-open-notes-at-point "Notes" :column "Open")
("u" org-ref-open-url-at-point "URL" :column "Open")
;; WWW actions
("ww" org-ref-wos-at-point "WOS" :column "WWW")
("wr" org-ref-wos-related-at-point "WOS related" :column "WWW")
("wc" org-ref-wos-citing-at-point "WOS citing" :column "WWW")
("wg" org-ref-google-scholar-at-point "Google Scholar" :column "WWW")
("wp" org-ref-pubmed-at-point "Pubmed" :column "WWW")
("wf" org-ref-crossref-at-point "Crossref" :column "WWW")
("wb" org-ref-biblio-at-point "Biblio" :column "WWW")
("e" org-ref-email-at-point "Email" :column "WWW")
;; Copyish actions
("K" (save-window-excursion
(let ((bibtex-completion-bibliography (org-ref-find-bibliography)))
(bibtex-completion-show-entry (list (org-ref-get-bibtex-key-under-cursor)))
(bibtex-copy-entry-as-kill)
(kill-new (pop bibtex-entry-kill-ring))))
"Copy bibtex" :column "Copy")
("a" org-ref-add-pdf-at-point "add pdf to library" :column "Copy")
("k" (kill-new (car (org-ref-get-bibtex-key-and-file))) "Copy key" :column "Copy")
("f" (kill-new (bibtex-completion-apa-format-reference
(org-ref-get-bibtex-key-under-cursor)))
"Copy formatted" :column "Copy")
("h" (kill-new
(format "* %s\n\n cite:&%s"
(bibtex-completion-apa-format-reference
(org-ref-get-bibtex-key-under-cursor))
(car (org-ref-get-bibtex-key-and-file))))
"Copy org heading"
:column "Copy")
;; Editing actions
("<left>" org-ref-cite-shift-left "Shift left" :color red :column "Edit")
("<right>" org-ref-cite-shift-right "Shift right" :color red :column "Edit")
("<up>" org-ref-sort-citation-link "Sort by year" :column "Edit")
("i" (funcall org-ref-insert-cite-function) "Insert cite" :column "Edit")
("t" org-ref-change-cite-type "Change cite type" :column "Edit")
("d" org-ref-delete-citation-at-point "Delete at point" :column "Edit")
("r" org-ref-replace-citation-at-point "Replace cite" :column "Edit")
("P" org-ref-edit-pre-post-notes "Edit pre/suffix" :column "Edit")
;; Navigation
("[" org-ref-previous-key "Previous key" :column "Navigation" :color red)
("]" org-ref-next-key "Next key" :column "Navigation" :color red)
("v" org-ref-jump-to-visible-key "Visible key" :column "Navigation" :color red)
("q" nil "Quit"))
(transient-define-prefix org-ref-citation-menu ()
"Citation actions."
[["Open"
("o" "Bibtex" org-ref-open-citation-at-point)
("p" "PDF" org-ref-open-pdf-at-point)
("n" "Notes" org-ref-open-notes-at-point)
("u" "URL" org-ref-open-url-at-point)]
["WWW"
("ww" "WOS" org-ref-wos-at-point)
("wr" "WOS related" org-ref-wos-related-at-point)
("wc" "WOS citing" org-ref-wos-citing-at-point)
("wg" "Google Scholar" org-ref-google-scholar-at-point)
("wp" "Pubmed" org-ref-pubmed-at-point)
("wf" "Crossref" org-ref-crossref-at-point)
("wb" "Biblio" org-ref-biblio-at-point)
("e" "Email" org-ref-email-at-point)]
["Copy"
("K" "Copy bibtex" (lambda ()
(interactive)
(save-window-excursion
(let ((bibtex-completion-bibliography (org-ref-find-bibliography)))
(bibtex-completion-show-entry (list (org-ref-get-bibtex-key-under-cursor)))
(bibtex-copy-entry-as-kill)
(kill-new (pop bibtex-entry-kill-ring))))))
("a" "Add pdf to library" org-ref-add-pdf-at-point)
("k" "Copy key" (lambda ()
(interactive)
(kill-new (car (org-ref-get-bibtex-key-and-file)))))
("f" "Copy formatted" (lambda ()
(interactive)
(kill-new (bibtex-completion-apa-format-reference
(org-ref-get-bibtex-key-under-cursor)))))
("h" "Copy org heading" (lambda ()
(interactive)
(kill-new
(format "* %s\n\n cite:&%s"
(bibtex-completion-apa-format-reference
(org-ref-get-bibtex-key-under-cursor))
(car (org-ref-get-bibtex-key-and-file))))))]
["Edit"
("<left>" "Shift left" org-ref-cite-shift-left :transient t)
("<right>" "Shift right" org-ref-cite-shift-right :transient t)
("<up>" "Sort by year" org-ref-sort-citation-link)
("i" "Insert cite" (lambda () (interactive) (funcall org-ref-insert-cite-function)))
("t" "Change cite type" org-ref-change-cite-type)
("d" "Delete at point" org-ref-delete-citation-at-point)
("r" "Replace cite" org-ref-replace-citation-at-point)
("P" "Edit pre/suffix" org-ref-edit-pre-post-notes)]
["Navigation"
("[" "Previous key" org-ref-previous-key :transient t)
("]" "Next key" org-ref-next-key :transient t)
("v" "Visible key" org-ref-jump-to-visible-key :transient t)
("q" "Quit" transient-quit-one)]])
(defun org-ref-cite-follow (_path)
"Follow a cite link."
(org-ref-citation-hydra/body))
(org-ref-citation-menu))
(define-obsolete-function-alias 'org-ref-citation-hydra/body
#'org-ref-citation-menu "3.1")
;; * Citation links tooltips
@@ -637,13 +635,13 @@ Use with apply-partially."
(format "[%s]" (cl-second prefix-suffix)))
(t
""))))
(s-format "\\${cmd}${prefix}${suffix}{${keys}}" 'aget
(org-ref--format-template "\\${cmd}${prefix}${suffix}{${keys}}"
`(("cmd" . ,cmd)
("prefix" . ,(string-trim prefix))
("suffix" . ,(string-trim suffix))
("keys" . ,(string-join keys ","))))))
(3
(s-format "\\${cmd}${prefix}${suffix}{${keys}}" 'aget
(org-ref--format-template "\\${cmd}${prefix}${suffix}{${keys}}"
`(("cmd" . ,cmd)
;; if there is more than one key, we only do global
;; prefix/suffix But for one key, we should allow local
@@ -748,7 +746,7 @@ Use with apply-partially."
(pcase backend
('latex
(let ((cite (org-ref-parse-cite-path path)))
(s-format "\\${cmd}${global-prefix}${global-suffix}${keys}" 'aget
(org-ref--format-template "\\${cmd}${global-prefix}${global-suffix}${keys}"
`(("cmd" . ,cmd)
("global-prefix" . ,(cond
((plist-get cite :prefix)
@@ -858,7 +856,7 @@ Use with apply-partially."
(setq i (seq-position references key (lambda (el key)
(string= key (plist-get el :key)))))
;; delete i'th reference
(setq references (-remove-at i references))
(setq references (org-ref--remove-at i references))
(setq data (plist-put data :references references))
(save-excursion
(goto-char begin)
@@ -1006,7 +1004,7 @@ arg COMMON, edit the common prefixes instead."
If not on a key, but on a cite, prompt for key."
(cond
(org-ref-activate-cite-links
(if-let ((key (get-text-property (point) 'cite-key)))
(if-let* ((key (get-text-property (point) 'cite-key)))
;; Point is on a key, so we get it directly
key
;; point is not on a key, but may still be on a cite link
@@ -1046,10 +1044,10 @@ If not on a key, but on a cite, prompt for key."
(prog1
(get-text-property (point) 'cite-key)
(goto-char cp)))))))))
;; org-ref-activate-cite-links is nil so font-lock does not put
;; text-properties on keys. We temporarily activate this
(t
(let ((el (org-element-context))
(org-ref-activate-cite-links t)) ;; temporary
@@ -1171,10 +1169,10 @@ If not on a key, but on a cite, prompt for key."
Otherwise run `right-word'. If the cursor moves off the link,
move to the beginning of the next cite link after this one."
(interactive)
(when-let (next (next-single-property-change (point) 'cite-key))
(when-let* ((next (next-single-property-change (point) 'cite-key)))
(goto-char next))
(unless (get-text-property (point) 'cite-key)
(when-let (next (next-single-property-change (point) 'cite-key))
(when-let* ((next (next-single-property-change (point) 'cite-key)))
(goto-char next))))
@@ -1184,10 +1182,10 @@ move to the beginning of the next cite link after this one."
Otherwise run `left-word'. If the cursor moves off the link,
move to the beginning of the previous cite link after this one."
(interactive)
(when-let (prev (previous-single-property-change (point) 'cite-key))
(when-let* ((prev (previous-single-property-change (point) 'cite-key)))
(goto-char prev))
(unless (get-text-property (point) 'cite-key)
(when-let (prev (previous-single-property-change (point) 'cite-key))
(when-let* ((prev (previous-single-property-change (point) 'cite-key)))
(goto-char prev))))
(defvar avy-goto-key)
@@ -1316,7 +1314,7 @@ Rules:
(string= key-at-point (plist-get el1 :key)))))
(setq data (plist-put data :references
(-insert-at
(org-ref--insert-at
(+ index (if (and (= 3 version) (looking-at "&"))
0
1))