Initial Commit
[packages] / xemacs-packages / auctex / style / shortvrb.el
1 ;;; shortvrb.el --- AUCTeX style for `shortvrb.sty'
2
3 ;; Copyright (C) 2009 Free Software Foundation, Inc.
4
5 ;; Author: Ralf Angeli <angeli@caeruleus.net>
6 ;; Maintainer: auctex-devel@gnu.org
7 ;; Created: 2009-12-23
8 ;; Keywords: tex
9
10 ;; This file is part of AUCTeX.
11
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)
15 ;; any later version.
16
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.
21
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
25 ;; 02110-1301, USA.
26
27 ;;; Commentary:
28
29 ;; This file adds support for `shortvrb.sty'.
30
31 ;; XXX: We might want provide users with the possibility to activate
32 ;; something like this for any file (incl. Plain TeX).  That would
33 ;; bring us one step closer to the goal of displaying texbook.tex
34 ;; without font locking going haywire.
35
36 ;; FIXME: The code does not work for preview.dtx because in that file
37 ;; the style list is empty.  In its master file, preview.drv, it
38 ;; works, however.  However, even if the style file is loaded by hand,
39 ;; it fails to fontify verbatim text in the documentation parts of the
40 ;; file.
41
42 ;;; Code:
43
44 (defcustom LaTeX-shortvrb-chars nil
45   "List of characters toggling verbatim mode.
46 When your document uses the shortvrb style and you have a
47 \\MakeShortVrb{\\|} in your file to write verbatim text as
48 |text|, then set this variable to the list (?|).  Then AUCTeX
49 fontifies |text| as verbatim.
50
51 Preferably, you should do this buffer-locally using a file
52 variable near the end of your document like so:
53
54   %% Local Variables:
55   %% LaTeX-shortvrb-chars: (?|)
56   %% End:
57
58 When you customize this variable to a non-nil value, then it
59 becomes the default value meaning that verbatim fontification is
60 always performed for the characters in the list, no matter if
61 your document actually defines shortvrb chars using
62 \\MakeShortVrb."
63   :group 'LaTeX-style
64   :type '(repeat character))
65 (put 'LaTeX-shortvrb-chars 'safe-local-variable 'listp)
66
67 (TeX-add-style-hook
68  "shortvrb"
69  (lambda ()
70    ;; Fontification
71    (when (and LaTeX-shortvrb-chars
72               (fboundp 'font-latex-set-syntactic-keywords)
73               (eq TeX-install-font-lock 'font-latex-setup))
74      (let (syntax-alist)
75        (dolist (char LaTeX-shortvrb-chars)
76          (add-to-list 'syntax-alist (cons char "|")))
77        (font-latex-add-to-syntax-alist syntax-alist))))
78  LaTeX-dialect)
79
80 ;; Don't look for file-local variables before this line, so that the example in
81 ;; the docstring isn't picked up.
82 \f
83
84 ;;; shortvrb.el ends here