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