pkg update and first config fix
org-brain not working, add org-roam
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: 20211019.1306
|
||||
;; Package-Commit: aa775340ba691d2322948bfdc6a88158568a1399
|
||||
;; Package-Version: 20221024.857
|
||||
;; Package-Commit: 78f5931e1cc82e7ae2bcf0508cf31d0d1629a8dd
|
||||
;; 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"))
|
||||
|
||||
@@ -368,7 +368,6 @@ bibliography file is reparsed.")
|
||||
(defvar bibtex-completion-string-hash-table nil
|
||||
"A hash table used for string replacements.")
|
||||
|
||||
|
||||
(defun bibtex-completion-normalize-bibliography (&optional type)
|
||||
"Return a list of bibliography file(s) in `bibtex-completion-bibliography'.
|
||||
If there are org mode bibliography-files, their corresponding
|
||||
@@ -383,7 +382,18 @@ their associated bibtex files."
|
||||
bib-file)
|
||||
for bibtex-file = (if (consp bib-file)
|
||||
(cdr bib-file)
|
||||
(concat (file-name-sans-extension main-file) ".bib"))
|
||||
(cond
|
||||
((string= (file-name-extension main-file) "bib") main-file)
|
||||
((string= (file-name-extension main-file) "org")
|
||||
(concat (file-name-sans-extension main-file) "bib"))
|
||||
((and (string= (file-name-extension main-file) "gpg")
|
||||
(string= (file-name-extension
|
||||
(file-name-sans-extension main-file)) "bib")) main-file)
|
||||
((and (string= (file-name-extension main-file) "gpg")
|
||||
(string= (file-name-extension
|
||||
(file-name-sans-extension main-file)) "org"))
|
||||
(concat (file-name-sans-extension
|
||||
(file-name-sans-extension main-file)) ".bib.gpg"))))
|
||||
unless (equal type 'bibtex)
|
||||
collect main-file
|
||||
unless (equal type 'main)
|
||||
@@ -488,7 +498,7 @@ The first element of these conses is a string containing authors,
|
||||
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)))
|
||||
(let ((files (bibtex-completion-normalize-bibliography 'bibtex))
|
||||
(ht-strings (make-hash-table :test #'equal))
|
||||
reparsed-files)
|
||||
|
||||
@@ -569,10 +579,9 @@ fields listed above) as an alist."
|
||||
|
||||
;; Finally return the list of candidates:
|
||||
(message "Done (re)loading bibliography.")
|
||||
(nreverse
|
||||
(cl-loop
|
||||
for file in files
|
||||
append (cddr (assoc file bibtex-completion-cache))))))
|
||||
(cl-loop
|
||||
for file in files
|
||||
append (reverse (cddr (assoc file bibtex-completion-cache))))))
|
||||
|
||||
(defun bibtex-completion-resolve-crossrefs (files reparsed-files)
|
||||
"Expand all entries with fields from cross-referenced entries in FILES, assuming that only those files in REPARSED-FILES were reparsed whereas the other files in FILES were up-to-date."
|
||||
@@ -1155,66 +1164,64 @@ The format depends on
|
||||
|
||||
(defun bibtex-completion-apa-get-value (field entry &optional default)
|
||||
"Return FIELD or ENTRY formatted following the APA guidelines.
|
||||
Return DEFAULT if FIELD is not present in ENTRY."
|
||||
;; Virtual fields:
|
||||
(pcase field
|
||||
("author-or-editor"
|
||||
;; Avoid if-let and when-let because they're not working reliably
|
||||
;; in all versions of Emacs that we currently support:
|
||||
(let ((value (bibtex-completion-get-value "author" entry)))
|
||||
(if value
|
||||
(bibtex-completion-apa-format-authors value)
|
||||
(bibtex-completion-apa-format-editors
|
||||
(bibtex-completion-get-value "editor" entry)))))
|
||||
("author-or-editor-abbrev"
|
||||
(let* ((value (bibtex-completion-get-value "author" entry)))
|
||||
(if value
|
||||
(bibtex-completion-apa-format-authors-abbrev value)
|
||||
(bibtex-completion-apa-format-editors-abbrev
|
||||
(bibtex-completion-get-value "editor" entry)))))
|
||||
("author-abbrev"
|
||||
(let ((value (bibtex-completion-get-value "author" entry)))
|
||||
(when value
|
||||
(bibtex-completion-apa-format-authors-abbrev value))))
|
||||
("editor-abbrev"
|
||||
(let ((value (bibtex-completion-get-value "editor" entry)))
|
||||
(when value
|
||||
(bibtex-completion-apa-format-editors-abbrev value))))
|
||||
(_
|
||||
;; Real fields:
|
||||
(let ((value (bibtex-completion-get-value field entry)))
|
||||
(if value
|
||||
(pcase field
|
||||
;; https://owl.english.purdue.edu/owl/resource/560/06/
|
||||
("author" (bibtex-completion-apa-format-authors value))
|
||||
("editor" (bibtex-completion-apa-format-editors value))
|
||||
;; When referring to books, chapters, articles, or Web pages,
|
||||
;; capitalize only the first letter of the first word of a
|
||||
;; title and subtitle, the first word after a colon or a dash
|
||||
;; in the title, and proper nouns. Do not capitalize the first
|
||||
;; letter of the second word in a hyphenated compound word.
|
||||
("title" (replace-regexp-in-string ; remove braces
|
||||
"[{}]"
|
||||
""
|
||||
(replace-regexp-in-string ; remove macros
|
||||
"\\\\[[:alpha:]]+{"
|
||||
Return DEFAULT if FIELD is not present in ENTRY. Return empty
|
||||
string if FIELD is not present in ENTRY and DEFAULT is nil."
|
||||
(or
|
||||
(pcase field
|
||||
;; Virtual fields:
|
||||
("author-or-editor"
|
||||
;; Avoid if-let and when-let because they're not working reliably
|
||||
;; in all versions of Emacs that we currently support:
|
||||
(if-let ((value (bibtex-completion-get-value "author" entry)))
|
||||
(bibtex-completion-apa-format-authors value)
|
||||
(when-let ((value (bibtex-completion-get-value "editor" entry)))
|
||||
(bibtex-completion-apa-format-editors value))))
|
||||
("author-or-editor-abbrev"
|
||||
(if-let ((value (bibtex-completion-get-value "author" entry)))
|
||||
(bibtex-completion-apa-format-authors-abbrev value)
|
||||
(when-let ((value (bibtex-completion-get-value "editor" entry)))
|
||||
(bibtex-completion-apa-format-editors-abbrev value))))
|
||||
("author-abbrev"
|
||||
(when-let ((value (bibtex-completion-get-value "author" entry)))
|
||||
(bibtex-completion-apa-format-authors-abbrev value)))
|
||||
("editor-abbrev"
|
||||
(when-let ((value (bibtex-completion-get-value "editor" entry)))
|
||||
(bibtex-completion-apa-format-editors-abbrev value)))
|
||||
(_
|
||||
;; Real fields:
|
||||
(let ((value (bibtex-completion-get-value field entry)))
|
||||
(if value
|
||||
(pcase field
|
||||
;; https://owl.english.purdue.edu/owl/resource/560/06/
|
||||
("author" (bibtex-completion-apa-format-authors value))
|
||||
("editor" (bibtex-completion-apa-format-editors value))
|
||||
;; When referring to books, chapters, articles, or Web pages,
|
||||
;; capitalize only the first letter of the first word of a
|
||||
;; title and subtitle, the first word after a colon or a dash
|
||||
;; in the title, and proper nouns. Do not capitalize the first
|
||||
;; letter of the second word in a hyphenated compound word.
|
||||
("title" (replace-regexp-in-string ; remove braces
|
||||
"[{}]"
|
||||
""
|
||||
(replace-regexp-in-string ; upcase initial letter
|
||||
"^[[:alpha:]]"
|
||||
'upcase
|
||||
(replace-regexp-in-string ; preserve stuff in braces from being downcased
|
||||
"\\(^[^{]*{\\)\\|\\(}[^{]*{\\)\\|\\(}.*$\\)\\|\\(^[^{}]*$\\)"
|
||||
(lambda (x) (downcase (s-replace "\\" "\\\\" x)))
|
||||
value)))))
|
||||
("booktitle" value)
|
||||
;; Maintain the punctuation and capitalization that is used by
|
||||
;; the journal in its title.
|
||||
("pages" (s-join "–" (s-split "[^0-9]+" value t)))
|
||||
("doi" (s-concat " http://dx.doi.org/" value))
|
||||
("year" (or value
|
||||
(car (split-string (bibtex-completion-get-value "date" entry "") "-"))))
|
||||
(_ value))
|
||||
(or default ""))))))
|
||||
(replace-regexp-in-string ; remove macros
|
||||
"\\\\[[:alpha:]]+{"
|
||||
""
|
||||
(replace-regexp-in-string ; upcase initial letter
|
||||
"^[[:alpha:]]"
|
||||
'upcase
|
||||
(replace-regexp-in-string ; preserve stuff in braces from being downcased
|
||||
"\\(^[^{]*{\\)\\|\\(}[^{]*{\\)\\|\\(}.*$\\)\\|\\(^[^{}]*$\\)"
|
||||
(lambda (x) (downcase (s-replace "\\" "\\\\" x)))
|
||||
value)))))
|
||||
("booktitle" value)
|
||||
;; Maintain the punctuation and capitalization that is used by
|
||||
;; the journal in its title.
|
||||
("pages" (s-join "–" (s-split "[^0-9]+" value t)))
|
||||
("doi" (s-concat " http://dx.doi.org/" value))
|
||||
("year" (or value
|
||||
(car (split-string (bibtex-completion-get-value "date" entry "") "-"))))
|
||||
(_ value))))))
|
||||
default ""))
|
||||
|
||||
(defun bibtex-completion-apa-format-authors (value &optional abbrev)
|
||||
"Format author list in VALUE in APA style.
|
||||
@@ -1611,10 +1618,20 @@ find the key of the BibTeX entry at point in an Org-mode buffer."
|
||||
(> (length key) 0)
|
||||
key))))
|
||||
|
||||
(defun bibtex-completion-get-key-org-cite ()
|
||||
"Return the org-cite key at point, nil otherwise.
|
||||
This function can be used by `bibtex-completion-key-at-point' to
|
||||
find the org-cite key at point in an Org-mode buffer."
|
||||
(when (eq major-mode 'org-mode)
|
||||
(let ((el (org-element-context)))
|
||||
(when (eq (car el) 'citation-reference)
|
||||
(plist-get (cadr el) :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)
|
||||
#'bibtex-completion-get-key-org-bibtex
|
||||
#'bibtex-completion-get-key-org-cite)
|
||||
"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.
|
||||
|
||||
Reference in New Issue
Block a user