update packages
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
;; Justin Burkett <justin@burkett.cc>
|
||||
;; Maintainer: Titus von der Malsburg <malsburg@posteo.de>
|
||||
;; URL: https://github.com/tmalsburg/helm-bibtex
|
||||
;; Package-Version: 20200513.852
|
||||
;; Package-Commit: 8a0dd9841316793aacddea744d6b8ca4a7857a35
|
||||
;; Package-Version: 20200908.1017
|
||||
;; Package-Commit: 1bb81d77e08296a50de7ebfe5cf5b0c715b7f3d6
|
||||
;; Version: 1.0.0
|
||||
;; Package-Requires: ((parsebib "1.0") (s "1.9.0") (dash "2.6.0") (f "0.16.2") (cl-lib "0.5") (biblio "0.2") (emacs "26.1"))
|
||||
|
||||
@@ -115,6 +115,8 @@ This should be a single character."
|
||||
'((org-mode . bibtex-completion-format-citation-ebib)
|
||||
(latex-mode . bibtex-completion-format-citation-cite)
|
||||
(markdown-mode . bibtex-completion-format-citation-pandoc-citeproc)
|
||||
(python-mode . bibtex-completion-format-citation-sphinxcontrib-bibtex)
|
||||
(rst-mode . bibtex-completion-format-citation-sphinxcontrib-bibtex)
|
||||
(default . bibtex-completion-format-citation-default))
|
||||
"The functions used for formatting citations.
|
||||
The publication can be cited, for example, as \cite{key} or
|
||||
@@ -419,7 +421,7 @@ Also sets `bibtex-completion-display-formats-internal'."
|
||||
(let* ((format-string (cdr format))
|
||||
(fields-width 0)
|
||||
(string-width
|
||||
(length
|
||||
(string-width
|
||||
(s-format format-string
|
||||
(lambda (field)
|
||||
(setq fields-width
|
||||
@@ -481,7 +483,7 @@ for string replacement."
|
||||
(defun bibtex-completion-candidates ()
|
||||
"Read the BibTeX files and return a list of conses, one for each entry.
|
||||
The first element of these conses is a string containing authors,
|
||||
editors, title, year, type, and key of the entry. This is string
|
||||
editors, title, year, type, and key of the entry. This string
|
||||
is used for matching. The second element is the entry (only the
|
||||
fields listed above) as an alist."
|
||||
(let ((files (nreverse (bibtex-completion-normalize-bibliography 'bibtex)))
|
||||
@@ -1032,6 +1034,10 @@ only adds KEYS to it."
|
||||
(s-join ", "
|
||||
(--map (format "ebib:%s" it) keys)))
|
||||
|
||||
(defun bibtex-completion-format-citation-sphinxcontrib-bibtex (keys)
|
||||
"Format sphinxcontrib-bibtex references for keys in KEYS."
|
||||
(format ":cite:`%s`" (s-join "," keys)))
|
||||
|
||||
(defun bibtex-completion-format-citation-org-link-to-PDF (keys)
|
||||
"Format org-links to PDFs associated with entries in KEYS.
|
||||
Uses first matching PDF if several are available. Entries for
|
||||
@@ -1539,41 +1545,65 @@ BibTeX files. If this fails, return nil."
|
||||
(require 'reftex-cite nil t)
|
||||
(ignore-errors (reftex-get-bibfile-list)))))
|
||||
|
||||
(defun bibtex-completion-get-key-bibtex ()
|
||||
"Return the key of the BibTeX entry at point, nil otherwise.
|
||||
This function can be used by `bibtex-completion-key-at-point' to
|
||||
find the key of the BibTeX entry at point in a BibTeX-mode
|
||||
buffer."
|
||||
(when (eq major-mode 'bibtex-mode)
|
||||
(save-excursion
|
||||
(bibtex-beginning-of-entry)
|
||||
(and (looking-at bibtex-entry-maybe-empty-head)
|
||||
(bibtex-key-in-head)))))
|
||||
|
||||
(defun bibtex-completion-get-key-latex ()
|
||||
"Return the key of the BibTeX entry at point, nil otherwise.
|
||||
This function can be used by `bibtex-completion-key-at-point' to
|
||||
find the key of the BibTeX entry at point in a LaTeX buffer."
|
||||
(when (and (derived-mode-p 'latex-mode)
|
||||
(require 'reftex-parse nil t))
|
||||
(save-excursion
|
||||
(skip-chars-backward "[:space:],;}")
|
||||
(let ((macro (reftex-what-macro 1)))
|
||||
(and (stringp (car macro))
|
||||
(string-match "\\`\\\\cite\\|cite\\'" (car macro))
|
||||
;; allow '_' in citekeys
|
||||
(let ((temp-syn-table (make-syntax-table)))
|
||||
(modify-syntax-entry ?_ "_" temp-syn-table)
|
||||
(with-syntax-table temp-syn-table
|
||||
(thing-at-point 'symbol))))))))
|
||||
|
||||
(defun bibtex-completion-get-key-org-bibtex ()
|
||||
"Return the key of the BibTeX entry at point, nil otherwise.
|
||||
This function can be used by `bibtex-completion-key-at-point' to
|
||||
find the key of the BibTeX entry at point in an Org-mode buffer."
|
||||
(when (eq major-mode 'org-mode)
|
||||
(let (key)
|
||||
(and (setq key (org-entry-get nil
|
||||
(if (boundp 'org-bibtex-key-property)
|
||||
org-bibtex-key-property
|
||||
"CUSTOM_ID")
|
||||
t))
|
||||
;; KEY may be the empty string the the property is
|
||||
;; present but has no value
|
||||
(> (length key) 0)
|
||||
key))))
|
||||
|
||||
(defvar bibtex-completion-key-at-point-functions
|
||||
(list #'bibtex-completion-get-key-bibtex
|
||||
#'bibtex-completion-get-key-latex
|
||||
#'bibtex-completion-get-key-org-bibtex)
|
||||
"List of functions to use to find the BibTeX key.
|
||||
The functions should take no argument and return the BibTeX
|
||||
key. Stops as soon as a function returns something.
|
||||
See `bibtex-completion-key-at-point' for details.")
|
||||
|
||||
(defun bibtex-completion-key-at-point ()
|
||||
"Return the key of the BibTeX entry at point.
|
||||
If the current file is a BibTeX file, return the key of the entry
|
||||
at point. Otherwise, try to use `reftex' to check whether point
|
||||
is at a citation macro, and if so return the key at
|
||||
point. Otherwise, if the current file is an org mode file, return
|
||||
the value of `org-bibtex-key-property' (or default to
|
||||
\"CUSTOM_ID\"). Otherwise, return nil."
|
||||
(or (and (eq major-mode 'bibtex-mode)
|
||||
(save-excursion
|
||||
(bibtex-beginning-of-entry)
|
||||
(and (looking-at bibtex-entry-maybe-empty-head)
|
||||
(bibtex-key-in-head))))
|
||||
(and (require 'reftex-parse nil t)
|
||||
(save-excursion
|
||||
(skip-chars-backward "[:space:],;}")
|
||||
(let ((macro (reftex-what-macro 1)))
|
||||
(and (stringp (car macro))
|
||||
(string-match "\\`\\\\cite\\|cite\\'" (car macro))
|
||||
;; allow '_' in citekeys
|
||||
(let ((temp-syn-table (make-syntax-table)))
|
||||
(modify-syntax-entry ?_ "_" temp-syn-table)
|
||||
(with-syntax-table temp-syn-table
|
||||
(thing-at-point 'symbol)))))))
|
||||
(and (eq major-mode 'org-mode)
|
||||
(let (key)
|
||||
(and (setq key (org-entry-get nil
|
||||
(if (boundp 'org-bibtex-key-property)
|
||||
org-bibtex-key-property
|
||||
"CUSTOM_ID")
|
||||
t))
|
||||
;; KEY may be the empty string the the property is
|
||||
;; present but has no value
|
||||
(> (length key) 0)
|
||||
key)))))
|
||||
The functions used to match the keys are defined in
|
||||
`bibtex-completion-key-at-point-functions'."
|
||||
(cl-some #'identity
|
||||
(mapcar #'funcall bibtex-completion-key-at-point-functions)))
|
||||
|
||||
(provide 'bibtex-completion)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user