1 ;;; harvard.el --- Support for Harvard Citation style package for AUCTeX.
3 ;; Harvard citation style is from Peter Williams
4 ;; available on the CTAN servers
6 ;; Version: $Id: harvard.el,v 1.10 2008/02/03 14:53:30 angeli Exp $
8 ;; Copyright (C) 1994 Berwin Turlach <berwin@core.ucl.ac.be>
9 ;; Copyright (C) 1997 Berwin Turlach <berwin.turlach@anu.edu.au>
10 ;; Copyright (C) 2005 Free Software Foundation, Inc.
12 ;; This program is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 3, or (at your option)
17 ;; This program is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with this program; if not, write to the Free Software Foundation,
24 ;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 (TeX-add-style-hook "harvard"
32 (LaTeX-add-environments
33 '("thebibliography" LaTeX-env-harvardbib ignore))
38 (TeX-arg-conditional TeX-arg-cite-note-p ([ "Note" ]) nil)
41 (TeX-arg-conditional TeX-arg-cite-note-p ([ "Note" ]) nil)
44 (TeX-arg-conditional TeX-arg-cite-note-p ([ "Note" ]) nil)
47 (TeX-arg-conditional TeX-arg-cite-note-p ([ "Note" ]) nil)
50 (TeX-arg-conditional TeX-arg-cite-note-p ([ "Note" ]) nil)
53 (TeX-arg-eval completing-read "Citation style: " '(("agsm") ("dcu"))))
55 (TeX-arg-eval completing-read "Citation mode: "
56 '(("full") ("abbr") ("default"))))
57 '("harvardparenthesis"
58 (TeX-arg-eval completing-read "Harvardparenthesis: "
59 '(("round") ("curly") ("angle") ("square"))))
62 completing-read "Bibliography style: "
63 '(("agsm") ("apsr") ("dcu") ("jmr") ("jphysicsB") ("kluwer") ("nederlands") ("econometrica")))
65 '("harvarditem" [ "Short citation" ]
66 "Complete citation" "Year" TeX-arg-define-cite))
68 (setq TeX-complete-list
69 (append '(("\\\\citeasnoun\\[[^]\n\r\\%]*\\]{\\([^{}\n\r\\%,]*\\)"
70 1 LaTeX-bibitem-list "}")
71 ("\\\\citeasnoun{\\([^{}\n\r\\%,]*\\)" 1
72 LaTeX-bibitem-list "}")
73 ("\\\\possessivecite\\[[^]\n\r\\%]*\\]{\\([^{}\n\r\\%,]*\\)"
74 1 LaTeX-bibitem-list "}")
75 ("\\\\possessivecite{\\([^{}\n\r\\%,]*\\)" 1
76 LaTeX-bibitem-list "}")
77 ("\\\\citename\\[[^]\n\r\\%]*\\]{\\([^{}\n\r\\%,]*\\)"
78 1 LaTeX-bibitem-list "}")
79 ("\\\\citename{\\([^{}\n\r\\%,]*\\)" 1
80 LaTeX-bibitem-list "}")
81 ("\\\\citeaffixed\\[[^]\n\r\\%]*\\]{\\([^{}\n\r\\%,]*\\)"
82 1 LaTeX-bibitem-list "}")
83 ("\\\\citeaffixed{\\([^{}\n\r\\%,]*\\)" 1
84 LaTeX-bibitem-list "}")
85 ("\\\\citeaffixed{\\([^{}\n\r\\%]*,\\)\\([^{}\n\r\\%,]*\\)"
87 ("\\\\citeyear\\[[^]\n\r\\%]*\\]{\\([^{}\n\r\\%,]*\\)"
88 1 LaTeX-bibitem-list "}")
89 ("\\\\citeyear{\\([^{}\n\r\\%,]*\\)" 1
90 LaTeX-bibitem-list "}")
91 ("\\\\citeyear{\\([^{}\n\r\\%]*,\\)\\([^{}\n\r\\%,]*\\)"
92 2 LaTeX-bibitem-list))
95 (setq LaTeX-auto-regexp-list
96 (append '(("\\\\harvarditem{\\([a-zA-Z][^%#'()={}]*\\)}{\\([0-9][^, %\"#'()={}]*\\)}{\\([a-zA-Z][^, %\"#'()={}]*\\)}" 3 LaTeX-auto-bibitem)
97 ("\\\\harvarditem\\[[^][\n\r]+\\]{\\([a-zA-Z][^%#'()={}]*\\)}{\\([0-9][^, %\"#'()={}]*\\)}{\\([a-zA-Z][^, %\"#'()={}]*\\)}" 3 LaTeX-auto-bibitem)
99 LaTeX-auto-regexp-list))
101 (setq LaTeX-item-list
102 (cons '("thebibliography" . LaTeX-item-harvardbib)
106 (when (fboundp 'reftex-set-cite-format)
107 (reftex-set-cite-format 'harvard)))))
109 (defun LaTeX-env-harvardbib (environment &optional ignore)
110 "Insert ENVIRONMENT with label for harvarditem."
111 (LaTeX-insert-environment environment
112 (concat TeX-grop "xx" TeX-grcl))
115 (delete-horizontal-space)
118 ;; Analog to LaTeX-item-bib from latex.el
119 (defun LaTeX-item-harvardbib ()
120 "Insert a new harvarditem."
121 (TeX-insert-macro "harvarditem"))
123 (defvar LaTeX-harvard-package-options '("full" "abbr" "default"
124 "agsmcite" "dcucite" "round"
125 "curly" "angle" "square" "none")
126 "Package options for the harvard package.")
128 ;; harvard.el ends here