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