1 ;;; natbib.el --- Style hook for the natbib package
3 ;; Copyright (C) 1997, 1998, 2004, 2007 Free Software Foundation, Inc.
5 ;; Authors: Berwin Turlach <statba@nus.edu.sg>
6 ;; Carsten Dominik <dominik@strw.leidenuniv.nl>
7 ;; Maintainer: auctex-devel@gnu.org
10 ;; This file is part of AUCTeX.
12 ;; AUCTeX is free software; you can redistribute it and/or modify it
13 ;; 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 ;; AUCTeX is distributed in the hope that it will be useful, but
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ;; General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with AUCTeX; see the file COPYING. If not, write to the Free
24 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
29 (TeX-add-style-hook "natbib"
32 ;; The number in the cdr of the following list indicates how many
33 ;; optional note arguments we consider useful. Prompting for those
34 ;; arguments will still depend upon `TeX-arg-cite-note-p'.
37 ("citet" . 1) ("citet*" . 1) ("citealt" . 1) ("citealt*" . 1)
38 ("citep" . 2) ("citep*" . 2) ("citealp" . 2) ("citealp*" . 2)
39 ("citeauthor" . 0) ("citeauthor*" . 0) ("citefullauthor" . 0)
40 ("citeyear" . 0) ("citeyearpar" . 0)
50 ;; No optional arguments
51 (list (car cmd) 'TeX-arg-cite))
53 ;; Just one optional argument, the post note
56 '(TeX-arg-conditional TeX-arg-cite-note-p (["Post-note"]) nil)
62 '(TeX-arg-conditional TeX-arg-cite-note-p (natbib-note-args) nil)
66 ;; Add the other symbols
69 '("bibpunct" ["Post note separator"]
72 "Punctuation between multiple citations"
73 "style [n]umeric [s]uperscript [a]uthor-year"
74 "Punctuation between author and year"
75 "Punctuation between years for common authors")
76 '("citestyle" "Style")
81 ;; Make an entry in TeX-complete-list
86 (mapconcat (lambda (x) (regexp-quote (car x)))
88 "\\)\\(\\[[^]\n\r\\%]*\\]\\)*{\\([^{}\n\r\\%,]*,\\)*\\([^{}\n\r\\%,]*\\)")
89 4 'LaTeX-bibitem-list "}")))
92 (when (and (fboundp 'font-latex-add-keywords)
93 (eq TeX-install-font-lock 'font-latex-setup))
94 (font-latex-add-keywords '(("cite" "*[[{")
100 ("citefullauthor" "[[{")
102 ("citeyearpar" "[[{")
107 (if (fboundp 'reftex-set-cite-format)
108 (reftex-set-cite-format 'natbib))))
111 (defun natbib-note-args (optional &optional prompt definition)
112 "Prompt for two note arguments a natbib citation command."
113 (if TeX-arg-cite-note-p
114 (let* ((pre (read-string
115 (TeX-argument-prompt optional optional "Pre-note")))
117 (TeX-argument-prompt optional optional "Post-note"))))
118 (if (not (string= pre "")) (insert "[" pre "]"))
119 (if (not (string= post ""))
120 (insert "[" post "]")
121 ;; Make sure that we have an empty post note if pre is not empty
122 (if (string= pre "") (insert "[]"))))))
124 (defvar LaTeX-natbib-package-options '("numbers" "super" "authoryear"
125 "round" "square" "angle" "curly"
126 "comma" "colon" "nobibstyle"
127 "bibstyle" "openbib" "sectionbib"
128 "sort" "sort&compress"
129 "longnamesfirst" "nonamebreak")
130 "Package options for the natbib package.")
132 ;; natbib.el ends here