;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; File: gnu-bibtex.el ; SCCS: %A% %G% %U% ; Description: BibTeX macro commands ; Author: Craig Zarmer, HP Labs/DCC ; Created: 25-Sep-86 ; Modified: Fri Jul 21 09:36:07 1995 (Andreas Paepcke) ; Language: Lisp ; Package: BIBTEX ; Status: Experimental (Do Not Distribute) ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Works best if you put the following into your .emacs file ; before loading this (replace my name with yours, of course: ; (setq header-user-name "Andreas Paepcke") (provide 'gnu-bibtex) ; These commands insert into the text buffer a template ; for various BibTeX database bibliography formats. (defvar *bibtex-user-name* "") (defvar *article-data* nil) (defvar *book-data* nil) (defvar *inbook-data* nil) (defvar *inproceedings-data* nil) (defvar *incollection-data* nil) (defvar *phdthesis-data* nil) (defvar *mastersthesis-data* nil) (defvar *techreport-data* nil) (defvar *generic-data* nil) (defvar *misc-data* nil) (defvar *manual-data* nil) (defun insert-generic-bibtex-data () (mapcar 'insert-string *generic-data*) ) (defun insert-line (str) (insert-string str) (move-to-fresh-line) ) (defun generic-bibtex-command (data) (let ( (current-line-pos (current-line)) ) (move-to-fresh-line) (mapcar 'insert-line data) (insert-generic-bibtex-data) (move-to-fresh-line) (search-for-template (+ 1 current-line-pos)) )) (defun move-to-fresh-line () (insert ?\n) ) (defun current-line () (beginning-of-line) (1+ (count-lines 1 (point))) ) (defun last-line () (1+ (count-lines 1 (buffer-size))) ) (defun search-for-template (line-no) (let ( (current-line-no (current-line)) (pos nil) ) (goto-line line-no) (setq pos (search-forward "~")) (cond ((and pos (eq (current-line) line-no)) (search-forward "~") t) (t (goto-line current-line-no) nil) ) )) (defun next-template-command () (interactive) (let ( (line (current-line)) (the-last-line (last-line)) ) (while (and (<= line the-last-line) (not (search-for-template line))) (setq line (+ 1 line)) ) (kill-backward-chars 1) )) (defun article () (interactive) (generic-bibtex-command *article-data*) ) (defun book () (interactive) (generic-bibtex-command *book-data*) ) (defun inbook () (interactive) (generic-bibtex-command *inbook-data*) ) (defun inproceedings () (interactive) (generic-bibtex-command *inproceedings-data*) ) (defun incollection () (interactive) (generic-bibtex-command *incollection-data*) ) (defun phdthesis () (interactive) (generic-bibtex-command *phdthesis-data*) ) (defun mastersthesis () (interactive) (generic-bibtex-command *mastersthesis-data*) ) (defun misc () (interactive) (generic-bibtex-command *misc-data*) ) (defun manual () (interactive) (generic-bibtex-command *manual-data*) ) (defun techreport () (interactive) (generic-bibtex-command *techreport-data*) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Data ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq *article-data* '("@ARTICLE{~" " ,AUTHOR = \"~\"" " ,TITLE = \"~\"" " ,JOURNAL = \"~\"" " ,YEAR = \"~\"" " ,month = \"~\"" " ,volume = \"~\"" " ,number = \"~\"" " ,pages = \"~\"" )) (setq *book-data* '("@BOOK{~" " ,AUTHOR = \"~\"" " ,TITLE = \"~\"" " ,PUBLISHER = \"~\"" " ,YEAR = \"~\"" " ,address = \"~\"" )) (setq *inbook-data* '("@INBOOK{~" " ,author = \"~\"" " ,editor = \"~\"" " ,TITLE = \"~\"" " ,PUBLISHER = \"~\"" " ,YEAR = \"~\"" " ,chapter = \"~\"" " ,pages = \"~\"" " ,volume = \"~\"" " ,series = \"~\"" " ,edition = \"~\"" " ,month = \"~\"" " ,address = \"~\"" )) (setq *inproceedings-data* '("@INPROCEEDINGS{~" " ,AUTHOR = \"~\"" " ,TITLE = \"~\"" " ,BOOKTITLE = \"~\"" " ,YEAR = \"~\"" " ,editor = \"~\"" " ,publisher = \"~\"" " ,address = \"~\"" )) (setq *incollection-data* '("@INCOLLECTION{~" " ,AUTHOR = \"~\"" " ,TITLE = \"~\"" " ,BOOKTITLE = \"~\"" " ,YEAR = \"~\"" " ,PUBLISHER = \"~\"" " ,address = \"~\"" " ,editor = \"~\"" " ,pages = \"~\"" )) (setq *phdthesis-data* '("@PHDTHESIS{~" " ,AUTHOR = \"~\"" " ,TITLE = \"~\"" " ,SCHOOL = \"~\"" " ,YEAR = \"~\"" " ,month = \"~\"" " ,address = \"~\"" )) (setq *mastersthesis-data* '("@MASTERSTHESIS{~" " ,AUTHOR = \"~\"" " ,TITLE = \"~\"" " ,SCHOOL = \"~\"" " ,YEAR = \"~\"" " ,month = \"~\"" " ,address = \"~\"" )) (setq *techreport-data* '("@TECHREPORT{~" " ,AUTHOR = \"~\"" " ,TITLE = \"~\"" " ,INSTITUTION = \"~\"" " ,YEAR = \"~\"" " ,month = \"~\"" " ,number = \"~\"" " ,address = \"~\"" )) (setq *misc-data* '("@MISC{~" " ,author = \"~\"" " ,title = \"~\"" " ,year = \"~\"" " ,month = \"~\"" " ,howpublished = \"~\"" " ,address = \"~\"" )) (setq *manual-data* '("@MANUAL{~" " ,TITLE = \"~\"" " ,author = \"~\"" " ,organization = \"~\"" " ,address = \"~\"" " ,edition = \"~\"" " ,month = \"~\"" " ,year = \"~\"" )) (defun set-bibtex-user (name) (interactive "sEnter your full name: ") (setq *bibtex-user-name* name) (setq *generic-data* (list (concat " ,entered-by = \"" *bibtex-user-name* "\"\n") " ,found-in = \"~\"\n" " ,status = \"~\"\n" " ,keywords = \"~\"\n" " ,comments = {~}\n" " }" )) ) (if (and (boundp 'header-user-name) (stringp header-user-name)) (set-bibtex-user header-user-name) (set-bibtex-user "Random"))