Initial Commit
[packages] / xemacs-packages / auctex / style / doc.el
1 ;;; doc.el --- AUCTeX style for `doc.sty'
2
3 ;; Copyright (C) 2004, 2008 Free Software Foundation, Inc.
4
5 ;; Author: Frank Küster <frank@kuesterei.ch>
6 ;; Maintainer: auctex-devel@gnu.org
7 ;; Keywords: tex
8
9 ;; This file is part of AUCTeX.
10
11 ;; AUCTeX is free software; you can redistribute it and/or modify it
12 ;; 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 ;; AUCTeX is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 ;; General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with AUCTeX; see the file COPYING.  If not, write to the Free
23 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 ;; 02110-1301, USA.
25
26 ;;; Commentary:
27
28 ;; This file adds support for `doc.sty'.
29
30 ;;; Code:
31
32 (defun LaTeX-env-no-comment (environment)
33   "Insert ENVIRONMENT and make sure there is no commented empty line inside."
34   (LaTeX-insert-environment environment)
35   (unless (TeX-active-mark)
36     (when (save-excursion
37             (beginning-of-line)
38             (looking-at (concat "[ \t]+$\\|[ \t]*"
39                                 TeX-comment-start-regexp "+[ \t]*$")))
40       (delete-region (line-beginning-position) (line-end-position))
41       (indent-according-to-mode))))
42
43 (defun LaTeX-doc-after-insert-macrocode (env start end)
44   "Make sure the macrocode environment is properly formatted after insertion."
45   (when (TeX-member env '("macrocode" "macrocode*") 'string-equal)
46     (save-excursion
47       (goto-char end)
48       (skip-chars-backward " \t")
49       (when (bolp)
50         (insert "%")
51         (indent-according-to-mode))
52       (goto-char start)
53       (skip-chars-backward " \t")
54       (when (bolp)
55         (insert "%")
56         (indent-according-to-mode)))))
57
58 (TeX-add-style-hook
59  "doc"
60  (lambda ()
61    (add-to-list (make-local-variable 'LaTeX-indent-environment-list)
62                 '("macrocode" current-indentation))
63    (add-to-list 'LaTeX-indent-environment-list
64                 '("macrocode*" current-indentation))
65    (add-hook 'LaTeX-after-insert-env-hooks 'LaTeX-doc-after-insert-macrocode
66              nil t)
67    (LaTeX-add-environments
68     "theglossary"
69     '("macrocode" LaTeX-env-no-comment)
70     '("macrocode*" LaTeX-env-no-comment)
71     '("macro" "Macro"))
72    (TeX-add-symbols
73     "EnableCrossrefs"
74     "DisableCrossrefs"
75     "DoNotIndex"
76     "DontCheckModules"
77     "CheckModules"
78     "Module"
79     '("DescribeMacro" "Macro")
80     '("DescribeEnv" "Environment")
81     "verbatim"
82     "verb"
83     "parg"
84     "oarg"
85     "marg"
86     "meta"
87     "cmd"
88     "makelabel"
89     "MacroFont"
90     "MacroFont"
91     "AltMacroFont"
92     "AltMacroFont"
93     "PrintMacroName"
94     "PrintDescribeMacro"
95     "PrintDescribeEnv"
96     "PrintEnvName"
97     "MakePrivateLetters"
98     "actualchar"
99     "quotechar"
100     "levelchar"
101     "encapchar"
102     "verbatimchar"
103     "SpecialIndex"
104     "SpecialMainIndex"
105     "SpecialMainEnvIndex"
106     "SpecialUsageIndex"
107     "SpecialEnvIndex"
108     "SortIndex"
109     "LeftBraceIndex"
110     "RightBraceIndex"
111     "PercentIndex"
112     "OldMakeindex"
113     "PercentIndex"
114     "IndexPrologue"
115     "IndexParms"
116     "subitem"
117     "subsubitem"
118     "indexspace"
119     "efill"
120     "pfill"
121     "PrintIndex"
122     '("changes" "version" TeX-arg-date t)
123     "generalname"
124     "RecordChanges"
125     "GlossaryPrologue"
126     "GlossaryParms"
127     "PrintChanges"
128     "AlsoImplementation"
129     "StopEventually"
130     "OnlyDescription"
131     "Finale"
132     "IndexInput"
133     "maketitle"
134     "MakeShortVerb"
135     "DeleteShortVerb"
136     "MakeShortverb"
137     "DeleteShortverb"
138     "CheckSum"
139     "CharacterTable"
140     "CharTableChanges"
141     "CodelineNumbered"
142     "CodelineIndex"
143     "PageIndex"
144     "theCodelineNo"
145     "theCodelineNo"
146     "DocstyleParms"
147     "MakePercentIgnore"
148     "MakePercentComment"
149     "DocInput"
150     "DocInclude"
151     "GetFileInfo"
152     "filename"
153     "fileinfo")
154    (TeX-run-style-hooks "shortvrb"))
155  LaTeX-dialect)
156
157 ;; Local Variables:
158 ;; coding: iso-8859-1
159 ;; End: