annotate lisp/informat.el @ 25310:f38d26cd9b8f

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