Initial Commit
[packages] / xemacs-packages / auctex / style / fancyref.el
1 ;;; fancyref.el --- AUCTeX style file with support for fancyref.sty
2
3 ;; Copyright (C) 1999 Free Software Foundation, Inc.
4
5 ;; Author: Carsten Dominik <dominik@strw.leidenuniv.nl>
6 ;; Maintainer: auctex-devel@gnu.org
7
8 ;; This file is part of AUCTeX.
9
10 ;; AUCTeX is free software; you can redistribute it and/or modify it
11 ;; under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 3, or (at your option)
13 ;; any later version.
14
15 ;; AUCTeX is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 ;; General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with AUCTeX; see the file COPYING.  If not, write to the Free
22 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23 ;; 02110-1301, USA.
24
25 ;;; Code:
26
27 (TeX-add-style-hook "fancyref"
28    (lambda ()
29      
30      (TeX-add-symbols
31
32       ;; The macros with label arguments
33       '("fref" [ TeX-arg-fancyref-format ] TeX-arg-ref)
34       '("Fref" [ TeX-arg-fancyref-format ] TeX-arg-ref)
35
36       ;; The macros which define new prefixes and formats
37       '("fancyrefchangeprefix" TeX-arg-macro "Prefix")
38       '("Frefformat" TeX-arg-fancyref-format TeX-arg-macro "Output")
39       '("frefformat" TeX-arg-fancyref-format TeX-arg-macro "Output")
40
41       ;; The delimiter
42       "fancyrefargdelim"
43
44       ;; All those names and abbreviations.
45       ;; Part
46       "fancyrefpartlabelprefix" 
47       "Frefpartname" "frefpartname"   
48       ;; Chapter
49       "fancyrefchalabelprefix"
50       "Frefchaname" "frefchaname"   
51       ;; Section
52       "fancyrefseclabelprefix"
53       "Frefsecname" "frefsecname"
54       ;; Equation
55       "fancyrefeqlabelprefix"
56       "Frefeqname" "frefeqname"   
57       ;; Figure
58       "fancyreffiglabelprefix"
59       "Freffigname" "freffigname" "Freffigshortname"
60       ;; Footnote
61       "fancyreffnlabelprefix"
62       "Freffnname" "freffnname"   
63       ;; Item
64       "fancyrefitemlabelprefix"
65       "Frefitemname" "frefitemname" 
66       ;; Table
67       "fancyreftablabelprefix"
68       "Freftabname" "freftabname" "Freftabshortname"
69       ;; Page
70       "Frefpgname" "frefpgname" "Frefpgshortname"
71       ;; On
72       "Frefonname" "frefonname" 
73       ;; See
74       "Frefseename" "frefseename"
75
76       ;; The spacing macros
77       "fancyrefloosespacing" "fancyreftightspacing" "fancyrefdefaultspacing"
78
79       ;; And the hook
80       "fancyrefhook")
81
82      ;; Insatall completion for labels and formats
83      (setq TeX-complete-list
84            (append
85             '(("\\\\[fF]ref\\(\\[[^]]*\\]\\)?{\\([^{}\n\r\\%,]*\\)" 
86                2 LaTeX-label-list "}")
87               ("\\\\[fF]ref\\[\\([^{}\n\r\\%,]*\\)" 
88                1 LaTeX-fancyref-formats "]")
89               ("\\\\[fF]refformat{\\([^{}\n\r\\%,]*\\)"
90                1 LaTeX-fancyref-formats "}"))
91             TeX-complete-list))
92      ;; Fontification
93      (when (and (featurep 'font-latex)
94                 (eq TeX-install-font-lock 'font-latex-setup))
95        (font-latex-add-keywords '(("fref" "[{") ("Fref" "[{")) 'reference)))
96    LaTeX-dialect)
97
98 ;; The following list keeps a list of available format names
99 ;; Note that this list is only updated when a format is used, not
100 ;; during buffer parsing.  We could install a regexp to look for
101 ;; formats, but this would not work in multifile documents since the
102 ;; formats are not written out to the auto files.
103 ;; For now, we just leave it at that.
104 (defvar LaTeX-fancyref-formats '(("plain") ("vario") ("margin") ("main"))
105   "List of formats for fancyref.")
106
107 (defun LaTeX-fancyref-formats () LaTeX-fancyref-formats)
108
109 (defun TeX-arg-fancyref-format (optional &optional prompt definition)
110   "Prompt for a fancyref format name.
111 If the user gives an unknown name, add it to the list."
112   (let ((format (completing-read (TeX-argument-prompt optional prompt "Format")
113                                  LaTeX-fancyref-formats)))
114     (if (not (string-equal "" format))
115         (add-to-list 'LaTeX-fancyref-formats (list format)))
116     (TeX-argument-insert format optional)))
117
118 (defvar LaTeX-fancyref-package-options '("english" "german" "loose"
119                                          "margin" "paren" "plain" "tight"
120                                          "vario")
121   "Package options for the fancyref package.")
122
123 ;;; fancyref.el ends here