]> code.delx.au - gnu-emacs-elpa/blob - auctex-11.86/style/harvard.el
fa38d2a9a1a1e466782477daa0ac83ec285b856c
[gnu-emacs-elpa] / auctex-11.86 / style / harvard.el
1 ;;; harvard.el --- Support for Harvard Citation style package for AUCTeX.
2
3 ;; Harvard citation style is from Peter Williams
4 ;; available on the CTAN servers
5
6 ;; Version: $Id: harvard.el,v 1.10 2008/02/03 14:53:30 angeli Exp $
7
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.
11
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)
15 ;; any later version.
16 ;;
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.
21 ;;
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.
25
26 ;;; Code:
27
28 (TeX-add-style-hook "harvard"
29 (function
30 (lambda ()
31
32 (LaTeX-add-environments
33 '("thebibliography" LaTeX-env-harvardbib ignore))
34
35 (TeX-add-symbols
36 "harvardand"
37 '("citeasnoun"
38 (TeX-arg-conditional TeX-arg-cite-note-p ([ "Note" ]) nil)
39 TeX-arg-cite)
40 '("possessivecite"
41 (TeX-arg-conditional TeX-arg-cite-note-p ([ "Note" ]) nil)
42 TeX-arg-cite)
43 '("citeaffixed"
44 (TeX-arg-conditional TeX-arg-cite-note-p ([ "Note" ]) nil)
45 TeX-arg-cite "Affix")
46 '("citeyear"
47 (TeX-arg-conditional TeX-arg-cite-note-p ([ "Note" ]) nil)
48 TeX-arg-cite)
49 '("citename"
50 (TeX-arg-conditional TeX-arg-cite-note-p ([ "Note" ]) nil)
51 TeX-arg-cite)
52 '("citationstyle"
53 (TeX-arg-eval completing-read "Citation style: " '(("agsm") ("dcu"))))
54 '("citationmode"
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"))))
60 '("bibliographystyle"
61 (TeX-arg-eval
62 completing-read "Bibliography style: "
63 '(("agsm") ("apsr") ("dcu") ("jmr") ("jphysicsB") ("kluwer") ("nederlands") ("econometrica")))
64 ignore)
65 '("harvarditem" [ "Short citation" ]
66 "Complete citation" "Year" TeX-arg-define-cite))
67
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\\%,]*\\)"
86 2 LaTeX-bibitem-list)
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))
93 TeX-complete-list))
94
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)
98 )
99 LaTeX-auto-regexp-list))
100
101 (setq LaTeX-item-list
102 (cons '("thebibliography" . LaTeX-item-harvardbib)
103 LaTeX-item-list))
104
105 ;; Tell RefTeX
106 (when (fboundp 'reftex-set-cite-format)
107 (reftex-set-cite-format 'harvard)))))
108
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))
113 (end-of-line 0)
114 (delete-char 1)
115 (delete-horizontal-space)
116 (LaTeX-insert-item))
117
118 ;; Analog to LaTeX-item-bib from latex.el
119 (defun LaTeX-item-harvardbib ()
120 "Insert a new harvarditem."
121 (TeX-insert-macro "harvarditem"))
122
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.")
127
128 ;; harvard.el ends here