It is cumbersome to enter BibTeX records into a bibliography via Emacs. The attached instructions show how to
enhance Emacs so that it 'understands' BibTeX records. You will be able to enter templates for all the BibTeX record
formats with M-x commands. The required fields will be in block-capitals. Each template has space for an abstract,
and each entry shows its author. Here is an example for an 'article' entry created with M-x article
:
@ARTICLE{~
,AUTHOR = "~"
,TITLE = "~"
,JOURNAL = "~"
,YEAR = "~"
,month = "~"
,volume = "~"
,number = "~"
,pages = "~"
,entered-by = "Andreas Paepcke"
,found-in = "~"
,status = "~"
,keywords = "~"
,comments = {~}
}
Just replace the '~' in each field with text. If you don't have information for a field, you can leave it in the record in case you want to complete the record later.
Installation simply involves a couple of lines in your .emacs file and the placement of the attached file in your file system.
Andreas
Put the attached file into a place where Emacs can find it and call it gnu-bibtex.el
. If you do not
put it into a directory that is included in Emac's search path, you have to tell Emacs where to find the file.
Assuming you put it into ~/emacsSupport, add the following to your .emacs file:
(setq load-path (cons (concat (getenv "HOME") "/emacsSupport") load-path))
In any case put the following into your .emacs after the above path instruction:
(setq header-user-name "Your Name")
(require 'gnu-bibtex)
That should be it.
Andreas
Cut here and put into a file called gnu-bibtex.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; 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"))