]> code.delx.au - gnu-emacs-elpa/blob - packages/auctex-11.86/style/natbib.el
(debbugs-emacs): New function and modes for listing the Emacs bugs, reading them...
[gnu-emacs-elpa] / packages / auctex-11.86 / style / natbib.el
1 ;;; natbib.el --- Style hook for the NatBib package
2 ;;;
3 ;;; AUTHOR: Carsten Dominik <dominik@strw.leidenuniv.nl>
4 ;;; building on older code from Berwin Turlach
5
6 ;;; Code:
7
8 (TeX-add-style-hook "natbib"
9 (function
10 (lambda ()
11 ;; The number in the cdr of the following list indicates how many
12 ;; optional note arguments we consider useful. Prompting for those
13 ;; arguments will still depend upon `TeX-arg-cite-note-p'.
14 (let ((citecmds
15 '(("cite" . 0)
16 ("citet" . 1) ("citet*" . 1) ("citealt" . 1) ("citealt*" . 1)
17 ("citep" . 2) ("citep*" . 2) ("citealp" . 2) ("citealp*" . 2)
18 ("citeauthor" . 0) ("citeauthor*" . 0) ("citefullauthor" . 0)
19 ("citeyear" . 0) ("citeyearpar" . 0)
20 ("shortcites" . 0))))
21
22 ;; Add these symbols
23 (apply
24 'TeX-add-symbols
25 (mapcar
26 (lambda (cmd)
27 (cond
28 ((= (cdr cmd) 0)
29 ;; No optional arguments
30 (list (car cmd) 'TeX-arg-cite))
31 ((= (cdr cmd) 1)
32 ;; Just one optional argument, the post note
33 (list
34 (car cmd)
35 '(TeX-arg-conditional TeX-arg-cite-note-p (["Post-note"]) nil)
36 'TeX-arg-cite))
37 ((= (cdr cmd) 2)
38 ;; Pre and post notes
39 (list
40 (car cmd)
41 '(TeX-arg-conditional TeX-arg-cite-note-p (natbib-note-args) nil)
42 'TeX-arg-cite))))
43 citecmds))
44
45 ;; Add the other symbols
46 (TeX-add-symbols
47 '("citetext" "Text")
48 '("bibpunct" ["Post note separator"]
49 "Opening bracket"
50 "Closing bracket"
51 "Punctuation between multiple citations"
52 "style [n]umeric [s]uperscript [a]uthor-year"
53 "Punctuation between author and year"
54 "Punctuation between years for common authors")
55 '("citestyle" "Style")
56 '("citeindextrue")
57 '("citeindexfalse")
58 '("citeindextype"))
59
60 ;; Make an entry in TeX-complete-list
61 (add-to-list
62 'TeX-complete-list
63 (list
64 (concat "\\\\\\("
65 (mapconcat (lambda (x) (regexp-quote (car x)))
66 citecmds "\\|")
67 "\\)\\(\\[[^]\n\r\\%]*\\]\\)*{\\([^{}\n\r\\%,]*,\\)*\\([^{}\n\r\\%,]*\\)")
68 4 'LaTeX-bibitem-list "}")))
69
70 ;; Fontification
71 (when (and (fboundp 'font-latex-add-keywords)
72 (eq TeX-install-font-lock 'font-latex-setup))
73 (font-latex-add-keywords '(("cite" "*[[{")
74 ("citet" "*[[{")
75 ("citealt" "*[[{")
76 ("citep" "*[[{")
77 ("citealp" "*[[{")
78 ("citeauthor" "*[[{")
79 ("citefullauthor" "[[{")
80 ("citeyear" "[[{")
81 ("citeyearpar" "[[{")
82 ("shortcites" "{"))
83 'reference))
84
85 ;; Tell RefTeX
86 (if (fboundp 'reftex-set-cite-format)
87 (reftex-set-cite-format 'natbib)))))
88
89 (defun natbib-note-args (optional &optional prompt definition)
90 "Prompt for two note arguments a natbib citation command."
91 (if TeX-arg-cite-note-p
92 (let* ((pre (read-string
93 (TeX-argument-prompt optional optional "Pre-note")))
94 (post (read-string
95 (TeX-argument-prompt optional optional "Post-note"))))
96 (if (not (string= pre "")) (insert "[" pre "]"))
97 (if (not (string= post ""))
98 (insert "[" post "]")
99 ;; Make sure that we have an empty post note if pre is not empty
100 (if (string= pre "") (insert "[]"))))))
101
102 (defvar LaTeX-natbib-package-options '("numbers" "super" "authoryear"
103 "round" "square" "angle" "curly"
104 "comma" "colon" "nobibstyle"
105 "bibstyle" "openbib" "sectionbib"
106 "sort" "sort&compress"
107 "longnamesfirst" "nonamebreak")
108 "Package options for the natbib package.")
109
110 ;; natbib.el ends here