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