Skip to content

Commit 5915c3a

Browse files
committed
feat: Make citar-{bibliography,{library,notes}-paths} safe local vars
Putting the `safe-local-variable` attribute on a variable makes it so that it can be customized in `.dir-locals.el`, in the `-*- ... -*-` header line, or in a `Local Variables` block at the end of a file without the user getting a prompt whether or not to allow this. `citar-bibliography`, `citar-library-paths`, and `citar-notes-paths` all are ripe for per-directory customization. For instance, when working on a paper with collaborators, you might store a bibtex file specific to your project adjacent to the paper. Suppose your bibliography file is called "custom_refs.bib"; you can put % Local Variables: % citar-bibliography: ("./custom_refs.bib") % End: At the end of the file, and now whenever citar is invoked, it will pull up references from just that bibtex database and not whatever `citar-bibliography` is set to globally.
1 parent 2c0547d commit 5915c3a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

README.org

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,17 @@ By default, this uses ~citar-open-entry-in-file~, which will open the relevant b
171171
The other included option is ~citar-open-entry-in-zotero~, which will select the item in Zotero.
172172
Note that functionality depends on [[https://retorque.re/zotero-better-bibtex/][Better BibTeX]] (which you should be using anyway!).
173173

174+
*** Per-project customization
175+
176+
When collaborating with others, it might be convenient to have a project-specific bibliography file that can be version controlled and shared among collaborators.
177+
You can set ~citar-bibliography~ with =add-file-local-variable= or =add-dir-local-variable= to add a custom value to ~citar-bibliography~ for just that file or directory respectively.
178+
179+
For example, if you are sharing a =custom_refs.bib= file adjacent to the =cool_new_paper.tex= that you're working on, using the aforementioned functions or adding the following to your =.dir-locals.el= will make citar /only/ search your shared bibliography:
180+
181+
#+begin_src emacs-lisp
182+
((latex-mode . ((citar-bibliography . '("custom_refs.bib")))))
183+
#+end_src
184+
174185
** Rich UI
175186
:PROPERTIES:
176187
:CUSTOM_ID: rich-ui

citar.el

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@ buffer.")
8181

8282
;;;; Bibliography, file, and note paths
8383

84+
;;;###autoload (put 'citar-bibliography 'safe-local-variable (lambda (val) (cl-every #'stringp val)))
8485
(defcustom citar-bibliography nil
8586
"A list of bibliography files."
8687
:group 'citar
8788
:type '(repeat file))
8889

90+
;;;###autoload (put 'citar-library-paths 'safe-local-variable (lambda (val) (cl-every #'stringp val)))
8991
(defcustom citar-library-paths nil
9092
"A list of files paths for related PDFs, etc."
9193
:group 'citar
@@ -101,6 +103,7 @@ When nil, the function will not filter the list of files."
101103
:group 'citar
102104
:type '(repeat string))
103105

106+
;;;###autoload (put 'citar-notes-paths 'safe-local-variable (lambda (val) (cl-every #'stringp val)))
104107
(defcustom citar-notes-paths nil
105108
"A list of file paths for bibliographic notes."
106109
:group 'citar

0 commit comments

Comments
 (0)