annotate lisp/informat.el @ 87264:864814308855

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