*** empty log message ***
[bpt/emacs.git] / lisp / info.el
CommitLineData
e3431643 1;;; info.el --- info package for Emacs.
e5167999 2
3d30065d 3;; Copyright (C) 1985, 86, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software
3ec18f3f 4;; Foundation, Inc.
3a801d0c 5
e5167999 6;; Maintainer: FSF
fd7fa35a 7;; Keywords: help
e5167999 8
a384cab3
JB
9;; This file is part of GNU Emacs.
10
11;; GNU Emacs is free software; you can redistribute it and/or modify
12;; it under the terms of the GNU General Public License as published by
e5167999 13;; the Free Software Foundation; either version 2, or (at your option)
a384cab3
JB
14;; any later version.
15
16;; GNU Emacs is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;; GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public License
b578f267
EN
22;; along with GNU Emacs; see the file COPYING. If not, write to the
23;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24;; Boston, MA 02111-1307, USA.
a384cab3 25
e5167999
ER
26;;; Commentary:
27
b578f267 28;; Note that nowadays we expect info files to be made using makeinfo.
e5167999
ER
29
30;;; Code:
31
bc6262c8
DL
32(eval-when-compile (require 'jka-compr))
33
ded3e3d8
RS
34(defgroup info nil
35 "Info subsystem"
36 :group 'help
37 :group 'docs)
38
39
a384cab3
JB
40(defvar Info-history nil
41 "List of info nodes user has visited.
42Each element of list is a list (FILENAME NODENAME BUFFERPOS).")
43
ded3e3d8 44(defcustom Info-enable-edit nil
d5913bf6 45 "*Non-nil means the \\<Info-mode-map>\\[Info-edit] command in Info can edit the current node.
ada0a60d
RS
46This is convenient if you want to write info files by hand.
47However, we recommend that you not do this.
48It is better to write a Texinfo file and generate the Info file from that,
ded3e3d8
RS
49because that gives you a printed manual as well."
50 :type 'boolean
51 :group 'info)
a384cab3 52
67f445d7 53(defvar Info-enable-active-nodes nil
a384cab3
JB
54 "Non-nil allows Info to execute Lisp code associated with nodes.
55The Lisp code is executed when the node is selected.")
67f445d7 56(put 'Info-enable-active-nodes 'risky-local-variable t)
a384cab3 57
ded3e3d8
RS
58(defcustom Info-fontify t
59 "*Non-nil enables highlighting and fonts in Info nodes."
60 :type 'boolean
61 :group 'info)
552775bd 62
93480d70 63(defface info-node
52cbdfbd
MB
64 '((((class color) (background light)) (:foreground "brown" :bold t :italic t))
65 (((class color) (background dark)) (:foreground "white" :bold t :italic t))
7a3abcd8 66 (t (:bold t :italic t)))
93480d70
RS
67 "Face for Info node names."
68 :group 'info)
69
70(defface info-menu-5
7a3abcd8
EZ
71 '((((class color)) (:foreground "red1"))
72 (t (:underline t)))
93480d70
RS
73 "Face for the fifth and tenth `*' in an Info menu."
74 :group 'info)
75
76(defface info-xref
52cbdfbd
MB
77 '((((class color) (background light)) (:foreground "magenta4" :bold t))
78 (((class color) (background dark)) (:foreground "cyan" :bold t))
7a3abcd8 79 (t (:bold t)))
93480d70
RS
80 "Face for Info cross-references."
81 :group 'info)
82
88ef7f62 83(defcustom Info-fontify-maximum-menu-size 100000
ded3e3d8
RS
84 "*Maximum size of menu to fontify if `Info-fontify' is non-nil."
85 :type 'integer
86 :group 'info)
bdf62a4d 87
50ac70af
MB
88(defcustom Info-use-header-line t
89 "*Non-nil means to put the beginning-of-node links in an emacs header-line.
90A header-line does not scroll with the rest of the buffer."
91 :type 'boolean
92 :group 'info)
93
94(defface info-header-xref
52cbdfbd 95 '((t (:inherit info-xref)))
50ac70af
MB
96 "Face for Info cross-references in a node header."
97 :group 'info)
98
99(defface info-header-node
8cc4cac1
MB
100 '(;; Because header-lines on tty's are usually reverse-video, the
101 ;; normal info-node colors probably won't look good, so just stick
102 ;; with bold-italic
103 (((type tty) (class color)) (:bold t :italic t))
104 (t (:inherit info-node)))
50ac70af
MB
105 "Face for Info nodes in a node header."
106 :group 'info)
107
7d3766a8 108(defvar Info-directory-list nil
a384cab3 109 "List of directories to search for Info documentation files.
aea2a8da 110nil means not yet initialized. In this case, Info uses the environment
44c327f9 111variable INFOPATH to initialize it, or `Info-default-directory-list'
e5bd2125 112if there is no INFOPATH variable in the environment.
778911b9
EZ
113
114When `Info-directory-list' is initialized from the value of
115`Info-default-directory-list', the first element of the resulting
116list is the directory where Emacs installs the Info files that
117come with it. This is so that Emacs's own manual, which suits the
118version of Emacs you are using, will always be found first. (If
119you want to override that, set INFOPATH in the environment.)
5da0f945
RS
120
121If you run the Emacs executable from the `src' directory in the Emacs
778911b9
EZ
122source tree, and INFOPATH is not defined, the `info' directory in the
123source tree is used as the first element of `Info-directory-list', in
124place of the installation Info directory. This is useful when you run
125a version of Emacs without installing it.")
a384cab3 126
ded3e3d8 127(defcustom Info-additional-directory-list nil
bdf62a4d 128 "List of additional directories to search for Info documentation files.
ded3e3d8
RS
129These directories are not searched for merging the `dir' file."
130 :type '(repeat directory)
131 :group 'info)
bdf62a4d 132
a384cab3 133(defvar Info-current-file nil
d6be34f3
RS
134 "Info file that Info is now looking at, or nil.
135This is the name that was specified in Info, not the actual file name.
4fceda3c
SM
136It doesn't contain directory names or file name extensions added by Info.
137Can also be t when using `Info-on-current-buffer'.")
a384cab3
JB
138
139(defvar Info-current-subfile nil
fdf4b680
DL
140 "Info subfile that is actually in the *info* buffer now.
141nil if current info file is not split into subfiles.")
a384cab3
JB
142
143(defvar Info-current-node nil
144 "Name of node that Info is now looking at, or nil.")
145
c5fe2ff1 146(defvar Info-tag-table-marker nil
a384cab3
JB
147 "Marker pointing at beginning of current Info file's tag table.
148Marker points nowhere if file has no tag table.")
149
c5fe2ff1
RS
150(defvar Info-tag-table-buffer nil
151 "Buffer used for indirect tag tables.")
152
552775bd
RS
153(defvar Info-current-file-completions nil
154 "Cached completion list for current Info file.")
155
1143a6b0 156(defvar Info-index-alternatives nil
fdf4b680 157 "List of possible matches for last `Info-index' command.")
1143a6b0 158
552775bd
RS
159(defvar Info-standalone nil
160 "Non-nil if Emacs was started solely as an Info browser.")
7d3766a8 161\f
bd0c9168 162(defvar Info-suffix-list
3c19e6c1
RS
163 ;; The MS-DOS list should work both when long file names are
164 ;; supported (Windows 9X), and when only 8+3 file names are available.
bd0c9168
RS
165 (if (eq system-type 'ms-dos)
166 '( (".gz" . "gunzip")
167 (".z" . "gunzip")
76dc74a2 168 (".bz2" . "bzip2 -dc")
3c19e6c1
RS
169 (".inz" . "gunzip")
170 (".igz" . "gunzip")
171 (".info.Z" . "gunzip")
172 (".info.gz" . "gunzip")
173 ("-info.Z" . "gunzip")
174 ("-info.gz" . "gunzip")
175 ("/index.gz". "gunzip")
176 ("/index.z" . "gunzip")
9b842cab 177 (".inf" . nil)
3c19e6c1
RS
178 (".info" . nil)
179 ("-info" . nil)
180 ("/index" . nil)
bd0c9168 181 ("" . nil))
a70dc410
RS
182 '( (".info.Z". "uncompress")
183 (".info.Y". "unyabba")
184 (".info.gz". "gunzip")
185 (".info.z". "gunzip")
bc6262c8 186 (".info.bz2" . "bzip2 -dc")
a70dc410
RS
187 (".info". nil)
188 ("-info.Z". "uncompress")
189 ("-info.Y". "unyabba")
190 ("-info.gz". "gunzip")
bc6262c8 191 ("-info.bz2" . "bzip2 -dc")
a70dc410
RS
192 ("-info.z". "gunzip")
193 ("-info". nil)
194 ("/index.Z". "uncompress")
195 ("/index.Y". "unyabba")
196 ("/index.gz". "gunzip")
197 ("/index.z". "gunzip")
bc6262c8 198 ("/index.bz2". "bzip2 -dc")
a70dc410
RS
199 ("/index". nil)
200 (".Z". "uncompress")
201 (".Y". "unyabba")
202 (".gz". "gunzip")
203 (".z". "gunzip")
bc6262c8 204 (".bz2" . "bzip2 -dc")
a70dc410 205 ("". nil)))
1143a6b0
ER
206 "List of file name suffixes and associated decoding commands.
207Each entry should be (SUFFIX . STRING); the file is given to
97f99202
KH
208the command as standard input. If STRING is nil, no decoding is done.
209Because the SUFFIXes are tried in order, the empty string should
210be last in the list.")
1143a6b0 211
c8e9dd54 212;; Concatenate SUFFIX onto FILENAME. SUFFIX should start with a dot.
bd0c9168
RS
213;; First, on ms-dos, delete some of the extension in FILENAME
214;; to make room.
215(defun info-insert-file-contents-1 (filename suffix)
216 (if (not (eq system-type 'ms-dos))
217 (concat filename suffix)
218 (let* ((sans-exts (file-name-sans-extension filename))
c8e9dd54
RS
219 ;; How long is the extension in FILENAME (not counting the dot).
220 (ext-len (max 0 (- (length filename) (length sans-exts) 1)))
221 ext-left)
9b842cab 222 ;; SUFFIX starts with a dot. If FILENAME already has one,
1583fe94 223 ;; get rid of the one in SUFFIX (unless suffix is empty).
c8e9dd54 224 (or (and (<= ext-len 0)
9b842cab 225 (not (eq (aref filename (1- (length filename))) ?.)))
1583fe94 226 (= (length suffix) 0)
9b842cab 227 (setq suffix (substring suffix 1)))
c8e9dd54
RS
228 ;; How many chars of that extension should we keep?
229 (setq ext-left (min ext-len (max 0 (- 3 (length suffix)))))
bd0c9168
RS
230 ;; Get rid of the rest of the extension, and add SUFFIX.
231 (concat (substring filename 0 (- (length filename)
232 (- ext-len ext-left)))
233 suffix))))
234
9c7924d5
RS
235(defun info-file-exists-p (filename)
236 (and (file-exists-p filename)
237 (not (file-directory-p filename))))
238
1143a6b0
ER
239(defun info-insert-file-contents (filename &optional visit)
240 "Insert the contents of an info file in the current buffer.
241Do the right thing if the file has been compressed or zipped."
97f99202
KH
242 (let ((tail Info-suffix-list)
243 fullname decoder)
244 (if (file-exists-p filename)
bd0c9168
RS
245 ;; FILENAME exists--see if that name contains a suffix.
246 ;; If so, set DECODE accordingly.
97f99202
KH
247 (progn
248 (while (and tail
249 (not (string-match
250 (concat (regexp-quote (car (car tail))) "$")
251 filename)))
252 (setq tail (cdr tail)))
253 (setq fullname filename
254 decoder (cdr (car tail))))
bd0c9168 255 ;; Try adding suffixes to FILENAME and see if we can find something.
97f99202 256 (while (and tail
9c7924d5
RS
257 (not (info-file-exists-p (info-insert-file-contents-1
258 filename (car (car tail))))))
97f99202 259 (setq tail (cdr tail)))
bd0c9168
RS
260 ;; If we found a file with a suffix, set DECODER according to the suffix
261 ;; and set FULLNAME to the file's actual name.
9b842cab 262 (setq fullname (info-insert-file-contents-1 filename (car (car tail)))
97f99202
KH
263 decoder (cdr (car tail)))
264 (or tail
bd0c9168 265 (error "Can't find %s or any compressed version of it" filename)))
e175bda2
RS
266 ;; check for conflict with jka-compr
267 (if (and (featurep 'jka-compr)
268 (jka-compr-installed-p)
269 (jka-compr-get-compression-info fullname))
270 (setq decoder nil))
97f99202 271 (if decoder
3c19e6c1
RS
272 (progn
273 (insert-file-contents-literally fullname visit)
274 (let ((buffer-read-only nil)
275 (coding-system-for-write 'no-conversion)
276 (default-directory (or (file-name-directory fullname)
277 default-directory)))
278 (call-process-region (point-min) (point-max) decoder t t)))
279 (insert-file-contents fullname visit))))
7d3766a8 280\f
7d3766a8 281(defun info-initialize ()
fdf4b680 282 "Initialize `Info-directory-list', if that hasn't been done yet."
7d3766a8
RS
283 (unless Info-directory-list
284 (let ((path (getenv "INFOPATH"))
285 (source (expand-file-name "info/" source-directory))
286 (sibling (if installation-directory
287 (expand-file-name "info/" installation-directory)))
288 alternative)
289 (setq Info-directory-list
78e7e8a0
MB
290 (prune-directory-list
291 (if path
292 (split-string path (regexp-quote path-separator))
293 (if (and sibling (file-exists-p sibling))
294 ;; Uninstalled, Emacs builddir != srcdir.
295 (setq alternative sibling)
296 ;; Uninstalled, builddir == srcdir
297 (setq alternative source))
298 (if (or (member alternative Info-default-directory-list)
299 ;; On DOS/NT, we use movable executables always,
300 ;; and we must always find the Info dir at run time.
301 (if (memq system-type '(ms-dos windows-nt))
302 nil
303 ;; Use invocation-directory for Info
304 ;; only if we used it for exec-directory also.
305 (not (string= exec-directory
306 (expand-file-name "lib-src/"
307 installation-directory))))
308 (not (file-exists-p alternative)))
309 Info-default-directory-list
310 ;; `alternative' contains the Info files that came with this
311 ;; version, so we should look there first. `Info-insert-dir'
312 ;; currently expects to find `alternative' first on the list.
313 (cons alternative
314 (reverse (cdr (reverse Info-default-directory-list)))))))))))
1143a6b0 315
a6e4564e
RS
316;;;###autoload
317(defun info-other-window (&optional file)
318 "Like `info' but show the Info buffer in another window."
319 (interactive (if current-prefix-arg
320 (list (read-file-name "Info file name: " nil nil t))))
321 (let (same-window-buffer-names)
322 (info file)))
399c88ad 323
d282974b 324;;;###autoload (add-hook 'same-window-buffer-names "*info*")
211d6309 325
a384cab3
JB
326;;;###autoload
327(defun info (&optional file)
328 "Enter Info, the documentation browser.
329Optional argument FILE specifies the file to examine;
330the default is the top-level directory of Info.
83d5c772
DL
331Called from a program, FILE may specify an Info node of the form
332`(FILENAME)NODENAME'.
a384cab3
JB
333
334In interactive use, a prefix argument directs this command
e341dab2
RS
335to read a file name from the minibuffer.
336
337The search path for Info files is in the variable `Info-directory-list'.
399c88ad 338The top-level Info directory is made by combining all the files named `dir'
e341dab2 339in all the directories in that path."
a384cab3
JB
340 (interactive (if current-prefix-arg
341 (list (read-file-name "Info file name: " nil nil t))))
a384cab3 342 (if file
c613e27e
KH
343 (progn
344 (pop-to-buffer "*info*")
345 ;; If argument already contains parentheses, don't add another set
346 ;; since the argument will then be parsed improperly. This also
347 ;; has the added benefit of allowing node names to be included
348 ;; following the parenthesized filename.
349 (if (and (stringp file) (string-match "(.*)" file))
350 (Info-goto-node file)
351 (Info-goto-node (concat "(" file ")"))))
35d2d241
RS
352 (if (get-buffer "*info*")
353 (pop-to-buffer "*info*")
354 (Info-directory))))
a384cab3 355
552775bd
RS
356;;;###autoload
357(defun info-standalone ()
358 "Run Emacs as a standalone Info reader.
359Usage: emacs -f info-standalone [filename]
360In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
361 (setq Info-standalone t)
362 (if (and command-line-args-left
363 (not (string-match "^-" (car command-line-args-left))))
364 (condition-case err
365 (progn
366 (info (car command-line-args-left))
367 (setq command-line-args-left (cdr command-line-args-left)))
368 (error (send-string-to-terminal
369 (format "%s\n" (if (eq (car-safe err) 'error)
370 (nth 1 err) err)))
371 (save-buffers-kill-emacs)))
372 (info)))
7d3766a8 373\f
11638562
EZ
374;; See if the the accessible portion of the buffer begins with a node
375;; delimiter, and the node header line which follows matches REGEXP.
376;; Typically, this test will be followed by a loop that examines the
377;; rest of the buffer with (search-forward "\n\^_"), and it's a pity
378;; to have the overhead of this special test inside the loop.
379
380;; This function changes match-data, but supposedly the caller might
381;; want to use the results of re-search-backward.
382
383;; The return value is the value of point at the beginning of matching
384;; REGERXP, if the function succeeds, nil otherwise.
385(defun Info-node-at-bob-matching (regexp)
760d5cb3
GM
386 (and (bobp) ; are we at beginning of buffer?
387 (looking-at "\^_") ; does it begin with node delimiter?
11638562
EZ
388 (let (beg)
389 (forward-line 1)
390 (setq beg (point))
760d5cb3 391 (forward-line 1) ; does the line after delimiter match REGEXP?
11638562
EZ
392 (re-search-backward regexp beg t))))
393
a384cab3 394(defun Info-find-node (filename nodename &optional no-going-back)
fdf4b680
DL
395 "Go to an info node specified as separate FILENAME and NODENAME.
396NO-GOING-BACK is non-nil if recovering from an error in this function;
397it says do not attempt further (recursive) error recovery."
d0e41cba 398 (info-initialize)
a384cab3
JB
399 ;; Convert filename to lower case if not found as specified.
400 ;; Expand it.
4fceda3c 401 (if (stringp filename)
a384cab3 402 (let (temp temp-downcase found)
37a3ff5b
RS
403 (setq filename (substitute-in-file-name filename))
404 (if (string= (downcase filename) "dir")
405 (setq found t)
406 (let ((dirs (if (string-match "^\\./" filename)
407 ;; If specified name starts with `./'
408 ;; then just try current directory.
409 '("./")
410 (if (file-name-absolute-p filename)
411 ;; No point in searching for an
412 ;; absolute file name
413 '(nil)
414 (if Info-additional-directory-list
415 (append Info-directory-list
416 Info-additional-directory-list)
417 Info-directory-list)))))
418 ;; Search the directory list for file FILENAME.
419 (while (and dirs (not found))
420 (setq temp (expand-file-name filename (car dirs)))
421 (setq temp-downcase
422 (expand-file-name (downcase filename) (car dirs)))
423 ;; Try several variants of specified name.
424 (let ((suffix-list Info-suffix-list))
425 (while (and suffix-list (not found))
426 (cond ((info-file-exists-p
427 (info-insert-file-contents-1
428 temp (car (car suffix-list))))
429 (setq found temp))
430 ((info-file-exists-p
431 (info-insert-file-contents-1
432 temp-downcase (car (car suffix-list))))
433 (setq found temp-downcase)))
434 (setq suffix-list (cdr suffix-list))))
435 (setq dirs (cdr dirs)))))
436 (if found
437 (setq filename found)
438 (error "Info file %s does not exist" filename))))
439 ;; Record the node we are leaving.
440 (if (and Info-current-file (not no-going-back))
441 (setq Info-history
442 (cons (list Info-current-file Info-current-node (point))
443 Info-history)))
a384cab3 444 ;; Go into info buffer.
c5fe2ff1 445 (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*"))
4fceda3c
SM
446 (Info-find-node-2 filename nodename no-going-back))
447
448(defun Info-on-current-buffer (&optional nodename)
449 "Use the `Info-mode' to browse the current info buffer.
450If a prefix arg is provided, it queries for the NODENAME which
451else defaults to `Top'."
452 (interactive
453 (list (if current-prefix-arg
454 (completing-read "Node name: " (Info-build-node-completions)
455 nil t "Top")
456 "Top")))
75296efc 457 (info-initialize)
4fceda3c
SM
458 (Info-mode)
459 (set (make-local-variable 'Info-current-file) t)
460 (Info-find-node-2 nil nodename))
461
357d11de
GM
462(defun Info-find-in-tag-table-1 (marker regexp case-fold)
463 "Find a node in a tag table.
464MARKER specifies the buffer and position to start searching at.
465REGEXP is a regular expression matching nodes or references. Its first
466group should match `Node:' or `Ref:'.
467CASE-FOLD t means search for a case-insensitive match.
468If a match was found, value is a list (FOUND-ANCHOR POS MODE), where
469FOUND-ANCHOR is non-nil if a `Ref:' was matched, POS is the position
470where the match was found, and MODE is `major-mode' of the buffer in
471which the match was found."
472 (let ((case-fold-search case-fold)
473 found-mode guesspos found-anchor)
474 (save-excursion
475 (set-buffer (marker-buffer marker))
476 (goto-char marker)
477
478 ;; Search tag table
479 (beginning-of-line)
480 (when (re-search-forward regexp nil t)
481 (list (string-equal "Ref:" (match-string 1))
482 (1+ (read (current-buffer)))
483 major-mode)))))
484
485(defun Info-find-in-tag-table (marker regexp)
486 "Find a node in a tag table.
487MARKER specifies the buffer and position to start searching at.
488REGEXP is a regular expression matching nodes or references. Its first
489group should match `Node:' or `Ref:'.
490If a match was found, value is a list (FOUND-ANCHOR POS MODE), where
491FOUND-ANCHOR is non-nil if a `Ref:' was matched, POS is the position
492where the match was found, and MODE is `major-mode' of the buffer in
493which the match was found.
494This function tries to find a case-sensitive match first, then a
495case-insensitive match is tried."
496 (let ((result (Info-find-in-tag-table-1 marker regexp nil)))
497 (when (null (car result))
498 (setq result (Info-find-in-tag-table-1 marker regexp t)))
499 result))
500
501(defun Info-find-node-in-buffer-1 (regexp case-fold)
502 "Find a node or anchor in the current buffer.
503REGEXP is a regular expression matching nodes or references. Its first
504group should match `Node:' or `Ref:'.
505CASE-FOLD t means search for a case-insensitive match.
506Value is the position at which a match was found, or nil if not found."
507 (let ((case-fold-search case-fold)
508 found)
509 (save-excursion
510 (when (Info-node-at-bob-matching regexp)
511 (setq found (point)))
512 (while (and (not found)
513 (search-forward "\n\^_" nil t))
514 (forward-line 1)
515 (let ((beg (point)))
516 (forward-line 1)
517 (when (re-search-backward regexp beg t)
518 (beginning-of-line)
519 (setq found (point)))))
520 found)))
521
522(defun Info-find-node-in-buffer (regexp)
523 "Find a node or anchor in the current buffer.
524REGEXP is a regular expression matching nodes or references. Its first
525group should match `Node:' or `Ref:'.
526Value is the position at which a match was found, or nil if not found.
527This function looks for a case-sensitive match first. If none is found,
528a case-insensitive match is tried."
529 (or (Info-find-node-in-buffer-1 regexp nil)
530 (Info-find-node-in-buffer-1 regexp t)))
531
4fceda3c 532(defun Info-find-node-2 (filename nodename &optional no-going-back)
9e5c2f50 533 (buffer-disable-undo (current-buffer))
a384cab3
JB
534 (or (eq major-mode 'Info-mode)
535 (Info-mode))
536 (widen)
537 (setq Info-current-node nil)
538 (unwind-protect
8bdf4b20
KH
539 (let ((case-fold-search t)
540 anchorpos)
37a3ff5b
RS
541 ;; Switch files if necessary
542 (or (null filename)
543 (equal Info-current-file filename)
544 (let ((buffer-read-only nil))
545 (setq Info-current-file nil
546 Info-current-subfile nil
547 Info-current-file-completions nil
548 buffer-file-name nil)
549 (erase-buffer)
550 (if (eq filename t)
551 (Info-insert-dir)
552 (info-insert-file-contents filename t)
553 (setq default-directory (file-name-directory filename)))
554 (set-buffer-modified-p nil)
555 ;; See whether file has a tag table. Record the location if yes.
556 (goto-char (point-max))
557 (forward-line -8)
558 ;; Use string-equal, not equal, to ignore text props.
559 (if (not (or (string-equal nodename "*")
560 (not
561 (search-forward "\^_\nEnd tag table\n" nil t))))
562 (let (pos)
563 ;; We have a tag table. Find its beginning.
564 ;; Is this an indirect file?
565 (search-backward "\nTag table:\n")
566 (setq pos (point))
567 (if (save-excursion
568 (forward-line 2)
569 (looking-at "(Indirect)\n"))
570 ;; It is indirect. Copy it to another buffer
571 ;; and record that the tag table is in that buffer.
572 (let ((buf (current-buffer))
573 (tagbuf
574 (or Info-tag-table-buffer
575 (generate-new-buffer " *info tag table*"))))
576 (setq Info-tag-table-buffer tagbuf)
577 (save-excursion
578 (set-buffer tagbuf)
9e5c2f50 579 (buffer-disable-undo (current-buffer))
37a3ff5b
RS
580 (setq case-fold-search t)
581 (erase-buffer)
582 (insert-buffer-substring buf))
583 (set-marker Info-tag-table-marker
584 (match-end 0) tagbuf))
585 (set-marker Info-tag-table-marker pos)))
586 (set-marker Info-tag-table-marker nil))
587 (setq Info-current-file
588 (if (eq filename t) "dir" filename))))
589 ;; Use string-equal, not equal, to ignore text props.
590 (if (string-equal nodename "*")
591 (progn (setq Info-current-node nodename)
592 (Info-set-mode-line))
593 ;; Possibilities:
594 ;;
595 ;; 1. Anchor found in tag table
596 ;; 2. Anchor *not* in tag table
597 ;;
598 ;; 3. Node found in tag table
599 ;; 4. Node *not* found in tag table, but found in file
600 ;; 5. Node *not* in tag table, and *not* in file
601 ;;
602 ;; *Or* the same, but in an indirect subfile.
603
604 ;; Search file for a suitable node.
8bdf4b20 605 (let ((guesspos (point-min))
357d11de 606 (regexp (concat "\\(Node:\\|Ref:\\) *\\("
dd31e4e8
GM
607 (if (stringp nodename)
608 (regexp-quote nodename)
609 "")
357d11de 610 "\\) *[,\t\n\177]"))
8bdf4b20 611 (nodepos nil))
37a3ff5b 612
82172606 613 (catch 'foo
357d11de 614
82172606 615 ;; First, search a tag table, if any
357d11de
GM
616 (when (marker-position Info-tag-table-marker)
617 (let* ((m Info-tag-table-marker)
618 (found (Info-find-in-tag-table m regexp)))
619
620 (when found
621 ;; FOUND is (ANCHOR POS MODE).
622 (setq guesspos (nth 1 found))
623
624 ;; If this is an indirect file, determine which
625 ;; file really holds this node and read it in.
626 (unless (eq (nth 2 found) 'Info-mode)
627 ;; Note that the current buffer must be the
628 ;; *info* buffer on entry to
629 ;; Info-read-subfile. Thus the hackery above.
630 (setq guesspos (Info-read-subfile guesspos)))
82172606
DL
631
632 ;; Handle anchor
357d11de
GM
633 (when (nth 0 found)
634 (goto-char (setq anchorpos guesspos))
635 (throw 'foo t)))))
82172606
DL
636
637 ;; Else we may have a node, which we search for:
638 (goto-char (max (point-min)
639 (- (byte-to-position guesspos) 1000)))
357d11de
GM
640
641 ;; Now search from our advised position (or from beg of
642 ;; buffer) to find the actual node. First, check
643 ;; whether the node is right where we are, in case the
644 ;; buffer begins with a node.
645 (let ((pos (Info-find-node-in-buffer regexp)))
646 (when pos
647 (goto-char pos)
648 (throw 'foo t))
649 (error "No such anchor in tag table or node in tag table or file: %s"
650 nodename)))
82172606
DL
651
652 (Info-select-node)
653 (goto-char (or anchorpos (point-min))))))
a384cab3
JB
654 ;; If we did not finish finding the specified node,
655 ;; go back to the previous one.
4db579ab 656 (or Info-current-node no-going-back (null Info-history)
37a3ff5b
RS
657 (let ((hist (car Info-history)))
658 (setq Info-history (cdr Info-history))
659 (Info-find-node (nth 0 hist) (nth 1 hist) t)
660 (goto-char (nth 2 hist))))))
a384cab3 661
44c327f9
JB
662;; Cache the contents of the (virtual) dir file, once we have merged
663;; it for the first time, so we can save time subsequently.
7ea13762
RS
664(defvar Info-dir-contents nil)
665
44c327f9
JB
666;; Cache for the directory we decided to use for the default-directory
667;; of the merged dir text.
668(defvar Info-dir-contents-directory nil)
669
c142ab2d
RS
670;; Record the file attributes of all the files from which we
671;; constructed Info-dir-contents.
672(defvar Info-dir-file-attributes nil)
673
4fba3b2c
RS
674(defvar Info-dir-file-name nil)
675
7ea13762 676;; Construct the Info directory node by merging the files named `dir'
44c327f9
JB
677;; from various directories. Set the *info* buffer's
678;; default-directory to the first directory we actually get any text
679;; from.
7ea13762 680(defun Info-insert-dir ()
c142ab2d
RS
681 (if (and Info-dir-contents Info-dir-file-attributes
682 ;; Verify that none of the files we used has changed
683 ;; since we used it.
684 (eval (cons 'and
b461e32d
SM
685 (mapcar (lambda (elt)
686 (let ((curr (file-attributes
687 ;; Handle symlinks
688 (file-truename (car elt)))))
689
690 ;; Don't compare the access time.
691 (if curr (setcar (nthcdr 4 curr) 0))
692 (setcar (nthcdr 4 (cdr elt)) 0)
693 (equal (cdr elt) curr)))
c142ab2d 694 Info-dir-file-attributes))))
4fba3b2c
RS
695 (progn
696 (insert Info-dir-contents)
697 (goto-char (point-min)))
dd31e4e8
GM
698 (let ((dirs (if Info-additional-directory-list
699 (append Info-directory-list
700 Info-additional-directory-list)
701 Info-directory-list))
1bcedb3b
RS
702 ;; Bind this in case the user sets it to nil.
703 (case-fold-search t)
4fba3b2c
RS
704 ;; This is set non-nil if we find a problem in some input files.
705 problems
f4008b6e 706 buffers buffer others nodes dirs-done)
44c327f9 707
825d6f08
RS
708 (setq Info-dir-file-attributes nil)
709
44c327f9 710 ;; Search the directory list for the directory file.
7ea13762 711 (while dirs
8d1abb42
RS
712 (let ((truename (file-truename (expand-file-name (car dirs)))))
713 (or (member truename dirs-done)
714 (member (directory-file-name truename) dirs-done)
715 ;; Try several variants of specified name.
716 ;; Try upcasing, appending `.info', or both.
825d6f08
RS
717 (let* (file
718 (attrs
719 (or
720 (progn (setq file (expand-file-name "dir" truename))
721 (file-attributes file))
722 (progn (setq file (expand-file-name "DIR" truename))
723 (file-attributes file))
724 (progn (setq file (expand-file-name "dir.info" truename))
725 (file-attributes file))
726 (progn (setq file (expand-file-name "DIR.INFO" truename))
727 (file-attributes file)))))
8d1abb42
RS
728 (setq dirs-done
729 (cons truename
730 (cons (directory-file-name truename)
731 dirs-done)))
825d6f08
RS
732 (if attrs
733 (save-excursion
734 (or buffers
735 (message "Composing main Info directory..."))
2d41cf59 736 (set-buffer (generate-new-buffer " info dir"))
9d499629
RS
737 (condition-case nil
738 (progn
739 (insert-file-contents file)
4fba3b2c
RS
740 (make-local-variable 'Info-dir-file-name)
741 (setq Info-dir-file-name file)
9d499629
RS
742 (setq buffers (cons (current-buffer) buffers)
743 Info-dir-file-attributes
744 (cons (cons file attrs)
745 Info-dir-file-attributes)))
746 (error (kill-buffer (current-buffer))))))))
3296453b
KH
747 (or (cdr dirs) (setq Info-dir-contents-directory
748 (file-name-as-directory (car dirs))))
825d6f08 749 (setq dirs (cdr dirs))))
399c88ad 750
4db579ab 751 (or buffers
81e14cb2 752 (error "Can't find the Info directory node"))
44c327f9 753 ;; Distinguish the dir file that comes with Emacs from all the
f4008b6e 754 ;; others. Yes, that is really what this is supposed to do.
f601cd3e
DL
755 ;; The definition of `Info-directory-list' puts it first on that
756 ;; list and so last in `buffers' at this point.
757 (setq buffer (car (last buffers))
758 others (delq buffer buffers))
44c327f9 759
debcea0c
KH
760 ;; Insert the entire original dir file as a start; note that we've
761 ;; already saved its default directory to use as the default
762 ;; directory for the whole concatenation.
7ea13762 763 (insert-buffer buffer)
44c327f9 764
7ea13762
RS
765 ;; Look at each of the other buffers one by one.
766 (while others
4fba3b2c 767 (let ((other (car others))
760d5cb3
GM
768 ;; Bind this in case the user sets it to nil.
769 (case-fold-search t)
4fba3b2c 770 this-buffer-nodes)
7ea13762
RS
771 ;; In each, find all the menus.
772 (save-excursion
773 (set-buffer other)
774 (goto-char (point-min))
775 ;; Find each menu, and add an elt to NODES for it.
776 (while (re-search-forward "^\\* Menu:" nil t)
777 (let (beg nodename end)
778 (forward-line 1)
779 (setq beg (point))
ba42ce14
EZ
780 (or (search-backward "\n\^_" nil 'move)
781 (looking-at "\^_")
782 (signal 'search-failed (list "\n\^_")))
7ea13762
RS
783 (search-forward "Node: ")
784 (setq nodename (Info-following-node-name))
3a6ade8a 785 (search-forward "\n\^_" nil 'move)
7ea13762
RS
786 (beginning-of-line)
787 (setq end (point))
4fba3b2c
RS
788 (setq this-buffer-nodes
789 (cons (list nodename other beg end)
790 this-buffer-nodes))))
791 (if (assoc-ignore-case "top" this-buffer-nodes)
792 (setq nodes (nconc this-buffer-nodes nodes))
793 (setq problems t)
794 (message "No `top' node in %s" Info-dir-file-name))))
7ea13762 795 (setq others (cdr others)))
fdf4b680
DL
796 ;; Add to the main menu a menu item for each other node.
797 (let ((case-fold-search t)
760d5cb3 798 (re-search-forward "^\\* Menu:")))
7ea13762
RS
799 (forward-line 1)
800 (let ((menu-items '("top"))
801 (nodes nodes)
802 (case-fold-search t)
3a6ade8a 803 (end (save-excursion (search-forward "\^_" nil t) (point))))
7ea13762
RS
804 (while nodes
805 (let ((nodename (car (car nodes))))
c3a29d70
RS
806 (save-excursion
807 (or (member (downcase nodename) menu-items)
b37daea4 808 (re-search-forward (concat "^\\* +"
c3a29d70
RS
809 (regexp-quote nodename)
810 "::")
811 end t)
812 (progn
813 (insert "* " nodename "::" "\n")
814 (setq menu-items (cons nodename menu-items))))))
7ea13762
RS
815 (setq nodes (cdr nodes))))
816 ;; Now take each node of each of the other buffers
817 ;; and merge it into the main buffer.
818 (while nodes
760d5cb3
GM
819 (let ((case-fold-search t)
820 (nodename (car (car nodes))))
7ea13762
RS
821 (goto-char (point-min))
822 ;; Find the like-named node in the main buffer.
ba42ce14 823 (if (re-search-forward (concat "^\^_.*\n.*Node: "
7ea13762
RS
824 (regexp-quote nodename)
825 "[,\n\t]")
826 nil t)
827 (progn
3a6ade8a 828 (search-forward "\n\^_" nil 'move)
25869acf
RS
829 (beginning-of-line)
830 (insert "\n"))
7ea13762
RS
831 ;; If none exists, add one.
832 (goto-char (point-max))
dfbf6104 833 (insert "\^_\nFile: dir\tNode: " nodename "\n\n* Menu:\n\n"))
7ea13762
RS
834 ;; Merge the text from the other buffer's menu
835 ;; into the menu in the like-named node in the main buffer.
25869acf 836 (apply 'insert-buffer-substring (cdr (car nodes))))
7ea13762
RS
837 (setq nodes (cdr nodes)))
838 ;; Kill all the buffers we just made.
839 (while buffers
840 (kill-buffer (car buffers))
825d6f08 841 (setq buffers (cdr buffers)))
4fba3b2c
RS
842 (goto-char (point-min))
843 (if problems
844 (message "Composing main Info directory...problems encountered, see `*Messages*'")
845 (message "Composing main Info directory...done")))
44c327f9
JB
846 (setq Info-dir-contents (buffer-string)))
847 (setq default-directory Info-dir-contents-directory))
7ea13762 848
c5fe2ff1
RS
849;; Note that on entry to this function the current-buffer must be the
850;; *info* buffer; not the info tags buffer.
a384cab3 851(defun Info-read-subfile (nodepos)
a361deba
RS
852 ;; NODEPOS is either a position (in the Info file as a whole,
853 ;; not relative to a subfile) or the name of a subfile.
a384cab3
JB
854 (let (lastfilepos
855 lastfilename)
a361deba
RS
856 (if (numberp nodepos)
857 (save-excursion
858 (set-buffer (marker-buffer Info-tag-table-marker))
859 (goto-char (point-min))
ba42ce14
EZ
860 (or (looking-at "\^_")
861 (search-forward "\n\^_"))
a361deba
RS
862 (forward-line 2)
863 (catch 'foo
864 (while (not (looking-at "\^_"))
865 (if (not (eolp))
866 (let ((beg (point))
867 thisfilepos thisfilename)
868 (search-forward ": ")
869 (setq thisfilename (buffer-substring beg (- (point) 2)))
870 (setq thisfilepos (read (current-buffer)))
871 ;; read in version 19 stops at the end of number.
872 ;; Advance to the next line.
873 (forward-line 1)
874 (if (> thisfilepos nodepos)
875 (throw 'foo t))
876 (setq lastfilename thisfilename)
877 (setq lastfilepos thisfilepos))
878 (forward-line 1)))))
879 (setq lastfilename nodepos)
880 (setq lastfilepos 0))
c5fe2ff1
RS
881 ;; Assume previous buffer is in Info-mode.
882 ;; (set-buffer (get-buffer "*info*"))
a384cab3
JB
883 (or (equal Info-current-subfile lastfilename)
884 (let ((buffer-read-only nil))
885 (setq buffer-file-name nil)
886 (widen)
887 (erase-buffer)
1143a6b0 888 (info-insert-file-contents lastfilename)
a384cab3
JB
889 (set-buffer-modified-p nil)
890 (setq Info-current-subfile lastfilename)))
891 (goto-char (point-min))
ba42ce14
EZ
892 (if (looking-at "\^_")
893 (forward-char 1)
894 (search-forward "\n\^_"))
a361deba
RS
895 (if (numberp nodepos)
896 (+ (- nodepos lastfilepos) (point)))))
a384cab3 897
50ac70af
MB
898(defvar Info-header-line nil
899 "If the info node header is hidden, the text of the header.")
900
a384cab3 901(defun Info-select-node ()
fdf4b680
DL
902"Select the info node that point is in.
903Bind this in case the user sets it to nil."
1bcedb3b
RS
904 (let ((case-fold-search t))
905 (save-excursion
760d5cb3
GM
906 ;; Find beginning of node.
907 (if (search-backward "\n\^_" nil 'move)
908 (forward-line 2)
909 (if (looking-at "\^_")
910 (forward-line 1)
911 (signal 'search-failed (list "\n\^_"))))
912 ;; Get nodename spelled as it is in the node.
913 (re-search-forward "Node:[ \t]*")
914 (setq Info-current-node
915 (buffer-substring-no-properties (point)
916 (progn
917 (skip-chars-forward "^,\t\n")
918 (point))))
919 (Info-set-mode-line)
920 ;; Find the end of it, and narrow.
921 (beginning-of-line)
922 (let (active-expression)
50ac70af 923 ;; Narrow to the node contents
760d5cb3
GM
924 (narrow-to-region (point)
925 (if (re-search-forward "\n[\^_\f]" nil t)
926 (prog1
927 (1- (point))
928 (if (looking-at "[\n\^_\f]*execute: ")
929 (progn
930 (goto-char (match-end 0))
931 (setq active-expression
932 (read (current-buffer))))))
933 (point-max)))
934 (if Info-enable-active-nodes (eval active-expression))
935 (if Info-fontify (Info-fontify-node))
50ac70af
MB
936 (if Info-use-header-line
937 (Info-setup-header-line)
938 (setq Info-header-line nil))
760d5cb3 939 (run-hooks 'Info-selection-hook)))))
a384cab3
JB
940
941(defun Info-set-mode-line ()
942 (setq mode-line-buffer-identification
943 (concat
e27c25ae
GM
944 " *Info* ("
945 (file-name-nondirectory (if (stringp Info-current-file)
946 Info-current-file
947 (or buffer-file-name "")))
948 ") "
a384cab3
JB
949 (or Info-current-node ""))))
950\f
50ac70af
MB
951;; Skip the node header and make it into a header-line. This function
952;; should be called when the node is already narrowed.
953(defun Info-setup-header-line ()
954 (goto-char (point-min))
955 (forward-line 1)
956 (set (make-local-variable 'Info-header-line)
957 (buffer-substring (point-min) (1- (point))))
958 (setq header-line-format 'Info-header-line)
959 (narrow-to-region (point) (point-max)))
960\f
a384cab3
JB
961;; Go to an info node specified with a filename-and-nodename string
962;; of the sort that is found in pointers in nodes.
963
4fceda3c
SM
964(defun Info-goto-node (nodename &optional fork)
965 "Go to info node named NAME. Give just NODENAME or (FILENAME)NODENAME.
966If FORK is non-nil, show the node in a new info buffer.
967If FORK is a string, it is the name to use for the new buffer."
968 (interactive (list (Info-read-node-name "Goto node: ") current-prefix-arg))
d0e41cba 969 (info-initialize)
4fceda3c 970 (if fork
760d5cb3
GM
971 (set-buffer
972 (clone-buffer (concat "*info-" (if (stringp fork) fork nodename) "*") t)))
a384cab3
JB
973 (let (filename)
974 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
975 nodename)
976 (setq filename (if (= (match-beginning 1) (match-end 1))
977 ""
978 (substring nodename (match-beginning 2) (match-end 2)))
979 nodename (substring nodename (match-beginning 3) (match-end 3)))
980 (let ((trim (string-match "\\s *\\'" filename)))
981 (if trim (setq filename (substring filename 0 trim))))
982 (let ((trim (string-match "\\s *\\'" nodename)))
983 (if trim (setq nodename (substring nodename 0 trim))))
e579232c 984 (if transient-mark-mode (deactivate-mark))
a384cab3
JB
985 (Info-find-node (if (equal filename "") nil filename)
986 (if (equal nodename "") "Top" nodename))))
552775bd 987
ddf89211
RS
988(defvar Info-read-node-completion-table)
989
03524be6 990;; This function is used as the "completion table" while reading a node name.
ddf89211 991;; It does completion using the alist in Info-read-node-completion-table
03524be6
RS
992;; unless STRING starts with an open-paren.
993(defun Info-read-node-name-1 (string predicate code)
994 (let ((no-completion (and (> (length string) 0) (eq (aref string 0) ?\())))
995 (cond ((eq code nil)
996 (if no-completion
997 string
ddf89211 998 (try-completion string Info-read-node-completion-table predicate)))
03524be6
RS
999 ((eq code t)
1000 (if no-completion
1001 nil
ddf89211 1002 (all-completions string Info-read-node-completion-table predicate)))
03524be6
RS
1003 ((eq code 'lambda)
1004 (if no-completion
1005 t
ddf89211 1006 (assoc string Info-read-node-completion-table))))))
03524be6 1007
552775bd
RS
1008(defun Info-read-node-name (prompt &optional default)
1009 (let* ((completion-ignore-case t)
ddf89211 1010 (Info-read-node-completion-table (Info-build-node-completions))
b6d61ffa 1011 (nodename (completing-read prompt 'Info-read-node-name-1 nil t)))
552775bd
RS
1012 (if (equal nodename "")
1013 (or default
1014 (Info-read-node-name prompt))
1015 nodename)))
1016
1017(defun Info-build-node-completions ()
1018 (or Info-current-file-completions
1bcedb3b
RS
1019 (let ((compl nil)
1020 ;; Bind this in case the user sets it to nil.
11638562
EZ
1021 (case-fold-search t)
1022 (node-regexp "Node: *\\([^,\n]*\\) *[,\n\t]"))
552775bd
RS
1023 (save-excursion
1024 (save-restriction
1025 (if (marker-buffer Info-tag-table-marker)
c5fe2ff1
RS
1026 (let ((marker Info-tag-table-marker))
1027 (set-buffer (marker-buffer marker))
cedb118c 1028 (widen)
c5fe2ff1 1029 (goto-char marker)
fdf4b680 1030 (while (re-search-forward "\n\\(Node\\|Ref\\): \\(.*\\)\177" nil t)
552775bd 1031 (setq compl
fdf4b680 1032 (cons (list (match-string-no-properties 2))
552775bd
RS
1033 compl))))
1034 (widen)
1035 (goto-char (point-min))
11638562
EZ
1036 ;; If the buffer begins with a node header, process that first.
1037 (if (Info-node-at-bob-matching node-regexp)
110d4e80 1038 (setq compl (list (match-string-no-properties 1))))
11638562 1039 ;; Now for the rest of the nodes.
552775bd
RS
1040 (while (search-forward "\n\^_" nil t)
1041 (forward-line 1)
1042 (let ((beg (point)))
1043 (forward-line 1)
11638562 1044 (if (re-search-backward node-regexp beg t)
399c88ad 1045 (setq compl
110d4e80 1046 (cons (list (match-string-no-properties 1))
552775bd 1047 compl))))))))
87d2b5a2 1048 (setq compl (cons '("*") compl))
552775bd 1049 (setq Info-current-file-completions compl))))
a384cab3 1050\f
aea2a8da
JB
1051(defun Info-restore-point (hl)
1052 "If this node has been visited, restore the point value when we left."
cedb118c
RS
1053 (while hl
1054 (if (and (equal (nth 0 (car hl)) Info-current-file)
e90d1271
RS
1055 ;; Use string-equal, not equal, to ignore text props.
1056 (string-equal (nth 1 (car hl)) Info-current-node))
cedb118c 1057 (progn
d96504df
KH
1058 (goto-char (nth 2 (car hl)))
1059 (setq hl nil)) ;terminate the while at next iter
cedb118c 1060 (setq hl (cdr hl)))))
aea2a8da 1061\f
2c80a618
GM
1062(defvar Info-search-history nil
1063 "The history list for `Info-search'.")
a384cab3
JB
1064
1065(defun Info-search (regexp)
1066 "Search for REGEXP, starting from point, and select node it's found in."
2c80a618
GM
1067 (interactive (list (read-string "Regexp search: "
1068 nil 'Info-search-history)))
1069 (when transient-mark-mode
1070 (deactivate-mark))
1071 (when (equal regexp "")
1072 (setq regexp (car Info-search-history)))
c47b5bbe
DL
1073 (when regexp
1074 (let ((found ()) current
1075 (onode Info-current-node)
1076 (ofile Info-current-file)
1077 (opoint (point))
1078 (ostart (window-start))
1079 (osubfile Info-current-subfile))
1080 (save-excursion
1081 (save-restriction
1082 (widen)
1083 (if (null Info-current-subfile)
a384cab3 1084 (progn (re-search-forward regexp) (setq found (point)))
c47b5bbe
DL
1085 (condition-case err
1086 (progn (re-search-forward regexp) (setq found (point)))
1087 (search-failed nil)))))
760d5cb3 1088 (if (not found) ;can only happen in subfile case -- else would have erred
c47b5bbe
DL
1089 (unwind-protect
1090 (let ((list ()))
1091 (save-excursion
1092 (set-buffer (marker-buffer Info-tag-table-marker))
c5fe2ff1 1093 (goto-char (point-min))
c47b5bbe
DL
1094 (search-forward "\n\^_\nIndirect:")
1095 (save-restriction
1096 (narrow-to-region (point)
1097 (progn (search-forward "\n\^_")
1098 (1- (point))))
1099 (goto-char (point-min))
1100 (search-forward (concat "\n" osubfile ": "))
1101 (beginning-of-line)
1102 (while (not (eobp))
1103 (re-search-forward "\\(^.*\\): [0-9]+$")
1104 (goto-char (+ (match-end 1) 2))
1105 (setq list (cons (cons (read (current-buffer))
110d4e80 1106 (match-string-no-properties 1))
c47b5bbe
DL
1107 list))
1108 (goto-char (1+ (match-end 0))))
1109 (setq list (nreverse list)
1110 current (car (car list))
1111 list (cdr list))))
1112 (while list
1113 (message "Searching subfile %s..." (cdr (car list)))
1114 (Info-read-subfile (car (car list)))
1115 (setq list (cdr list))
1116;;; (goto-char (point-min))
1117 (if (re-search-forward regexp nil t)
1118 (setq found (point) list ())))
1119 (if found
1120 (message "")
1121 (signal 'search-failed (list regexp))))
1122 (if (not found)
1123 (progn (Info-read-subfile osubfile)
1124 (goto-char opoint)
1125 (Info-select-node)
1126 (set-window-start (selected-window) ostart)))))
760d5cb3
GM
1127 (widen)
1128 (goto-char found)
1129 (Info-select-node)
1130 ;; Use string-equal, not equal, to ignore text props.
1131 (or (and (string-equal onode Info-current-node)
1132 (equal ofile Info-current-file))
1133 (setq Info-history (cons (list ofile onode opoint)
1134 Info-history))))))
a384cab3 1135\f
a384cab3 1136(defun Info-extract-pointer (name &optional errorname)
fdf4b680
DL
1137 "Extract the value of the node-pointer named NAME.
1138If there is none, use ERRORNAME in the error message;
1139if ERRORNAME is nil, just return nil.
1140Bind this in case the user sets it to nil."
1bcedb3b
RS
1141 (let ((case-fold-search t))
1142 (save-excursion
50ac70af
MB
1143 (save-restriction
1144 (goto-char (point-min))
1145 (when Info-header-line
1146 ;; expose the header line in the buffer
1147 (widen)
1148 (forward-line -1))
1149 (let ((bound (point)))
1150 (forward-line 1)
1151 (cond ((re-search-backward (concat name ":") nil bound)
1bcedb3b
RS
1152 (goto-char (match-end 0))
1153 (Info-following-node-name))
50ac70af
MB
1154 ((not (eq errorname t))
1155 (error "Node has no %s"
1156 (capitalize (or errorname name))))))))))
a384cab3
JB
1157
1158(defun Info-following-node-name (&optional allowedchars)
fdf4b680
DL
1159 "Return the node name in the buffer following point.
1160ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
1161saying which chars may appear in the node name."
a384cab3 1162 (skip-chars-forward " \t")
70d78eb6 1163 (buffer-substring-no-properties
a384cab3
JB
1164 (point)
1165 (progn
1166 (while (looking-at (concat "[" (or allowedchars "^,\t\n") "]"))
1167 (skip-chars-forward (concat (or allowedchars "^,\t\n") "("))
1168 (if (looking-at "(")
1169 (skip-chars-forward "^)")))
1170 (skip-chars-backward " ")
1171 (point))))
1172
1173(defun Info-next ()
1174 "Go to the next node of this node."
1175 (interactive)
1176 (Info-goto-node (Info-extract-pointer "next")))
1177
1178(defun Info-prev ()
1179 "Go to the previous node of this node."
1180 (interactive)
1181 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous")))
1182
5dab2fb4
RS
1183(defun Info-up (&optional same-file)
1184 "Go to the superior node of this node.
1185If SAME-FILE is non-nil, do not move to a different Info file."
a384cab3 1186 (interactive)
5dab2fb4 1187 (let ((node (Info-extract-pointer "up")))
4fceda3c 1188 (and (or same-file (not (stringp Info-current-file)))
5dab2fb4
RS
1189 (string-match "^(" node)
1190 (error "Up node is in another Info file"))
1191 (Info-goto-node node))
aea2a8da 1192 (Info-restore-point Info-history))
a384cab3
JB
1193
1194(defun Info-last ()
1195 "Go back to the last node visited."
1196 (interactive)
1197 (or Info-history
1198 (error "This is the first Info node you looked at"))
1199 (let (filename nodename opoint)
1200 (setq filename (car (car Info-history)))
1201 (setq nodename (car (cdr (car Info-history))))
1202 (setq opoint (car (cdr (cdr (car Info-history)))))
1203 (setq Info-history (cdr Info-history))
1204 (Info-find-node filename nodename)
1205 (setq Info-history (cdr Info-history))
1206 (goto-char opoint)))
1207
48e5b471 1208;;;###autoload
a384cab3
JB
1209(defun Info-directory ()
1210 "Go to the Info directory node."
1211 (interactive)
1212 (Info-find-node "dir" "top"))
1213\f
1214(defun Info-follow-reference (footnotename)
fdf4b680
DL
1215 "Follow cross reference named FOOTNOTENAME to the node it refers to.
1216FOOTNOTENAME may be an abbreviation of the reference name."
a384cab3
JB
1217 (interactive
1218 (let ((completion-ignore-case t)
1bcedb3b 1219 (case-fold-search t)
67bc89ab 1220 completions default alt-default (start-point (point)) str i bol eol)
a384cab3 1221 (save-excursion
67bc89ab
RS
1222 ;; Store end and beginning of line.
1223 (end-of-line)
1224 (setq eol (point))
1225 (beginning-of-line)
1226 (setq bol (point))
1227
a384cab3
JB
1228 (goto-char (point-min))
1229 (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t)
110d4e80 1230 (setq str (buffer-substring-no-properties
a384cab3
JB
1231 (match-beginning 1)
1232 (1- (point))))
1233 ;; See if this one should be the default.
1234 (and (null default)
1f179e27 1235 (<= (match-beginning 0) start-point)
a384cab3
JB
1236 (<= start-point (point))
1237 (setq default t))
67bc89ab
RS
1238 ;; See if this one should be the alternate default.
1239 (and (null alt-default)
1240 (and (<= bol (match-beginning 0))
1241 (<= (point) eol))
1242 (setq alt-default t))
a384cab3
JB
1243 (setq i 0)
1244 (while (setq i (string-match "[ \n\t]+" str i))
1245 (setq str (concat (substring str 0 i) " "
1246 (substring str (match-end 0))))
1247 (setq i (1+ i)))
1248 ;; Record as a completion and perhaps as default.
1249 (if (eq default t) (setq default str))
67bc89ab 1250 (if (eq alt-default t) (setq alt-default str))
ec6d29af
KH
1251 ;; Don't add this string if it's a duplicate.
1252 ;; We use a loop instead of "(assoc str completions)" because
1253 ;; we want to do a case-insensitive compare.
1254 (let ((tail completions)
1255 (tem (downcase str)))
1256 (while (and tail
1257 (not (string-equal tem (downcase (car (car tail))))))
1258 (setq tail (cdr tail)))
1259 (or tail
1260 (setq completions
1261 (cons (cons str nil)
1262 completions))))))
67bc89ab
RS
1263 ;; If no good default was found, try an alternate.
1264 (or default
1265 (setq default alt-default))
1266 ;; If only one cross-reference found, then make it default.
1267 (if (eq (length completions) 1)
1268 (setq default (car (car completions))))
a384cab3 1269 (if completions
b0ebdfe5
RS
1270 (let ((input (completing-read (if default
1271 (concat "Follow reference named: ("
1272 default ") ")
1273 "Follow reference named: ")
1274 completions nil t)))
1275 (list (if (equal input "")
1276 default input)))
a384cab3 1277 (error "No cross-references in this node"))))
ebf8f7e1
RS
1278
1279 (unless footnotename
1280 (error "No reference was specified"))
1281
1bcedb3b
RS
1282 (let (target beg i (str (concat "\\*note " (regexp-quote footnotename)))
1283 (case-fold-search t))
a384cab3
JB
1284 (while (setq i (string-match " " str i))
1285 (setq str (concat (substring str 0 i) "[ \t\n]+" (substring str (1+ i))))
1286 (setq i (+ i 6)))
1287 (save-excursion
1288 (goto-char (point-min))
1289 (or (re-search-forward str nil t)
1290 (error "No cross-reference named %s" footnotename))
1291 (goto-char (+ (match-beginning 0) 5))
1292 (setq target
1293 (Info-extract-menu-node-name "Bad format cross reference" t)))
1294 (while (setq i (string-match "[ \t\n]+" target i))
1295 (setq target (concat (substring target 0 i) " "
1296 (substring target (match-end 0))))
1297 (setq i (+ i 1)))
1298 (Info-goto-node target)))
1299
1300(defun Info-extract-menu-node-name (&optional errmessage multi-line)
1301 (skip-chars-forward " \t\n")
1302 (let ((beg (point))
1303 str i)
1304 (skip-chars-forward "^:")
1305 (forward-char 1)
1306 (setq str
1307 (if (looking-at ":")
70d78eb6 1308 (buffer-substring-no-properties beg (1- (point)))
a384cab3
JB
1309 (skip-chars-forward " \t\n")
1310 (Info-following-node-name (if multi-line "^.,\t" "^.,\t\n"))))
1311 (while (setq i (string-match "\n" str i))
1312 (aset str i ?\ ))
2e52ff59
RS
1313 ;; Collapse multiple spaces.
1314 (while (string-match " +" str)
1315 (setq str (replace-match " " t t str)))
a384cab3
JB
1316 str))
1317
e8adde3f 1318;; No one calls this.
9e5c2f50
RS
1319;;(defun Info-menu-item-sequence (list)
1320;; (while list
e8adde3f 1321;; (Info-menu (car list))
9e5c2f50 1322;; (setq list (cdr list))))
a384cab3 1323
6356e646
RS
1324(defvar Info-complete-menu-buffer)
1325
e8adde3f 1326(defun Info-complete-menu-item (string predicate action)
760d5cb3
GM
1327 (let ((completion-ignore-case t)
1328 (case-fold-search t))
e8adde3f
RS
1329 (cond ((eq action nil)
1330 (let (completions
b37daea4 1331 (pattern (concat "\n\\* +\\("
e8adde3f
RS
1332 (regexp-quote string)
1333 "[^:\t\n]*\\):")))
1334 (save-excursion
1335 (set-buffer Info-complete-menu-buffer)
1336 (goto-char (point-min))
763da090 1337 (search-forward "\n* Menu:")
e8adde3f 1338 (while (re-search-forward pattern nil t)
110d4e80
DL
1339 (setq completions
1340 (cons (cons (match-string-no-properties 1)
1341 (match-beginning 1))
1342 completions))))
e8adde3f
RS
1343 (try-completion string completions predicate)))
1344 ((eq action t)
1345 (let (completions
b37daea4 1346 (pattern (concat "\n\\* +\\("
e8adde3f
RS
1347 (regexp-quote string)
1348 "[^:\t\n]*\\):")))
1349 (save-excursion
1350 (set-buffer Info-complete-menu-buffer)
1351 (goto-char (point-min))
763da090 1352 (search-forward "\n* Menu:")
e8adde3f 1353 (while (re-search-forward pattern nil t)
110d4e80
DL
1354 (setq completions (cons (cons
1355 (match-string-no-properties 1)
1356 (match-beginning 1))
e8adde3f
RS
1357 completions))))
1358 (all-completions string completions predicate)))
1359 (t
1360 (save-excursion
1361 (set-buffer Info-complete-menu-buffer)
1362 (goto-char (point-min))
763da090 1363 (search-forward "\n* Menu:")
b37daea4 1364 (re-search-forward (concat "\n\\* +"
e8adde3f
RS
1365 (regexp-quote string)
1366 ":")
1367 nil t))))))
1368
1369
4fceda3c 1370(defun Info-menu (menu-item &optional fork)
a384cab3
JB
1371 "Go to node for menu item named (or abbreviated) NAME.
1372Completion is allowed, and the menu item point is on is the default."
1373 (interactive
1374 (let ((completions '())
1375 ;; If point is within a menu item, use that item as the default
1376 (default nil)
1377 (p (point))
211d6309 1378 beg
760d5cb3
GM
1379 (last nil)
1380 (case-fold-search t))
a384cab3
JB
1381 (save-excursion
1382 (goto-char (point-min))
1383 (if (not (search-forward "\n* menu:" nil t))
1384 (error "No menu in this node"))
e8adde3f
RS
1385 (setq beg (point))
1386 (and (< (point) p)
1387 (save-excursion
1388 (goto-char p)
1389 (end-of-line)
4fc14e5a 1390 (if (re-search-backward "\n\\* +\\([^:\t\n]*\\):" beg t)
110d4e80 1391 (setq default (match-string-no-properties 1))))))
a384cab3
JB
1392 (let ((item nil))
1393 (while (null item)
e8adde3f
RS
1394 (setq item (let ((completion-ignore-case t)
1395 (Info-complete-menu-buffer (current-buffer)))
a384cab3
JB
1396 (completing-read (if default
1397 (format "Menu item (default %s): "
1398 default)
760d5cb3 1399 "Menu item: ")
e8adde3f 1400 'Info-complete-menu-item nil t)))
aea2a8da
JB
1401 ;; we rely on the fact that completing-read accepts an input
1402 ;; of "" even when the require-match argument is true and ""
1403 ;; is not a valid possibility
a384cab3
JB
1404 (if (string= item "")
1405 (if default
1406 (setq item default)
760d5cb3
GM
1407 ;; ask again
1408 (setq item nil))))
4fceda3c 1409 (list item current-prefix-arg))))
a384cab3
JB
1410 ;; there is a problem here in that if several menu items have the same
1411 ;; name you can only go to the node of the first with this command.
4fceda3c 1412 (Info-goto-node (Info-extract-menu-item menu-item) (if fork menu-item)))
399c88ad 1413
a384cab3
JB
1414(defun Info-extract-menu-item (menu-item)
1415 (setq menu-item (regexp-quote menu-item))
1bcedb3b
RS
1416 (let ((case-fold-search t))
1417 (save-excursion
760d5cb3
GM
1418 (let ((case-fold-search t))
1419 (goto-char (point-min))
1420 (or (search-forward "\n* menu:" nil t)
1421 (error "No menu in this node"))
1422 (or (re-search-forward (concat "\n\\* +" menu-item ":") nil t)
1423 (re-search-forward (concat "\n\\* +" menu-item) nil t)
1424 (error "No such item in menu"))
1425 (beginning-of-line)
1426 (forward-char 2)
1427 (Info-extract-menu-node-name)))))
a384cab3
JB
1428
1429;; If COUNT is nil, use the last item in the menu.
1430(defun Info-extract-menu-counting (count)
1bcedb3b
RS
1431 (let ((case-fold-search t))
1432 (save-excursion
760d5cb3
GM
1433 (let ((case-fold-search t))
1434 (goto-char (point-min))
1435 (or (search-forward "\n* menu:" nil t)
1436 (error "No menu in this node"))
1437 (if count
1438 (or (search-forward "\n* " nil t count)
1439 (error "Too few items in menu"))
1440 (while (search-forward "\n* " nil t)
1441 nil))
1442 (Info-extract-menu-node-name)))))
a384cab3 1443
e38e7367
RM
1444(defun Info-nth-menu-item ()
1445 "Go to the node of the Nth menu item.
1446N is the digit argument used to invoke this command."
a384cab3 1447 (interactive)
e38e7367
RM
1448 (Info-goto-node
1449 (Info-extract-menu-counting
1450 (- (aref (this-command-keys) (1- (length (this-command-keys)))) ?0))))
a384cab3
JB
1451
1452(defun Info-top-node ()
1453 "Go to the Top node of this file."
1454 (interactive)
1455 (Info-goto-node "Top"))
1456
1457(defun Info-final-node ()
1458 "Go to the final node in this file."
1459 (interactive)
1460 (Info-goto-node "Top")
760d5cb3
GM
1461 (let ((Info-history nil)
1462 (case-fold-search t))
a384cab3
JB
1463 ;; Go to the last node in the menu of Top.
1464 (Info-goto-node (Info-extract-menu-counting nil))
1465 ;; If the last node in the menu is not last in pointer structure,
399c88ad 1466 ;; move forward until we can't go any farther.
a384cab3
JB
1467 (while (Info-forward-node t t) nil)
1468 ;; Then keep moving down to last subnode, unless we reach an index.
1469 (while (and (not (string-match "\\<index\\>" Info-current-node))
1470 (save-excursion (search-forward "\n* Menu:" nil t)))
1471 (Info-goto-node (Info-extract-menu-counting nil)))))
1472
1473(defun Info-forward-node (&optional not-down no-error)
1474 "Go forward one node, considering all nodes as forming one sequence."
1475 (interactive)
1476 (goto-char (point-min))
1477 (forward-line 1)
760d5cb3
GM
1478 (let ((case-fold-search t))
1479 ;; three possibilities, in order of priority:
1480 ;; 1. next node is in a menu in this node (but not in an index)
1481 ;; 2. next node is next at same level
1482 ;; 3. next node is up and next
1483 (cond ((and (not not-down)
1484 (save-excursion (search-forward "\n* menu:" nil t))
1485 (not (string-match "\\<index\\>" Info-current-node)))
1486 (Info-goto-node (Info-extract-menu-counting 1))
1487 t)
1488 ((save-excursion (search-backward "next:" nil t))
1489 (Info-next)
1490 t)
1491 ((and (save-excursion (search-backward "up:" nil t))
1492 ;; Use string-equal, not equal, to ignore text props.
1493 (not (string-equal (downcase (Info-extract-pointer "up"))
1494 "top")))
1495 (let ((old-node Info-current-node))
1496 (Info-up)
1497 (let (Info-history success)
1498 (unwind-protect
1499 (setq success (Info-forward-node t no-error))
1500 (or success (Info-goto-node old-node))))))
1501 (no-error nil)
1502 (t (error "No pointer forward from this node")))))
a384cab3
JB
1503
1504(defun Info-backward-node ()
1505 "Go backward one node, considering all nodes as forming one sequence."
1506 (interactive)
1507 (let ((prevnode (Info-extract-pointer "prev[ious]*" t))
760d5cb3
GM
1508 (upnode (Info-extract-pointer "up" t))
1509 (case-fold-search t))
a384cab3
JB
1510 (cond ((and upnode (string-match "(" upnode))
1511 (error "First node in file"))
1512 ((and upnode (or (null prevnode)
e90d1271
RS
1513 ;; Use string-equal, not equal,
1514 ;; to ignore text properties.
1515 (string-equal (downcase prevnode)
1516 (downcase upnode))))
a384cab3
JB
1517 (Info-up))
1518 (prevnode
1519 ;; If we move back at the same level,
1520 ;; go down to find the last subnode*.
1521 (Info-prev)
1522 (let (Info-history)
1523 (while (and (not (string-match "\\<index\\>" Info-current-node))
1524 (save-excursion (search-forward "\n* Menu:" nil t)))
1525 (Info-goto-node (Info-extract-menu-counting nil)))))
1526 (t
1527 (error "No pointer backward from this node")))))
1528
1529(defun Info-exit ()
1530 "Exit Info by selecting some other buffer."
1531 (interactive)
552775bd
RS
1532 (if Info-standalone
1533 (save-buffers-kill-emacs)
4643e92f 1534 (quit-window)))
a384cab3 1535
253db917
ER
1536(defun Info-next-menu-item ()
1537 (interactive)
fdf4b680 1538 ;; Bind this in case the user sets it to nil.
760d5cb3
GM
1539 (let* ((case-fold-search t)
1540 (node
1541 (save-excursion
1542 (forward-line -1)
1543 (search-forward "\n* menu:" nil t)
1544 (and (search-forward "\n* " nil t)
1545 (Info-extract-menu-node-name)))))
fadfb77f
RS
1546 (if node (Info-goto-node node)
1547 (error "No more items in menu"))))
253db917
ER
1548
1549(defun Info-last-menu-item ()
1550 (interactive)
1551 (save-excursion
1552 (forward-line 1)
fdf4b680 1553 ;; Bind this in case the user sets it to nil.
760d5cb3
GM
1554 (let* ((case-fold-search t)
1555 (beg (save-excursion
1556 (and (search-backward "\n* menu:" nil t)
1557 (point)))))
0a56332b
RS
1558 (or (and beg (search-backward "\n* " beg t))
1559 (error "No previous items in menu")))
1560 (Info-goto-node (save-excursion
1561 (goto-char (match-end 0))
1562 (Info-extract-menu-node-name)))))
253db917 1563
552775bd 1564(defmacro Info-no-error (&rest body)
253db917
ER
1565 (list 'condition-case nil (cons 'progn (append body '(t))) '(error nil)))
1566
1567(defun Info-next-preorder ()
3c9179ea
RS
1568 "Go to the next subnode or the next node, or go up a level."
1569 (interactive)
1570 (cond ((Info-no-error (Info-next-menu-item)))
1571 ((Info-no-error (Info-next)))
5dab2fb4 1572 ((Info-no-error (Info-up t))
ed690657
KH
1573 ;; Since we have already gone thru all the items in this menu,
1574 ;; go up to the end of this node.
b54d0f0e
RS
1575 (goto-char (point-max))
1576 ;; Since logically we are done with the node with that menu,
1577 ;; move on from it.
1578 (Info-next-preorder))
3c9179ea
RS
1579 (t
1580 (error "No more nodes"))))
253db917
ER
1581
1582(defun Info-last-preorder ()
1583 "Go to the last node, popping up a level if there is none."
1584 (interactive)
0a56332b
RS
1585 (cond ((Info-no-error
1586 (Info-last-menu-item)
1587 ;; If we go down a menu item, go to the end of the node
1588 ;; so we can scroll back through it.
ed690657 1589 (goto-char (point-max)))
b54d0f0e
RS
1590 ;; Keep going down, as long as there are nested menu nodes.
1591 (while (Info-no-error
1592 (Info-last-menu-item)
1593 ;; If we go down a menu item, go to the end of the node
1594 ;; so we can scroll back through it.
1595 (goto-char (point-max))))
ed690657 1596 (recenter -1))
5dab2fb4
RS
1597 ((and (not (equal (Info-extract-pointer "up")
1598 (Info-extract-pointer "prev"))))
1599 (Info-no-error (Info-prev))
ed690657 1600 (goto-char (point-max))
b54d0f0e
RS
1601 (while (Info-no-error
1602 (Info-last-menu-item)
1603 ;; If we go down a menu item, go to the end of the node
1604 ;; so we can scroll back through it.
1605 (goto-char (point-max))))
ed690657 1606 (recenter -1))
5dab2fb4 1607 ((Info-no-error (Info-up t))
ed690657 1608 (goto-char (point-min))
760d5cb3
GM
1609 (let ((case-fold-search t))
1610 (or (search-forward "\n* Menu:" nil t)
1611 (goto-char (point-max)))))
ed690657 1612 (t (error "No previous nodes"))))
253db917
ER
1613
1614(defun Info-scroll-up ()
3f32dc86 1615 "Scroll one screenful forward in Info, considering all nodes as one sequence.
280d11ed
RS
1616Once you scroll far enough in a node that its menu appears on the screen
1617but after point, the next scroll moves into its first subnode.
1618
1619When you scroll past the end of a node, that goes to the next node; if
1620this node has no successor, it moves to the parent node's successor,
1621and so on. If point is inside the menu of a node, it moves to
1622subnode indicated by the following menu item. (That case won't
1623normally result from this command, but can happen in other ways.)"
1624
253db917 1625 (interactive)
0a56332b
RS
1626 (if (or (< (window-start) (point-min))
1627 (> (window-start) (point-max)))
1628 (set-window-start (selected-window) (point)))
760d5cb3
GM
1629 (let* ((case-fold-search t)
1630 (virtual-end (save-excursion
1631 (goto-char (point-min))
1632 (if (search-forward "\n* Menu:" nil t)
1633 (point)
1634 (point-max)))))
0a56332b
RS
1635 (if (or (< virtual-end (window-start))
1636 (pos-visible-in-window-p virtual-end))
1637 (Info-next-preorder)
1638 (scroll-up))))
253db917
ER
1639
1640(defun Info-scroll-down ()
3f32dc86 1641 "Scroll one screenful back in Info, considering all nodes as one sequence.
ed690657
KH
1642Within the menu of a node, this goes to its last subnode.
1643When you scroll past the beginning of a node, that goes to the
1644previous node or back up to the parent node."
253db917 1645 (interactive)
0a56332b
RS
1646 (if (or (< (window-start) (point-min))
1647 (> (window-start) (point-max)))
1648 (set-window-start (selected-window) (point)))
760d5cb3
GM
1649 (let* ((case-fold-search t)
1650 (current-point (point))
b54d0f0e
RS
1651 (virtual-end (save-excursion
1652 (beginning-of-line)
1653 (setq current-point (point))
1654 (goto-char (point-min))
1655 (search-forward "\n* Menu:"
1656 current-point
1657 t))))
0a56332b
RS
1658 (if (or virtual-end (pos-visible-in-window-p (point-min)))
1659 (Info-last-preorder)
1660 (scroll-down))))
253db917 1661
56cda6f5 1662(defun Info-next-reference (&optional recur)
552775bd
RS
1663 "Move cursor to the next cross-reference or menu item in the node."
1664 (interactive)
1665 (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:")
1bcedb3b
RS
1666 (old-pt (point))
1667 (case-fold-search t))
552775bd
RS
1668 (or (eobp) (forward-char 1))
1669 (or (re-search-forward pat nil t)
1670 (progn
1671 (goto-char (point-min))
1672 (or (re-search-forward pat nil t)
1673 (progn
1674 (goto-char old-pt)
1675 (error "No cross references in this node")))))
1676 (goto-char (match-beginning 0))
1677 (if (looking-at "\\* Menu:")
56cda6f5
RS
1678 (if recur
1679 (error "No cross references in this node")
1680 (Info-next-reference t)))))
552775bd 1681
56cda6f5 1682(defun Info-prev-reference (&optional recur)
552775bd
RS
1683 "Move cursor to the previous cross-reference or menu item in the node."
1684 (interactive)
1685 (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:")
1bcedb3b
RS
1686 (old-pt (point))
1687 (case-fold-search t))
552775bd
RS
1688 (or (re-search-backward pat nil t)
1689 (progn
1690 (goto-char (point-max))
1691 (or (re-search-backward pat nil t)
1692 (progn
1693 (goto-char old-pt)
1694 (error "No cross references in this node")))))
1695 (goto-char (match-beginning 0))
1696 (if (looking-at "\\* Menu:")
56cda6f5
RS
1697 (if recur
1698 (error "No cross references in this node")
1699 (Info-prev-reference t)))))
552775bd 1700
1143a6b0 1701(defun Info-index (topic)
fdf4b680 1702 "Look up a string TOPIC in the index for this file.
1143a6b0
ER
1703The index is defined as the first node in the top-level menu whose
1704name contains the word \"Index\", plus any immediately following
1705nodes whose names also contain the word \"Index\".
1706If there are no exact matches to the specified topic, this chooses
1707the first match which is a case-insensitive substring of a topic.
1708Use the `,' command to see the other matches.
1709Give a blank topic name to go to the Index node itself."
1710 (interactive "sIndex topic: ")
1711 (let ((orignode Info-current-node)
1712 (rnode nil)
b37daea4 1713 (pattern (format "\n\\* +\\([^\n:]*%s[^\n:]*\\):[ \t]*\\([^.\n]*\\)\\.[ \t]*\\([0-9]*\\)"
1143a6b0 1714 (regexp-quote topic)))
1bcedb3b
RS
1715 node
1716 (case-fold-search t))
1143a6b0
ER
1717 (Info-goto-node "Top")
1718 (or (search-forward "\n* menu:" nil t)
1719 (error "No index"))
1720 (or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t)
1721 (error "No index"))
1722 (goto-char (match-beginning 1))
c696ac76
RS
1723 ;; Here, and subsequently in this function,
1724 ;; we bind Info-history to nil for internal node-switches
1725 ;; so that we don't put junk in the history.
1726 ;; In the first Info-goto-node call, above, we do update the history
1727 ;; because that is what the user's previous node choice into it.
1728 (let ((Info-history nil))
1143a6b0
ER
1729 (Info-goto-node (Info-extract-menu-node-name)))
1730 (or (equal topic "")
1731 (let ((matches nil)
1732 (exact nil)
c696ac76 1733 (Info-history nil)
1143a6b0
ER
1734 found)
1735 (while
1736 (progn
1737 (goto-char (point-min))
1738 (while (re-search-forward pattern nil t)
1739 (setq matches
110d4e80
DL
1740 (cons (list (match-string-no-properties 1)
1741 (match-string-no-properties 2)
1143a6b0
ER
1742 Info-current-node
1743 (string-to-int (concat "0"
110d4e80 1744 (match-string 3))))
1143a6b0
ER
1745 matches)))
1746 (and (setq node (Info-extract-pointer "next" t))
1747 (string-match "\\<Index\\>" node)))
1748 (Info-goto-node node))
1749 (or matches
1750 (progn
81e14cb2 1751 (Info-goto-node orignode)
920bdaab 1752 (error "No `%s' in index" topic)))
1143a6b0
ER
1753 ;; Here it is a feature that assoc is case-sensitive.
1754 (while (setq found (assoc topic matches))
1755 (setq exact (cons found exact)
1756 matches (delq found matches)))
1757 (setq Info-index-alternatives (nconc exact (nreverse matches)))
1758 (Info-index-next 0)))))
1759
1760(defun Info-index-next (num)
1761 "Go to the next matching index item from the last `i' command."
1762 (interactive "p")
1763 (or Info-index-alternatives
882e61bf 1764 (error "No previous `i' command"))
1143a6b0
ER
1765 (while (< num 0)
1766 (setq num (+ num (length Info-index-alternatives))))
1767 (while (> num 0)
1768 (setq Info-index-alternatives
1769 (nconc (cdr Info-index-alternatives)
1770 (list (car Info-index-alternatives)))
1771 num (1- num)))
1772 (Info-goto-node (nth 1 (car Info-index-alternatives)))
1773 (if (> (nth 3 (car Info-index-alternatives)) 0)
1774 (forward-line (nth 3 (car Info-index-alternatives)))
760d5cb3 1775 (forward-line 3) ; don't search in headers
1143a6b0 1776 (let ((name (car (car Info-index-alternatives))))
920bdaab
RS
1777 (Info-find-index-name name)))
1778 (message "Found `%s' in %s. %s"
1143a6b0
ER
1779 (car (car Info-index-alternatives))
1780 (nth 2 (car Info-index-alternatives))
1781 (if (cdr Info-index-alternatives)
1782 "(Press `,' for more)"
1783 "(Only match)")))
1784
920bdaab
RS
1785(defun Info-find-index-name (name)
1786 "Move point to the place within the current node where NAME is defined."
1bcedb3b
RS
1787 (let ((case-fold-search t))
1788 (if (or (re-search-forward (format
1789 "[a-zA-Z]+: %s\\( \\|$\\)"
1790 (regexp-quote name)) nil t)
1791 (search-forward (format "`%s'" name) nil t)
1792 (and (string-match "\\`.*\\( (.*)\\)\\'" name)
1793 (search-forward
1794 (format "`%s'" (substring name 0 (match-beginning 1)))
1795 nil t))
1796 (search-forward name nil t))
1797 (beginning-of-line)
1798 (goto-char (point-min)))))
920bdaab 1799
a384cab3
JB
1800(defun Info-undefined ()
1801 "Make command be undefined in Info."
1802 (interactive)
1803 (ding))
1804
1805(defun Info-help ()
1806 "Enter the Info tutorial."
1807 (interactive)
1808 (delete-other-windows)
1809 (Info-find-node "info"
1810 (if (< (window-height) 23)
1811 "Help-Small-Screen"
1812 "Help")))
1813
1814(defun Info-summary ()
1815 "Display a brief summary of all Info commands."
1816 (interactive)
1817 (save-window-excursion
1818 (switch-to-buffer "*Help*")
881c84c7 1819 (setq buffer-read-only nil)
a384cab3
JB
1820 (erase-buffer)
1821 (insert (documentation 'Info-mode))
9d29f94c 1822 (help-mode)
a384cab3
JB
1823 (goto-char (point-min))
1824 (let (ch flag)
1825 (while (progn (setq flag (not (pos-visible-in-window-p (point-max))))
1826 (message (if flag "Type Space to see more"
1827 "Type Space to return to Info"))
1614c867 1828 (if (not (eq ?\ (setq ch (read-event))))
dbc4e1c1 1829 (progn (setq unread-command-events (list ch)) nil)
a384cab3 1830 flag))
552775bd
RS
1831 (scroll-up)))
1832 (bury-buffer "*Help*")))
a384cab3
JB
1833\f
1834(defun Info-get-token (pos start all &optional errorstring)
fdf4b680 1835 "Return the token around POS.
a384cab3
JB
1836POS must be somewhere inside the token
1837START is a regular expression which will match the
1838 beginning of the tokens delimited string
1839ALL is a regular expression with a single
90a715f0 1840 parenthesized subpattern which is the token to be
fdf4b680 1841 returned. E.g. '{\(.*\)}' would return any string
a384cab3 1842 enclosed in braces around POS.
fdf4b680 1843ERRORSTRING optional fourth argument, controls action on no match
a384cab3
JB
1844 nil: return nil
1845 t: beep
1846 a string: signal an error, using that string."
1bcedb3b
RS
1847 (let ((case-fold-search t))
1848 (save-excursion
1849 (goto-char pos)
1850 ;; First look for a match for START that goes across POS.
1851 (while (and (not (bobp)) (> (point) (- pos (length start)))
1852 (not (looking-at start)))
1853 (forward-char -1))
1854 ;; If we did not find one, search back for START
1855 ;; (this finds only matches that end at or before POS).
1856 (or (looking-at start)
1857 (progn
1858 (goto-char pos)
1859 (re-search-backward start (max (point-min) (- pos 200)) 'yes)))
1860 (let (found)
1861 (while (and (re-search-forward all (min (point-max) (+ pos 200)) 'yes)
1862 (not (setq found (and (<= (match-beginning 0) pos)
1863 (> (match-end 0) pos))))))
1864 (if (and found (<= (match-beginning 0) pos)
1865 (> (match-end 0) pos))
110d4e80 1866 (match-string-no-properties 1)
1bcedb3b
RS
1867 (cond ((null errorstring)
1868 nil)
1869 ((eq errorstring t)
1870 (beep)
1871 nil)
1872 (t
1873 (error "No %s around position %d" errorstring pos))))))))
a384cab3 1874
981947af 1875(defun Info-mouse-follow-nearest-node (click)
f9969361
RS
1876 "\\<Info-mode-map>Follow a node reference near point.
1877Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click.
981947af 1878At end of the node's text, moves to the next node, or up if none."
f9969361 1879 (interactive "e")
9e5c2f50
RS
1880 (let* ((start (event-start click))
1881 (window (car start))
1882 (pos (car (cdr start))))
1883 (select-window window)
1884 (goto-char pos))
981947af
KH
1885 (and (not (Info-try-follow-nearest-node))
1886 (save-excursion (forward-line 1) (eobp))
ed690657 1887 (Info-next-preorder)))
981947af
KH
1888
1889(defun Info-follow-nearest-node ()
1890 "\\<Info-mode-map>Follow a node reference near point.
1891Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where point is.
1892If no reference to follow, moves to the next node, or up if none."
1893 (interactive)
1894 (or (Info-try-follow-nearest-node)
ed690657 1895 (Info-next-preorder)))
981947af
KH
1896
1897;; Common subroutine.
1898(defun Info-try-follow-nearest-node ()
1899 "Follow a node reference near point. Return non-nil if successful."
a384cab3
JB
1900 (let (node)
1901 (cond
981947af
KH
1902 ((setq node (Info-get-token (point) "\\*note[ \n]"
1903 "\\*note[ \n]\\([^:]*\\):"))
a384cab3 1904 (Info-follow-reference node))
b37daea4 1905 ((setq node (Info-get-token (point) "\\* +" "\\* +\\([^:]*\\)::"))
a384cab3 1906 (Info-goto-node node))
631ba13e
RS
1907 ((Info-get-token (point) "\\* +" "\\* +\\([^:]*\\):")
1908 (beginning-of-line)
1909 (forward-char 2)
1910 (setq node (Info-extract-menu-node-name))
1911 (Info-goto-node node))
bc2ada62 1912 ((setq node (Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)"))
a384cab3 1913 (Info-goto-node node))
bc2ada62 1914 ((setq node (Info-get-token (point) "Next: " "Next: \\([^,\n\t]*\\)"))
a384cab3 1915 (Info-goto-node node))
bc2ada62 1916 ((setq node (Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)"))
a384cab3 1917 (Info-goto-node "Top"))
bc2ada62 1918 ((setq node (Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)"))
981947af
KH
1919 (Info-goto-node node)))
1920 node))
a384cab3
JB
1921\f
1922(defvar Info-mode-map nil
1923 "Keymap containing Info commands.")
1924(if Info-mode-map
1925 nil
1926 (setq Info-mode-map (make-keymap))
1927 (suppress-keymap Info-mode-map)
1928 (define-key Info-mode-map "." 'beginning-of-buffer)
253db917 1929 (define-key Info-mode-map " " 'Info-scroll-up)
981947af 1930 (define-key Info-mode-map "\C-m" 'Info-follow-nearest-node)
552775bd
RS
1931 (define-key Info-mode-map "\t" 'Info-next-reference)
1932 (define-key Info-mode-map "\e\t" 'Info-prev-reference)
e38e7367
RM
1933 (define-key Info-mode-map "1" 'Info-nth-menu-item)
1934 (define-key Info-mode-map "2" 'Info-nth-menu-item)
1935 (define-key Info-mode-map "3" 'Info-nth-menu-item)
1936 (define-key Info-mode-map "4" 'Info-nth-menu-item)
1937 (define-key Info-mode-map "5" 'Info-nth-menu-item)
1938 (define-key Info-mode-map "6" 'Info-nth-menu-item)
1939 (define-key Info-mode-map "7" 'Info-nth-menu-item)
1940 (define-key Info-mode-map "8" 'Info-nth-menu-item)
1941 (define-key Info-mode-map "9" 'Info-nth-menu-item)
82a4c008 1942 (define-key Info-mode-map "0" 'undefined)
a384cab3
JB
1943 (define-key Info-mode-map "?" 'Info-summary)
1944 (define-key Info-mode-map "]" 'Info-forward-node)
1945 (define-key Info-mode-map "[" 'Info-backward-node)
1946 (define-key Info-mode-map "<" 'Info-top-node)
1947 (define-key Info-mode-map ">" 'Info-final-node)
1948 (define-key Info-mode-map "b" 'beginning-of-buffer)
1949 (define-key Info-mode-map "d" 'Info-directory)
1950 (define-key Info-mode-map "e" 'Info-edit)
1951 (define-key Info-mode-map "f" 'Info-follow-reference)
1952 (define-key Info-mode-map "g" 'Info-goto-node)
1953 (define-key Info-mode-map "h" 'Info-help)
1143a6b0 1954 (define-key Info-mode-map "i" 'Info-index)
a384cab3
JB
1955 (define-key Info-mode-map "l" 'Info-last)
1956 (define-key Info-mode-map "m" 'Info-menu)
1957 (define-key Info-mode-map "n" 'Info-next)
1958 (define-key Info-mode-map "p" 'Info-prev)
1959 (define-key Info-mode-map "q" 'Info-exit)
1960 (define-key Info-mode-map "s" 'Info-search)
47fc33ca
RS
1961 ;; For consistency with Rmail.
1962 (define-key Info-mode-map "\M-s" 'Info-search)
4fceda3c 1963 (define-key Info-mode-map "\M-n" 'clone-buffer)
db0c9809 1964 (define-key Info-mode-map "t" 'Info-top-node)
a384cab3 1965 (define-key Info-mode-map "u" 'Info-up)
1143a6b0 1966 (define-key Info-mode-map "," 'Info-index-next)
803eaf50 1967 (define-key Info-mode-map "\177" 'Info-scroll-down)
981947af 1968 (define-key Info-mode-map [mouse-2] 'Info-mouse-follow-nearest-node)
aea2a8da 1969 )
75a209d4
RS
1970
1971(defun Info-check-pointer (item)
fdf4b680 1972 "Non-nil if ITEM is present in this node."
75a209d4
RS
1973 (condition-case nil
1974 (Info-extract-pointer item)
1975 (error nil)))
1976
d4af987a
DL
1977(easy-menu-define
1978 Info-mode-menu Info-mode-map
1979 "Menu for info files."
1980 '("Info"
1981 ["Up" Info-up :active (Info-check-pointer "up")
1982 :help "Go up in the Info tree"]
1983 ["Next" Info-next :active (Info-check-pointer "next")
1984 :help "Go to the next node"]
1985 ["Previous" Info-prev :active (Info-check-pointer "prev[ious]*")
1986 :help "Go to the previous node"]
1987 ["Backward" Info-backward-node
1988 :help "Go backward one node, considering all as a sequence"]
1989 ["Forward" Info-forward-node
1990 :help "Go forward one node, considering all as a sequence"]
1991 ["Top" Info-top-node
1992 :help "Go to top node of file"]
1993 ["Final Node" Info-final-node
1994 :help "Go to final node in this file"]
1995 ("Menu Item" ["You should never see this" report-emacs-bug t])
1996 ("Reference" ["You should never see this" report-emacs-bug t])
1997 ["Search..." Info-search
1998 :help "Search for regular expression in this Info file"]
1999 ["Goto Node..." Info-goto-node
2000 :help "Go to a named node"]
2001 ["Last" Info-last Info-history
2002 :help "Go to the last node you were at"]
2003 ("Index..."
2004 ["Lookup a String" Info-index
2005 :help "Look for a string in the index items"]
2006 ["Next Matching Item" Info-index-next
2007 :help "Look for another occurrence of previous item"])
2008 ["Exit" Info-exit t]))
75a209d4
RS
2009
2010(defvar Info-menu-last-node nil)
2011;; Last node the menu was created for.
6d2c8e3e 2012;; Value is a list, (FILE-NAME NODE-NAME).
75a209d4
RS
2013
2014(defun Info-menu-update ()
fdf4b680 2015 "Update the Info menu for the current node."
75a209d4
RS
2016 (condition-case nil
2017 (if (or (not (eq major-mode 'Info-mode))
6d2c8e3e
RS
2018 (equal (list Info-current-file Info-current-node)
2019 Info-menu-last-node))
75a209d4
RS
2020 ()
2021 ;; Update menu menu.
2022 (let* ((Info-complete-menu-buffer (current-buffer))
2023 (items (nreverse (condition-case nil
2024 (Info-complete-menu-item
2025 "" (lambda (e) t) t)
2026 (error nil))))
399c88ad 2027 entries current
75a209d4
RS
2028 (number 0))
2029 (while (and items (< number 9))
2030 (setq current (car items)
2031 items (cdr items)
2032 number (1+ number))
399c88ad 2033 (setq entries (cons `[,current
75a209d4
RS
2034 (Info-menu ,current)
2035 :keys ,(format "%d" number)]
2036 entries)))
2037 (if items
2038 (setq entries (cons ["Other..." Info-menu t] entries)))
2039 (or entries
2040 (setq entries (list ["No menu" nil nil])))
d4af987a 2041 (easy-menu-change '("Info") "Menu Item" (nreverse entries)))
75a209d4
RS
2042 ;; Update reference menu. Code stolen from `Info-follow-reference'.
2043 (let ((items nil)
399c88ad 2044 str i entries current
1bcedb3b
RS
2045 (number 0)
2046 (case-fold-search t))
75a209d4
RS
2047 (save-excursion
2048 (goto-char (point-min))
2049 (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t)
2050 (setq str (buffer-substring
2051 (match-beginning 1)
2052 (1- (point))))
2053 (setq i 0)
2054 (while (setq i (string-match "[ \n\t]+" str i))
2055 (setq str (concat (substring str 0 i) " "
2056 (substring str (match-end 0))))
2057 (setq i (1+ i)))
2058 (setq items
2059 (cons str items))))
2060 (while (and items (< number 9))
2061 (setq current (car items)
2062 items (cdr items)
2063 number (1+ number))
399c88ad 2064 (setq entries (cons `[,current
75a209d4
RS
2065 (Info-follow-reference ,current)
2066 t]
2067 entries)))
2068 (if items
2069 (setq entries (cons ["Other..." Info-follow-reference t]
2070 entries)))
2071 (or entries
2072 (setq entries (list ["No references" nil nil])))
2073 (easy-menu-change '("Info") "Reference" (nreverse entries)))
2074 ;; Update last seen node.
6d2c8e3e 2075 (setq Info-menu-last-node (list Info-current-file Info-current-node)))
75a209d4
RS
2076 ;; Try to avoid entering infinite beep mode in case of errors.
2077 (error (ding))))
2078
a384cab3
JB
2079\f
2080;; Info mode is suitable only for specially formatted data.
68bc119c 2081(put 'Info-mode 'mode-class 'special)
a384cab3
JB
2082
2083(defun Info-mode ()
fdf4b680 2084 "Info mode provides commands for browsing through the Info documentation tree.
a384cab3
JB
2085Documentation in Info is divided into \"nodes\", each of which discusses
2086one topic and contains references to other nodes which discuss related
2087topics. Info has commands to follow the references and show you other nodes.
2088
fdf4b680 2089\\<Info-mode-map>\
a384cab3 2090\\[Info-help] Invoke the Info tutorial.
6b136ab9 2091\\[Info-exit] Quit Info: reselect previously selected buffer.
a384cab3
JB
2092
2093Selecting other nodes:
21d5959f
RS
2094\\[Info-mouse-follow-nearest-node]
2095 Follow a node reference you click on.
2096 This works with menu items, cross references, and
2097 the \"next\", \"previous\" and \"up\", depending on where you click.
6b136ab9 2098\\[Info-follow-nearest-node] Follow a node reference near point, like \\[Info-mouse-follow-nearest-node].
a384cab3 2099\\[Info-next] Move to the \"next\" node of this node.
bc2ada62 2100\\[Info-prev] Move to the \"previous\" node of this node.
a384cab3
JB
2101\\[Info-up] Move \"up\" from this node.
2102\\[Info-menu] Pick menu item specified by name (or abbreviation).
2103 Picking a menu item causes another node to be selected.
aea2a8da 2104\\[Info-directory] Go to the Info directory node.
a384cab3
JB
2105\\[Info-follow-reference] Follow a cross reference. Reads name of reference.
2106\\[Info-last] Move to the last node you were at.
1143a6b0
ER
2107\\[Info-index] Look up a topic in this file's Index and move to that node.
2108\\[Info-index-next] (comma) Move to the next match from a previous `i' command.
6b136ab9
DL
2109\\[Info-top-node] Go to the Top node of this file.
2110\\[Info-final-node] Go to the final node in this file.
2111\\[Info-backward-node] Go backward one node, considering all nodes as forming one sequence.
2112\\[Info-forward-node] Go forward one node, considering all nodes as forming one sequence.
a384cab3
JB
2113
2114Moving within a node:
177c3549
RS
2115\\[Info-scroll-up] Normally, scroll forward a full screen.
2116Once you scroll far enough in a node that its menu appears on the screen
2117but after point, the next scroll moves into its first subnode.
2118When after all menu items (or if their is no menu), move up to
2119the parent node.
2120\\[Info-scroll-down] Normally, scroll backward. If the beginning of the buffer is
803eaf50 2121already visible, try to go to the previous menu entry, or up if there is none.
399c88ad 2122\\[beginning-of-buffer] Go to beginning of node.
a384cab3 2123
a384cab3
JB
2124Advanced commands:
2125\\[Info-exit] Quit Info: reselect previously selected buffer.
2126\\[Info-edit] Edit contents of selected node.
21271 Pick first item in node's menu.
21282, 3, 4, 5 Pick second ... fifth item in node's menu.
2129\\[Info-goto-node] Move to node specified by name.
2130 You may include a filename as well, as (FILENAME)NODENAME.
552775bd 2131\\[universal-argument] \\[info] Move to new Info file with completion.
a384cab3 2132\\[Info-search] Search through this Info file for specified regexp,
803eaf50 2133 and select the node in which the next occurrence is found.
552775bd
RS
2134\\[Info-next-reference] Move cursor to next cross-reference or menu item.
2135\\[Info-prev-reference] Move cursor to previous cross-reference or menu item."
a384cab3
JB
2136 (kill-all-local-variables)
2137 (setq major-mode 'Info-mode)
2138 (setq mode-name "Info")
f73299f3 2139 (setq tab-width 8)
a384cab3 2140 (use-local-map Info-mode-map)
75a209d4
RS
2141 (make-local-hook 'activate-menubar-hook)
2142 (add-hook 'activate-menubar-hook 'Info-menu-update nil t)
a384cab3
JB
2143 (set-syntax-table text-mode-syntax-table)
2144 (setq local-abbrev-table text-mode-abbrev-table)
2145 (setq case-fold-search t)
2146 (setq buffer-read-only t)
a384cab3
JB
2147 (make-local-variable 'Info-current-file)
2148 (make-local-variable 'Info-current-subfile)
2149 (make-local-variable 'Info-current-node)
2150 (make-local-variable 'Info-tag-table-marker)
c5fe2ff1
RS
2151 (setq Info-tag-table-marker (make-marker))
2152 (make-local-variable 'Info-tag-table-buffer)
2153 (setq Info-tag-table-buffer nil)
a384cab3 2154 (make-local-variable 'Info-history)
1143a6b0 2155 (make-local-variable 'Info-index-alternatives)
93480d70
RS
2156 ;; This is for the sake of the invisible text we use handling titles.
2157 (make-local-variable 'line-move-ignore-invisible)
2158 (setq line-move-ignore-invisible t)
4fceda3c 2159 (add-hook (make-local-hook 'clone-buffer-hook) 'Info-clone-buffer-hook nil t)
a384cab3
JB
2160 (Info-set-mode-line)
2161 (run-hooks 'Info-mode-hook))
2162
4fceda3c
SM
2163(defun Info-clone-buffer-hook ()
2164 (when (bufferp Info-tag-table-buffer)
2165 (setq Info-tag-table-buffer
2166 (with-current-buffer Info-tag-table-buffer (clone-buffer)))
2167 (let ((m Info-tag-table-marker))
2168 (when (and (markerp m) (marker-position m))
2169 (setq Info-tag-table-marker
2170 (with-current-buffer Info-tag-table-buffer
2171 (copy-marker (marker-position m))))))))
2172
a384cab3
JB
2173(defvar Info-edit-map nil
2174 "Local keymap used within `e' command of Info.")
2175(if Info-edit-map
2176 nil
2177 (setq Info-edit-map (nconc (make-sparse-keymap) text-mode-map))
2178 (define-key Info-edit-map "\C-c\C-c" 'Info-cease-edit))
2179
2180;; Info-edit mode is suitable only for specially formatted data.
68bc119c 2181(put 'Info-edit-mode 'mode-class 'special)
a384cab3
JB
2182
2183(defun Info-edit-mode ()
2184 "Major mode for editing the contents of an Info node.
a426b157 2185Like text mode with the addition of `Info-cease-edit'
a384cab3
JB
2186which returns to Info mode for browsing.
2187\\{Info-edit-map}"
a384cab3
JB
2188 (use-local-map Info-edit-map)
2189 (setq major-mode 'Info-edit-mode)
2190 (setq mode-name "Info Edit")
2191 (kill-local-variable 'mode-line-buffer-identification)
2192 (setq buffer-read-only nil)
2c609f53 2193 (force-mode-line-update)
e82c28f9
KH
2194 (buffer-enable-undo (current-buffer))
2195 (run-hooks 'Info-edit-mode-hook))
2196
2197(defun Info-edit ()
2198 "Edit the contents of this Info node.
2199Allowed only if variable `Info-enable-edit' is non-nil."
2200 (interactive)
2201 (or Info-enable-edit
2202 (error "Editing info nodes is not enabled"))
2203 (Info-edit-mode)
8ab3e50b 2204 (message "%s" (substitute-command-keys
760d5cb3 2205 "Editing: Type \\<Info-edit-map>\\[Info-cease-edit] to return to info")))
a384cab3
JB
2206
2207(defun Info-cease-edit ()
2208 "Finish editing Info node; switch back to Info proper."
2209 (interactive)
2210 ;; Do this first, so nothing has changed if user C-g's at query.
2211 (and (buffer-modified-p)
2212 (y-or-n-p "Save the file? ")
2213 (save-buffer))
2214 (use-local-map Info-mode-map)
2215 (setq major-mode 'Info-mode)
2216 (setq mode-name "Info")
2217 (Info-set-mode-line)
2218 (setq buffer-read-only t)
2c609f53 2219 (force-mode-line-update)
a384cab3
JB
2220 (and (marker-position Info-tag-table-marker)
2221 (buffer-modified-p)
2222 (message "Tags may have changed. Use Info-tagify if necessary")))
f0a8a3f1 2223\f
f88ab1c9 2224(defvar Info-file-list-for-emacs
dd31e4e8 2225 '("ediff" "forms" "gnus" ("mh" . "mh-e") "sc" "message"
af718538
EZ
2226 ("dired" . "dired-x") ("c" . "ccmode") "viper" "vip"
2227 ("skeleton" . "autotype") ("auto-insert" . "autotype")
2228 ("copyright" . "autotype") ("executable" . "autotype")
2229 ("time-stamp" . "autotype") ("quickurl" . "autotype")
2230 ("tempo" . "autotype") ("hippie-expand" . "autotype")
2231 ("cvs" . "pcl-cvs")
2232 "ebrowse" "cl" "idlwave" "reftex" "widget" "woman")
f88ab1c9
RS
2233 "List of Info files that describe Emacs commands.
2234An element can be a file name, or a list of the form (PREFIX . FILE)
2235where PREFIX is a name prefix and FILE is the file to look in.
2236If the element is just a file name, the file name also serves as the prefix.")
2237
f0a8a3f1 2238(defun Info-find-emacs-command-nodes (command)
f88ab1c9 2239 "Return a list of locations documenting COMMAND.
f57b2cd8
RS
2240The `info-file' property of COMMAND says which Info manual to search.
2241If COMMAND has no property, the variable `Info-file-list-for-emacs'
2242defines heuristics for which Info manual to try.
fdf4b680 2243The locations are of the format used in `Info-history', i.e.
f0a8a3f1 2244\(FILENAME NODENAME BUFFERPOS\)."
f0a8a3f1 2245 (let ((where '())
b37daea4 2246 (cmd-desc (concat "^\\* +" (regexp-quote (symbol-name command))
218c2cc7 2247 "\\( <[0-9]+>\\)?:\\s *\\(.*\\)\\.$"))
f88ab1c9
RS
2248 (info-file "emacs")) ;default
2249 ;; Determine which info file this command is documented in.
2250 (if (get command 'info-file)
2251 (setq info-file (get command 'info-file))
2252 ;; If it doesn't say explicitly, test its name against
2253 ;; various prefixes that we know.
2254 (let ((file-list Info-file-list-for-emacs))
2255 (while file-list
2256 (let* ((elt (car file-list))
2257 (name (if (consp elt)
2258 (car elt)
2259 elt))
2260 (file (if (consp elt) (cdr elt) elt))
f57b2cd8 2261 (regexp (concat "\\`" (regexp-quote name)
f88ab1c9
RS
2262 "\\(\\'\\|-\\)")))
2263 (if (string-match regexp (symbol-name command))
2264 (setq info-file file file-list nil))
2265 (setq file-list (cdr file-list))))))
218c2cc7
EZ
2266 (Info-find-node info-file "Top")
2267 (or (and (search-forward "\n* menu:" nil t)
2268 (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t))
2269 (error "Info file `%s' appears to lack an index" info-file))
2270 (goto-char (match-beginning 1))
2271 ;; Bind Info-history to nil, to prevent the index nodes from
2272 ;; getting into the node history.
2273 (let ((Info-history nil)
2274 (exact nil)
2275 node found)
2276 (Info-goto-node (Info-extract-menu-node-name))
2277 (while
2278 (progn
2279 (goto-char (point-min))
2280 (while (re-search-forward cmd-desc nil t)
2281 (setq where
2282 (cons (list Info-current-file
2283 (match-string-no-properties 2)
760d5cb3
GM
2284 0)
2285 where)))
218c2cc7
EZ
2286 (and (setq node (Info-extract-pointer "next" t))
2287 (string-match "\\<Index\\>" node)))
2288 (Info-goto-node node)))
2289 where))
f0a8a3f1
RM
2290
2291;;;###autoload
2292(defun Info-goto-emacs-command-node (command)
e0568e86 2293 "Go to the Info node in the Emacs manual for command COMMAND.
f88ab1c9 2294The command is found by looking up in Emacs manual's Command Index
f57b2cd8
RS
2295or in another manual found via COMMAND's `info-file' property or
2296the variable `Info-file-list-for-emacs'."
f0a8a3f1
RM
2297 (interactive "CFind documentation for command: ")
2298 (or (commandp command)
2299 (signal 'wrong-type-argument (list 'commandp command)))
2300 (let ((where (Info-find-emacs-command-nodes command)))
2301 (if where
2302 (let ((num-matches (length where)))
2303 ;; Get Info running, and pop to it in another window.
2304 (save-window-excursion
2305 (info))
c5fe2ff1
RS
2306 ;; FIXME It would be cool if this could use a buffer other
2307 ;; than *info*.
f0a8a3f1 2308 (pop-to-buffer "*info*")
218c2cc7
EZ
2309 ;; Bind Info-history to nil, to prevent the last Index node
2310 ;; visited by Info-find-emacs-command-nodes from being
2311 ;; pushed onto the history.
2312 (let ((Info-history nil))
2313 (Info-find-node (car (car where))
2314 (car (cdr (car where)))))
f0a8a3f1
RM
2315 (if (> num-matches 1)
2316 (progn
218c2cc7
EZ
2317 ;; (car where) will be pushed onto Info-history
2318 ;; when/if they go to another node. Put the other
2319 ;; nodes that were found on the history.
f0a8a3f1 2320 (setq Info-history (nconc (cdr where) Info-history))
8ab3e50b 2321 (message "Found %d other entr%s. Use %s to see %s."
cedb118c
RS
2322 (1- num-matches)
2323 (if (> num-matches 2) "ies" "y")
8ab3e50b 2324 (substitute-command-keys "\\[Info-last]")
cedb118c 2325 (if (> num-matches 2) "them" "it")))))
e9b81433 2326 (error "Couldn't find documentation for %s" command))))
f0a8a3f1
RM
2327
2328;;;###autoload
2329(defun Info-goto-emacs-key-command-node (key)
2330 "Go to the Info node in the Emacs manual the command bound to KEY, a string.
fdf4b680 2331Interactively, if the binding is `execute-extended-command', a command is read.
f88ab1c9 2332The command is found by looking up in Emacs manual's Command Index
f57b2cd8
RS
2333or in another manual found via COMMAND's `info-file' property or
2334the variable `Info-file-list-for-emacs'."
ea33749b 2335 (interactive "kFind documentation for key: ")
f0a8a3f1
RM
2336 (let ((command (key-binding key)))
2337 (cond ((null command)
9e5c2f50 2338 (message "%s is undefined" (key-description key)))
f0a8a3f1
RM
2339 ((and (interactive-p)
2340 (eq command 'execute-extended-command))
2341 (Info-goto-emacs-command-node
2342 (read-command "Find documentation for command: ")))
2343 (t
2344 (Info-goto-emacs-command-node command)))))
552775bd 2345\f
bbed5c3f 2346(defface Info-title-1-face
8ec8f673 2347 '((t (:height 1.2 :inherit Info-title-2-face)))
bbed5c3f
GM
2348 "Face for Info titles at level 1."
2349 :group 'info)
2350
2351(defface Info-title-2-face
8ec8f673 2352 '((t (:height 1.2 :inherit Info-title-3-face)))
bbed5c3f
GM
2353 "Face for Info titles at level 2."
2354 :group 'info)
2355
2356(defface Info-title-3-face
8ec8f673 2357 '((t (:height 1.2 :weight bold :inherit variable-pitch)))
bbed5c3f
GM
2358 "Face for Info titles at level 3."
2359 :group 'info)
2360
552775bd
RS
2361(defun Info-fontify-node ()
2362 (save-excursion
1bcedb3b
RS
2363 (let ((buffer-read-only nil)
2364 (case-fold-search t))
552775bd 2365 (goto-char (point-min))
35d2d241
RS
2366 (when (looking-at "^File: [^,: \t]+,?[ \t]+")
2367 (goto-char (match-end 0))
50ac70af 2368 (while (looking-at "[ \t]*\\([^:, \t\n]+\\):[ \t]+\\([^:,\t\n]+\\),?")
35d2d241 2369 (goto-char (match-end 0))
50ac70af
MB
2370 (let* ((nbeg (match-beginning 2))
2371 (nend (match-end 2))
2372 (tbeg (match-beginning 1))
2373 (tag (buffer-substring tbeg (match-end 1))))
2374 (if (string-equal tag "Node")
2375 (put-text-property nbeg nend 'face 'info-header-node)
2376 (put-text-property nbeg nend 'face 'info-header-xref)
2377 (put-text-property nbeg nend 'mouse-face 'highlight)
2378 (put-text-property tbeg nend
2379 'help-echo
2380 (concat "Goto node "
2381 (buffer-substring nbeg nend)))
2382 (let ((fun (cdr (assoc tag '(("Prev" . Info-prev)
2383 ("Next" . Info-next)
2384 ("Up" . Info-up))))))
2385 (when fun
2386 (let ((keymap (make-sparse-keymap)))
2387 (define-key keymap [header-line mouse-1] fun)
2388 (define-key keymap [header-line mouse-2] fun)
2389 (put-text-property tbeg nend 'local-map keymap))))
2390 ))))
552775bd 2391 (goto-char (point-min))
98d8273c 2392 (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*+\\|=+\\|-+\\)$"
760d5cb3 2393 nil t)
bbed5c3f
GM
2394 (let ((c (preceding-char))
2395 face)
2396 (cond ((= c ?*) (setq face 'Info-title-1-face))
2397 ((= c ?=) (setq face 'Info-title-2-face))
399c88ad 2398 (t (setq face 'Info-title-3-face)))
bbed5c3f
GM
2399 (put-text-property (match-beginning 1) (match-end 1)
2400 'face face))
93480d70
RS
2401 ;; This is a serious problem for trying to handle multiple
2402 ;; frame types at once. We want this text to be invisible
2403 ;; on frames that can display the font above.
2404 (if (memq (framep (selected-frame)) '(x pc w32))
a198aa54 2405 (add-text-properties (match-end 1) (match-end 2)
0e8c11d8 2406 '(invisible t intangible t))))
98d8273c 2407 (goto-char (point-min))
7757c476 2408 (while (re-search-forward "\\*Note[ \n\t]+\\([^:]*\\):" nil t)
552775bd
RS
2409 (if (= (char-after (1- (match-beginning 0))) ?\") ; hack
2410 nil
2411 (put-text-property (match-beginning 1) (match-end 1)
9a87b430
RS
2412 'face 'info-xref)
2413 (put-text-property (match-beginning 1) (match-end 1)
2414 'mouse-face 'highlight)))
552775bd
RS
2415 (goto-char (point-min))
2416 (if (and (search-forward "\n* Menu:" nil t)
2417 (not (string-match "\\<Index\\>" Info-current-node))
2418 ;; Don't take time to annotate huge menus
34a0a4ee 2419 (< (- (point-max) (point)) Info-fontify-maximum-menu-size))
552775bd 2420 (let ((n 0))
b37daea4 2421 (while (re-search-forward "^\\* +\\([^:\t\n]*\\):" nil t)
552775bd 2422 (setq n (1+ n))
760d5cb3 2423 (if (memq n '(5 9)) ; visual aids to help with 1-9 keys
552775bd
RS
2424 (put-text-property (match-beginning 0)
2425 (1+ (match-beginning 0))
2426 'face 'info-menu-5))
2427 (put-text-property (match-beginning 1) (match-end 1)
35d2d241 2428 'face 'info-xref)
9a87b430
RS
2429 (put-text-property (match-beginning 1) (match-end 1)
2430 'mouse-face 'highlight))))
552775bd 2431 (set-buffer-modified-p nil))))
c5fe2ff1
RS
2432\f
2433
2434;; When an Info buffer is killed, make sure the associated tags buffer
2435;; is killed too.
2436(defun Info-kill-buffer ()
2437 (and (eq major-mode 'Info-mode)
2438 Info-tag-table-buffer
2439 (kill-buffer Info-tag-table-buffer)))
2440
2441(add-hook 'kill-buffer-hook 'Info-kill-buffer)
3cb6768f
EL
2442
2443;;; Speedbar support:
2444;; These functions permit speedbar to display the "tags" in the
2445;; current info node.
96ee3f29 2446(eval-when-compile (require 'speedbar))
3cb6768f 2447
96ee3f29
KH
2448(defvar Info-speedbar-key-map nil
2449 "Keymap used when in the info display mode.")
3cb6768f 2450
96ee3f29
KH
2451(defun Info-install-speedbar-variables ()
2452 "Install those variables used by speedbar to enhance Info."
2453 (if Info-speedbar-key-map
2454 nil
2455 (setq Info-speedbar-key-map (speedbar-make-specialized-keymap))
2456
2457 ;; Basic tree features
2458 (define-key Info-speedbar-key-map "e" 'speedbar-edit-line)
2459 (define-key Info-speedbar-key-map "\C-m" 'speedbar-edit-line)
2460 (define-key Info-speedbar-key-map "+" 'speedbar-expand-line)
2461 (define-key Info-speedbar-key-map "-" 'speedbar-contract-line)
2462 )
2463
2464 (speedbar-add-expansion-list '("Info" Info-speedbar-menu-items
2465 Info-speedbar-key-map
2466 Info-speedbar-hierarchy-buttons)))
3cb6768f
EL
2467
2468(defvar Info-speedbar-menu-items
96ee3f29
KH
2469 '(["Browse Node" speedbar-edit-line t]
2470 ["Expand Node" speedbar-expand-line
2471 (save-excursion (beginning-of-line)
2472 (looking-at "[0-9]+: *.\\+. "))]
2473 ["Contract Node" speedbar-contract-line
2474 (save-excursion (beginning-of-line)
2475 (looking-at "[0-9]+: *.-. "))]
2476 )
3cb6768f
EL
2477 "Additional menu-items to add to speedbar frame.")
2478
96ee3f29
KH
2479;; Make sure our special speedbar major mode is loaded
2480(if (featurep 'speedbar)
2481 (Info-install-speedbar-variables)
2482 (add-hook 'speedbar-load-hook 'Info-install-speedbar-variables))
2483
2484;;; Info hierarchy display method
2485;;;###autoload
2486(defun Info-speedbar-browser ()
2487 "Initialize speedbar to display an info node browser.
2488This will add a speedbar major display mode."
2489 (interactive)
2490 (require 'speedbar)
2491 ;; Make sure that speedbar is active
2492 (speedbar-frame-mode 1)
2493 ;; Now, throw us into Info mode on speedbar.
2494 (speedbar-change-initial-expansion-list "Info")
2495 )
2496
2497(defun Info-speedbar-hierarchy-buttons (directory depth &optional node)
2498 "Display an Info directory hierarchy in speedbar.
2499DIRECTORY is the current directory in the attached frame.
2500DEPTH is the current indentation depth.
2501NODE is an optional argument that is used to represent the
2502specific node to expand."
2503 (if (and (not node)
2504 (save-excursion (goto-char (point-min))
1bcedb3b
RS
2505 (let ((case-fold-search t))
2506 (looking-at "Info Nodes:"))))
96ee3f29
KH
2507 ;; Update our "current node" maybe?
2508 nil
2509 ;; We cannot use the generic list code, that depends on all leaves
2510 ;; being known at creation time.
2511 (if (not node)
2512 (speedbar-with-writable (insert "Info Nodes:\n")))
5fdc7997
EL
2513 (let ((completions nil)
2514 (cf (selected-frame)))
2515 (select-frame speedbar-attached-frame)
2516 (save-window-excursion
2517 (setq completions
2518 (Info-speedbar-fetch-file-nodes (or node '"(dir)top"))))
2519 (select-frame cf)
96ee3f29
KH
2520 (if completions
2521 (speedbar-with-writable
2522 (while completions
2523 (speedbar-make-tag-line 'bracket ?+ 'Info-speedbar-expand-node
2524 (cdr (car completions))
2525 (car (car completions))
2526 'Info-speedbar-goto-node
2527 (cdr (car completions))
2528 'info-xref depth)
2529 (setq completions (cdr completions)))
2530 t)
2531 nil))))
399c88ad 2532
96ee3f29
KH
2533(defun Info-speedbar-goto-node (text node indent)
2534 "When user clicks on TEXT, goto an info NODE.
2535The INDENT level is ignored."
760d5cb3
GM
2536 (select-frame speedbar-attached-frame)
2537 (let* ((buff (or (get-buffer "*info*")
2538 (progn (info) (get-buffer "*info*"))))
2539 (bwin (get-buffer-window buff 0)))
2540 (if bwin
2541 (progn
2542 (select-window bwin)
2543 (raise-frame (window-frame bwin)))
2544 (if speedbar-power-click
2545 (let ((pop-up-frames t)) (select-window (display-buffer buff)))
2546 (select-frame speedbar-attached-frame)
2547 (switch-to-buffer buff)))
2548 (let ((junk (string-match "^(\\([^)]+\\))\\([^.]+\\)$" node))
2549 (file (match-string 1 node))
2550 (node (match-string 2 node)))
2551 (Info-find-node file node)
2552 ;; If we do a find-node, and we were in info mode, restore
2553 ;; the old default method. Once we are in info mode, it makes
2554 ;; sense to return to whatever method the user was using before.
2555 (if (string= speedbar-initial-expansion-list-name "Info")
2556 (speedbar-change-initial-expansion-list
2557 speedbar-previously-used-expansion-list-name)))))
96ee3f29
KH
2558
2559(defun Info-speedbar-expand-node (text token indent)
2560 "Expand the node the user clicked on.
2561TEXT is the text of the button we clicked on, a + or - item.
2562TOKEN is data related to this node (NAME . FILE).
2563INDENT is the current indentation depth."
2564 (cond ((string-match "+" text) ;we have to expand this file
2565 (speedbar-change-expand-button-char ?-)
2566 (if (speedbar-with-writable
760d5cb3
GM
2567 (save-excursion
2568 (end-of-line) (forward-char 1)
2569 (Info-speedbar-hierarchy-buttons nil (1+ indent) token)))
96ee3f29
KH
2570 (speedbar-change-expand-button-char ?-)
2571 (speedbar-change-expand-button-char ??)))
2572 ((string-match "-" text) ;we have to contract this node
2573 (speedbar-change-expand-button-char ?+)
2574 (speedbar-delete-subblock indent))
2575 (t (error "Ooops... not sure what to do")))
2576 (speedbar-center-buffer-smartly))
2577
2578(defun Info-speedbar-fetch-file-nodes (nodespec)
2579 "Fetch the subnodes from the info NODESPEC.
2580NODESPEC is a string of the form: (file)node.
2581Optional THISFILE represends the filename of"
2582 (save-excursion
2583 ;; Set up a buffer we can use to fake-out Info.
2584 (set-buffer (get-buffer-create "*info-browse-tmp*"))
2585 (if (not (equal major-mode 'Info-mode))
2586 (Info-mode))
2587 ;; Get the node into this buffer
2588 (let ((junk (string-match "^(\\([^)]+\\))\\([^.]+\\)$" nodespec))
2589 (file (match-string 1 nodespec))
2590 (node (match-string 2 nodespec)))
2591 (Info-find-node file node))
2592 ;; Scan the created buffer
2593 (goto-char (point-min))
2594 (let ((completions nil)
1bcedb3b 2595 (case-fold-search t)
96ee3f29
KH
2596 (thisfile (progn (string-match "^(\\([^)]+\\))" nodespec)
2597 (match-string 1 nodespec))))
2598 ;; Always skip the first one...
2599 (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
2600 (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
2601 (let ((name (match-string 1)))
2602 (if (looking-at " *\\(([^)]+)[^.\n]+\\)\\.")
2603 (setq name (cons name (match-string 1)))
2604 (if (looking-at " *\\(([^)]+)\\)\\.")
2605 (setq name (cons name (concat (match-string 1) "Top")))
2606 (if (looking-at " \\([^.]+\\).")
2607 (setq name
2608 (cons name (concat "(" thisfile ")" (match-string 1))))
2609 (setq name (cons name (concat "(" thisfile ")" name))))))
2610 (setq completions (cons name completions))))
2611 (nreverse completions))))
2612
2613;;; Info mode node listing
3cb6768f
EL
2614(defun Info-speedbar-buttons (buffer)
2615 "Create a speedbar display to help navigation in an Info file.
2616BUFFER is the buffer speedbar is requesting buttons for."
96ee3f29 2617 (if (save-excursion (goto-char (point-min))
1bcedb3b
RS
2618 (let ((case-fold-search t))
2619 (not (looking-at "Info Nodes:"))))
96ee3f29
KH
2620 (erase-buffer))
2621 (Info-speedbar-hierarchy-buttons nil 0)
2622 )
49116ac0 2623
48e5b471
DL
2624(dolist (mess '("^Node has no Previous$"
2625 "^No menu in this node$"
2626 "^Node has no Next$"
399c88ad
SS
2627 "^No cross-references in this node^"
2628 search-failed
48e5b471
DL
2629 "^No \".*\" in index$"))
2630 (add-to-list 'debug-ignored-errors mess))
2631
49116ac0
JB
2632(provide 'info)
2633
1a06eabd 2634;;; info.el ends here