Skip to content

Commit

Permalink
Merge pull request #443 from rdiaz02/no-auto-reload
Browse files Browse the repository at this point in the history
Add a customisation for toggling of proactive reloading of bibliography, II.
  • Loading branch information
tmalsburg authored Jan 9, 2024
2 parents f9a21aa + 70d9e9e commit 93806ce
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions bibtex-completion.el
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ composed of the BibTeX-key plus a \".pdf\" suffix."
:group 'bibtex-completion
:type '(choice directory (repeat directory)))

;; From https://github.com/mwlodarczak/helm-bibtex/commit/4a421cae9b7d4cdb4a0933080633564b1774addb
(defcustom bibtex-completion-watch-bibliography t
"If non-nil (the default) the bibliography is reloaded
proactively every time any of the BibTeX files changes.
Changing the value of this variable after you load helm-bibtex
has no effect: if you load helm-bibtex with this variable
set to t and then decide you do not want to proactively reload the
bibliography, you have to restart Emacs with the new setting
(and likewise for loading helm-bibtex with the variable set to nil
and later deciding you want to proactively reload the bibliography)."
:group 'bibtex-completion
:type 'boolean)


(defcustom bibtex-completion-pdf-open-function 'find-file
"The function used for opening PDF files.
This can be an arbitrary function that takes one argument: the
Expand Down Expand Up @@ -414,15 +428,16 @@ Also sets `bibtex-completion-display-formats-internal'."
;; watches for automatic reloading of the bibliography when a file
;; is changed:
(mapc (lambda (file)
(if (f-file? file)
(let ((watch-descriptor
(file-notify-add-watch file
'(change)
(lambda (event) (bibtex-completion-candidates)))))
(setq bibtex-completion-file-watch-descriptors
(cons watch-descriptor bibtex-completion-file-watch-descriptors)))
(if (f-file? file)
(if bibtex-completion-watch-bibliography
(let ((watch-descriptor
(file-notify-add-watch file
'(change)
(lambda (event) (bibtex-completion-candidates)))))
(setq bibtex-completion-file-watch-descriptors
(cons watch-descriptor bibtex-completion-file-watch-descriptors))))
(user-error "Bibliography file %s could not be found" file)))
(bibtex-completion-normalize-bibliography))
(bibtex-completion-normalize-bibliography))

;; Pre-calculate minimal widths needed by the format strings for
;; various entry types:
Expand Down

0 comments on commit 93806ce

Please sign in to comment.