name: add-bib-entry description: Use when adding works to Pablo's bibliography, creating BibTeX/BibLaTeX entries, adding DOI/ISBN/URL references, resolving missing citekeys, or preparing notes that cite works not yet in the configured bibliography files.
Add Bib Entry
Core Rule
Use Pablo's Emacs bibliography workflow, not ad hoc BibTeX, whenever a work has a DOI, ISBN, URL, or other identifier. The desired end state is a clean BibLaTeX entry plus associated files: always a PDF where the workflow can obtain one, and sometimes an HTML file for web pages.
Workflow
Check whether the work is already present.
- Prefer
search_bibliographyif available. - Otherwise search active bibliography files with
rg. - Get active paths from Emacs rather than guessing:
emacsclient -e '(progn (require '\''paths nil t) (list paths-file-personal-bibliography-new paths-file-personal-bibliography-old paths-files-bibliography-all citar-bibliography))'
- Prefer
Choose the target BibTeX file.
- For Pablo's personal notes, default to
paths-file-personal-bibliography-new, normally/Users/pablostafforini/My Drive/bibliography/new.bib. - Do not add new personal references to
old.bibor Babel/Tlön bibliography files unless the user or project context explicitly calls for that.
- For Pablo's personal notes, default to
Add and process the entry through Zotra/Ebib.
- If you need to inspect or reload an Elpaca package involved in this workflow, resolve it with
/Users/pablostafforini/My Drive/dotfiles/bin/elpaca-package-path PACKAGE. In particular, usebin/elpaca-package-path annas-archive annas-archive.elfor Anna's Archive source. Do not uselocate-library,symbol-file, or~/.emacs.d/elpaca/...as the source authority. - Manual/full workflow: run
zotra-extras-add-entryin Emacs. It imports metadata via Zotra/Zotero translators, prompts for the target bibfile, opens the entry in Ebib, and then runs the Ebib processing path. - Headless/agent workflow: prefer
add_bib_entry_and_processwhen available. It imports through Zotra, opens the generated key in Ebib, runs the Ebib processing path noninteractively, waits for asynchronous attachment work, and returns the key plus attached-file status. - Headless Emacs equivalent:
emacsclient -e '(progn (require '\''gptel-extras) (gptel-extras-add-bib-entry-and-process "IDENTIFIER" "/Users/pablostafforini/My Drive/bibliography/new.bib"))' - Use
add_bib_entryonly as a metadata-only fallback. It deliberately passesDO-NOT-OPENtozotra-extras-add-entry, so it does not run Ebib post-processing or attach files.
- If you need to inspect or reload an Elpaca package involved in this workflow, resolve it with
Complete post-processing.
- The full manual path calls
zotra-extras-open-in-ebib, which confirms the entry type/key and invokesebib-extras-process-entry. ebib-extras-process-entryregenerates/validates the key, sets language, callsebib-extras-attach-files, and checks crossrefs.ebib-extras-attach-fileschooses attachments from DOI, ISBN/book type, video URL, or online/article URL:- DOI: searches/downloads through Anna's Archive.
- ISBN/book-like entries: searches/downloads through Anna's Archive.
- Online/article URLs: generates PDF and HTML files with
eww-extras-url-to-file.
- Anna's Archive downloads may fall back to the external browser. If the returned file list is empty or incomplete, inspect the
filefield and Downloads/library directories before reporting the exact missing attachment. - For DOI article PDFs, prefer the historical headless download path when live Emacs/EWW is fragile:
This mirrorspython3 scripts/download_annas_article.py DOI CITEKEY "/Users/pablostafforini/My Drive/bibliography/new.bib"stafforini.com/scripts/download-missing-pdfs.py: it reads the Anna's Archive key frompass show tlon/core/annas-archive, fetches the DOI SciDB page, extracts the MD5, downloads viadyn/api/fast_download.json, saves~/My Drive/library-pdf/CITEKEY.pdf, and inserts thefilefield. Readclaude/context/secrets.mdbefore invoking secret-backed commands, and never print the key. - Re-read the generated entry and do targeted metadata cleanup only for fields the programmatic path missed:
- Site-hosted articles, blog posts, and other
@onlineworks needjournaltitleset to the site/publication name, such asPlanned Obsolescence. Zotra often omits this field; add it manually when missing. - Every work needs a publication year. Do not leave works undated, and do not use
date = {forthcoming}as the only date. For forthcoming works, use the year that the available evidence makes most likely: publisher metadata, DOI metadata, announcement pages, scheduled issue data, or the best available estimate. - Works contained in larger works (
@incollection,@inbook,@bookinbook, chapters, encyclopedia entries, stories in collections, and similar cases) should cross-reference the larger work. Search active bibliography files for the parent title/editor/publisher/year; if the parent is missing, add it first. Then setcrossref = {ParentKey}on the contained work and keep parent-level metadata on the parent entry. Search existing entries withrg -n "crossref = \\{|@incollection|@inbook|@bookinbook" BIBFILEfor local patterns.
- Site-hosted articles, blog posts, and other
- The full manual path calls
Use the returned/generated citekey in notes.
- Cite as
[cite:@Key]. - After editing notes, verify every citekey resolves in the active bibliography files.
- Cite as
Fallbacks
- If Zotra cannot import the work, inspect the relevant implementation before hand-writing BibTeX:
/Users/pablostafforini/My Drive/dotfiles/emacs/extras/zotra-extras.el/Users/pablostafforini/My Drive/dotfiles/emacs/extras/ebib-extras.el- Anna's Archive download behavior: run
"/Users/pablostafforini/My Drive/dotfiles/bin/elpaca-package-path" annas-archive annas-archive.eland inspect the returned file. - package docs in
/Users/pablostafforini/My Drive/dotfiles/emacs/extras/doc/zotra-extras.organdebib-extras.org
- Manual BibTeX is acceptable only for genuinely unsupported cases, and only after the Zotra/Ebib path and relevant implementation have been inspected. Say that it is a fallback and still enforce the same metadata invariants: a publication year for every work,
journaltitlefor site-hosted works, parentcrossrefentries for contained works, valid key style, required fields, and citation resolution. - If associated-file download/attachment requires live Emacs interaction, browser/authentication, or a manual choice between candidates, leave the entry in a clearly inspectable state and report the exact missing piece.
Verification
Before finishing:
- Re-read the added BibTeX entry and cited note lines.
- Confirm the citekey appears in one active bibliography file.
- Confirm the
filefield references existing PDF/HTML files when expected. - Keep unrelated user changes in bibliography files unstaged/uncommitted unless explicitly asked.
- If committing, commit bibliography and note changes separately when they live in different repos.