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