1 ;;; harvard.el --- Support for Harvard Citation style package for AUCTeX.
3 ;; Copyright (C) 1994, 1997, 2005 Free Software Foundation, Inc.
5 ;; Author: Berwin Turlach <statba@nus.edu.sg>
6 ;; Maintainer: auctex-devel@gnu.org
9 ;; This file is part of AUCTeX.
11 ;; AUCTeX is free software; you can redistribute it and/or modify it
12 ;; under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 3, or (at your option)
16 ;; AUCTeX is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with AUCTeX; see the file COPYING. If not, write to the Free
23 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
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))))
110 (defun LaTeX-env-harvardbib (environment &optional ignore)
111 "Insert ENVIRONMENT with label for harvarditem."
112 (LaTeX-insert-environment environment
113 (concat TeX-grop "xx" TeX-grcl))
116 (delete-horizontal-space)
119 ;; Analog to LaTeX-item-bib from latex.el
120 (defun LaTeX-item-harvardbib ()
121 "Insert a new harvarditem."
122 (TeX-insert-macro "harvarditem"))
124 (defvar LaTeX-harvard-package-options '("full" "abbr" "default"
125 "agsmcite" "dcucite" "round"
126 "curly" "angle" "square" "none")
127 "Package options for the harvard package.")
129 ;; harvard.el ends here