1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-21 06:55:35 +00:00

org-cite-basic--key-completion-table: Reuse bibliography for speed

* lisp/oc-basic.el (org-cite-basic--key-completion-table): Supply the
pre-calculated bibliography entries when getting entry fields.  This
avoids excessive file change checks inside
`org-cite-basic--parse-bibliography'.
This commit is contained in:
Ihor Radchenko 2022-04-10 19:21:01 +08:00
parent 7ddc5b57c0
commit fa5c832e9b
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B

View File

@ -734,19 +734,24 @@ Return nil if there are no bibliography files or no entries."
(t
(clrhash org-cite-basic--completion-cache)
(dolist (key (org-cite-basic--all-keys))
(let ((completion
(concat
(let ((author (org-cite-basic--get-field 'author key nil t)))
(if author
(truncate-string-to-width
(replace-regexp-in-string " and " "; " author)
org-cite-basic-author-column-end nil ?\s)
(make-string org-cite-basic-author-column-end ?\s)))
org-cite-basic-column-separator
(let ((date (org-cite-basic--get-year key nil 'no-suffix)))
(format "%4s" (or date "")))
org-cite-basic-column-separator
(org-cite-basic--get-field 'title key nil t))))
(let* ((entry (org-cite-basic--get-entry
key
;; Supply pre-calculated bibliography to avoid
;; performance degradation.
(list :cite-basic/bibliography entries)))
(completion
(concat
(let ((author (org-cite-basic--get-field 'author entry nil 'raw)))
(if author
(truncate-string-to-width
(replace-regexp-in-string " and " "; " author)
org-cite-basic-author-column-end nil ?\s)
(make-string org-cite-basic-author-column-end ?\s)))
org-cite-basic-column-separator
(let ((date (org-cite-basic--get-year entry nil 'no-suffix)))
(format "%4s" (or date "")))
org-cite-basic-column-separator
(org-cite-basic--get-field 'title entry nil t))))
(puthash completion key org-cite-basic--completion-cache)))
(unless (map-empty-p org-cite-basic--completion-cache) ;no key
(puthash entries t org-cite-basic--completion-cache)