annotate lisp/packages/detexinfo.el @ 24:4103f0995bd7 r19-15b95

Import from CVS: tag r19-15b95
author cvs
date Mon, 13 Aug 2007 08:51:03 +0200
parents 0293115a14e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; detexinfo.el --- remove Texinfo commands from a Texinfo source file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1992-1993 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: tex, docs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
20 ;; along with XEmacs; see the file COPYING. If not, write to the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
22 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Here is a handy keybinding:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (global-set-key "\C-x\\" 'detexinfo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;;;;;;;;;;;;;;; detexinfo.el ;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; Remove Texinfo commands from a Texinfo source file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; Copyright (C) 1991, 1992 Free Software Foundation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; Robert J. Chassell
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; bugs to bug-texinfo@prep.ai.mit.edu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;; ==> test version <==
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;; Fails if Texinfo source file contains formatting errors.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;; Version 0.05 - 3 Jun 1992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;; Add to list of removed commands. Improve messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;; Version 0.04 - 27 Jan 1992
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;; Rewrite to insert detexinfo'd text into a temporary buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;; Version 0.03 - 27 Dec 1991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;; Improved messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;; Version 0.02 - 13 Nov 1991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;; detexinfo-remove-inline-cmd, detexinfo-syntax-table: Handle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;;; nested commands.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;; detexinfo: Handle nested @'s, eg @samp{@}} and @samp{@@};
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;; replace @TeX{} with TeX.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;; Version 0.01 - 13 Nov 1991
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;; Based on detex.el, by Bengt Martensson, 4 Oct 1987
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (defvar detexinfo-buffer-name "*detexinfo*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 "*Name of the temporary buffer used by \\[detexinfo].")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (defvar detexinfo-syntax-table nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (if detexinfo-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (setq detexinfo-syntax-table (make-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (modify-syntax-entry ?\[ "." detexinfo-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (modify-syntax-entry ?\] "." detexinfo-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (modify-syntax-entry ?\" "." detexinfo-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (modify-syntax-entry ?\\ "." detexinfo-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (modify-syntax-entry ?\( "." detexinfo-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (modify-syntax-entry ?\) "." detexinfo-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (modify-syntax-entry ?{ "(}" detexinfo-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (modify-syntax-entry ?} "){" detexinfo-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (defun detexinfo ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 "Remove Texinfo commands from current buffer, copying result to new buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 BUG: Fails if Texinfo source file contains formatting errors."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (let ((input-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;; Find a buffer to use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (switch-to-buffer (get-buffer-create detexinfo-buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (setq major-mode 'detexinfo-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (set-syntax-table detexinfo-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (insert-buffer-substring input-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; Replace @{ and @} with %#* and *#% temporarily, so @samp{@{} works.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;; What is a better way of doing this??
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (while (search-forward "@{" nil t) ; e.g., @samp{@{}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (replace-match "%#*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (while (search-forward "@}" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (forward-char -3) ; e.g., @samp{@@}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (if (looking-at "@") ; Two @@ in a row
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (delete-char 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (insert "%&%#"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (delete-char 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (insert "*#%")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;; Remove @refill, the only inline command without braces.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (while (search-forward "@refill" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (replace-match ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;; Replace @TeX{} with TeX
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (while (search-forward "@TeX{}" nil t) (replace-match "TeX" t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (detexinfo-remove-line-cmds-without-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (detexinfo-remove-inline-cmds-without-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (detexinfo-remove-inline-cmds-keep-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (detexinfo-remove-line-cmds-deletable-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (detexinfo-remove-line-cmds-maybe-delete-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (detexinfo-remove-line-cmds-keep-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;; Now replace %#*, *#%, and %&%# with {, }, and @@.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (while (search-forward "%#*" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (replace-match "{"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (while (search-forward "*#%" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (replace-match "}"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (while (search-forward "%&%#" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (replace-match "@@"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;; Scan for remaining two character @-commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (while (search-forward "@" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (cond ((looking-at "[*:]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (delete-region (1- (point)) (1+ (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ((looking-at "[{}^@.'`]\"?!")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (delete-region (1- (point)) (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (message "Done...removed Texinfo commands from buffer. You may save it.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (defun detexinfo-remove-whole-line (cmd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 "Delete Texinfo line command CMD at beginning of line and rest of line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (concat "^@" cmd "[ \n]+") (point-max) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (delete-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (point) (save-excursion (end-of-line) (1+ (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (defun detexinfo-remove-inline-cmd (cmd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 "Delete Texinfo inline command CMD, eg. @point, @code."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (re-search-forward (concat "@" cmd "{") (point-max) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (delete-char -1)) ; delete right brace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (delete-region (point) (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;;; 1. @setfilename and other line commands with args to delete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (defvar detexinfo-line-cmds-deletable-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 '("enumerate" "ftable" "vtable" "itemize" "table"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 "setfilename" "settitle" "setchapternewpage"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 "footnotestyle" "paragraphindent"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 "include" "need" "sp"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 "clear" "ifclear" "ifset" "set"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 "defcodeindex" "defindex" "syncodeindex" "synindex")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 "List of Texinfo commands whose arguments should be deleted.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (defun detexinfo-remove-line-cmds-deletable-arg ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 "Delete Texinfo line commands together with their args, eg @setfilename."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (message "Removing commands such as @enumerate...with their arguments...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (mapcar 'detexinfo-remove-whole-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 detexinfo-line-cmds-deletable-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;;; 2. @cindex and other cmds with args that may be deleted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;;; This list is here just to make it easier to revise the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;;; categories. In particular, you might want to keep the index entries.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (defvar detexinfo-line-cmds-maybe-delete-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 '("cindex" "findex" "kindex" "pindex" "tindex" "vindex" "node"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 "c" "comment" "end" "headings" "printindex" "vskip"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 "evenfooting" "evenheading" "everyfooting" "everyheading"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 "oddfooting" "oddheading")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 "List of Texinfo commands whose arguments may possibly be deleted.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (defun detexinfo-remove-line-cmds-maybe-delete-arg ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 "Delete Texinfo line commands together with their arguments, eg, @cindex."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (message "Removing commands such as @cindex...with their arguments...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (mapcar 'detexinfo-remove-whole-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 detexinfo-line-cmds-maybe-delete-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;;; 3. @chapter and other line cmds with args to keep.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (defvar detexinfo-line-cmds-keep-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 '("top" "chapter" "section" "subsection" "subsubsection"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 "unnumbered" "unnumberedsec" "unnumberedsubsec" "unnumberedsubsubsec"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 "majorheading" "chapheading" "heading" "subheading" "subsubheading"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 "appendix" "appendixsec" "appendixsubsec" "appendixsubsubsec"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 "item" "itemx"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 "title" "subtitle" "center" "author" "exdent"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 "defcv" "deffn" "defivar" "defmac" "defmethod" "defop" "defopt"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 "defspec" "deftp" "deftypefn" "deftypefun" "deftypvr"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 "deftypevar" "defun" "defvar" "defvr")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 "List of Texinfo line commands whose arguments should be kept.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (defun detexinfo-remove-line-cmds-keep-arg ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 "Delete Texinfo line commands but keep their arguments, eg @chapter."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (message "Removing commands such as @chapter...but not their arguments...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (mapcar 'detexinfo-remove-line-cmd-keep-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 detexinfo-line-cmds-keep-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (defun detexinfo-remove-line-cmd-keep-arg (cmd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 "Delete Texinfo line command CMD but keep its argument, eg @chapter."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (concat "^@" cmd "[ \n]+") (point-max) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (delete-region (match-beginning 0) (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 ;;; 4. @bye and other line commands without args.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (defvar detexinfo-line-cmds-without-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 '("bye" "contents" "display" "example" "finalout"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 "flushleft" "flushright" "format" "group" "ifhtml" "ifinfo" "iftex"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 "ignore" "lisp" "menu" "noindent" "page" "quotation"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 "shortcontents" "smallbook" "smallexample" "smalllisp"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 "summarycontents" "tex" "thischapter" "thischaptername"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 "thisfile" "thispage" "thissection" "thistitle" "titlepage")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 "List of Texinfo commands without arguments that should be deleted.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (defun detexinfo-remove-line-cmds-without-arg ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 "Delete line Texinfo commands that lack args, eg. @example."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (message "Removing commands such as @example...that lack arguments...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (mapcar 'detexinfo-remove-whole-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 detexinfo-line-cmds-without-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ;;; 5. @equiv and other inline cmds without args.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (defvar detexinfo-inline-cmds-without-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 '("equiv" "error" "expansion" "point" "print" "result"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 "asis" "br" "bullet" "dots" "minus" "today")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 "List of Texinfo inline commands without arguments that should be deleted.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (defun detexinfo-remove-inline-cmds-without-arg ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 "Delete Texinfo inline commands in that lack arguments."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (message "Removing within line commands such as @result...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (mapcar 'detexinfo-remove-inline-cmd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 detexinfo-inline-cmds-without-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;;; 6. @code and other inline cmds with args to keep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (defvar detexinfo-inline-cmds-keep-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 '("b" "cartouche" "cite" "code" "copyright" "ctrl" "dfn" "dmn"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 "emph" "file" "footnote" "i" "inforef"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 "kbd" "key" "pxref" "r" "ref" "samp" "sc" "titlefont"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 "strong" "t" "var" "w" "xref")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 "List of Texinfo inline commands with arguments that should be kept.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (defun detexinfo-remove-inline-cmds-keep-arg ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 "Delete Texinfo inline commands but keep its arg, eg. @code."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 "Removing within line commands such as @code...but not their arguments...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (mapcar 'detexinfo-remove-inline-cmd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 detexinfo-inline-cmds-keep-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 ;;;;;;;;;;;;;;;; end detexinfo.el ;;;;;;;;;;;;;;;;