;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/bibtex/bibtex-book.el (require 'bibtex) (defun create-book (&optional author isbn publisher title year) "Insert a Bibtex entry (book) at point. \nOptionally insert AUTHOR, ISBN, PUBLISHER, TITLE, and YEAR. \nTo insert an entry with blank fields, use \\[new-book]." (interactive "stitle: \nsauthor: \nspublisher: \nsyear: \nsISBN: ") (let*((bib-str-nils (format "@book{,\n author = {%s},\n isbn = {%s},\n publisher = {%s},\n title = {%s},\n year = {%s}\n}" author isbn publisher title year)) (bib-str (replace-regexp-in-string "{nil}" "{}" bib-str-nils)) ) (beginning-of-line) (let ((beg (point))) (insert bib-str) (goto-char (+ beg 23)) ))) (defun new-book () "Insert a Bibtex book entry with blank fields at point. \nSee `create-book'." (interactive) (create-book "" "978-") ) (defun validate-compile-count () (interactive) (when (bibtex-validate t) (let*((beg (point-min)) (num-books (+ (how-many "^@book" beg) (how-many "^@periodical" beg) ))) (message "%s" num-books) (sleep-for 2) (save-window-excursion (compile "make") )))) (provide 'bibtex-book)