660
|
1 ;;; informat.el --- info support functions package for Emacs
|
|
2
|
846
|
3 ;; Copyright (C) 1986 Free Software Foundation, Inc.
|
|
4
|
807
|
5 ;; Maintainer: FSF
|
811
|
6 ;; Keywords: help
|
807
|
7
|
257
|
8 ;; This file is part of GNU Emacs.
|
|
9
|
|
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
11 ;; it under the terms of the GNU General Public License as published by
|
807
|
12 ;; the Free Software Foundation; either version 2, or (at your option)
|
257
|
13 ;; any later version.
|
|
14
|
|
15 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18 ;; GNU General Public License for more details.
|
|
19
|
|
20 ;; You should have received a copy of the GNU General Public License
|
14169
|
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
23 ;; Boston, MA 02111-1307, USA.
|
257
|
24
|
22693
|
25 ;;; Commentary:
|
|
26
|
|
27 ;; Nowadays, the Texinfo formatting commands always tagify a buffer
|
|
28 ;; (as does `makeinfo') since @anchor commands need tag tables.
|
|
29
|
807
|
30 ;;; Code:
|
|
31
|
257
|
32 (require 'info)
|
|
33
|
|
34 ;;;###autoload
|
22693
|
35 (defun Info-tagify (&optional input-buffer-name)
|
|
36 "Create or update Info file tag table in current buffer or in a region."
|
257
|
37 (interactive)
|
|
38 ;; Save and restore point and restrictions.
|
|
39 ;; save-restrictions would not work
|
|
40 ;; because it records the old max relative to the end.
|
|
41 ;; We record it relative to the beginning.
|
22693
|
42 (if input-buffer-name
|
|
43 (message "Tagifying region in %s ..." input-buffer-name)
|
|
44 (message
|
|
45 "Tagifying %s ..." (file-name-nondirectory (buffer-file-name))))
|
257
|
46 (let ((omin (point-min))
|
|
47 (omax (point-max))
|
|
48 (nomax (= (point-max) (1+ (buffer-size))))
|
|
49 (opoint (point)))
|
|
50 (unwind-protect
|
22660
|
51 (progn
|
25427
dde5fcbfa2af
(Info-tagify): Don't insert more than one newline before the tag table.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
52 (widen)
|
22660
|
53 (goto-char (point-min))
|
|
54 (if (search-forward "\^_\nIndirect:\n" nil t)
|
22693
|
55 (message
|
|
56 "Cannot tagify split info file. Run this before splitting.")
|
22660
|
57 (let (tag-list
|
|
58 refillp
|
|
59 (case-fold-search t)
|
|
60 (regexp
|
|
61 (concat
|
|
62 "\\("
|
|
63
|
|
64
|
|
65 "\\("
|
|
66 "@anchor" ; match-string 2 matches @anchor
|
|
67 "\\)"
|
|
68 "\\(-no\\|-yes\\)" ; match-string 3 matches -no or -yes
|
|
69 "\\("
|
|
70 "-refill"
|
|
71 "\\)"
|
|
72
|
|
73 "\\("
|
|
74 "{"
|
|
75 "\\)"
|
|
76 "\\("
|
|
77 "[^}]+" ; match-string 6 matches arg to anchor
|
|
78 "\\)"
|
|
79 "\\("
|
|
80 "}"
|
|
81 "\\)"
|
|
82
|
|
83 "\\|"
|
|
84
|
|
85 "\\("
|
25427
dde5fcbfa2af
(Info-tagify): Don't insert more than one newline before the tag table.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
86 "\n\^_\\(\^L\\)?"
|
22660
|
87 "\\)"
|
|
88
|
|
89 "\\("
|
25427
dde5fcbfa2af
(Info-tagify): Don't insert more than one newline before the tag table.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
90 "\n\\(File:[ \t]*\\([^,\n\t]*\\)[,\t\n]+[ \t\n]*\\)?"
|
22660
|
91 "Node:[ \t]*"
|
|
92 "\\("
|
25427
dde5fcbfa2af
(Info-tagify): Don't insert more than one newline before the tag table.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
93 "[^,\n\t]*" ; match-string 13 matches arg to node name
|
22660
|
94 "\\)"
|
|
95 "[,\t\n]"
|
|
96 "\\)"
|
|
97
|
|
98 "\\)"
|
|
99 )))
|
|
100 (while (re-search-forward regexp nil t)
|
|
101 (if (string-equal "@anchor" (match-string 2))
|
|
102 (progn
|
|
103 ;; kludge lest lose match-data
|
|
104 (if (string-equal "-yes" (match-string 3))
|
|
105 (setq refillp t))
|
|
106 (setq tag-list
|
|
107 (cons (list
|
|
108 (concat "Ref: " (match-string 6))
|
|
109 (match-beginning 0))
|
|
110 tag-list))
|
|
111 (if (eq refillp t)
|
|
112 ;; set start and end so texinfo-format-refill works
|
|
113 (let ((texinfo-command-start (match-beginning 0))
|
|
114 (texinfo-command-end (match-end 0)))
|
|
115 (texinfo-format-refill))
|
|
116 (delete-region (match-beginning 0) (match-end 0))))
|
|
117 ;; else this is a Node
|
|
118 (setq tag-list
|
|
119 (cons (list
|
25427
dde5fcbfa2af
(Info-tagify): Don't insert more than one newline before the tag table.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
120 (concat "Node: " (match-string-no-properties 13))
|
dde5fcbfa2af
(Info-tagify): Don't insert more than one newline before the tag table.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
121 (1+ (match-beginning 10)))
|
22660
|
122 tag-list))))
|
|
123
|
257
|
124 (goto-char (point-max))
|
|
125 (forward-line -8)
|
|
126 (let ((buffer-read-only nil))
|
|
127 (if (search-forward "\^_\nEnd tag table\n" nil t)
|
|
128 (let ((end (point)))
|
|
129 (search-backward "\nTag table:\n")
|
|
130 (beginning-of-line)
|
|
131 (delete-region (point) end)))
|
|
132 (goto-char (point-max))
|
25427
dde5fcbfa2af
(Info-tagify): Don't insert more than one newline before the tag table.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
133 (or (bolp)
|
dde5fcbfa2af
(Info-tagify): Don't insert more than one newline before the tag table.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
134 (newline))
|
dde5fcbfa2af
(Info-tagify): Don't insert more than one newline before the tag table.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
135 (insert "\^_\f\nTag table:\n")
|
18137
985e47a14cab
(Info-tagify): Don't set Info-tag-table-marker if not in Info mode.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
136 (if (eq major-mode 'info-mode)
|
985e47a14cab
(Info-tagify): Don't set Info-tag-table-marker if not in Info mode.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
137 (move-marker Info-tag-table-marker (point)))
|
22660
|
138 (setq tag-list (nreverse tag-list))
|
|
139 (while tag-list
|
|
140 (insert (car (car tag-list)) ?\177)
|
22693
|
141 (princ (car (cdr (car tag-list))) (current-buffer))
|
257
|
142 (insert ?\n)
|
22660
|
143 (setq tag-list (cdr tag-list)))
|
257
|
144 (insert "\^_\nEnd tag table\n")))))
|
|
145 (goto-char opoint)
|
|
146 (narrow-to-region omin (if nomax (1+ (buffer-size))
|
|
147 (min omax (point-max))))))
|
22693
|
148 (if input-buffer-name
|
25427
dde5fcbfa2af
(Info-tagify): Don't insert more than one newline before the tag table.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
149 (message "Tagifying region in %s done" input-buffer-name)
|
22693
|
150 (message
|
25427
dde5fcbfa2af
(Info-tagify): Don't insert more than one newline before the tag table.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
151 "Tagifying %s done" (file-name-nondirectory (buffer-file-name)))))
|
22693
|
152
|
257
|
153
|
|
154 ;;;###autoload
|
|
155 (defun Info-split ()
|
|
156 "Split an info file into an indirect file plus bounded-size subfiles.
|
|
157 Each subfile will be up to 50,000 characters plus one node.
|
|
158
|
|
159 To use this command, first visit a large Info file that has a tag
|
|
160 table. The buffer is modified into a (small) indirect info file which
|
|
161 should be saved in place of the original visited file.
|
|
162
|
|
163 The subfiles are written in the same directory the original file is
|
|
164 in, with names generated by appending `-' and a number to the original
|
|
165 file name. The indirect file still functions as an Info file, but it
|
|
166 contains just the tag table and a directory of subfiles."
|
|
167
|
|
168 (interactive)
|
|
169 (if (< (buffer-size) 70000)
|
|
170 (error "This is too small to be worth splitting"))
|
|
171 (goto-char (point-min))
|
|
172 (search-forward "\^_")
|
|
173 (forward-char -1)
|
|
174 (let ((start (point))
|
22693
|
175 (chars-deleted 0)
|
257
|
176 subfiles
|
|
177 (subfile-number 1)
|
|
178 (case-fold-search t)
|
|
179 (filename (file-name-sans-versions buffer-file-name)))
|
|
180 (goto-char (point-max))
|
|
181 (forward-line -8)
|
|
182 (setq buffer-read-only nil)
|
|
183 (or (search-forward "\^_\nEnd tag table\n" nil t)
|
|
184 (error "Tag table required; use M-x Info-tagify"))
|
|
185 (search-backward "\nTag table:\n")
|
|
186 (if (looking-at "\nTag table:\n\^_")
|
|
187 (error "Tag table is just a skeleton; use M-x Info-tagify"))
|
|
188 (beginning-of-line)
|
|
189 (forward-char 1)
|
|
190 (save-restriction
|
|
191 (narrow-to-region (point-min) (point))
|
|
192 (goto-char (point-min))
|
|
193 (while (< (1+ (point)) (point-max))
|
|
194 (goto-char (min (+ (point) 50000) (point-max)))
|
|
195 (search-forward "\^_" nil 'move)
|
|
196 (setq subfiles
|
22693
|
197 (cons (list (+ start chars-deleted)
|
257
|
198 (concat (file-name-nondirectory filename)
|
|
199 (format "-%d" subfile-number)))
|
|
200 subfiles))
|
|
201 ;; Put a newline at end of split file, to make Unix happier.
|
|
202 (insert "\n")
|
|
203 (write-region (point-min) (point)
|
|
204 (concat filename (format "-%d" subfile-number)))
|
|
205 (delete-region (1- (point)) (point))
|
|
206 ;; Back up over the final ^_.
|
|
207 (forward-char -1)
|
22693
|
208 (setq chars-deleted (+ chars-deleted (- (point) start)))
|
257
|
209 (delete-region start (point))
|
|
210 (setq subfile-number (1+ subfile-number))))
|
|
211 (while subfiles
|
|
212 (goto-char start)
|
|
213 (insert (nth 1 (car subfiles))
|
10156
|
214 (format ": %d" (1- (car (car subfiles))))
|
257
|
215 "\n")
|
|
216 (setq subfiles (cdr subfiles)))
|
|
217 (goto-char start)
|
|
218 (insert "\^_\nIndirect:\n")
|
|
219 (search-forward "\nTag Table:\n")
|
|
220 (insert "(Indirect)\n")))
|
|
221
|
18422
|
222 (defvar Info-validate-allnodes)
|
|
223 (defvar Info-validate-thisnode)
|
|
224 (defvar Info-validate-lossages)
|
|
225
|
257
|
226 ;;;###autoload
|
|
227 (defun Info-validate ()
|
|
228 "Check current buffer for validity as an Info file.
|
|
229 Check that every node pointer points to an existing node."
|
|
230 (interactive)
|
|
231 (save-excursion
|
|
232 (save-restriction
|
|
233 (widen)
|
|
234 (goto-char (point-min))
|
|
235 (if (search-forward "\nTag table:\n(Indirect)\n" nil t)
|
|
236 (error "Don't yet know how to validate indirect info files: \"%s\""
|
|
237 (buffer-name (current-buffer))))
|
|
238 (goto-char (point-min))
|
18422
|
239 (let ((Info-validate-allnodes '(("*")))
|
257
|
240 (regexp "Node:[ \t]*\\([^,\n\t]*\\)[,\t\n]")
|
|
241 (case-fold-search t)
|
|
242 (tags-losing nil)
|
18422
|
243 (Info-validate-lossages ()))
|
257
|
244 (while (search-forward "\n\^_" nil t)
|
|
245 (forward-line 1)
|
|
246 (let ((beg (point)))
|
|
247 (forward-line 1)
|
|
248 (if (re-search-backward regexp beg t)
|
|
249 (let ((name (downcase
|
18422
|
250 (buffer-substring-no-properties
|
|
251 (match-beginning 1)
|
|
252 (progn
|
|
253 (goto-char (match-end 1))
|
|
254 (skip-chars-backward " \t")
|
|
255 (point))))))
|
|
256 (if (assoc name Info-validate-allnodes)
|
|
257 (setq Info-validate-lossages
|
257
|
258 (cons (list name "Duplicate node-name" nil)
|
18422
|
259 Info-validate-lossages))
|
|
260 (setq Info-validate-allnodes
|
|
261 (cons (list name
|
|
262 (progn
|
|
263 (end-of-line)
|
|
264 (and (re-search-backward
|
|
265 "prev[ious]*:" beg t)
|
|
266 (progn
|
|
267 (goto-char (match-end 0))
|
|
268 (downcase
|
|
269 (Info-following-node-name)))))
|
|
270 beg)
|
|
271 Info-validate-allnodes)))))))
|
257
|
272 (goto-char (point-min))
|
|
273 (while (search-forward "\n\^_" nil t)
|
|
274 (forward-line 1)
|
|
275 (let ((beg (point))
|
18422
|
276 Info-validate-thisnode next)
|
257
|
277 (forward-line 1)
|
|
278 (if (re-search-backward regexp beg t)
|
|
279 (save-restriction
|
25427
dde5fcbfa2af
(Info-tagify): Don't insert more than one newline before the tag table.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
280 (let ((md (match-data)))
|
dde5fcbfa2af
(Info-tagify): Don't insert more than one newline before the tag table.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
281 (search-forward "\n\^_" nil 'move)
|
dde5fcbfa2af
(Info-tagify): Don't insert more than one newline before the tag table.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
282 (narrow-to-region beg (point))
|
dde5fcbfa2af
(Info-tagify): Don't insert more than one newline before the tag table.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
283 (set-match-data md))
|
18422
|
284 (setq Info-validate-thisnode (downcase
|
|
285 (buffer-substring-no-properties
|
|
286 (match-beginning 1)
|
|
287 (progn
|
|
288 (goto-char (match-end 1))
|
|
289 (skip-chars-backward " \t")
|
|
290 (point)))))
|
257
|
291 (end-of-line)
|
|
292 (and (search-backward "next:" nil t)
|
|
293 (setq next (Info-validate-node-name "invalid Next"))
|
18422
|
294 (assoc next Info-validate-allnodes)
|
|
295 (if (equal (car (cdr (assoc next Info-validate-allnodes)))
|
|
296 Info-validate-thisnode)
|
257
|
297 ;; allow multiple `next' pointers to one node
|
18422
|
298 (let ((tem Info-validate-lossages))
|
257
|
299 (while tem
|
|
300 (if (and (equal (car (cdr (car tem)))
|
|
301 "should have Previous")
|
|
302 (equal (car (car tem))
|
|
303 next))
|
18422
|
304 (setq Info-validate-lossages
|
|
305 (delq (car tem) Info-validate-lossages)))
|
257
|
306 (setq tem (cdr tem))))
|
18422
|
307 (setq Info-validate-lossages
|
257
|
308 (cons (list next
|
|
309 "should have Previous"
|
18422
|
310 Info-validate-thisnode)
|
|
311 Info-validate-lossages))))
|
257
|
312 (end-of-line)
|
|
313 (if (re-search-backward "prev[ious]*:" nil t)
|
|
314 (Info-validate-node-name "invalid Previous"))
|
|
315 (end-of-line)
|
|
316 (if (search-backward "up:" nil t)
|
|
317 (Info-validate-node-name "invalid Up"))
|
|
318 (if (re-search-forward "\n* Menu:" nil t)
|
|
319 (while (re-search-forward "\n\\* " nil t)
|
|
320 (Info-validate-node-name
|
18422
|
321 (concat "invalid menu item "
|
|
322 (buffer-substring (point)
|
|
323 (save-excursion
|
|
324 (skip-chars-forward "^:")
|
|
325 (point))))
|
|
326 (Info-extract-menu-node-name))))
|
257
|
327 (goto-char (point-min))
|
|
328 (while (re-search-forward "\\*note[ \n]*[^:\t]*:" nil t)
|
|
329 (goto-char (+ (match-beginning 0) 5))
|
|
330 (skip-chars-forward " \n")
|
|
331 (Info-validate-node-name
|
|
332 (concat "invalid reference "
|
|
333 (buffer-substring (point)
|
|
334 (save-excursion
|
|
335 (skip-chars-forward "^:")
|
|
336 (point))))
|
|
337 (Info-extract-menu-node-name "Bad format cross-reference")))))))
|
|
338 (setq tags-losing (not (Info-validate-tags-table)))
|
18422
|
339 (if (or Info-validate-lossages tags-losing)
|
257
|
340 (with-output-to-temp-buffer " *problems in info file*"
|
18422
|
341 (while Info-validate-lossages
|
257
|
342 (princ "In node \"")
|
18422
|
343 (princ (car (car Info-validate-lossages)))
|
257
|
344 (princ "\", ")
|
18422
|
345 (let ((tem (nth 1 (car Info-validate-lossages))))
|
257
|
346 (cond ((string-match "\n" tem)
|
|
347 (princ (substring tem 0 (match-beginning 0)))
|
|
348 (princ "..."))
|
|
349 (t
|
|
350 (princ tem))))
|
18422
|
351 (if (nth 2 (car Info-validate-lossages))
|
257
|
352 (progn
|
|
353 (princ ": ")
|
18422
|
354 (let ((tem (nth 2 (car Info-validate-lossages))))
|
257
|
355 (cond ((string-match "\n" tem)
|
|
356 (princ (substring tem 0 (match-beginning 0)))
|
|
357 (princ "..."))
|
|
358 (t
|
|
359 (princ tem))))))
|
|
360 (terpri)
|
18422
|
361 (setq Info-validate-lossages (cdr Info-validate-lossages)))
|
257
|
362 (if tags-losing (princ "\nTags table must be recomputed\n")))
|
|
363 ;; Here if info file is valid.
|
|
364 ;; If we already made a list of problems, clear it out.
|
|
365 (save-excursion
|
|
366 (if (get-buffer " *problems in info file*")
|
|
367 (progn
|
|
368 (set-buffer " *problems in info file*")
|
|
369 (kill-buffer (current-buffer)))))
|
|
370 (message "File appears valid"))))))
|
|
371
|
|
372 (defun Info-validate-node-name (kind &optional name)
|
|
373 (if name
|
|
374 nil
|
|
375 (goto-char (match-end 0))
|
|
376 (skip-chars-forward " \t")
|
|
377 (if (= (following-char) ?\()
|
|
378 nil
|
|
379 (setq name
|
13291
49de0d4ca42e
(Info-validate, Info-validate-node-name): Use buffer-substring-no-properties.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
380 (buffer-substring-no-properties
|
257
|
381 (point)
|
|
382 (progn
|
18422
|
383 (skip-chars-forward "^,\t\n")
|
|
384 (skip-chars-backward " ")
|
|
385 (point))))))
|
257
|
386 (if (null name)
|
|
387 nil
|
|
388 (setq name (downcase name))
|
|
389 (or (and (> (length name) 0) (= (aref name 0) ?\())
|
18422
|
390 (assoc name Info-validate-allnodes)
|
|
391 (setq Info-validate-lossages
|
|
392 (cons (list Info-validate-thisnode kind name)
|
|
393 Info-validate-lossages))))
|
257
|
394 name)
|
|
395
|
|
396 (defun Info-validate-tags-table ()
|
|
397 (goto-char (point-min))
|
|
398 (if (not (search-forward "\^_\nEnd tag table\n" nil t))
|
|
399 t
|
|
400 (not (catch 'losing
|
|
401 (let* ((end (match-beginning 0))
|
|
402 (start (progn (search-backward "\nTag table:\n")
|
|
403 (1- (match-end 0))))
|
|
404 tem)
|
18422
|
405 (setq tem Info-validate-allnodes)
|
257
|
406 (while tem
|
|
407 (goto-char start)
|
|
408 (or (equal (car (car tem)) "*")
|
|
409 (search-forward (concat "Node: "
|
|
410 (car (car tem))
|
|
411 "\177")
|
|
412 end t)
|
|
413 (throw 'losing 'x))
|
|
414 (setq tem (cdr tem)))
|
|
415 (goto-char (1+ start))
|
|
416 (while (looking-at ".*Node: \\(.*\\)\177\\([0-9]+\\)$")
|
13291
49de0d4ca42e
(Info-validate, Info-validate-node-name): Use buffer-substring-no-properties.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
417 (setq tem (downcase (buffer-substring-no-properties
|
257
|
418 (match-beginning 1)
|
|
419 (match-end 1))))
|
18422
|
420 (setq tem (assoc tem Info-validate-allnodes))
|
257
|
421 (if (or (not tem)
|
|
422 (< 1000 (progn
|
|
423 (goto-char (match-beginning 2))
|
|
424 (setq tem (- (car (cdr (cdr tem)))
|
|
425 (read (current-buffer))))
|
|
426 (if (> tem 0) tem (- tem)))))
|
13291
49de0d4ca42e
(Info-validate, Info-validate-node-name): Use buffer-substring-no-properties.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
427 (throw 'losing 'y))
|
49de0d4ca42e
(Info-validate, Info-validate-node-name): Use buffer-substring-no-properties.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
428 (forward-line 1)))
|
49de0d4ca42e
(Info-validate, Info-validate-node-name): Use buffer-substring-no-properties.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
429 (if (looking-at "\^_\n")
|
49de0d4ca42e
(Info-validate, Info-validate-node-name): Use buffer-substring-no-properties.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
430 (forward-line 1))
|
257
|
431 (or (looking-at "End tag table\n")
|
|
432 (throw 'losing 'z))
|
|
433 nil))))
|
|
434
|
|
435 ;;;###autoload
|
|
436 (defun batch-info-validate ()
|
|
437 "Runs `Info-validate' on the files remaining on the command line.
|
|
438 Must be used only with -batch, and kills Emacs on completion.
|
|
439 Each file will be processed even if an error occurred previously.
|
|
440 For example, invoke \"emacs -batch -f batch-info-validate $info/ ~/*.info\""
|
|
441 (if (not noninteractive)
|
38412
|
442 (error "batch-info-validate may only be used -batch"))
|
257
|
443 (let ((version-control t)
|
|
444 (auto-save-default nil)
|
|
445 (find-file-run-dired nil)
|
|
446 (kept-old-versions 259259)
|
|
447 (kept-new-versions 259259))
|
|
448 (let ((error 0)
|
|
449 file
|
|
450 (files ()))
|
|
451 (while command-line-args-left
|
|
452 (setq file (expand-file-name (car command-line-args-left)))
|
|
453 (cond ((not (file-exists-p file))
|
|
454 (message ">> %s does not exist!" file)
|
|
455 (setq error 1
|
|
456 command-line-args-left (cdr command-line-args-left)))
|
|
457 ((file-directory-p file)
|
|
458 (setq command-line-args-left (nconc (directory-files file)
|
|
459 (cdr command-line-args-left))))
|
|
460 (t
|
|
461 (setq files (cons file files)
|
|
462 command-line-args-left (cdr command-line-args-left)))))
|
|
463 (while files
|
|
464 (setq file (car files)
|
|
465 files (cdr files))
|
|
466 (let ((lose nil))
|
|
467 (condition-case err
|
|
468 (progn
|
|
469 (if buffer-file-name (kill-buffer (current-buffer)))
|
|
470 (find-file file)
|
|
471 (buffer-disable-undo (current-buffer))
|
|
472 (set-buffer-modified-p nil)
|
|
473 (fundamental-mode)
|
|
474 (let ((case-fold-search nil))
|
|
475 (goto-char (point-max))
|
|
476 (cond ((search-backward "\n\^_\^L\nTag table:\n" nil t)
|
|
477 (message "%s already tagified" file))
|
|
478 ((< (point-max) 30000)
|
|
479 (message "%s too small to bother tagifying" file))
|
|
480 (t
|
923
|
481 (Info-tagify))))
|
257
|
482 (let ((loss-name " *problems in info file*"))
|
|
483 (message "Checking validity of info file %s..." file)
|
|
484 (if (get-buffer loss-name)
|
|
485 (kill-buffer loss-name))
|
|
486 (Info-validate)
|
|
487 (if (not (get-buffer loss-name))
|
|
488 nil ;(message "Checking validity of info file %s... OK" file)
|
|
489 (message "----------------------------------------------------------------------")
|
|
490 (message ">> PROBLEMS IN INFO FILE %s" file)
|
|
491 (save-excursion
|
|
492 (set-buffer loss-name)
|
13291
49de0d4ca42e
(Info-validate, Info-validate-node-name): Use buffer-substring-no-properties.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
493 (princ (buffer-substring-no-properties
|
49de0d4ca42e
(Info-validate, Info-validate-node-name): Use buffer-substring-no-properties.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
494 (point-min) (point-max))))
|
257
|
495 (message "----------------------------------------------------------------------")
|
|
496 (setq error 1 lose t)))
|
|
497 (if (and (buffer-modified-p)
|
|
498 (not lose))
|
|
499 (progn (message "Saving modified %s" file)
|
|
500 (save-buffer))))
|
|
501 (error (message ">> Error: %s" (prin1-to-string err))))))
|
|
502 (kill-emacs error))))
|
660
|
503
|
18383
|
504 (provide 'informat)
|
|
505
|
660
|
506 ;;; informat.el ends here
|