(change-log-font-lock-keywords): Names in parenthesized lists can
[emacs.git] / lisp / info.el
blobcefe603a4001b2a95521370c736b683f0246fdd8
1 ;;; info.el --- info package for Emacs
3 ;; Copyright (C) 1985,86,92,93,94,95,96,97,98,99,2000,01,02,03,2004
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.
29 ;; In particular we make these assumptions:
30 ;; - a menu item MAY contain colons but not colon-space ": "
31 ;; - a menu item ending with ": " (but not ":: ") is an index entry
32 ;; - a node name MAY NOT contain a colon
33 ;; This distinction is to support indexing of computer programming
34 ;; language terms that may contain ":" but not ": ".
36 ;;; Code:
38 (eval-when-compile (require 'jka-compr))
40 (defgroup info nil
41 "Info subsystem"
42 :group 'help
43 :group 'docs)
46 (defvar Info-history nil
47 "Stack of info nodes user has visited.
48 Each element of list is a list (FILENAME NODENAME BUFFERPOS).")
50 (defvar Info-history-forward nil
51 "Stack of info nodes user has visited with `Info-history-back' command.
52 Each element of list is a list (FILENAME NODENAME BUFFERPOS).")
54 (defvar Info-history-list nil
55 "List of all info nodes user has visited.
56 Each element of list is a list (FILENAME NODENAME).")
58 (defcustom Info-enable-edit nil
59 "*Non-nil means the \\<Info-mode-map>\\[Info-edit] command in Info can edit the current node.
60 This is convenient if you want to write info files by hand.
61 However, we recommend that you not do this.
62 It is better to write a Texinfo file and generate the Info file from that,
63 because that gives you a printed manual as well."
64 :type 'boolean
65 :group 'info)
67 (defvar Info-enable-active-nodes nil
68 "Non-nil allows Info to execute Lisp code associated with nodes.
69 The Lisp code is executed when the node is selected.")
70 (put 'Info-enable-active-nodes 'risky-local-variable t)
72 (defface info-node
73 '((((class color) (background light)) :foreground "brown" :weight bold :slant italic)
74 (((class color) (background dark)) :foreground "white" :weight bold :slant italic)
75 (t :weight bold :slant italic))
76 "Face for Info node names."
77 :group 'info)
79 (defface info-menu-5
80 '((((class color)) :foreground "red1")
81 (t :underline t))
82 "Face for every third `*' in an Info menu."
83 :group 'info)
85 (defface info-xref
86 '((((class color) (background light)) :foreground "blue" :underline t)
87 (((class color) (background dark)) :foreground "cyan" :underline t)
88 (t :underline t))
89 "Face for Info cross-references."
90 :group 'info)
92 (defface info-xref-visited
93 '((default :inherit info-xref)
94 (((class color) (background light)) :foreground "magenta4")
95 (((class color) (background dark)) :foreground "magenta3")) ;"violet"?
96 "Face for visited Info cross-references."
97 :group 'info)
99 (defcustom Info-fontify-visited-nodes t
100 "*Non-nil means to fontify visited nodes in a different face."
101 :version "22.1"
102 :type 'boolean
103 :group 'info)
105 (defcustom Info-fontify-maximum-menu-size 100000
106 "*Maximum size of menu to fontify if `font-lock-mode' is non-nil."
107 :type 'integer
108 :group 'info)
110 (defcustom Info-use-header-line t
111 "*Non-nil means to put the beginning-of-node links in an Emacs header-line.
112 A header-line does not scroll with the rest of the buffer."
113 :type 'boolean
114 :group 'info)
116 (defface info-header-xref
117 '((t :inherit info-xref))
118 "Face for Info cross-references in a node header."
119 :group 'info)
121 (defface info-header-node
122 '((t :inherit info-node))
123 "Face for Info nodes in a node header."
124 :group 'info)
126 (defvar Info-directory-list nil
127 "List of directories to search for Info documentation files.
128 If nil, meaning not yet initialized, Info uses the environment
129 variable INFOPATH to initialize it, or `Info-default-directory-list'
130 if there is no INFOPATH variable in the environment, or the
131 concatenation of the two if INFOPATH ends with a colon.
133 When `Info-directory-list' is initialized from the value of
134 `Info-default-directory-list', and Emacs is installed in one of the
135 standard directories, the directory of Info files that come with Emacs
136 is put last (so that local Info files override standard ones).
138 When `Info-directory-list' is initialized from the value of
139 `Info-default-directory-list', and Emacs is not installed in one
140 of the standard directories, the first element of the resulting
141 list is the directory where Emacs installs the Info files that
142 come with it. This is so that Emacs's own manual, which suits the
143 version of Emacs you are using, will always be found first. This
144 is useful when you install an experimental version of Emacs without
145 removing the standard installation.
147 If you want to override the order of directories in
148 `Info-default-directory-list', set INFOPATH in the environment.
150 If you run the Emacs executable from the `src' directory in the Emacs
151 source tree, and INFOPATH is not defined, the `info' directory in the
152 source tree is used as the first element of `Info-directory-list', in
153 place of the installation Info directory. This is useful when you run
154 a version of Emacs without installing it.")
156 (defcustom Info-additional-directory-list nil
157 "List of additional directories to search for Info documentation files.
158 These directories are searched after those in `Info-directory-list'."
159 :type '(repeat directory)
160 :group 'info)
162 (defcustom Info-scroll-prefer-subnodes nil
163 "*If non-nil, \\<Info-mode-map>\\[Info-scroll-up] in a menu visits subnodes.
164 If this is non-nil, and you scroll far enough in a node that its menu
165 appears on the screen, the next \\<Info-mode-map>\\[Info-scroll-up]
166 moves to a subnode indicated by the following menu item. This means
167 that you visit a subnode before getting to the end of the menu.
169 Setting this option to nil results in behavior similar to the stand-alone
170 Info reader program, which visits the first subnode from the menu only
171 when you hit the end of the current node."
172 :version "22.1"
173 :type 'boolean
174 :group 'info)
176 (defcustom Info-hide-note-references t
177 "*If non-nil, hide the tag and section reference in *note and * menu items.
178 If value is non-nil but not `hide', also replaces the \"*note\" with \"see\".
179 If value is non-nil but not t or `hide', the reference section is still shown."
180 :version "22.1"
181 :type '(choice (const :tag "No hiding" nil)
182 (const :tag "Replace tag and hide reference" t)
183 (const :tag "Hide tag and reference" hide)
184 (other :tag "Only replace tag" tag))
185 :group 'info)
187 (defcustom Info-refill-paragraphs nil
188 "*If non-nil, attempt to refill paragraphs with hidden references.
189 This refilling may accidentally remove explicit line breaks in the info
190 file, so be prepared for a few surprises if you enable this feature."
191 :version "22.1"
192 :type 'boolean
193 :group 'info)
195 (defcustom Info-search-whitespace-regexp "\\s-+"
196 "*If non-nil, regular expression to match a sequence of whitespace chars.
197 This applies to Info search for regular expressions.
198 You might want to use something like \"[ \\t\\r\\n]+\" instead.
199 In the Customization buffer, that is `[' followed by a space,
200 a tab, a carriage return (control-M), a newline, and `]+'."
201 :type 'regexp
202 :group 'info)
204 (defcustom Info-isearch-search t
205 "*If non-nil, isearch in Info searches through multiple nodes.
206 Before leaving the initial Info node, where isearch was started,
207 it fails once with the error message [initial node], and with
208 subsequent C-s/C-r continues through other nodes without failing
209 with this error message in other nodes. When isearch fails for
210 the rest of the manual, it wraps aroung the whole manual and
211 restarts the search from the top/final node depending on
212 search direction.
214 Setting this option to nil restores the default isearch behavior
215 with wrapping around the current Info node."
216 :version "22.1"
217 :type 'boolean
218 :group 'info)
220 (defvar Info-isearch-initial-node nil)
222 (defcustom Info-mode-hook
223 ;; Try to obey obsolete Info-fontify settings.
224 (unless (and (boundp 'Info-fontify) (null Info-fontify))
225 '(turn-on-font-lock))
226 "Hooks run when `Info-mode' is called."
227 :type 'hook
228 :group 'info)
230 (defcustom Info-selection-hook nil
231 "Hooks run when `Info-select-node' is called."
232 :type 'hook
233 :group 'info)
235 (defvar Info-edit-mode-hook nil
236 "Hooks run when `Info-edit-mode' is called.")
238 (defvar Info-current-file nil
239 "Info file that Info is now looking at, or nil.
240 This is the name that was specified in Info, not the actual file name.
241 It doesn't contain directory names or file name extensions added by Info.
242 Can also be t when using `Info-on-current-buffer'.")
244 (defvar Info-current-subfile nil
245 "Info subfile that is actually in the *info* buffer now.
246 nil if current info file is not split into subfiles.")
248 (defvar Info-current-node nil
249 "Name of node that Info is now looking at, or nil.")
251 (defvar Info-tag-table-marker nil
252 "Marker pointing at beginning of current Info file's tag table.
253 Marker points nowhere if file has no tag table.")
255 (defvar Info-tag-table-buffer nil
256 "Buffer used for indirect tag tables.")
258 (defvar Info-current-file-completions nil
259 "Cached completion list for current Info file.")
261 (defvar Info-index-alternatives nil
262 "List of possible matches for last `Info-index' command.")
264 (defvar Info-point-loc nil
265 "Point location within a selected node.
266 If string, the point is moved to the proper occurrence of the
267 name of the followed cross reference within a selected node.
268 If number, the point is moved to the corresponding line.")
270 (defvar Info-standalone nil
271 "Non-nil if Emacs was started solely as an Info browser.")
273 (defvar Info-suffix-list
274 ;; The MS-DOS list should work both when long file names are
275 ;; supported (Windows 9X), and when only 8+3 file names are available.
276 (if (eq system-type 'ms-dos)
277 '( (".gz" . "gunzip")
278 (".z" . "gunzip")
279 (".bz2" . ("bzip2" "-dc"))
280 (".inz" . "gunzip")
281 (".igz" . "gunzip")
282 (".info.Z" . "gunzip")
283 (".info.gz" . "gunzip")
284 ("-info.Z" . "gunzip")
285 ("-info.gz" . "gunzip")
286 ("/index.gz". "gunzip")
287 ("/index.z" . "gunzip")
288 (".inf" . nil)
289 (".info" . nil)
290 ("-info" . nil)
291 ("/index" . nil)
292 ("" . nil))
293 '( (".info.Z". "uncompress")
294 (".info.Y". "unyabba")
295 (".info.gz". "gunzip")
296 (".info.z". "gunzip")
297 (".info.bz2" . ("bzip2" "-dc"))
298 (".info". nil)
299 ("-info.Z". "uncompress")
300 ("-info.Y". "unyabba")
301 ("-info.gz". "gunzip")
302 ("-info.bz2" . ("bzip2" "-dc"))
303 ("-info.z". "gunzip")
304 ("-info". nil)
305 ("/index.Z". "uncompress")
306 ("/index.Y". "unyabba")
307 ("/index.gz". "gunzip")
308 ("/index.z". "gunzip")
309 ("/index.bz2". ("bzip2" "-dc"))
310 ("/index". nil)
311 (".Z". "uncompress")
312 (".Y". "unyabba")
313 (".gz". "gunzip")
314 (".z". "gunzip")
315 (".bz2" . ("bzip2" "-dc"))
316 ("". nil)))
317 "List of file name suffixes and associated decoding commands.
318 Each entry should be (SUFFIX . STRING); the file is given to
319 the command as standard input.
321 STRING may be a list of strings. In that case, the first element is
322 the command name, and the rest are arguments to that command.
324 If STRING is nil, no decoding is done.
325 Because the SUFFIXes are tried in order, the empty string should
326 be last in the list.")
328 ;; Concatenate SUFFIX onto FILENAME. SUFFIX should start with a dot.
329 ;; First, on MS-DOS with no long file names support, delete some of
330 ;; the extension in FILENAME to make room.
331 (defun info-insert-file-contents-1 (filename suffix lfn)
332 (if lfn ; long file names are supported
333 (concat filename suffix)
334 (let* ((sans-exts (file-name-sans-extension filename))
335 ;; How long is the extension in FILENAME (not counting the dot).
336 (ext-len (max 0 (- (length filename) (length sans-exts) 1)))
337 ext-left)
338 ;; SUFFIX starts with a dot. If FILENAME already has one,
339 ;; get rid of the one in SUFFIX (unless suffix is empty).
340 (or (and (<= ext-len 0)
341 (not (eq (aref filename (1- (length filename))) ?.)))
342 (= (length suffix) 0)
343 (setq suffix (substring suffix 1)))
344 ;; How many chars of that extension should we keep?
345 (setq ext-left (min ext-len (max 0 (- 3 (length suffix)))))
346 ;; Get rid of the rest of the extension, and add SUFFIX.
347 (concat (substring filename 0 (- (length filename)
348 (- ext-len ext-left)))
349 suffix))))
351 (defun info-file-exists-p (filename)
352 (and (file-exists-p filename)
353 (not (file-directory-p filename))))
355 (defun info-insert-file-contents (filename &optional visit)
356 "Insert the contents of an info file in the current buffer.
357 Do the right thing if the file has been compressed or zipped."
358 (let* ((tail Info-suffix-list)
359 (lfn (if (fboundp 'msdos-long-file-names)
360 (msdos-long-file-names)
362 (check-short (and (fboundp 'msdos-long-file-names)
363 lfn))
364 fullname decoder done)
365 (if (info-file-exists-p filename)
366 ;; FILENAME exists--see if that name contains a suffix.
367 ;; If so, set DECODE accordingly.
368 (progn
369 (while (and tail
370 (not (string-match
371 (concat (regexp-quote (car (car tail))) "$")
372 filename)))
373 (setq tail (cdr tail)))
374 (setq fullname filename
375 decoder (cdr (car tail))))
376 ;; Try adding suffixes to FILENAME and see if we can find something.
377 (while (and tail (not done))
378 (setq fullname (info-insert-file-contents-1 filename
379 (car (car tail)) lfn))
380 (if (info-file-exists-p fullname)
381 (setq done t
382 ;; If we found a file with a suffix, set DECODER
383 ;; according to the suffix.
384 decoder (cdr (car tail)))
385 ;; When the MS-DOS port runs on Windows, we need to check
386 ;; the short variant of a long file name as well.
387 (when check-short
388 (setq fullname (info-insert-file-contents-1 filename
389 (car (car tail)) nil))
390 (if (info-file-exists-p fullname)
391 (setq done t
392 decoder (cdr (car tail))))))
393 (setq tail (cdr tail)))
394 (or tail
395 (error "Can't find %s or any compressed version of it" filename)))
396 ;; check for conflict with jka-compr
397 (if (and (featurep 'jka-compr)
398 (jka-compr-installed-p)
399 (jka-compr-get-compression-info fullname))
400 (setq decoder nil))
401 (if decoder
402 (progn
403 (insert-file-contents-literally fullname visit)
404 (let ((buffer-read-only nil)
405 (coding-system-for-write 'no-conversion)
406 (default-directory (or (file-name-directory fullname)
407 default-directory)))
408 (or (consp decoder)
409 (setq decoder (list decoder)))
410 (apply 'call-process-region (point-min) (point-max)
411 (car decoder) t t nil (cdr decoder))))
412 (insert-file-contents fullname visit))))
414 (defun Info-default-dirs ()
415 (let ((source (expand-file-name "info/" source-directory))
416 (sibling (if installation-directory
417 (expand-file-name "info/" installation-directory)
418 (if invocation-directory
419 (let ((infodir (expand-file-name
420 "../info/"
421 invocation-directory)))
422 (if (file-exists-p infodir)
423 infodir
424 (setq infodir (expand-file-name
425 "../../../info/"
426 invocation-directory))
427 (and (file-exists-p infodir)
428 infodir))))))
429 alternative)
430 (setq alternative
431 (if (and sibling (file-exists-p sibling))
432 ;; Uninstalled, Emacs builddir != srcdir.
433 sibling
434 ;; Uninstalled, builddir == srcdir
435 source))
436 (if (or (member alternative Info-default-directory-list)
437 ;; On DOS/NT, we use movable executables always,
438 ;; and we must always find the Info dir at run time.
439 (if (memq system-type '(ms-dos windows-nt))
441 ;; Use invocation-directory for Info
442 ;; only if we used it for exec-directory also.
443 (not (string= exec-directory
444 (expand-file-name "lib-src/"
445 installation-directory))))
446 (not (file-exists-p alternative)))
447 Info-default-directory-list
448 ;; `alternative' contains the Info files that came with this
449 ;; version, so we should look there first. `Info-insert-dir'
450 ;; currently expects to find `alternative' first on the list.
451 (cons alternative
452 ;; Don't drop the last part, it might contain non-Emacs stuff.
453 ;; (reverse (cdr (reverse
454 Info-default-directory-list)))) ;; )))
456 (defun info-initialize ()
457 "Initialize `Info-directory-list', if that hasn't been done yet."
458 (unless Info-directory-list
459 (let ((path (getenv "INFOPATH")))
460 (setq Info-directory-list
461 (prune-directory-list
462 (if path
463 (if (string-match ":\\'" path)
464 (append (split-string (substring path 0 -1)
465 (regexp-quote path-separator))
466 (Info-default-dirs))
467 (split-string path (regexp-quote path-separator)))
468 (Info-default-dirs)))))))
470 ;;;###autoload
471 (defun info-other-window (&optional file)
472 "Like `info' but show the Info buffer in another window."
473 (interactive (if current-prefix-arg
474 (list (read-file-name "Info file name: " nil nil t))))
475 (let (same-window-buffer-names same-window-regexps)
476 (info file)))
478 ;;;###autoload (add-hook 'same-window-regexps "\\*info\\*\\(\\|<[0-9]+>\\)")
480 ;;;###autoload (put 'info 'info-file "emacs")
481 ;;;###autoload
482 (defun info (&optional file buffer)
483 "Enter Info, the documentation browser.
484 Optional argument FILE specifies the file to examine;
485 the default is the top-level directory of Info.
486 Called from a program, FILE may specify an Info node of the form
487 `(FILENAME)NODENAME'.
488 Optional argument BUFFER specifies the Info buffer name;
489 the default buffer name is *info*. If BUFFER exists,
490 just switch to BUFFER. Otherwise, create a new buffer
491 with the top-level Info directory.
493 In interactive use, a non-numeric prefix argument directs
494 this command to read a file name from the minibuffer.
495 A numeric prefix argument selects an Info buffer with the prefix number
496 appended to the Info buffer name.
498 The search path for Info files is in the variable `Info-directory-list'.
499 The top-level Info directory is made by combining all the files named `dir'
500 in all the directories in that path."
501 (interactive (list
502 (if (and current-prefix-arg (not (numberp current-prefix-arg)))
503 (read-file-name "Info file name: " nil nil t))
504 (if (numberp current-prefix-arg)
505 (format "*info*<%s>" current-prefix-arg))))
506 (pop-to-buffer (or buffer "*info*"))
507 (if (and buffer (not (eq major-mode 'Info-mode)))
508 (Info-mode))
509 (if file
510 ;; If argument already contains parentheses, don't add another set
511 ;; since the argument will then be parsed improperly. This also
512 ;; has the added benefit of allowing node names to be included
513 ;; following the parenthesized filename.
514 (if (and (stringp file) (string-match "(.*)" file))
515 (Info-goto-node file)
516 (Info-goto-node (concat "(" file ")")))
517 (if (zerop (buffer-size))
518 (Info-directory))))
520 ;;;###autoload
521 (defun info-emacs-manual ()
522 "Display the Emacs manual in Info mode."
523 (interactive)
524 (info "emacs"))
526 ;;;###autoload
527 (defun info-standalone ()
528 "Run Emacs as a standalone Info reader.
529 Usage: emacs -f info-standalone [filename]
530 In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
531 (setq Info-standalone t)
532 (if (and command-line-args-left
533 (not (string-match "^-" (car command-line-args-left))))
534 (condition-case err
535 (progn
536 (info (car command-line-args-left))
537 (setq command-line-args-left (cdr command-line-args-left)))
538 (error (send-string-to-terminal
539 (format "%s\n" (if (eq (car-safe err) 'error)
540 (nth 1 err) err)))
541 (save-buffers-kill-emacs)))
542 (info)))
544 ;; See if the accessible portion of the buffer begins with a node
545 ;; delimiter, and the node header line which follows matches REGEXP.
546 ;; Typically, this test will be followed by a loop that examines the
547 ;; rest of the buffer with (search-forward "\n\^_"), and it's a pity
548 ;; to have the overhead of this special test inside the loop.
550 ;; This function changes match-data, but supposedly the caller might
551 ;; want to use the results of re-search-backward.
553 ;; The return value is the value of point at the beginning of matching
554 ;; REGEXP, if the function succeeds, nil otherwise.
555 (defun Info-node-at-bob-matching (regexp)
556 (and (bobp) ; are we at beginning of buffer?
557 (looking-at "\^_") ; does it begin with node delimiter?
558 (let (beg)
559 (forward-line 1)
560 (setq beg (point))
561 (forward-line 1) ; does the line after delimiter match REGEXP?
562 (re-search-backward regexp beg t))))
564 (defun Info-find-file (filename &optional noerror)
565 "Return expanded FILENAME, or t, if FILENAME is \"dir\".
566 Optional second argument NOERROR, if t, means if file is not found
567 just return nil (no error)."
568 ;; Convert filename to lower case if not found as specified.
569 ;; Expand it.
570 (if (stringp filename)
571 (let (temp temp-downcase found)
572 (setq filename (substitute-in-file-name filename))
573 (cond
574 ((string= (downcase filename) "dir")
575 (setq found t))
576 ((string= filename "apropos")
577 (setq found 'apropos))
578 ((string= filename "history")
579 (setq found 'history))
580 ((string= filename "toc")
581 (setq found 'toc))
583 (let ((dirs (if (string-match "^\\./" filename)
584 ;; If specified name starts with `./'
585 ;; then just try current directory.
586 '("./")
587 (if (file-name-absolute-p filename)
588 ;; No point in searching for an
589 ;; absolute file name
590 '(nil)
591 (if Info-additional-directory-list
592 (append Info-directory-list
593 Info-additional-directory-list)
594 Info-directory-list)))))
595 ;; Search the directory list for file FILENAME.
596 (while (and dirs (not found))
597 (setq temp (expand-file-name filename (car dirs)))
598 (setq temp-downcase
599 (expand-file-name (downcase filename) (car dirs)))
600 ;; Try several variants of specified name.
601 (let ((suffix-list Info-suffix-list)
602 (lfn (if (fboundp 'msdos-long-file-names)
603 (msdos-long-file-names)
604 t)))
605 (while (and suffix-list (not found))
606 (cond ((info-file-exists-p
607 (info-insert-file-contents-1
608 temp (car (car suffix-list)) lfn))
609 (setq found temp))
610 ((info-file-exists-p
611 (info-insert-file-contents-1
612 temp-downcase (car (car suffix-list)) lfn))
613 (setq found temp-downcase))
614 ((and (fboundp 'msdos-long-file-names)
616 (info-file-exists-p
617 (info-insert-file-contents-1
618 temp (car (car suffix-list)) nil)))
619 (setq found temp)))
620 (setq suffix-list (cdr suffix-list))))
621 (setq dirs (cdr dirs))))))
622 (if found
623 (setq filename found)
624 (if noerror
625 (setq filename nil)
626 (error "Info file %s does not exist" filename)))
627 filename)))
629 (defun Info-find-node (filename nodename &optional no-going-back)
630 "Go to an info node specified as separate FILENAME and NODENAME.
631 NO-GOING-BACK is non-nil if recovering from an error in this function;
632 it says do not attempt further (recursive) error recovery."
633 (info-initialize)
634 (setq filename (Info-find-file filename))
635 ;; Go into info buffer.
636 (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*"))
637 ;; Record the node we are leaving.
638 (if (and Info-current-file (not no-going-back))
639 (setq Info-history
640 (cons (list Info-current-file Info-current-node (point))
641 Info-history)))
642 (Info-find-node-2 filename nodename no-going-back))
644 (defun Info-on-current-buffer (&optional nodename)
645 "Use the `Info-mode' to browse the current info buffer.
646 If a prefix arg is provided, it queries for the NODENAME which
647 else defaults to \"Top\"."
648 (interactive
649 (list (if current-prefix-arg
650 (completing-read "Node name: " (Info-build-node-completions)
651 nil t "Top"))))
652 (unless nodename (setq nodename "Top"))
653 (info-initialize)
654 (Info-mode)
655 (set (make-local-variable 'Info-current-file) t)
656 (Info-find-node-2 nil nodename))
658 ;; It's perhaps a bit nasty to kill the *info* buffer to force a re-read,
659 ;; but at least it keeps this routine (which is only for the benefit of
660 ;; makeinfo-buffer) out of the way of normal operations.
662 (defun Info-revert-find-node (filename nodename)
663 "Go to an info node FILENAME and NODENAME, re-reading disk contents.
664 When *info* is already displaying FILENAME and NODENAME, the window position
665 is preserved, if possible."
666 (pop-to-buffer "*info*")
667 (let ((old-filename Info-current-file)
668 (old-nodename Info-current-node)
669 (pcolumn (current-column))
670 (pline (count-lines (point-min) (line-beginning-position)))
671 (wline (count-lines (point-min) (window-start)))
672 (old-history Info-history)
673 (new-history (and Info-current-file
674 (list Info-current-file Info-current-node (point)))))
675 (kill-buffer (current-buffer))
676 (Info-find-node filename nodename)
677 (setq Info-history old-history)
678 (if (and (equal old-filename Info-current-file)
679 (equal old-nodename Info-current-node))
680 (progn
681 ;; note goto-line is no good, we want to measure from point-min
682 (goto-char (point-min))
683 (forward-line wline)
684 (set-window-start (selected-window) (point))
685 (goto-char (point-min))
686 (forward-line pline)
687 (move-to-column pcolumn))
688 ;; only add to the history when coming from a different file+node
689 (if new-history
690 (setq Info-history (cons new-history Info-history))))))
692 (defun Info-find-in-tag-table-1 (marker regexp case-fold)
693 "Find a node in a tag table.
694 MARKER specifies the buffer and position to start searching at.
695 REGEXP is a regular expression matching nodes or references. Its first
696 group should match `Node:' or `Ref:'.
697 CASE-FOLD t means search for a case-insensitive match.
698 If a match was found, value is a list (FOUND-ANCHOR POS MODE), where
699 FOUND-ANCHOR is non-nil if a `Ref:' was matched, POS is the position
700 where the match was found, and MODE is `major-mode' of the buffer in
701 which the match was found."
702 (let ((case-fold-search case-fold))
703 (save-excursion
704 (set-buffer (marker-buffer marker))
705 (goto-char marker)
707 ;; Search tag table
708 (beginning-of-line)
709 (when (re-search-forward regexp nil t)
710 (list (string-equal "Ref:" (match-string 1))
711 (+ (point-min) (read (current-buffer)))
712 major-mode)))))
714 (defun Info-find-in-tag-table (marker regexp)
715 "Find a node in a tag table.
716 MARKER specifies the buffer and position to start searching at.
717 REGEXP is a regular expression matching nodes or references. Its first
718 group should match `Node:' or `Ref:'.
719 If a match was found, value is a list (FOUND-ANCHOR POS MODE), where
720 FOUND-ANCHOR is non-nil if a `Ref:' was matched, POS is the position
721 where the match was found, and MODE is `major-mode' of the buffer in
722 which the match was found.
723 This function tries to find a case-sensitive match first, then a
724 case-insensitive match is tried."
725 (let ((result (Info-find-in-tag-table-1 marker regexp nil)))
726 (when (null (car result))
727 (setq result (Info-find-in-tag-table-1 marker regexp t)))
728 result))
730 (defun Info-find-node-in-buffer-1 (regexp case-fold)
731 "Find a node or anchor in the current buffer.
732 REGEXP is a regular expression matching nodes or references. Its first
733 group should match `Node:' or `Ref:'.
734 CASE-FOLD t means search for a case-insensitive match.
735 Value is the position at which a match was found, or nil if not found."
736 (let ((case-fold-search case-fold)
737 found)
738 (save-excursion
739 (when (Info-node-at-bob-matching regexp)
740 (setq found (point)))
741 (while (and (not found)
742 (search-forward "\n\^_" nil t))
743 (forward-line 1)
744 (let ((beg (point)))
745 (forward-line 1)
746 (when (re-search-backward regexp beg t)
747 (beginning-of-line)
748 (setq found (point)))))
749 found)))
751 (defun Info-find-node-in-buffer (regexp)
752 "Find a node or anchor in the current buffer.
753 REGEXP is a regular expression matching nodes or references. Its first
754 group should match `Node:' or `Ref:'.
755 Value is the position at which a match was found, or nil if not found.
756 This function looks for a case-sensitive match first. If none is found,
757 a case-insensitive match is tried."
758 (or (Info-find-node-in-buffer-1 regexp nil)
759 (Info-find-node-in-buffer-1 regexp t)))
761 (defun Info-find-node-2 (filename nodename &optional no-going-back)
762 (buffer-disable-undo (current-buffer))
763 (or (eq major-mode 'Info-mode)
764 (Info-mode))
765 (widen)
766 (setq Info-current-node nil)
767 (unwind-protect
768 (let ((case-fold-search t)
769 anchorpos)
770 ;; Switch files if necessary
771 (or (null filename)
772 (equal Info-current-file filename)
773 (let ((buffer-read-only nil))
774 (setq Info-current-file nil
775 Info-current-subfile nil
776 Info-current-file-completions nil
777 buffer-file-name nil)
778 (erase-buffer)
779 (cond
780 ((eq filename t)
781 (Info-insert-dir))
782 ((eq filename 'apropos)
783 (insert-buffer-substring " *info-apropos*"))
784 ((eq filename 'history)
785 (insert-buffer-substring " *info-history*"))
786 ((eq filename 'toc)
787 (insert-buffer-substring " *info-toc*"))
789 (info-insert-file-contents filename nil)
790 (setq default-directory (file-name-directory filename))))
791 (set-buffer-modified-p nil)
792 ;; See whether file has a tag table. Record the location if yes.
793 (goto-char (point-max))
794 (forward-line -8)
795 ;; Use string-equal, not equal, to ignore text props.
796 (if (not (or (string-equal nodename "*")
797 (not
798 (search-forward "\^_\nEnd tag table\n" nil t))))
799 (let (pos)
800 ;; We have a tag table. Find its beginning.
801 ;; Is this an indirect file?
802 (search-backward "\nTag table:\n")
803 (setq pos (point))
804 (if (save-excursion
805 (forward-line 2)
806 (looking-at "(Indirect)\n"))
807 ;; It is indirect. Copy it to another buffer
808 ;; and record that the tag table is in that buffer.
809 (let ((buf (current-buffer))
810 (tagbuf
811 (or Info-tag-table-buffer
812 (generate-new-buffer " *info tag table*"))))
813 (setq Info-tag-table-buffer tagbuf)
814 (save-excursion
815 (set-buffer tagbuf)
816 (buffer-disable-undo (current-buffer))
817 (setq case-fold-search t)
818 (erase-buffer)
819 (insert-buffer-substring buf))
820 (set-marker Info-tag-table-marker
821 (match-end 0) tagbuf))
822 (set-marker Info-tag-table-marker pos)))
823 (set-marker Info-tag-table-marker nil))
824 (setq Info-current-file
825 (cond
826 ((eq filename t) "dir")
827 ((eq filename 'apropos) "apropos")
828 ((eq filename 'history) "history")
829 ((eq filename 'toc) "toc")
830 (t filename)))
832 ;; Use string-equal, not equal, to ignore text props.
833 (if (string-equal nodename "*")
834 (progn (setq Info-current-node nodename)
835 (Info-set-mode-line))
836 ;; Possibilities:
838 ;; 1. Anchor found in tag table
839 ;; 2. Anchor *not* in tag table
841 ;; 3. Node found in tag table
842 ;; 4. Node *not* found in tag table, but found in file
843 ;; 5. Node *not* in tag table, and *not* in file
845 ;; *Or* the same, but in an indirect subfile.
847 ;; Search file for a suitable node.
848 (let ((guesspos (point-min))
849 (regexp (concat "\\(Node:\\|Ref:\\) *\\("
850 (if (stringp nodename)
851 (regexp-quote nodename)
853 "\\) *[,\t\n\177]")))
855 (catch 'foo
857 ;; First, search a tag table, if any
858 (when (marker-position Info-tag-table-marker)
859 (let* ((m Info-tag-table-marker)
860 (found (Info-find-in-tag-table m regexp)))
862 (when found
863 ;; FOUND is (ANCHOR POS MODE).
864 (setq guesspos (nth 1 found))
866 ;; If this is an indirect file, determine which
867 ;; file really holds this node and read it in.
868 (unless (eq (nth 2 found) 'Info-mode)
869 ;; Note that the current buffer must be the
870 ;; *info* buffer on entry to
871 ;; Info-read-subfile. Thus the hackery above.
872 (setq guesspos (Info-read-subfile guesspos)))
874 ;; Handle anchor
875 (when (nth 0 found)
876 (goto-char (setq anchorpos guesspos))
877 (throw 'foo t)))))
879 ;; Else we may have a node, which we search for:
880 (goto-char (max (point-min)
881 (- (byte-to-position guesspos) 1000)))
883 ;; Now search from our advised position (or from beg of
884 ;; buffer) to find the actual node. First, check
885 ;; whether the node is right where we are, in case the
886 ;; buffer begins with a node.
887 (let ((pos (Info-find-node-in-buffer regexp)))
888 (when pos
889 (goto-char pos)
890 (throw 'foo t)))
892 (when (string-match "\\([^.]+\\)\\." nodename)
893 (let (Info-point-loc)
894 (Info-find-node-2
895 filename (match-string 1 nodename) no-going-back))
896 (widen)
897 (throw 'foo t))
899 ;; No such anchor in tag table or node in tag table or file
900 (error "No such node or anchor: %s" nodename))
902 (Info-select-node)
903 (goto-char (point-min))
904 (cond (anchorpos
905 (let ((new-history (list Info-current-file
906 (substring-no-properties nodename))))
907 ;; Add anchors to the history too
908 (setq Info-history-list
909 (cons new-history
910 (delete new-history Info-history-list))))
911 (goto-char anchorpos))
912 ((numberp Info-point-loc)
913 (forward-line (1- Info-point-loc))
914 (setq Info-point-loc nil))
915 ((stringp Info-point-loc)
916 (Info-find-index-name Info-point-loc)
917 (setq Info-point-loc nil))))))
918 ;; If we did not finish finding the specified node,
919 ;; go back to the previous one.
920 (or Info-current-node no-going-back (null Info-history)
921 (let ((hist (car Info-history)))
922 (setq Info-history (cdr Info-history))
923 (Info-find-node (nth 0 hist) (nth 1 hist) t)
924 (goto-char (nth 2 hist))))))
926 ;; Cache the contents of the (virtual) dir file, once we have merged
927 ;; it for the first time, so we can save time subsequently.
928 (defvar Info-dir-contents nil)
930 ;; Cache for the directory we decided to use for the default-directory
931 ;; of the merged dir text.
932 (defvar Info-dir-contents-directory nil)
934 ;; Record the file attributes of all the files from which we
935 ;; constructed Info-dir-contents.
936 (defvar Info-dir-file-attributes nil)
938 (defvar Info-dir-file-name nil)
940 ;; Construct the Info directory node by merging the files named `dir'
941 ;; from various directories. Set the *info* buffer's
942 ;; default-directory to the first directory we actually get any text
943 ;; from.
944 (defun Info-insert-dir ()
945 (if (and Info-dir-contents Info-dir-file-attributes
946 ;; Verify that none of the files we used has changed
947 ;; since we used it.
948 (eval (cons 'and
949 (mapcar (lambda (elt)
950 (let ((curr (file-attributes
951 ;; Handle symlinks
952 (file-truename (car elt)))))
954 ;; Don't compare the access time.
955 (if curr (setcar (nthcdr 4 curr) 0))
956 (setcar (nthcdr 4 (cdr elt)) 0)
957 (equal (cdr elt) curr)))
958 Info-dir-file-attributes))))
959 (progn
960 (insert Info-dir-contents)
961 (goto-char (point-min)))
962 (let ((dirs (if Info-additional-directory-list
963 (append Info-directory-list
964 Info-additional-directory-list)
965 Info-directory-list))
966 (dir-file-attrs nil)
967 ;; Bind this in case the user sets it to nil.
968 (case-fold-search t)
969 ;; This is set non-nil if we find a problem in some input files.
970 problems
971 buffers buffer others nodes dirs-done)
973 ;; Search the directory list for the directory file.
974 (while dirs
975 (let ((truename (file-truename (expand-file-name (car dirs)))))
976 (or (member truename dirs-done)
977 (member (directory-file-name truename) dirs-done)
978 ;; Try several variants of specified name.
979 ;; Try upcasing, appending `.info', or both.
980 (let* (file
981 (attrs
983 (progn (setq file (expand-file-name "dir" truename))
984 (file-attributes file))
985 (progn (setq file (expand-file-name "DIR" truename))
986 (file-attributes file))
987 (progn (setq file (expand-file-name "dir.info" truename))
988 (file-attributes file))
989 (progn (setq file (expand-file-name "DIR.INFO" truename))
990 (file-attributes file)))))
991 (setq dirs-done
992 (cons truename
993 (cons (directory-file-name truename)
994 dirs-done)))
995 (if attrs
996 (save-excursion
997 (or buffers
998 (message "Composing main Info directory..."))
999 (set-buffer (generate-new-buffer " info dir"))
1000 (condition-case nil
1001 (progn
1002 (insert-file-contents file)
1003 (set (make-local-variable 'Info-dir-file-name)
1004 file)
1005 (push (current-buffer) buffers)
1006 (push (cons file attrs) dir-file-attrs))
1007 (error (kill-buffer (current-buffer))))))))
1008 (unless (cdr dirs)
1009 (set (make-local-variable 'Info-dir-contents-directory)
1010 (file-name-as-directory (car dirs))))
1011 (setq dirs (cdr dirs))))
1013 (or buffers
1014 (error "Can't find the Info directory node"))
1016 ;; Distinguish the dir file that comes with Emacs from all the
1017 ;; others. Yes, that is really what this is supposed to do.
1018 ;; The definition of `Info-directory-list' puts it first on that
1019 ;; list and so last in `buffers' at this point.
1020 (setq buffer (car (last buffers))
1021 others (delq buffer buffers))
1023 ;; Insert the entire original dir file as a start; note that we've
1024 ;; already saved its default directory to use as the default
1025 ;; directory for the whole concatenation.
1026 (insert-buffer buffer)
1028 ;; Look at each of the other buffers one by one.
1029 (dolist (other others)
1030 (let (this-buffer-nodes)
1031 ;; In each, find all the menus.
1032 (with-current-buffer other
1033 (goto-char (point-min))
1034 ;; Find each menu, and add an elt to NODES for it.
1035 (while (re-search-forward "^\\* Menu:" nil t)
1036 (while (and (zerop (forward-line 1)) (eolp)))
1037 (let ((beg (point))
1038 nodename end)
1039 (re-search-backward "^\^_")
1040 (search-forward "Node: ")
1041 (setq nodename (Info-following-node-name))
1042 (search-forward "\n\^_" nil 'move)
1043 (beginning-of-line)
1044 (setq end (point))
1045 (push (list nodename other beg end) this-buffer-nodes)))
1046 (if (assoc-string "top" this-buffer-nodes t)
1047 (setq nodes (nconc this-buffer-nodes nodes))
1048 (setq problems t)
1049 (message "No `top' node in %s" Info-dir-file-name)))))
1050 ;; Add to the main menu a menu item for each other node.
1051 (re-search-forward "^\\* Menu:")
1052 (forward-line 1)
1053 (let ((menu-items '("top"))
1054 (end (save-excursion (search-forward "\^_" nil t) (point))))
1055 (dolist (node nodes)
1056 (let ((nodename (car node)))
1057 (save-excursion
1058 (or (member (downcase nodename) menu-items)
1059 (re-search-forward (concat "^\\* +"
1060 (regexp-quote nodename)
1061 "::")
1062 end t)
1063 (progn
1064 (insert "* " nodename "::" "\n")
1065 (push nodename menu-items)))))))
1066 ;; Now take each node of each of the other buffers
1067 ;; and merge it into the main buffer.
1068 (dolist (node nodes)
1069 (let ((case-fold-search t)
1070 (nodename (car node)))
1071 (goto-char (point-min))
1072 ;; Find the like-named node in the main buffer.
1073 (if (re-search-forward (concat "^\^_.*\n.*Node: "
1074 (regexp-quote nodename)
1075 "[,\n\t]")
1076 nil t)
1077 (progn
1078 (search-forward "\n\^_" nil 'move)
1079 (beginning-of-line)
1080 (insert "\n"))
1081 ;; If none exists, add one.
1082 (goto-char (point-max))
1083 (insert "\^_\nFile: dir\tNode: " nodename "\n\n* Menu:\n\n"))
1084 ;; Merge the text from the other buffer's menu
1085 ;; into the menu in the like-named node in the main buffer.
1086 (apply 'insert-buffer-substring (cdr node))))
1087 (Info-dir-remove-duplicates)
1088 ;; Kill all the buffers we just made, including the special one excised.
1089 (mapc 'kill-buffer (cons buffer buffers))
1090 (goto-char (point-min))
1091 (if problems
1092 (message "Composing main Info directory...problems encountered, see `*Messages*'")
1093 (message "Composing main Info directory...done"))
1094 (set (make-local-variable 'Info-dir-contents) (buffer-string))
1095 (set (make-local-variable 'Info-dir-file-attributes) dir-file-attrs)))
1096 (setq default-directory Info-dir-contents-directory))
1098 (defvar Info-streamline-headings
1099 '(("Emacs" . "Emacs")
1100 ("Programming" . "Programming")
1101 ("Libraries" . "Libraries")
1102 ("World Wide Web\\|Net Utilities" . "Net Utilities"))
1103 "List of elements (RE . NAME) to merge headings matching RE to NAME.")
1105 (defun Info-dir-remove-duplicates ()
1106 (let (limit)
1107 (goto-char (point-min))
1108 ;; Remove duplicate headings in the same menu.
1109 (while (search-forward "\n* Menu:" nil t)
1110 (setq limit (save-excursion (search-forward "\n\^_" nil t)))
1111 ;; Look for the next heading to unify.
1112 (while (re-search-forward "^\\(\\w.*\\)\n\\*" limit t)
1113 (let ((name (match-string 1))
1114 (start (match-beginning 0))
1115 (entries nil) re)
1116 ;; Check whether this heading should be streamlined.
1117 (save-match-data
1118 (dolist (x Info-streamline-headings)
1119 (when (string-match (car x) name)
1120 (setq name (cdr x))
1121 (setq re (car x)))))
1122 (if re (replace-match name t t nil 1))
1123 (goto-char (if (re-search-forward "^[^* \n\t]" limit t)
1124 (match-beginning 0)
1125 (or limit (point-max))))
1126 ;; Look for other headings of the same category and merge them.
1127 (save-excursion
1128 (while (re-search-forward "^\\(\\w.*\\)\n\\*" limit t)
1129 (when (if re (save-match-data (string-match re (match-string 1)))
1130 (equal name (match-string 1)))
1131 (forward-line 0)
1132 ;; Delete redundant heading.
1133 (delete-region (match-beginning 0) (point))
1134 ;; Push the entries onto `text'.
1135 (push
1136 (delete-and-extract-region
1137 (point)
1138 (if (re-search-forward "^[^* \n\t]" nil t)
1139 (match-beginning 0)
1140 (or limit (point-max)))) entries))))
1141 ;; Insert the entries just found.
1142 (while (= (line-beginning-position 0) (1- (point)))
1143 (backward-char))
1144 (dolist (entry (nreverse entries))
1145 (insert entry)
1146 (while (= (line-beginning-position 0) (1- (point)))
1147 (delete-region (1- (point)) (point))))
1149 ;; Now remove duplicate entries under the same heading.
1150 (let ((seen nil)
1151 (limit (point)))
1152 (goto-char start)
1153 (while (re-search-forward "^* \\([^:\n]+:\\(:\\|[^.\n]+\\).\\)"
1154 limit 'move)
1155 (let ((x (match-string 1)))
1156 (if (member-ignore-case x seen)
1157 (delete-region (match-beginning 0)
1158 (progn (re-search-forward "^[^ \t]" nil t)
1159 (match-beginning 0)))
1160 (push x seen))))))))))
1162 ;; Note that on entry to this function the current-buffer must be the
1163 ;; *info* buffer; not the info tags buffer.
1164 (defun Info-read-subfile (nodepos)
1165 ;; NODEPOS is either a position (in the Info file as a whole,
1166 ;; not relative to a subfile) or the name of a subfile.
1167 (let (lastfilepos
1168 lastfilename)
1169 (if (numberp nodepos)
1170 (save-excursion
1171 (set-buffer (marker-buffer Info-tag-table-marker))
1172 (goto-char (point-min))
1173 (or (looking-at "\^_")
1174 (search-forward "\n\^_"))
1175 (forward-line 2)
1176 (catch 'foo
1177 (while (not (looking-at "\^_"))
1178 (if (not (eolp))
1179 (let ((beg (point))
1180 thisfilepos thisfilename)
1181 (search-forward ": ")
1182 (setq thisfilename (buffer-substring beg (- (point) 2)))
1183 (setq thisfilepos (+ (point-min) (read (current-buffer))))
1184 ;; read in version 19 stops at the end of number.
1185 ;; Advance to the next line.
1186 (forward-line 1)
1187 (if (> thisfilepos nodepos)
1188 (throw 'foo t))
1189 (setq lastfilename thisfilename)
1190 (setq lastfilepos thisfilepos))
1191 (forward-line 1)))))
1192 (setq lastfilename nodepos)
1193 (setq lastfilepos 0))
1194 ;; Assume previous buffer is in Info-mode.
1195 ;; (set-buffer (get-buffer "*info*"))
1196 (or (equal Info-current-subfile lastfilename)
1197 (let ((buffer-read-only nil))
1198 (setq buffer-file-name nil)
1199 (widen)
1200 (erase-buffer)
1201 (info-insert-file-contents lastfilename)
1202 (set-buffer-modified-p nil)
1203 (setq Info-current-subfile lastfilename)))
1204 ;; Widen in case we are in the same subfile as before.
1205 (widen)
1206 (goto-char (point-min))
1207 (if (looking-at "\^_")
1208 (forward-char 1)
1209 (search-forward "\n\^_"))
1210 (if (numberp nodepos)
1211 (+ (- nodepos lastfilepos) (point)))))
1213 (defun Info-unescape-quotes (value)
1214 "Unescape double quotes and backslashes in VALUE."
1215 (let ((start 0)
1216 (unquote value))
1217 (while (string-match "[^\\\"]*\\(\\\\\\)[\\\\\"]" unquote start)
1218 (setq unquote (replace-match "" t t unquote 1))
1219 (setq start (- (match-end 0) 1)))
1220 unquote))
1222 ;; As of Texinfo 4.6, makeinfo writes constructs like
1223 ;; \0\h[image param=value ...\h\0]
1224 ;; into the Info file for handling images.
1225 (defun Info-split-parameter-string (parameter-string)
1226 "Return alist of (\"KEY\" . \"VALUE\") from PARAMETER-STRING; a
1227 whitespace separated list of KEY=VALUE pairs. If VALUE contains
1228 whitespace or double quotes, it must be quoted in double quotes and
1229 any double quotes or backslashes must be escaped (\\\",\\\\)."
1230 (let ((start 0)
1231 (parameter-alist))
1232 (while (string-match
1233 "\\s *\\([^=]+\\)=\\(?:\\([^\\s \"]+\\)\\|\\(?:\"\\(\\(?:[^\\\"]\\|\\\\[\\\\\"]\\)*\\)\"\\)\\)"
1234 parameter-string start)
1235 (setq start (match-end 0))
1236 (push (cons (match-string 1 parameter-string)
1237 (or (match-string 2 parameter-string)
1238 (Info-unescape-quotes
1239 (match-string 3 parameter-string))))
1240 parameter-alist))
1241 parameter-alist))
1243 (defun Info-display-images-node ()
1244 "Display images in current node."
1245 (save-excursion
1246 (let ((inhibit-read-only t)
1247 (case-fold-search t))
1248 (goto-char (point-min))
1249 (while (re-search-forward
1250 "\\(\0\b[[]image\\(\\(?:[^\b]\\|[^\0]+\b\\)*\\)\0\b[]]\\)"
1251 nil t)
1252 (let* ((start (match-beginning 1))
1253 (parameter-alist (Info-split-parameter-string (match-string 2)))
1254 (src (cdr (assoc-string "src" parameter-alist)))
1255 (image-file (if src (if (file-name-absolute-p src) src
1256 (concat default-directory src))
1257 ""))
1258 (image (if (file-exists-p image-file)
1259 (create-image image-file)
1260 "[broken image]")))
1261 (if (not (get-text-property start 'display))
1262 (add-text-properties
1263 start (point) `(display ,image rear-nonsticky (display)))))))
1264 (set-buffer-modified-p nil)))
1266 ;; Texinfo 4.7 adds cookies of the form ^@^H[NAME CONTENTS ^@^H].
1267 ;; Hide any construct of the general form ^@[^@-^_][ ... ^@[^@-^_]],
1268 ;; including one optional trailing newline.
1269 (defun Info-hide-cookies-node ()
1270 "Hide unrecognised cookies in current node."
1271 (save-excursion
1272 (let ((inhibit-read-only t)
1273 (case-fold-search t))
1274 (goto-char (point-min))
1275 (while (re-search-forward
1276 "\\(\0[\0-\37][[][^\0]*\0[\0-\37][]]\n?\\)"
1277 nil t)
1278 (let* ((start (match-beginning 1)))
1279 (if (not (get-text-property start 'invisible))
1280 (put-text-property start (point) 'invisible t)))))
1281 (set-buffer-modified-p nil)))
1283 (defun Info-select-node ()
1284 "Select the info node that point is in."
1285 ;; Bind this in case the user sets it to nil.
1286 (let ((case-fold-search t))
1287 (save-excursion
1288 ;; Find beginning of node.
1289 (if (search-backward "\n\^_" nil 'move)
1290 (forward-line 2)
1291 (if (looking-at "\^_")
1292 (forward-line 1)
1293 (signal 'search-failed (list "\n\^_"))))
1294 ;; Get nodename spelled as it is in the node.
1295 (re-search-forward "Node:[ \t]*")
1296 (setq Info-current-node
1297 (buffer-substring-no-properties (point)
1298 (progn
1299 (skip-chars-forward "^,\t\n")
1300 (point))))
1301 (Info-set-mode-line)
1302 ;; Find the end of it, and narrow.
1303 (beginning-of-line)
1304 (let (active-expression)
1305 ;; Narrow to the node contents
1306 (narrow-to-region (point)
1307 (if (re-search-forward "\n[\^_\f]" nil t)
1308 (prog1
1309 (1- (point))
1310 (if (looking-at "[\n\^_\f]*execute: ")
1311 (progn
1312 (goto-char (match-end 0))
1313 (setq active-expression
1314 (read (current-buffer))))))
1315 (point-max)))
1316 (if Info-enable-active-nodes (eval active-expression))
1317 ;; Add a new unique history item to full history list
1318 (let ((new-history (list Info-current-file Info-current-node)))
1319 (setq Info-history-list
1320 (cons new-history (delete new-history Info-history-list)))
1321 (setq Info-history-forward nil))
1322 (if (not (eq Info-fontify-maximum-menu-size nil))
1323 (Info-fontify-node))
1324 (Info-display-images-node)
1325 (Info-hide-cookies-node)
1326 (run-hooks 'Info-selection-hook)))))
1328 (defun Info-set-mode-line ()
1329 (setq mode-line-buffer-identification
1330 (nconc (propertized-buffer-identification "%b")
1331 (list
1332 (concat " ("
1333 (file-name-nondirectory
1334 (if (stringp Info-current-file)
1335 Info-current-file
1336 (or buffer-file-name "")))
1337 ") "
1338 (or Info-current-node ""))))))
1340 ;; Go to an info node specified with a filename-and-nodename string
1341 ;; of the sort that is found in pointers in nodes.
1343 ;;;###autoload
1344 (defun Info-goto-node (nodename &optional fork)
1345 "Go to info node named NODENAME. Give just NODENAME or (FILENAME)NODENAME.
1346 If NODENAME is of the form (FILENAME)NODENAME, the node is in the Info file
1347 FILENAME; otherwise, NODENAME should be in the current Info file (or one of
1348 its sub-files).
1349 Completion is available, but only for node names in the current Info file.
1350 If FORK is non-nil (interactively with a prefix arg), show the node in
1351 a new info buffer.
1352 If FORK is a string, it is the name to use for the new buffer."
1353 (interactive (list (Info-read-node-name "Go to node: ") current-prefix-arg))
1354 (info-initialize)
1355 (if fork
1356 (set-buffer
1357 (clone-buffer (concat "*info-" (if (stringp fork) fork nodename) "*") t)))
1358 (let (filename)
1359 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
1360 nodename)
1361 (setq filename (if (= (match-beginning 1) (match-end 1))
1363 (match-string 2 nodename))
1364 nodename (match-string 3 nodename))
1365 (let ((trim (string-match "\\s +\\'" filename)))
1366 (if trim (setq filename (substring filename 0 trim))))
1367 (let ((trim (string-match "\\s +\\'" nodename)))
1368 (if trim (setq nodename (substring nodename 0 trim))))
1369 (if transient-mark-mode (deactivate-mark))
1370 (Info-find-node (if (equal filename "") nil filename)
1371 (if (equal nodename "") "Top" nodename))))
1373 (defvar Info-read-node-completion-table)
1375 ;; This function is used as the "completion table" while reading a node name.
1376 ;; It does completion using the alist in Info-read-node-completion-table
1377 ;; unless STRING starts with an open-paren.
1378 (defun Info-read-node-name-1 (string predicate code)
1379 (cond
1380 ;; First complete embedded file names.
1381 ((string-match "\\`([^)]*\\'" string)
1382 (let ((file (substring string 1)))
1383 (cond
1384 ((eq code nil)
1385 (let ((comp (try-completion file 'locate-file-completion
1386 (cons Info-directory-list
1387 (mapcar 'car Info-suffix-list)))))
1388 (cond
1389 ((eq comp t) (concat string ")"))
1390 (comp (concat "(" comp)))))
1391 ((eq code t) (all-completions file 'locate-file-completion
1392 (cons Info-directory-list
1393 (mapcar 'car Info-suffix-list))))
1394 (t nil))))
1395 ;; If a file name was given, then any node is fair game.
1396 ((string-match "\\`(" string)
1397 (cond
1398 ((eq code nil) string)
1399 ((eq code t) nil)
1400 (t t)))
1401 ;; Otherwise use Info-read-node-completion-table.
1402 ((eq code nil)
1403 (try-completion string Info-read-node-completion-table predicate))
1404 ((eq code t)
1405 (all-completions string Info-read-node-completion-table predicate))
1407 (test-completion string Info-read-node-completion-table predicate))))
1409 (defun Info-read-node-name (prompt &optional default)
1410 (let* ((completion-ignore-case t)
1411 (Info-read-node-completion-table (Info-build-node-completions))
1412 (nodename (completing-read prompt 'Info-read-node-name-1 nil t)))
1413 (if (equal nodename "")
1414 (or default
1415 (Info-read-node-name prompt))
1416 nodename)))
1418 (defun Info-build-node-completions ()
1419 (or Info-current-file-completions
1420 (let ((compl nil)
1421 ;; Bind this in case the user sets it to nil.
1422 (case-fold-search t)
1423 (node-regexp "Node: *\\([^,\n]*\\) *[,\n\t]"))
1424 (save-excursion
1425 (save-restriction
1426 (if (marker-buffer Info-tag-table-marker)
1427 (let ((marker Info-tag-table-marker))
1428 (set-buffer (marker-buffer marker))
1429 (widen)
1430 (goto-char marker)
1431 (while (re-search-forward "\n\\(Node\\|Ref\\): \\(.*\\)\177" nil t)
1432 (setq compl
1433 (cons (list (match-string-no-properties 2))
1434 compl))))
1435 (widen)
1436 (goto-char (point-min))
1437 ;; If the buffer begins with a node header, process that first.
1438 (if (Info-node-at-bob-matching node-regexp)
1439 (setq compl (list (match-string-no-properties 1))))
1440 ;; Now for the rest of the nodes.
1441 (while (search-forward "\n\^_" nil t)
1442 (forward-line 1)
1443 (let ((beg (point)))
1444 (forward-line 1)
1445 (if (re-search-backward node-regexp beg t)
1446 (setq compl
1447 (cons (list (match-string-no-properties 1))
1448 compl))))))))
1449 (setq compl (cons '("*") compl))
1450 (set (make-local-variable 'Info-current-file-completions) compl))))
1452 (defun Info-restore-point (hl)
1453 "If this node has been visited, restore the point value when we left."
1454 (while hl
1455 (if (and (equal (nth 0 (car hl)) Info-current-file)
1456 ;; Use string-equal, not equal, to ignore text props.
1457 (string-equal (nth 1 (car hl)) Info-current-node))
1458 (progn
1459 (goto-char (nth 2 (car hl)))
1460 (setq hl nil)) ;terminate the while at next iter
1461 (setq hl (cdr hl)))))
1463 (defvar Info-search-history nil
1464 "The history list for `Info-search'.")
1466 (defvar Info-search-case-fold nil
1467 "The value of `case-fold-search' from previous `Info-search' command.")
1469 (defun Info-search (regexp &optional bound noerror count direction)
1470 "Search for REGEXP, starting from point, and select node it's found in.
1471 If DIRECTION is `backward', search in the reverse direction."
1472 (interactive (list (read-string
1473 (if Info-search-history
1474 (format "Regexp search%s (default `%s'): "
1475 (if case-fold-search "" " case-sensitively")
1476 (car Info-search-history))
1477 (format "Regexp search%s: "
1478 (if case-fold-search "" " case-sensitively")))
1479 nil 'Info-search-history)))
1480 (when transient-mark-mode
1481 (deactivate-mark))
1482 (when (equal regexp "")
1483 (setq regexp (car Info-search-history)))
1484 (when regexp
1485 (let (found beg-found give-up
1486 (backward (eq direction 'backward))
1487 (onode Info-current-node)
1488 (ofile Info-current-file)
1489 (opoint (point))
1490 (opoint-min (point-min))
1491 (opoint-max (point-max))
1492 (ostart (window-start))
1493 (osubfile Info-current-subfile))
1494 (setq Info-search-case-fold case-fold-search)
1495 (save-excursion
1496 (save-restriction
1497 (widen)
1498 (when backward
1499 ;; Hide Info file header for backward search
1500 (narrow-to-region (save-excursion
1501 (goto-char (point-min))
1502 (search-forward "\n\^_")
1503 (1- (point)))
1504 (point-max)))
1505 (while (and (not give-up)
1506 (save-match-data
1507 (or (null found)
1508 (if backward
1509 (isearch-range-invisible found beg-found)
1510 (isearch-range-invisible beg-found found))
1511 ;; Skip node header line
1512 (and (save-excursion (forward-line -1)
1513 (looking-at "\^_"))
1514 (forward-line (if backward -1 1)))
1515 ;; Skip Tag Table node
1516 (save-excursion
1517 (and (search-backward "\^_" nil t)
1518 (looking-at "\^_\nTag Table"))))))
1519 (let ((search-spaces-regexp Info-search-whitespace-regexp))
1520 (if (if backward
1521 (re-search-backward regexp bound t)
1522 (re-search-forward regexp bound t))
1523 (setq found (point) beg-found (if backward (match-end 0)
1524 (match-beginning 0)))
1525 (setq give-up t))))))
1527 (when (and isearch-mode Info-isearch-search
1528 (not Info-isearch-initial-node)
1529 (not bound)
1530 (or give-up (and found (not (and (> found opoint-min)
1531 (< found opoint-max))))))
1532 (signal 'search-failed (list regexp "initial node")))
1534 ;; If no subfiles, give error now.
1535 (if give-up
1536 (if (null Info-current-subfile)
1537 (let ((search-spaces-regexp Info-search-whitespace-regexp))
1538 (if backward
1539 (re-search-backward regexp)
1540 (re-search-forward regexp)))
1541 (setq found nil)))
1543 (if (and bound (not found))
1544 (signal 'search-failed (list regexp)))
1546 (unless (or found bound)
1547 (unwind-protect
1548 ;; Try other subfiles.
1549 (let ((list ()))
1550 (save-excursion
1551 (set-buffer (marker-buffer Info-tag-table-marker))
1552 (goto-char (point-min))
1553 (search-forward "\n\^_\nIndirect:")
1554 (save-restriction
1555 (narrow-to-region (point)
1556 (progn (search-forward "\n\^_")
1557 (1- (point))))
1558 (goto-char (point-min))
1559 ;; Find the subfile we just searched.
1560 (search-forward (concat "\n" osubfile ": "))
1561 ;; Skip that one.
1562 (forward-line (if backward 0 1))
1563 (if backward (forward-char -1))
1564 ;; Make a list of all following subfiles.
1565 ;; Each elt has the form (VIRT-POSITION . SUBFILENAME).
1566 (while (not (if backward (bobp) (eobp)))
1567 (if backward
1568 (re-search-backward "\\(^.*\\): [0-9]+$")
1569 (re-search-forward "\\(^.*\\): [0-9]+$"))
1570 (goto-char (+ (match-end 1) 2))
1571 (setq list (cons (cons (+ (point-min)
1572 (read (current-buffer)))
1573 (match-string-no-properties 1))
1574 list))
1575 (goto-char (if backward
1576 (1- (match-beginning 0))
1577 (1+ (match-end 0)))))
1578 ;; Put in forward order
1579 (setq list (nreverse list))))
1580 (while list
1581 (message "Searching subfile %s..." (cdr (car list)))
1582 (Info-read-subfile (car (car list)))
1583 (when backward
1584 ;; Hide Info file header for backward search
1585 (narrow-to-region (save-excursion
1586 (goto-char (point-min))
1587 (search-forward "\n\^_")
1588 (1- (point)))
1589 (point-max))
1590 (goto-char (point-max)))
1591 (setq list (cdr list))
1592 (setq give-up nil found nil)
1593 (while (and (not give-up)
1594 (save-match-data
1595 (or (null found)
1596 (if backward
1597 (isearch-range-invisible found beg-found)
1598 (isearch-range-invisible beg-found found))
1599 ;; Skip node header line
1600 (and (save-excursion (forward-line -1)
1601 (looking-at "\^_"))
1602 (forward-line (if backward -1 1)))
1603 ;; Skip Tag Table node
1604 (save-excursion
1605 (and (search-backward "\^_" nil t)
1606 (looking-at "\^_\nTag Table"))))))
1607 (let ((search-spaces-regexp Info-search-whitespace-regexp))
1608 (if (if backward
1609 (re-search-backward regexp nil t)
1610 (re-search-forward regexp nil t))
1611 (setq found (point) beg-found (if backward (match-end 0)
1612 (match-beginning 0)))
1613 (setq give-up t))))
1614 (if give-up
1615 (setq found nil))
1616 (if found
1617 (setq list nil)))
1618 (if found
1619 (message "")
1620 (signal 'search-failed (list regexp))))
1621 (if (not found)
1622 (progn (Info-read-subfile osubfile)
1623 (goto-char opoint)
1624 (Info-select-node)
1625 (set-window-start (selected-window) ostart)))))
1627 (if (and (string= osubfile Info-current-subfile)
1628 (> found opoint-min)
1629 (< found opoint-max))
1630 ;; Search landed in the same node
1631 (goto-char found)
1632 (widen)
1633 (goto-char found)
1634 (save-match-data (Info-select-node)))
1636 ;; Use string-equal, not equal, to ignore text props.
1637 (or (and (string-equal onode Info-current-node)
1638 (equal ofile Info-current-file))
1639 (and isearch-mode isearch-wrapped
1640 (eq opoint (if isearch-forward opoint-min opoint-max)))
1641 (setq Info-history (cons (list ofile onode opoint)
1642 Info-history))))))
1644 (defun Info-search-case-sensitively ()
1645 "Search for a regexp case-sensitively."
1646 (interactive)
1647 (let ((case-fold-search nil))
1648 (call-interactively 'Info-search)))
1650 (defun Info-search-next ()
1651 "Search for next regexp from a previous `Info-search' command."
1652 (interactive)
1653 (let ((case-fold-search Info-search-case-fold))
1654 (if Info-search-history
1655 (Info-search (car Info-search-history))
1656 (call-interactively 'Info-search))))
1658 (defun Info-search-backward (regexp &optional bound noerror count)
1659 "Search for REGEXP in the reverse direction."
1660 (interactive (list (read-string
1661 (if Info-search-history
1662 (format "Regexp search%s backward (default `%s'): "
1663 (if case-fold-search "" " case-sensitively")
1664 (car Info-search-history))
1665 (format "Regexp search%s backward: "
1666 (if case-fold-search "" " case-sensitively")))
1667 nil 'Info-search-history)))
1668 (Info-search regexp bound noerror count 'backward))
1670 (defun Info-isearch-search ()
1671 (if Info-isearch-search
1672 (lambda (string &optional bound noerror count)
1673 (if isearch-word
1674 (Info-search (concat "\\b" (replace-regexp-in-string
1675 "\\W+" "\\\\W+"
1676 (replace-regexp-in-string
1677 "^\\W+\\|\\W+$" "" string)) "\\b")
1678 bound noerror count
1679 (unless isearch-forward 'backward))
1680 (Info-search (if isearch-regexp string (regexp-quote string))
1681 bound noerror count
1682 (unless isearch-forward 'backward))
1683 (point)))
1684 (let ((isearch-search-fun-function nil))
1685 (isearch-search-fun))))
1687 (defun Info-isearch-wrap ()
1688 (if Info-isearch-search
1689 (if Info-isearch-initial-node
1690 (progn
1691 (if isearch-forward (Info-top-node) (Info-final-node))
1692 (goto-char (if isearch-forward (point-min) (point-max))))
1693 (setq Info-isearch-initial-node Info-current-node)
1694 (setq isearch-wrapped nil))
1695 (goto-char (if isearch-forward (point-min) (point-max)))))
1697 (defun Info-isearch-push-state ()
1698 `(lambda (cmd)
1699 (Info-isearch-pop-state cmd ,Info-current-file ,Info-current-node)))
1701 (defun Info-isearch-pop-state (cmd file node)
1702 (or (and (string= Info-current-file file)
1703 (string= Info-current-node node))
1704 (progn (Info-find-node file node) (sit-for 0))))
1706 (defun Info-isearch-start ()
1707 (setq Info-isearch-initial-node nil))
1709 (defun Info-extract-pointer (name &optional errorname)
1710 "Extract the value of the node-pointer named NAME.
1711 If there is none, use ERRORNAME in the error message;
1712 if ERRORNAME is nil, just return nil."
1713 ;; Bind this in case the user sets it to nil.
1714 (let ((case-fold-search t))
1715 (save-excursion
1716 (goto-char (point-min))
1717 (let ((bound (point)))
1718 (forward-line 1)
1719 (cond ((re-search-backward
1720 (concat name ":" (Info-following-node-name-re)) bound t)
1721 (match-string 1))
1722 ((not (eq errorname t))
1723 (error "Node has no %s"
1724 (capitalize (or errorname name)))))))))
1726 (defun Info-following-node-name-re (&optional allowedchars)
1727 "Return a regexp matching a node name.
1728 ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
1729 saying which chars may appear in the node name.
1730 Submatch 1 is the complete node name.
1731 Submatch 2 if non-nil is the parenthesized file name part of the node name.
1732 Submatch 3 is the local part of the node name.
1733 End of submatch 0, 1, and 3 are the same, so you can safely concat."
1734 (concat "[ \t]*" ;Skip leading space.
1735 "\\(\\(([^)]+)\\)?" ;Node name can start with a file name.
1736 "\\([" (or allowedchars "^,\t\n") "]*" ;Any number of allowed chars.
1737 "[" (or allowedchars "^,\t\n") " ]" ;The last char can't be a space.
1738 "\\|\\)\\)")) ;Allow empty node names.
1740 ;;; For compatibility; other files have used this name.
1741 (defun Info-following-node-name ()
1742 (and (looking-at (Info-following-node-name-re))
1743 (match-string 1)))
1745 (defun Info-next ()
1746 "Go to the next node of this node."
1747 (interactive)
1748 (Info-goto-node (Info-extract-pointer "next")))
1750 (defun Info-prev ()
1751 "Go to the previous node of this node."
1752 (interactive)
1753 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous")))
1755 (defun Info-up (&optional same-file)
1756 "Go to the superior node of this node.
1757 If SAME-FILE is non-nil, do not move to a different Info file."
1758 (interactive)
1759 (let ((old-node Info-current-node)
1760 (old-file Info-current-file)
1761 (node (Info-extract-pointer "up")) p)
1762 (and (or same-file (not (stringp Info-current-file)))
1763 (string-match "^(" node)
1764 (error "Up node is in another Info file"))
1765 (Info-goto-node node)
1766 (setq p (point))
1767 (goto-char (point-min))
1768 (if (and (search-forward "\n* Menu:" nil t)
1769 (re-search-forward
1770 (if (string-equal old-node "Top")
1771 (concat "\n\\*[^:]+: +(" (file-name-nondirectory old-file) ")")
1772 (concat "\n\\* +\\(" (regexp-quote old-node)
1773 ":\\|[^:]+: +" (regexp-quote old-node) "\\)"))
1774 nil t))
1775 (beginning-of-line)
1776 (goto-char p)
1777 (Info-restore-point Info-history))))
1779 (defun Info-history-back ()
1780 "Go back in the history to the last node visited."
1781 (interactive)
1782 (or Info-history
1783 (error "This is the first Info node you looked at"))
1784 (let ((history-forward
1785 (cons (list Info-current-file Info-current-node (point))
1786 Info-history-forward))
1787 filename nodename opoint)
1788 (setq filename (car (car Info-history)))
1789 (setq nodename (car (cdr (car Info-history))))
1790 (setq opoint (car (cdr (cdr (car Info-history)))))
1791 (setq Info-history (cdr Info-history))
1792 (Info-find-node filename nodename)
1793 (setq Info-history (cdr Info-history))
1794 (setq Info-history-forward history-forward)
1795 (goto-char opoint)))
1797 (defalias 'Info-last 'Info-history-back)
1799 (defun Info-history-forward ()
1800 "Go forward in the history of visited nodes."
1801 (interactive)
1802 (or Info-history-forward
1803 (error "This is the last Info node you looked at"))
1804 (let ((history-forward (cdr Info-history-forward))
1805 filename nodename opoint)
1806 (setq filename (car (car Info-history-forward)))
1807 (setq nodename (car (cdr (car Info-history-forward))))
1808 (setq opoint (car (cdr (cdr (car Info-history-forward)))))
1809 (Info-find-node filename nodename)
1810 (setq Info-history-forward history-forward)
1811 (goto-char opoint)))
1813 ;;;###autoload
1814 (defun Info-directory ()
1815 "Go to the Info directory node."
1816 (interactive)
1817 (Info-find-node "dir" "top"))
1819 (defun Info-history ()
1820 "Go to a node with a menu of visited nodes."
1821 (interactive)
1822 (let ((curr-file Info-current-file)
1823 (curr-node Info-current-node)
1825 (with-current-buffer (get-buffer-create " *info-history*")
1826 (let ((inhibit-read-only t))
1827 (erase-buffer)
1828 (goto-char (point-min))
1829 (insert "\n\^_\nFile: history, Node: Top, Up: (dir)\n\n")
1830 (insert "Recently Visited Nodes\n**********************\n\n")
1831 (insert "* Menu:\n\n")
1832 (let ((hl (delete '("history" "Top") Info-history-list)))
1833 (while hl
1834 (let ((file (nth 0 (car hl)))
1835 (node (nth 1 (car hl))))
1836 (if (and (string-equal file curr-file)
1837 (string-equal node curr-node))
1838 (setq p (point)))
1839 (insert "* " node ": (" (file-name-nondirectory file)
1840 ")" node ".\n"))
1841 (setq hl (cdr hl))))))
1842 (Info-find-node "history" "Top")
1843 (goto-char (or p (point-min)))))
1845 (defun Info-toc ()
1846 "Go to a node with table of contents of the current Info file.
1847 Table of contents is created from the tree structure of menus."
1848 (interactive)
1849 (let ((curr-file (substring-no-properties Info-current-file))
1850 (curr-node (substring-no-properties Info-current-node))
1852 (with-current-buffer (get-buffer-create " *info-toc*")
1853 (let ((inhibit-read-only t)
1854 (node-list (Info-build-toc curr-file)))
1855 (erase-buffer)
1856 (goto-char (point-min))
1857 (insert "\n\^_\nFile: toc, Node: Top, Up: (dir)\n\n")
1858 (insert "Table of Contents\n*****************\n\n")
1859 (insert "*Note Top: (" curr-file ")Top.\n")
1860 (Info-insert-toc
1861 (nth 2 (assoc "Top" node-list)) ; get Top nodes
1862 node-list 0 curr-file))
1863 (if (not (bobp))
1864 (let ((Info-hide-note-references 'hide)
1865 (Info-fontify-visited-nodes nil))
1866 (Info-mode)
1867 (setq Info-current-file "toc" Info-current-node "Top")
1868 (goto-char (point-min))
1869 (narrow-to-region (or (re-search-forward "\n[\^_\f]\n" nil t)
1870 (point-min))
1871 (point-max))
1872 (Info-fontify-node)
1873 (widen)))
1874 (goto-char (point-min))
1875 (if (setq p (search-forward (concat "*Note " curr-node ":") nil t))
1876 (setq p (- p (length curr-node) 2))))
1877 (Info-find-node "toc" "Top")
1878 (goto-char (or p (point-min)))))
1880 (defun Info-insert-toc (nodes node-list level curr-file)
1881 "Insert table of contents with references to nodes."
1882 (let ((section "Top"))
1883 (while nodes
1884 (let ((node (assoc (car nodes) node-list)))
1885 (unless (member (nth 1 node) (list nil section))
1886 (insert (setq section (nth 1 node)) "\n"))
1887 (insert (make-string level ?\t))
1888 (insert "*Note " (car nodes) ": (" curr-file ")" (car nodes) ".\n")
1889 (Info-insert-toc (nth 2 node) node-list (1+ level) curr-file)
1890 (setq nodes (cdr nodes))))))
1892 (defun Info-build-toc (file)
1893 "Build table of contents from menus of Info FILE and its subfiles."
1894 (with-temp-buffer
1895 (let* ((file (and (stringp file) (Info-find-file file)))
1896 (default-directory (or (and (stringp file)
1897 (file-name-directory file))
1898 default-directory))
1899 (main-file (and (stringp file) file))
1900 (sections '(("Top" "Top")))
1901 nodes subfiles)
1902 (while (or main-file subfiles)
1903 (or main-file (message "Searching subfile %s..." (car subfiles)))
1904 (erase-buffer)
1905 (info-insert-file-contents (or main-file (car subfiles)))
1906 (goto-char (point-min))
1907 (while (and (search-forward "\n\^_\nFile:" nil 'move)
1908 (search-forward "Node: " nil 'move))
1909 (let ((nodename (substring-no-properties (Info-following-node-name)))
1910 (bound (- (or (save-excursion (search-forward "\n\^_" nil t))
1911 (point-max)) 2))
1912 (section "Top")
1913 menu-items)
1914 (when (and (not (Info-index-node nodename file))
1915 (re-search-forward "^\\* Menu:" bound t))
1916 (forward-line 1)
1917 (beginning-of-line)
1918 (setq bound (or (and (equal nodename "Top")
1919 (save-excursion
1920 (re-search-forward
1921 "^[ \t-]*The Detailed Node Listing" nil t)))
1922 bound))
1923 (while (< (point) bound)
1924 (cond
1925 ;; Menu item line
1926 ((looking-at "^\\* +[^:]+:")
1927 (beginning-of-line)
1928 (forward-char 2)
1929 (let ((menu-node-name (substring-no-properties
1930 (Info-extract-menu-node-name))))
1931 (setq menu-items (cons menu-node-name menu-items))
1932 (if (equal nodename "Top")
1933 (setq sections
1934 (cons (list menu-node-name section) sections)))))
1935 ;; Other non-empty strings in the Top node are section names
1936 ((and (equal nodename "Top")
1937 (looking-at "^\\([^ \t\n*=.-][^:\n]*\\)"))
1938 (setq section (match-string-no-properties 1))))
1939 (forward-line 1)
1940 (beginning-of-line)))
1941 (setq nodes (cons (list nodename
1942 (cadr (assoc nodename sections))
1943 (nreverse menu-items))
1944 nodes))
1945 (goto-char bound)))
1946 (if main-file
1947 (save-excursion
1948 (goto-char (point-min))
1949 (if (search-forward "\n\^_\nIndirect:" nil t)
1950 (let ((bound (save-excursion (search-forward "\n\^_" nil t))))
1951 (while (re-search-forward "^\\(.*\\): [0-9]+$" bound t)
1952 (setq subfiles (cons (match-string-no-properties 1)
1953 subfiles)))))
1954 (setq subfiles (nreverse subfiles)
1955 main-file nil))
1956 (setq subfiles (cdr subfiles))))
1957 (message "")
1958 (nreverse nodes))))
1960 (defun Info-follow-reference (footnotename &optional fork)
1961 "Follow cross reference named FOOTNOTENAME to the node it refers to.
1962 FOOTNOTENAME may be an abbreviation of the reference name.
1963 If FORK is non-nil (interactively with a prefix arg), show the node in
1964 a new info buffer. If FORK is a string, it is the name to use for the
1965 new buffer."
1966 (interactive
1967 (let ((completion-ignore-case t)
1968 (case-fold-search t)
1969 completions default alt-default (start-point (point)) str i bol eol)
1970 (save-excursion
1971 ;; Store end and beginning of line.
1972 (end-of-line)
1973 (setq eol (point))
1974 (beginning-of-line)
1975 (setq bol (point))
1977 (goto-char (point-min))
1978 (while (re-search-forward "\\*note[ \n\t]+\\([^:]*\\):" nil t)
1979 (setq str (match-string-no-properties 1))
1980 ;; See if this one should be the default.
1981 (and (null default)
1982 (<= (match-beginning 0) start-point)
1983 (<= start-point (point))
1984 (setq default t))
1985 ;; See if this one should be the alternate default.
1986 (and (null alt-default)
1987 (and (<= bol (match-beginning 0))
1988 (<= (point) eol))
1989 (setq alt-default t))
1990 (setq i 0)
1991 (while (setq i (string-match "[ \n\t]+" str i))
1992 (setq str (concat (substring str 0 i) " "
1993 (substring str (match-end 0))))
1994 (setq i (1+ i)))
1995 ;; Record as a completion and perhaps as default.
1996 (if (eq default t) (setq default str))
1997 (if (eq alt-default t) (setq alt-default str))
1998 ;; Don't add this string if it's a duplicate.
1999 (or (assoc-string str completions t)
2000 (push str completions))))
2001 ;; If no good default was found, try an alternate.
2002 (or default
2003 (setq default alt-default))
2004 ;; If only one cross-reference found, then make it default.
2005 (if (eq (length completions) 1)
2006 (setq default (car completions)))
2007 (if completions
2008 (let ((input (completing-read (if default
2009 (concat
2010 "Follow reference named: (default "
2011 default ") ")
2012 "Follow reference named: ")
2013 completions nil t)))
2014 (list (if (equal input "")
2015 default input) current-prefix-arg))
2016 (error "No cross-references in this node"))))
2018 (unless footnotename
2019 (error "No reference was specified"))
2021 (let (target i (str (concat "\\*note " (regexp-quote footnotename)))
2022 (case-fold-search t))
2023 (while (setq i (string-match " " str i))
2024 (setq str (concat (substring str 0 i) "[ \t\n]+" (substring str (1+ i))))
2025 (setq i (+ i 6)))
2026 (save-excursion
2027 ;; Move point to the beginning of reference if point is on reference
2028 (or (looking-at "\\*note[ \n\t]+")
2029 (and (looking-back "\\*note[ \n\t]+")
2030 (goto-char (match-beginning 0)))
2031 (if (and (save-excursion
2032 (goto-char (+ (point) 5)) ; skip a possible *note
2033 (re-search-backward "\\*note[ \n\t]+" nil t)
2034 (looking-at str))
2035 (<= (point) (match-end 0)))
2036 (goto-char (match-beginning 0))))
2037 ;; Go to the reference closest to point
2038 (let ((next-ref (save-excursion (and (re-search-forward str nil t)
2039 (+ (match-beginning 0) 5))))
2040 (prev-ref (save-excursion (and (re-search-backward str nil t)
2041 (+ (match-beginning 0) 5)))))
2042 (goto-char (cond ((and next-ref prev-ref)
2043 (if (< (abs (- next-ref (point)))
2044 (abs (- prev-ref (point))))
2045 next-ref prev-ref))
2046 ((or next-ref prev-ref))
2047 ((error "No cross-reference named %s" footnotename))))
2048 (setq target (Info-extract-menu-node-name t))))
2049 (while (setq i (string-match "[ \t\n]+" target i))
2050 (setq target (concat (substring target 0 i) " "
2051 (substring target (match-end 0))))
2052 (setq i (+ i 1)))
2053 (Info-goto-node target fork)))
2055 (defconst Info-menu-entry-name-re "\\(?:[^:]\\|:[^:,.;() \t\n]\\)*"
2056 ;; We allow newline because this is also used in Info-follow-reference,
2057 ;; where the xref name might be wrapped over two lines.
2058 "Regexp that matches a menu entry name upto but not including the colon.
2059 Because of ambiguities, this should be concatenated with something like
2060 `:' and `Info-following-node-name-re'.")
2062 (defun Info-extract-menu-node-name (&optional multi-line index-node)
2063 (skip-chars-forward " \t\n")
2064 (when (looking-at (concat Info-menu-entry-name-re ":\\(:\\|"
2065 (Info-following-node-name-re
2066 (cond
2067 (index-node "^,\t\n")
2068 (multi-line "^.,\t")
2069 (t "^.,\t\n")))
2070 "\\)"
2071 (if index-node
2072 "\\.\\(?:[ \t\n]+(line +\\([0-9]+\\))\\)?"
2073 "")))
2074 (if index-node
2075 (setq Info-point-loc
2076 (if (match-beginning 5)
2077 (string-to-number (match-string 5))
2078 (buffer-substring (match-beginning 0) (1- (match-beginning 1)))))
2079 ;;; Uncomment next line to use names of cross-references in non-index nodes:
2080 ;;; (setq Info-point-loc
2081 ;;; (buffer-substring (match-beginning 0) (1- (match-beginning 1))))
2083 (replace-regexp-in-string
2084 "[ \n]+" " "
2085 (or (match-string 2)
2086 ;; If the node name is the menu entry name (using `entry::').
2087 (buffer-substring (match-beginning 0) (1- (match-beginning 1)))))))
2089 ;; No one calls this.
2090 ;;(defun Info-menu-item-sequence (list)
2091 ;; (while list
2092 ;; (Info-menu (car list))
2093 ;; (setq list (cdr list))))
2095 (defvar Info-complete-menu-buffer)
2096 (defvar Info-complete-next-re nil)
2097 (defvar Info-complete-nodes nil)
2098 (defvar Info-complete-cache nil)
2100 (defconst Info-node-spec-re
2101 (concat (Info-following-node-name-re "^.,:") "[,:.]")
2102 "Regexp to match the text after a : until the terminating `.'.")
2104 (defun Info-complete-menu-item (string predicate action)
2105 ;; This uses two dynamically bound variables:
2106 ;; - `Info-complete-menu-buffer' which contains the buffer in which
2107 ;; is the menu of items we're trying to complete.
2108 ;; - `Info-complete-next-re' which, if non-nil, indicates that we should
2109 ;; also look for menu items in subsequent nodes as long as those
2110 ;; nodes' names match `Info-complete-next-re'. This feature is currently
2111 ;; not used.
2112 ;; - `Info-complete-nodes' which, if non-nil, indicates that we should
2113 ;; also look for menu items in these nodes. This feature is currently
2114 ;; only used for completion in Info-index.
2116 ;; Note that `Info-complete-menu-buffer' could be current already,
2117 ;; so we want to save point.
2118 (save-excursion
2119 (set-buffer Info-complete-menu-buffer)
2120 (let ((completion-ignore-case t)
2121 (case-fold-search t)
2122 (orignode Info-current-node)
2123 nextnode)
2124 (goto-char (point-min))
2125 (search-forward "\n* Menu:")
2126 (if (not (memq action '(nil t)))
2127 (re-search-forward
2128 (concat "\n\\* +" (regexp-quote string) ":") nil t)
2129 (let ((pattern (concat "\n\\* +\\("
2130 (regexp-quote string)
2131 Info-menu-entry-name-re "\\):" Info-node-spec-re))
2132 completions)
2133 ;; Check the cache.
2134 (if (and (equal (nth 0 Info-complete-cache) Info-current-file)
2135 (equal (nth 1 Info-complete-cache) Info-current-node)
2136 (equal (nth 2 Info-complete-cache) Info-complete-next-re)
2137 (equal (nth 5 Info-complete-cache) Info-complete-nodes)
2138 (let ((prev (nth 3 Info-complete-cache)))
2139 (eq t (compare-strings string 0 (length prev)
2140 prev 0 nil t))))
2141 ;; We can reuse the previous list.
2142 (setq completions (nth 4 Info-complete-cache))
2143 ;; The cache can't be used.
2144 (while
2145 (progn
2146 (while (re-search-forward pattern nil t)
2147 (push (match-string-no-properties 1)
2148 completions))
2149 ;; Check subsequent nodes if applicable.
2150 (or (and Info-complete-next-re
2151 (setq nextnode (Info-extract-pointer "next" t))
2152 (string-match Info-complete-next-re nextnode))
2153 (and Info-complete-nodes
2154 (setq Info-complete-nodes (cdr Info-complete-nodes)
2155 nextnode (car Info-complete-nodes)))))
2156 (Info-goto-node nextnode))
2157 ;; Go back to the start node (for the next completion).
2158 (unless (equal Info-current-node orignode)
2159 (Info-goto-node orignode))
2160 ;; Update the cache.
2161 (set (make-local-variable 'Info-complete-cache)
2162 (list Info-current-file Info-current-node
2163 Info-complete-next-re string completions
2164 Info-complete-nodes)))
2165 (if action
2166 (all-completions string completions predicate)
2167 (try-completion string completions predicate)))))))
2170 (defun Info-menu (menu-item &optional fork)
2171 "Go to the node pointed to by the menu item named (or abbreviated) MENU-ITEM.
2172 The menu item should one of those listed in the current node's menu.
2173 Completion is allowed, and the default menu item is the one point is on.
2174 If FORK is non-nil (interactively with a prefix arg), show the node in
2175 a new info buffer. If FORK is a string, it is the name to use for the
2176 new buffer."
2177 (interactive
2178 (let ((completions '())
2179 ;; If point is within a menu item, use that item as the default
2180 (default nil)
2181 (p (point))
2183 (last nil)
2184 (case-fold-search t))
2185 (save-excursion
2186 (goto-char (point-min))
2187 (if (not (search-forward "\n* menu:" nil t))
2188 (error "No menu in this node"))
2189 (setq beg (point))
2190 (and (< (point) p)
2191 (save-excursion
2192 (goto-char p)
2193 (end-of-line)
2194 (if (re-search-backward (concat "\n\\* +\\("
2195 Info-menu-entry-name-re
2196 "\\):") beg t)
2197 (setq default (match-string-no-properties 1))))))
2198 (let ((item nil))
2199 (while (null item)
2200 (setq item (let ((completion-ignore-case t)
2201 (Info-complete-menu-buffer (current-buffer)))
2202 (completing-read (if default
2203 (format "Menu item (default %s): "
2204 default)
2205 "Menu item: ")
2206 'Info-complete-menu-item nil t)))
2207 ;; we rely on the fact that completing-read accepts an input
2208 ;; of "" even when the require-match argument is true and ""
2209 ;; is not a valid possibility
2210 (if (string= item "")
2211 (if default
2212 (setq item default)
2213 ;; ask again
2214 (setq item nil))))
2215 (list item current-prefix-arg))))
2216 ;; there is a problem here in that if several menu items have the same
2217 ;; name you can only go to the node of the first with this command.
2218 (Info-goto-node (Info-extract-menu-item menu-item) (if fork menu-item)))
2220 (defun Info-extract-menu-item (menu-item)
2221 (setq menu-item (regexp-quote menu-item))
2222 (let ((case-fold-search t))
2223 (save-excursion
2224 (let ((case-fold-search t))
2225 (goto-char (point-min))
2226 (or (search-forward "\n* menu:" nil t)
2227 (error "No menu in this node"))
2228 (or (re-search-forward (concat "\n\\* +" menu-item ":") nil t)
2229 (re-search-forward (concat "\n\\* +" menu-item) nil t)
2230 (error "No such item in menu"))
2231 (beginning-of-line)
2232 (forward-char 2)
2233 (Info-extract-menu-node-name nil (Info-index-node))))))
2235 ;; If COUNT is nil, use the last item in the menu.
2236 (defun Info-extract-menu-counting (count)
2237 (let ((case-fold-search t))
2238 (save-excursion
2239 (let ((case-fold-search t))
2240 (goto-char (point-min))
2241 (or (search-forward "\n* menu:" nil t)
2242 (error "No menu in this node"))
2243 (if count
2244 (or (search-forward "\n* " nil t count)
2245 (error "Too few items in menu"))
2246 (while (search-forward "\n* " nil t)
2247 nil))
2248 (Info-extract-menu-node-name nil (Info-index-node))))))
2250 (defun Info-nth-menu-item ()
2251 "Go to the node of the Nth menu item.
2252 N is the digit argument used to invoke this command."
2253 (interactive)
2254 (Info-goto-node
2255 (Info-extract-menu-counting
2256 (- (aref (this-command-keys) (1- (length (this-command-keys)))) ?0))))
2258 (defun Info-top-node ()
2259 "Go to the Top node of this file."
2260 (interactive)
2261 (Info-goto-node "Top"))
2263 (defun Info-final-node ()
2264 "Go to the final node in this file."
2265 (interactive)
2266 (Info-goto-node "Top")
2267 (let ((Info-history nil)
2268 (case-fold-search t))
2269 ;; Go to the last node in the menu of Top.
2270 (Info-goto-node (Info-extract-menu-counting nil))
2271 ;; If the last node in the menu is not last in pointer structure,
2272 ;; move forward until we can't go any farther.
2273 (while (Info-forward-node t t) nil)
2274 ;; Then keep moving down to last subnode, unless we reach an index.
2275 (while (and (not (Info-index-node))
2276 (save-excursion (search-forward "\n* Menu:" nil t)))
2277 (Info-goto-node (Info-extract-menu-counting nil)))))
2279 (defun Info-forward-node (&optional not-down no-error)
2280 "Go forward one node, considering all nodes as forming one sequence."
2281 (interactive)
2282 (goto-char (point-min))
2283 (forward-line 1)
2284 (let ((case-fold-search t))
2285 ;; three possibilities, in order of priority:
2286 ;; 1. next node is in a menu in this node (but not in an index)
2287 ;; 2. next node is next at same level
2288 ;; 3. next node is up and next
2289 (cond ((and (not not-down)
2290 (save-excursion (search-forward "\n* menu:" nil t))
2291 (not (Info-index-node)))
2292 (Info-goto-node (Info-extract-menu-counting 1))
2294 ((save-excursion (search-backward "next:" nil t))
2295 (Info-next)
2297 ((and (save-excursion (search-backward "up:" nil t))
2298 ;; Use string-equal, not equal, to ignore text props.
2299 (not (string-equal (downcase (Info-extract-pointer "up"))
2300 "top")))
2301 (let ((old-node Info-current-node))
2302 (Info-up)
2303 (let (Info-history success)
2304 (unwind-protect
2305 (setq success (Info-forward-node t no-error))
2306 (or success (Info-goto-node old-node))))))
2307 (no-error nil)
2308 (t (error "No pointer forward from this node")))))
2310 (defun Info-backward-node ()
2311 "Go backward one node, considering all nodes as forming one sequence."
2312 (interactive)
2313 (let ((prevnode (Info-extract-pointer "prev[ious]*" t))
2314 (upnode (Info-extract-pointer "up" t))
2315 (case-fold-search t))
2316 (cond ((and upnode (string-match "(" upnode))
2317 (error "First node in file"))
2318 ((and upnode (or (null prevnode)
2319 ;; Use string-equal, not equal,
2320 ;; to ignore text properties.
2321 (string-equal (downcase prevnode)
2322 (downcase upnode))))
2323 (Info-up))
2324 (prevnode
2325 ;; If we move back at the same level,
2326 ;; go down to find the last subnode*.
2327 (Info-prev)
2328 (let (Info-history)
2329 (while (and (not (Info-index-node))
2330 (save-excursion (search-forward "\n* Menu:" nil t)))
2331 (Info-goto-node (Info-extract-menu-counting nil)))))
2333 (error "No pointer backward from this node")))))
2335 (defun Info-exit ()
2336 "Exit Info by selecting some other buffer."
2337 (interactive)
2338 (if Info-standalone
2339 (save-buffers-kill-emacs)
2340 (quit-window)))
2342 (defun Info-next-menu-item ()
2343 "Go to the node of the next menu item."
2344 (interactive)
2345 ;; Bind this in case the user sets it to nil.
2346 (let* ((case-fold-search t)
2347 (node
2348 (save-excursion
2349 (forward-line -1)
2350 (search-forward "\n* menu:" nil t)
2351 (and (search-forward "\n* " nil t)
2352 (Info-extract-menu-node-name)))))
2353 (if node (Info-goto-node node)
2354 (error "No more items in menu"))))
2356 (defun Info-last-menu-item ()
2357 "Go to the node of the previous menu item."
2358 (interactive)
2359 (save-excursion
2360 (forward-line 1)
2361 ;; Bind this in case the user sets it to nil.
2362 (let* ((case-fold-search t)
2363 (beg (save-excursion
2364 (and (search-backward "\n* menu:" nil t)
2365 (point)))))
2366 (or (and beg (search-backward "\n* " beg t))
2367 (error "No previous items in menu")))
2368 (Info-goto-node (save-excursion
2369 (goto-char (match-end 0))
2370 (Info-extract-menu-node-name)))))
2372 (defmacro Info-no-error (&rest body)
2373 (list 'condition-case nil (cons 'progn (append body '(t))) '(error nil)))
2375 (defun Info-next-preorder ()
2376 "Go to the next subnode or the next node, or go up a level."
2377 (interactive)
2378 (cond ((Info-no-error (Info-next-menu-item)))
2379 ((Info-no-error (Info-next)))
2380 ((Info-no-error (Info-up t))
2381 ;; Since we have already gone thru all the items in this menu,
2382 ;; go up to the end of this node.
2383 (goto-char (point-max))
2384 ;; Since logically we are done with the node with that menu,
2385 ;; move on from it.
2386 (Info-next-preorder))
2388 (error "No more nodes"))))
2390 (defun Info-last-preorder ()
2391 "Go to the last node, popping up a level if there is none."
2392 (interactive)
2393 (cond ((Info-no-error
2394 (Info-last-menu-item)
2395 ;; If we go down a menu item, go to the end of the node
2396 ;; so we can scroll back through it.
2397 (goto-char (point-max)))
2398 ;; Keep going down, as long as there are nested menu nodes.
2399 (while (Info-no-error
2400 (Info-last-menu-item)
2401 ;; If we go down a menu item, go to the end of the node
2402 ;; so we can scroll back through it.
2403 (goto-char (point-max))))
2404 (recenter -1))
2405 ((and (Info-no-error (Info-extract-pointer "prev"))
2406 (not (equal (Info-extract-pointer "up")
2407 (Info-extract-pointer "prev"))))
2408 (Info-no-error (Info-prev))
2409 (goto-char (point-max))
2410 (while (Info-no-error
2411 (Info-last-menu-item)
2412 ;; If we go down a menu item, go to the end of the node
2413 ;; so we can scroll back through it.
2414 (goto-char (point-max))))
2415 (recenter -1))
2416 ((Info-no-error (Info-up t))
2417 (goto-char (point-min))
2418 (let ((case-fold-search t))
2419 (or (search-forward "\n* Menu:" nil t)
2420 (goto-char (point-max)))))
2421 (t (error "No previous nodes"))))
2423 (defun Info-scroll-up ()
2424 "Scroll one screenful forward in Info, considering all nodes as one sequence.
2425 Once you scroll far enough in a node that its menu appears on the screen
2426 but after point, the next scroll moves into its first subnode, unless
2427 `Info-scroll-prefer-subnodes' is nil.
2429 When you scroll past the end of a node, that goes to the next node if
2430 `Info-scroll-prefer-subnodes' is non-nil and to the first subnode otherwise;
2431 if this node has no successor, it moves to the parent node's successor,
2432 and so on. If `Info-scroll-prefer-subnodes' is non-nil and point is inside
2433 the menu of a node, it moves to subnode indicated by the following menu
2434 item. (That case won't normally result from this command, but can happen
2435 in other ways.)"
2437 (interactive)
2438 (if (or (< (window-start) (point-min))
2439 (> (window-start) (point-max)))
2440 (set-window-start (selected-window) (point)))
2441 (let* ((case-fold-search t)
2442 (virtual-end (save-excursion
2443 (goto-char (point-min))
2444 (if (and Info-scroll-prefer-subnodes
2445 (search-forward "\n* Menu:" nil t))
2446 (point)
2447 (point-max)))))
2448 (if (or (< virtual-end (window-start))
2449 (pos-visible-in-window-p virtual-end))
2450 (cond
2451 (Info-scroll-prefer-subnodes (Info-next-preorder))
2452 ((Info-no-error (Info-goto-node (Info-extract-menu-counting 1))))
2453 (t (Info-next-preorder)))
2454 (scroll-up))))
2456 (defun Info-scroll-down ()
2457 "Scroll one screenful back in Info, considering all nodes as one sequence.
2458 If point is within the menu of a node, and `Info-scroll-prefer-subnodes'
2459 is non-nil, this goes to its last subnode. When you scroll past the
2460 beginning of a node, that goes to the previous node or back up to the
2461 parent node."
2462 (interactive)
2463 (if (or (< (window-start) (point-min))
2464 (> (window-start) (point-max)))
2465 (set-window-start (selected-window) (point)))
2466 (let* ((case-fold-search t)
2467 (current-point (point))
2468 (virtual-end
2469 (and Info-scroll-prefer-subnodes
2470 (save-excursion
2471 (beginning-of-line)
2472 (setq current-point (point))
2473 (goto-char (point-min))
2474 (search-forward "\n* Menu:"
2475 current-point
2476 t)))))
2477 (if (or virtual-end
2478 (pos-visible-in-window-p (point-min) nil t))
2479 (Info-last-preorder)
2480 (scroll-down))))
2482 (defun Info-next-reference (&optional recur)
2483 "Move cursor to the next cross-reference or menu item in the node."
2484 (interactive)
2485 (let ((pat "\\*note[ \n\t]+\\([^:]+\\):\\|^\\* .*:\\|[hf]t?tp://")
2486 (old-pt (point))
2487 (case-fold-search t))
2488 (or (eobp) (forward-char 1))
2489 (or (re-search-forward pat nil t)
2490 (progn
2491 (goto-char (point-min))
2492 (or (re-search-forward pat nil t)
2493 (progn
2494 (goto-char old-pt)
2495 (error "No cross references in this node")))))
2496 (goto-char (or (match-beginning 1) (match-beginning 0)))
2497 (if (looking-at "\\* Menu:")
2498 (if recur
2499 (error "No cross references in this node")
2500 (Info-next-reference t)))))
2502 (defun Info-prev-reference (&optional recur)
2503 "Move cursor to the previous cross-reference or menu item in the node."
2504 (interactive)
2505 (let ((pat "\\*note[ \n\t]+\\([^:]+\\):\\|^\\* .*:\\|[hf]t?tp://")
2506 (old-pt (point))
2507 (case-fold-search t))
2508 (or (re-search-backward pat nil t)
2509 (progn
2510 (goto-char (point-max))
2511 (or (re-search-backward pat nil t)
2512 (progn
2513 (goto-char old-pt)
2514 (error "No cross references in this node")))))
2515 (goto-char (or (match-beginning 1) (match-beginning 0)))
2516 (if (looking-at "\\* Menu:")
2517 (if recur
2518 (error "No cross references in this node")
2519 (Info-prev-reference t)))))
2521 (defvar Info-index-nodes nil
2522 "Alist of cached index node names of visited Info files.
2523 Each element has the form (INFO-FILE INDEX-NODE-NAMES-LIST).")
2525 (defun Info-index-nodes (&optional file)
2526 "Return a list of names of all index nodes in Info FILE.
2527 If FILE is omitted, it defaults to the current Info file.
2528 First look in a list of cached index node names. Then scan Info
2529 file and its subfiles for nodes with the index cookie. Then try
2530 to find index nodes starting from the first node in the top level
2531 menu whose name contains the word \"Index\", plus any immediately
2532 following nodes whose names also contain the word \"Index\"."
2533 (or file (setq file Info-current-file))
2534 (or (assoc file Info-index-nodes)
2535 ;; Skip virtual Info files
2536 (and (member file '("dir" "history" "toc" "apropos"))
2537 (setq Info-index-nodes (cons (cons file nil) Info-index-nodes)))
2538 (not (stringp file))
2539 ;; Find nodes with index cookie
2540 (let* ((default-directory (or (and (stringp file)
2541 (file-name-directory
2542 (setq file (Info-find-file file))))
2543 default-directory))
2544 Info-history Info-history-list Info-fontify-maximum-menu-size
2545 (main-file file) subfiles nodes node)
2546 (condition-case nil
2547 (with-temp-buffer
2548 (while (or main-file subfiles)
2549 (erase-buffer)
2550 (info-insert-file-contents (or main-file (car subfiles)))
2551 (goto-char (point-min))
2552 (while (search-forward "\0\b[index\0\b]" nil 'move)
2553 (save-excursion
2554 (re-search-backward "^\^_")
2555 (search-forward "Node: ")
2556 (setq nodes (cons (Info-following-node-name) nodes))))
2557 (if main-file
2558 (save-excursion
2559 (goto-char (point-min))
2560 (if (search-forward "\n\^_\nIndirect:" nil t)
2561 (let ((bound (save-excursion (search-forward "\n\^_" nil t))))
2562 (while (re-search-forward "^\\(.*\\): [0-9]+$" bound t)
2563 (setq subfiles (cons (match-string-no-properties 1)
2564 subfiles)))))
2565 (setq subfiles (nreverse subfiles)
2566 main-file nil))
2567 (setq subfiles (cdr subfiles)))))
2568 (error nil))
2569 (if nodes
2570 (setq nodes (nreverse nodes)
2571 Info-index-nodes (cons (cons file nodes) Info-index-nodes)))
2572 nodes)
2573 ;; Find nodes with the word "Index" in the node name
2574 (let ((case-fold-search t)
2575 Info-history Info-history-list Info-fontify-maximum-menu-size
2576 nodes node)
2577 (condition-case nil
2578 (with-temp-buffer
2579 (Info-mode)
2580 (Info-find-node file "Top")
2581 (when (and (search-forward "\n* menu:" nil t)
2582 (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t))
2583 (goto-char (match-beginning 1))
2584 (setq nodes (list (Info-extract-menu-node-name)))
2585 (Info-goto-node (car nodes))
2586 (while (and (setq node (Info-extract-pointer "next" t))
2587 (string-match "\\<Index\\>" node))
2588 (setq nodes (cons node nodes))
2589 (Info-goto-node node))))
2590 (error nil))
2591 (if nodes
2592 (setq nodes (nreverse nodes)
2593 Info-index-nodes (cons (cons file nodes) Info-index-nodes)))
2594 nodes)
2595 ;; If file has no index nodes, still add it to the cache
2596 (setq Info-index-nodes (cons (cons file nil) Info-index-nodes)))
2597 (cdr (assoc file Info-index-nodes)))
2599 (defun Info-index-node (&optional node file)
2600 "Return non-nil value if NODE is an index node.
2601 If NODE is nil, check the current Info node.
2602 If FILE is nil, check the current Info file."
2603 (if (or (and node (not (equal node Info-current-node)))
2604 (assoc (or file Info-current-file) Info-index-nodes))
2605 (member (or node Info-current-node) (Info-index-nodes file))
2606 ;; Don't search all index nodes if request is only for the current node
2607 ;; and file is not in the cache of index nodes
2609 (save-match-data
2610 (string-match "\\<Index\\>" (or node Info-current-node "")))
2611 (save-excursion
2612 (goto-char (+ (or (save-excursion
2613 (search-backward "\n\^_" nil t))
2614 (point-min)) 2))
2615 (search-forward "\0\b[index\0\b]"
2616 (or (save-excursion
2617 (search-forward "\n\^_" nil t))
2618 (point-max)) t)))))
2620 (defun Info-goto-index ()
2621 "Go to the first index node."
2622 (let ((node (car (Info-index-nodes))))
2623 (or node (error "No index"))
2624 (Info-goto-node node)))
2626 ;;;###autoload
2627 (defun Info-index (topic)
2628 "Look up a string TOPIC in the index for this file.
2629 If there are no exact matches to the specified topic, this chooses
2630 the first match which is a case-insensitive substring of a topic.
2631 Use the \\<Info-mode-map>\\[Info-index-next] command to see the other matches.
2632 Give a blank topic name to go to the Index node itself."
2633 (interactive
2634 (list
2635 (let ((Info-complete-menu-buffer (clone-buffer))
2636 (Info-complete-nodes (Info-index-nodes))
2637 (Info-history-list nil))
2638 (if (equal Info-current-file "dir")
2639 (error "The Info directory node has no index; use m to select a manual"))
2640 (unwind-protect
2641 (with-current-buffer Info-complete-menu-buffer
2642 (Info-goto-index)
2643 (completing-read "Index topic: " 'Info-complete-menu-item))
2644 (kill-buffer Info-complete-menu-buffer)))))
2645 (if (equal Info-current-file "dir")
2646 (error "The Info directory node has no index; use m to select a manual"))
2647 (let ((orignode Info-current-node)
2648 (pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^\n]*\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?"
2649 (regexp-quote topic)))
2650 node (nodes (Info-index-nodes))
2651 (ohist-list Info-history-list)
2652 (case-fold-search t))
2653 (Info-goto-index)
2654 (or (equal topic "")
2655 (let ((matches nil)
2656 (exact nil)
2657 ;; We bind Info-history to nil for internal node-switches so
2658 ;; that we don't put junk in the history. In the first
2659 ;; Info-goto-index call, above, we do update the history
2660 ;; because that is what the user's previous node choice into it.
2661 (Info-history nil)
2662 found)
2663 (while
2664 (progn
2665 (goto-char (point-min))
2666 (while (re-search-forward pattern nil t)
2667 (push (list (match-string-no-properties 1)
2668 (match-string-no-properties 2)
2669 Info-current-node
2670 (string-to-number (concat "0"
2671 (match-string 3))))
2672 matches))
2673 (setq nodes (cdr nodes) node (car nodes)))
2674 (Info-goto-node node))
2675 (or matches
2676 (progn
2677 (Info-goto-node orignode)
2678 (error "No `%s' in index" topic)))
2679 ;; Here it is a feature that assoc is case-sensitive.
2680 (while (setq found (assoc topic matches))
2681 (setq exact (cons found exact)
2682 matches (delq found matches)))
2683 (setq Info-history-list ohist-list)
2684 (setq Info-index-alternatives (nconc exact (nreverse matches)))
2685 (Info-index-next 0)))))
2687 (defun Info-index-next (num)
2688 "Go to the next matching index item from the last \\<Info-mode-map>\\[Info-index] command."
2689 (interactive "p")
2690 (or Info-index-alternatives
2691 (error "No previous `i' command"))
2692 (while (< num 0)
2693 (setq num (+ num (length Info-index-alternatives))))
2694 (while (> num 0)
2695 (setq Info-index-alternatives
2696 (nconc (cdr Info-index-alternatives)
2697 (list (car Info-index-alternatives)))
2698 num (1- num)))
2699 (Info-goto-node (nth 1 (car Info-index-alternatives)))
2700 (if (> (nth 3 (car Info-index-alternatives)) 0)
2701 (forward-line (1- (nth 3 (car Info-index-alternatives))))
2702 (forward-line 3) ; don't search in headers
2703 (let ((name (car (car Info-index-alternatives))))
2704 (Info-find-index-name name)))
2705 (message "Found `%s' in %s. %s"
2706 (car (car Info-index-alternatives))
2707 (nth 2 (car Info-index-alternatives))
2708 (if (cdr Info-index-alternatives)
2709 "(`,' tries to find next)"
2710 "(Only match)")))
2712 (defun Info-find-index-name (name)
2713 "Move point to the place within the current node where NAME is defined."
2714 (let ((case-fold-search t))
2715 (if (or (re-search-forward (format
2716 "[a-zA-Z]+: %s\\( \\|$\\)"
2717 (regexp-quote name)) nil t)
2718 ;; Find a function definition with a return type.
2719 (re-search-forward (format
2720 "[a-zA-Z]+: [a-zA-Z0-9_ *&]+ %s\\( \\|$\\)"
2721 (regexp-quote name)) nil t)
2722 (search-forward (format "`%s'" name) nil t)
2723 (and (string-match "\\`.*\\( (.*)\\)\\'" name)
2724 (search-forward
2725 (format "`%s'" (substring name 0 (match-beginning 1)))
2726 nil t))
2727 (search-forward name nil t)
2728 ;; Try again without the " <1>" makeinfo can append
2729 (and (string-match "\\`\\(.*\\) <[0-9]+>\\'" name)
2730 (Info-find-index-name (match-string 1 name))))
2731 (progn (beginning-of-line) t) ;; non-nil for recursive call
2732 (goto-char (point-min)))))
2734 ;;;###autoload
2735 (defun info-apropos (string)
2736 "Grovel indices of all known Info files on your system for STRING.
2737 Build a menu of the possible matches."
2738 (interactive "sIndex apropos: ")
2739 (unless (string= string "")
2740 (let ((pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^\n]+\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?"
2741 (regexp-quote string)))
2742 (ohist Info-history)
2743 (ohist-list Info-history-list)
2744 (current-node Info-current-node)
2745 (current-file Info-current-file)
2746 manuals matches node nodes)
2747 (let ((Info-fontify-maximum-menu-size nil))
2748 (Info-directory)
2749 (message "Searching indices...")
2750 (goto-char (point-min))
2751 (re-search-forward "\\* Menu: *\n" nil t)
2752 (while (re-search-forward "\\*.*: *(\\([^)]+\\))" nil t)
2753 (add-to-list 'manuals (match-string 1)))
2754 (dolist (manual manuals)
2755 (message "Searching %s" manual)
2756 (if (setq nodes (Info-index-nodes (Info-find-file manual)))
2757 (condition-case nil
2758 (save-excursion
2759 (Info-find-node manual (car nodes))
2760 (while
2761 (progn
2762 (goto-char (point-min))
2763 (while (re-search-forward pattern nil t)
2764 (add-to-list 'matches
2765 (list manual
2766 (match-string-no-properties 1)
2767 (match-string-no-properties 2)
2768 (match-string-no-properties 3))))
2769 (setq nodes (cdr nodes) node (car nodes)))
2770 (Info-goto-node node)))
2771 (error nil)))))
2772 (Info-goto-node (concat "(" current-file ")" current-node))
2773 (setq Info-history ohist
2774 Info-history-list ohist-list)
2775 (message "Searching indices...done")
2776 (if (null matches)
2777 (message "No matches found")
2778 (with-current-buffer (get-buffer-create " *info-apropos*")
2779 (erase-buffer)
2780 (insert "\n\^_\nFile: apropos, Node: Index, Up: (dir)\n")
2781 (insert "* Menu: \nNodes whose indices contain \"" string "\"\n\n")
2782 (dolist (entry matches)
2783 (insert
2784 (format "* %-38s (%s)%s.%s\n"
2785 (concat (nth 1 entry) " [" (nth 0 entry) "]:")
2786 (nth 0 entry)
2787 (nth 2 entry)
2788 (if (nth 3 entry)
2789 (concat " (line " (nth 3 entry) ")")
2790 "")))))
2791 (Info-find-node "apropos" "Index")
2792 (setq Info-complete-cache nil)))))
2794 (defun Info-undefined ()
2795 "Make command be undefined in Info."
2796 (interactive)
2797 (ding))
2799 (defun Info-help ()
2800 "Enter the Info tutorial."
2801 (interactive)
2802 (delete-other-windows)
2803 (Info-find-node "info"
2804 (if (< (window-height) 23)
2805 "Help-Small-Screen"
2806 "Help")))
2808 (defun Info-summary ()
2809 "Display a brief summary of all Info commands."
2810 (interactive)
2811 (save-window-excursion
2812 (switch-to-buffer "*Help*")
2813 (setq buffer-read-only nil)
2814 (erase-buffer)
2815 (insert (documentation 'Info-mode))
2816 (help-mode)
2817 (goto-char (point-min))
2818 (let (ch flag)
2819 (while (progn (setq flag (not (pos-visible-in-window-p (point-max))))
2820 (message (if flag "Type Space to see more"
2821 "Type Space to return to Info"))
2822 (if (not (eq ?\ (setq ch (read-event))))
2823 (progn (setq unread-command-events (list ch)) nil)
2824 flag))
2825 (scroll-up)))
2826 (bury-buffer "*Help*")))
2828 (defun Info-get-token (pos start all &optional errorstring)
2829 "Return the token around POS.
2830 POS must be somewhere inside the token
2831 START is a regular expression which will match the
2832 beginning of the tokens delimited string
2833 ALL is a regular expression with a single
2834 parenthesized subpattern which is the token to be
2835 returned. E.g. '{\(.*\)}' would return any string
2836 enclosed in braces around POS.
2837 ERRORSTRING optional fourth argument, controls action on no match
2838 nil: return nil
2839 t: beep
2840 a string: signal an error, using that string."
2841 (let ((case-fold-search t))
2842 (save-excursion
2843 (goto-char pos)
2844 ;; First look for a match for START that goes across POS.
2845 (while (and (not (bobp)) (> (point) (- pos (length start)))
2846 (not (looking-at start)))
2847 (forward-char -1))
2848 ;; If we did not find one, search back for START
2849 ;; (this finds only matches that end at or before POS).
2850 (or (looking-at start)
2851 (progn
2852 (goto-char pos)
2853 (re-search-backward start (max (point-min) (- pos 200)) 'yes)))
2854 (let (found)
2855 (while (and (re-search-forward all (min (point-max) (+ pos 200)) 'yes)
2856 (not (setq found (and (<= (match-beginning 0) pos)
2857 (> (match-end 0) pos))))))
2858 (if (and found (<= (match-beginning 0) pos)
2859 (> (match-end 0) pos))
2860 (match-string-no-properties 1)
2861 (cond ((null errorstring)
2862 nil)
2863 ((eq errorstring t)
2864 (beep)
2865 nil)
2867 (error "No %s around position %d" errorstring pos))))))))
2869 (defun Info-mouse-follow-nearest-node (click)
2870 "\\<Info-mode-map>Follow a node reference near point.
2871 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click.
2872 At end of the node's text, moves to the next node, or up if none."
2873 (interactive "e")
2874 (mouse-set-point click)
2875 (and (not (Info-try-follow-nearest-node))
2876 (save-excursion (forward-line 1) (eobp))
2877 (Info-next-preorder)))
2879 (defun Info-follow-nearest-node (&optional fork)
2880 "Follow a node reference near point.
2881 If point is on a reference, follow that reference. Otherwise,
2882 if point is in a menu item description, follow that menu item."
2883 (interactive "P")
2884 (or (Info-try-follow-nearest-node fork)
2885 (when (save-excursion
2886 (search-backward "\n* menu:" nil t))
2887 (save-excursion
2888 (beginning-of-line)
2889 (while (not (or (bobp) (looking-at "[^ \t]\\|[ \t]*$")))
2890 (beginning-of-line 0))
2891 (when (looking-at "\\* +\\([^\t\n]*\\):")
2892 (Info-goto-node
2893 (Info-extract-menu-item (match-string-no-properties 1)) fork)
2894 t)))
2895 (error "Point neither on reference nor in menu item description")))
2897 ;; Common subroutine.
2898 (defun Info-try-follow-nearest-node (&optional fork)
2899 "Follow a node reference near point. Return non-nil if successful."
2900 (let (node)
2901 (cond
2902 ((Info-get-token (point) "[hf]t?tp://" "[hf]t?tp://\\([^ \t\n\"`({<>})']+\\)")
2903 (setq node t)
2904 (browse-url (browse-url-url-at-point)))
2905 ((setq node (Info-get-token (point) "\\*note[ \n\t]+"
2906 "\\*note[ \n\t]+\\([^:]*\\):\\(:\\|[ \n\t]*(\\)?"))
2907 (Info-follow-reference node fork))
2908 ;; menu item: node name
2909 ((setq node (Info-get-token (point) "\\* +" "\\* +\\([^:]*\\)::"))
2910 (Info-goto-node node fork))
2911 ;; menu item: node name or index entry
2912 ((Info-get-token (point) "\\* +" "\\* +\\(.*\\): ")
2913 (beginning-of-line)
2914 (forward-char 2)
2915 (setq node (Info-extract-menu-node-name nil (Info-index-node)))
2916 (Info-goto-node node fork))
2917 ((setq node (Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)"))
2918 (Info-goto-node node fork))
2919 ((setq node (Info-get-token (point) "Next: " "Next: \\([^,\n\t]*\\)"))
2920 (Info-goto-node node fork))
2921 ((setq node (Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)"))
2922 (Info-goto-node "Top" fork))
2923 ((setq node (Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)"))
2924 (Info-goto-node node fork)))
2925 node))
2927 (defvar Info-mode-map nil
2928 "Keymap containing Info commands.")
2929 (if Info-mode-map
2931 (setq Info-mode-map (make-keymap))
2932 (suppress-keymap Info-mode-map)
2933 (define-key Info-mode-map "." 'beginning-of-buffer)
2934 (define-key Info-mode-map " " 'Info-scroll-up)
2935 (define-key Info-mode-map "\C-m" 'Info-follow-nearest-node)
2936 (define-key Info-mode-map "\t" 'Info-next-reference)
2937 (define-key Info-mode-map [(shift tab)] 'Info-prev-reference)
2938 (define-key Info-mode-map [backtab] 'Info-prev-reference)
2939 (define-key Info-mode-map "1" 'Info-nth-menu-item)
2940 (define-key Info-mode-map "2" 'Info-nth-menu-item)
2941 (define-key Info-mode-map "3" 'Info-nth-menu-item)
2942 (define-key Info-mode-map "4" 'Info-nth-menu-item)
2943 (define-key Info-mode-map "5" 'Info-nth-menu-item)
2944 (define-key Info-mode-map "6" 'Info-nth-menu-item)
2945 (define-key Info-mode-map "7" 'Info-nth-menu-item)
2946 (define-key Info-mode-map "8" 'Info-nth-menu-item)
2947 (define-key Info-mode-map "9" 'Info-nth-menu-item)
2948 (define-key Info-mode-map "0" 'undefined)
2949 (define-key Info-mode-map "?" 'Info-summary)
2950 (define-key Info-mode-map "]" 'Info-forward-node)
2951 (define-key Info-mode-map "[" 'Info-backward-node)
2952 (define-key Info-mode-map "<" 'Info-top-node)
2953 (define-key Info-mode-map ">" 'Info-final-node)
2954 (define-key Info-mode-map "b" 'beginning-of-buffer)
2955 (define-key Info-mode-map "c" 'Info-copy-current-node-name)
2956 (define-key Info-mode-map "d" 'Info-directory)
2957 (define-key Info-mode-map "e" 'Info-edit)
2958 (define-key Info-mode-map "f" 'Info-follow-reference)
2959 (define-key Info-mode-map "g" 'Info-goto-node)
2960 (define-key Info-mode-map "h" 'Info-help)
2961 (define-key Info-mode-map "i" 'Info-index)
2962 (define-key Info-mode-map "l" 'Info-history-back)
2963 (define-key Info-mode-map "L" 'Info-history)
2964 (define-key Info-mode-map "m" 'Info-menu)
2965 (define-key Info-mode-map "n" 'Info-next)
2966 (define-key Info-mode-map "p" 'Info-prev)
2967 (define-key Info-mode-map "q" 'Info-exit)
2968 (define-key Info-mode-map "r" 'Info-history-forward)
2969 (define-key Info-mode-map "s" 'Info-search)
2970 (define-key Info-mode-map "S" 'Info-search-case-sensitively)
2971 ;; For consistency with Rmail.
2972 (define-key Info-mode-map "\M-s" 'Info-search)
2973 (define-key Info-mode-map "\M-n" 'clone-buffer)
2974 (define-key Info-mode-map "t" 'Info-top-node)
2975 (define-key Info-mode-map "T" 'Info-toc)
2976 (define-key Info-mode-map "u" 'Info-up)
2977 ;; For consistency with dired-copy-filename-as-kill.
2978 (define-key Info-mode-map "w" 'Info-copy-current-node-name)
2979 (define-key Info-mode-map "," 'Info-index-next)
2980 (define-key Info-mode-map "\177" 'Info-scroll-down)
2981 (define-key Info-mode-map [mouse-2] 'Info-mouse-follow-nearest-node)
2982 (define-key Info-mode-map [follow-link] 'mouse-face)
2985 (defun Info-check-pointer (item)
2986 "Non-nil if ITEM is present in this node."
2987 (condition-case nil
2988 (Info-extract-pointer item)
2989 (error nil)))
2991 (easy-menu-define
2992 Info-mode-menu Info-mode-map
2993 "Menu for info files."
2994 '("Info"
2995 ["Up" Info-up :active (Info-check-pointer "up")
2996 :help "Go up in the Info tree"]
2997 ["Next" Info-next :active (Info-check-pointer "next")
2998 :help "Go to the next node"]
2999 ["Previous" Info-prev :active (Info-check-pointer "prev[ious]*")
3000 :help "Go to the previous node"]
3001 ["Backward" Info-backward-node
3002 :help "Go backward one node, considering all as a sequence"]
3003 ["Forward" Info-forward-node
3004 :help "Go forward one node, considering all as a sequence"]
3005 ["Beginning" beginning-of-buffer
3006 :help "Go to beginning of this node"]
3007 ["Top" Info-top-node
3008 :help "Go to top node of file"]
3009 ["Final Node" Info-final-node
3010 :help "Go to final node in this file"]
3011 ("Menu Item" ["You should never see this" report-emacs-bug t])
3012 ("Reference" ["You should never see this" report-emacs-bug t])
3013 ["Search..." Info-search
3014 :help "Search for regular expression in this Info file"]
3015 ["Search Case-Sensitively..." Info-search-case-sensitively
3016 :help "Search for regular expression case sensitively"]
3017 ["Search Next" Info-search-next
3018 :help "Search for another occurrence of regular expression"]
3019 ["Go to Node..." Info-goto-node
3020 :help "Go to a named node"]
3021 ["Back in history" Info-history-back :active Info-history
3022 :help "Go back in history to the last node you were at"]
3023 ["Forward in history" Info-history-forward :active Info-history-forward
3024 :help "Go forward in history"]
3025 ["History" Info-history :active Info-history-list
3026 :help "Go to menu of visited nodes"]
3027 ["Table of Contents" Info-toc
3028 :help "Go to table of contents"]
3029 ("Index"
3030 ["Lookup a String..." Info-index
3031 :help "Look for a string in the index items"]
3032 ["Next Matching Item" Info-index-next :active Info-index-alternatives
3033 :help "Look for another occurrence of previous item"]
3034 ["Lookup a string in all indices..." info-apropos
3035 :help "Look for a string in the indices of all manuals"])
3036 ["Edit" Info-edit :help "Edit contents of this node"
3037 :active Info-enable-edit]
3038 ["Copy Node Name" Info-copy-current-node-name
3039 :help "Copy the name of the current node into the kill ring"]
3040 ["Clone Info buffer" clone-buffer
3041 :help "Create a twin copy of the current Info buffer."]
3042 ["Exit" Info-exit :help "Stop reading Info"]))
3045 (defvar info-tool-bar-map
3046 (if (display-graphic-p)
3047 (let ((map (make-sparse-keymap)))
3048 (tool-bar-local-item-from-menu 'Info-exit "close" map Info-mode-map)
3049 (tool-bar-local-item-from-menu 'Info-prev "left_arrow" map Info-mode-map)
3050 (tool-bar-local-item-from-menu 'Info-next "right_arrow" map Info-mode-map)
3051 (tool-bar-local-item-from-menu 'Info-up "up_arrow" map Info-mode-map)
3052 (tool-bar-local-item-from-menu 'Info-history-back "back_arrow" map Info-mode-map)
3053 (tool-bar-local-item-from-menu 'Info-history-forward "fwd_arrow" map Info-mode-map)
3054 (tool-bar-local-item-from-menu 'Info-top-node "home" map Info-mode-map)
3055 (tool-bar-local-item-from-menu 'Info-index "index" map Info-mode-map)
3056 (tool-bar-local-item-from-menu 'Info-goto-node "jump_to" map Info-mode-map)
3057 (tool-bar-local-item-from-menu 'Info-search "search" map Info-mode-map)
3058 map)))
3060 (defvar Info-menu-last-node nil)
3061 ;; Last node the menu was created for.
3062 ;; Value is a list, (FILE-NAME NODE-NAME).
3064 (defun Info-menu-update ()
3065 "Update the Info menu for the current node."
3066 (condition-case nil
3067 (if (or (not (eq major-mode 'Info-mode))
3068 (equal (list Info-current-file Info-current-node)
3069 Info-menu-last-node))
3071 ;; Update menu menu.
3072 (let* ((Info-complete-menu-buffer (current-buffer))
3073 (items (nreverse (condition-case nil
3074 (Info-complete-menu-item "" nil t)
3075 (error nil))))
3076 entries current
3077 (number 0))
3078 (while (and items (< number 9))
3079 (setq current (car items)
3080 items (cdr items)
3081 number (1+ number))
3082 (setq entries (cons `[,current
3083 (Info-menu ,current)
3084 :keys ,(format "%d" number)]
3085 entries)))
3086 (if items
3087 (setq entries (cons ["Other..." Info-menu t] entries)))
3088 (or entries
3089 (setq entries (list ["No menu" nil nil] nil :active)))
3090 (easy-menu-change '("Info") "Menu Item" (nreverse entries)))
3091 ;; Update reference menu. Code stolen from `Info-follow-reference'.
3092 (let ((items nil)
3093 str i entries current
3094 (number 0)
3095 (case-fold-search t))
3096 (save-excursion
3097 (goto-char (point-min))
3098 (while (re-search-forward "\\*note[ \n\t]+\\([^:]*\\):" nil t)
3099 (setq str (match-string 1))
3100 (setq i 0)
3101 (while (setq i (string-match "[ \n\t]+" str i))
3102 (setq str (concat (substring str 0 i) " "
3103 (substring str (match-end 0))))
3104 (setq i (1+ i)))
3105 (setq items
3106 (cons str items))))
3107 (while (and items (< number 9))
3108 (setq current (car items)
3109 items (cdr items)
3110 number (1+ number))
3111 (setq entries (cons `[,current
3112 (Info-follow-reference ,current)
3114 entries)))
3115 (if items
3116 (setq entries (cons ["Other..." Info-follow-reference t]
3117 entries)))
3118 (or entries
3119 (setq entries (list ["No references" nil nil] nil :active)))
3120 (easy-menu-change '("Info") "Reference" (nreverse entries)))
3121 ;; Update last seen node.
3122 (setq Info-menu-last-node (list Info-current-file Info-current-node)))
3123 ;; Try to avoid entering infinite beep mode in case of errors.
3124 (error (ding))))
3127 (defun Info-copy-current-node-name (&optional arg)
3128 "Put the name of the current info node into the kill ring.
3129 The name of the info file is prepended to the node name in parentheses.
3130 With a zero prefix arg, put the name inside a function call to `info'."
3131 (interactive "P")
3132 (unless Info-current-node
3133 (error "No current info node"))
3134 (let ((node (concat "(" (file-name-nondirectory
3135 (or (and (stringp Info-current-file)
3136 Info-current-file)
3137 buffer-file-name
3138 ""))
3139 ")" Info-current-node)))
3140 (if (zerop (prefix-numeric-value arg))
3141 (setq node (concat "(info \"" node "\")")))
3142 (kill-new node)
3143 (message "%s" node)))
3146 ;; Info mode is suitable only for specially formatted data.
3147 (put 'Info-mode 'mode-class 'special)
3148 (put 'Info-mode 'no-clone-indirect t)
3150 (defun Info-mode ()
3151 "Info mode provides commands for browsing through the Info documentation tree.
3152 Documentation in Info is divided into \"nodes\", each of which discusses
3153 one topic and contains references to other nodes which discuss related
3154 topics. Info has commands to follow the references and show you other nodes.
3156 \\<Info-mode-map>\
3157 \\[Info-help] Invoke the Info tutorial.
3158 \\[Info-exit] Quit Info: reselect previously selected buffer.
3160 Selecting other nodes:
3161 \\[Info-mouse-follow-nearest-node]
3162 Follow a node reference you click on.
3163 This works with menu items, cross references, and
3164 the \"next\", \"previous\" and \"up\", depending on where you click.
3165 \\[Info-follow-nearest-node] Follow a node reference near point, like \\[Info-mouse-follow-nearest-node].
3166 \\[Info-next] Move to the \"next\" node of this node.
3167 \\[Info-prev] Move to the \"previous\" node of this node.
3168 \\[Info-up] Move \"up\" from this node.
3169 \\[Info-menu] Pick menu item specified by name (or abbreviation).
3170 Picking a menu item causes another node to be selected.
3171 \\[Info-directory] Go to the Info directory node.
3172 \\[Info-follow-reference] Follow a cross reference. Reads name of reference.
3173 \\[Info-history-back] Move back in history to the last node you were at.
3174 \\[Info-history-forward] Move forward in history to the node you returned from after using \\[Info-history-back].
3175 \\[Info-history] Go to menu of visited nodes.
3176 \\[Info-toc] Go to table of contents of the current Info file.
3177 \\[Info-top-node] Go to the Top node of this file.
3178 \\[Info-final-node] Go to the final node in this file.
3179 \\[Info-backward-node] Go backward one node, considering all nodes as forming one sequence.
3180 \\[Info-forward-node] Go forward one node, considering all nodes as forming one sequence.
3181 \\[Info-index] Look up a topic in this file's Index and move to that node.
3182 \\[Info-index-next] (comma) Move to the next match from a previous \\<Info-mode-map>\\[Info-index] command.
3183 \\[info-apropos] Look for a string in the indices of all manuals.
3185 Moving within a node:
3186 \\[Info-scroll-up] Normally, scroll forward a full screen.
3187 Once you scroll far enough in a node that its menu appears on the
3188 screen but after point, the next scroll moves into its first
3189 subnode. When after all menu items (or if there is no menu),
3190 move up to the parent node.
3191 \\[Info-scroll-down] Normally, scroll backward. If the beginning of the buffer is
3192 already visible, try to go to the previous menu entry, or up
3193 if there is none.
3194 \\[beginning-of-buffer] Go to beginning of node.
3196 Advanced commands:
3197 \\[Info-copy-current-node-name] Put name of current info node in the kill ring.
3198 \\[clone-buffer] Select a new cloned Info buffer in another window.
3199 \\[Info-edit] Edit contents of selected node.
3200 1 .. 9 Pick first ... ninth item in node's menu.
3201 Every third `*' is highlighted to help pick the right number.
3202 \\[Info-goto-node] Move to node specified by name.
3203 You may include a filename as well, as (FILENAME)NODENAME.
3204 \\[universal-argument] \\[info] Move to new Info file with completion.
3205 \\[universal-argument] N \\[info] Select Info buffer with prefix number in the name *info*<N>.
3206 \\[Info-search] Search through this Info file for specified regexp,
3207 and select the node in which the next occurrence is found.
3208 \\[Info-search-case-sensitively] Search through this Info file for specified regexp case-sensitively.
3209 \\[Info-search-next] Search for another occurrence of regexp
3210 from a previous \\<Info-mode-map>\\[Info-search] command.
3211 \\[Info-next-reference] Move cursor to next cross-reference or menu item.
3212 \\[Info-prev-reference] Move cursor to previous cross-reference or menu item."
3213 (kill-all-local-variables)
3214 (setq major-mode 'Info-mode)
3215 (setq mode-name "Info")
3216 (setq tab-width 8)
3217 (use-local-map Info-mode-map)
3218 (add-hook 'activate-menubar-hook 'Info-menu-update nil t)
3219 (set-syntax-table text-mode-syntax-table)
3220 (setq local-abbrev-table text-mode-abbrev-table)
3221 (setq case-fold-search t)
3222 (setq buffer-read-only t)
3223 (make-local-variable 'Info-current-file)
3224 (make-local-variable 'Info-current-subfile)
3225 (make-local-variable 'Info-current-node)
3226 (make-local-variable 'Info-tag-table-marker)
3227 (setq Info-tag-table-marker (make-marker))
3228 (make-local-variable 'Info-tag-table-buffer)
3229 (setq Info-tag-table-buffer nil)
3230 (make-local-variable 'Info-history)
3231 (make-local-variable 'Info-history-forward)
3232 (make-local-variable 'Info-index-alternatives)
3233 (setq header-line-format
3234 (if Info-use-header-line
3235 '(:eval (get-text-property (point-min) 'header-line))
3236 nil)) ; so the header line isn't displayed
3237 (set (make-local-variable 'tool-bar-map) info-tool-bar-map)
3238 ;; This is for the sake of the invisible text we use handling titles.
3239 (make-local-variable 'line-move-ignore-invisible)
3240 (setq line-move-ignore-invisible t)
3241 (make-local-variable 'desktop-save-buffer)
3242 (setq desktop-save-buffer 'Info-desktop-buffer-misc-data)
3243 (add-hook 'clone-buffer-hook 'Info-clone-buffer-hook nil t)
3244 (add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
3245 (add-hook 'isearch-mode-hook 'Info-isearch-start nil t)
3246 (set (make-local-variable 'isearch-search-fun-function)
3247 'Info-isearch-search)
3248 (set (make-local-variable 'isearch-wrap-function)
3249 'Info-isearch-wrap)
3250 (set (make-local-variable 'isearch-push-state-function)
3251 'Info-isearch-push-state)
3252 (set (make-local-variable 'search-whitespace-regexp)
3253 Info-search-whitespace-regexp)
3254 (Info-set-mode-line)
3255 (run-hooks 'Info-mode-hook))
3257 (defun Info-clone-buffer-hook ()
3258 (when (bufferp Info-tag-table-buffer)
3259 (setq Info-tag-table-buffer
3260 (with-current-buffer Info-tag-table-buffer (clone-buffer))))
3261 (let ((m Info-tag-table-marker))
3262 (when (markerp m)
3263 (setq Info-tag-table-marker
3264 (if (and (marker-position m) (bufferp Info-tag-table-buffer))
3265 (with-current-buffer Info-tag-table-buffer
3266 (copy-marker (marker-position m)))
3267 (make-marker))))))
3269 (defvar Info-edit-map (let ((map (make-sparse-keymap)))
3270 (set-keymap-parent map text-mode-map)
3271 (define-key map "\C-c\C-c" 'Info-cease-edit)
3272 map)
3273 "Local keymap used within `e' command of Info.")
3275 ;; Info-edit mode is suitable only for specially formatted data.
3276 (put 'Info-edit-mode 'mode-class 'special)
3278 (defun Info-edit-mode ()
3279 "Major mode for editing the contents of an Info node.
3280 Like text mode with the addition of `Info-cease-edit'
3281 which returns to Info mode for browsing.
3282 \\{Info-edit-map}"
3283 (use-local-map Info-edit-map)
3284 (setq major-mode 'Info-edit-mode)
3285 (setq mode-name "Info Edit")
3286 (kill-local-variable 'mode-line-buffer-identification)
3287 (setq buffer-read-only nil)
3288 (force-mode-line-update)
3289 (buffer-enable-undo (current-buffer))
3290 (run-hooks 'Info-edit-mode-hook))
3292 (defun Info-edit ()
3293 "Edit the contents of this Info node.
3294 Allowed only if variable `Info-enable-edit' is non-nil."
3295 (interactive)
3296 (or Info-enable-edit
3297 (error "Editing info nodes is not enabled"))
3298 (Info-edit-mode)
3299 (message "%s" (substitute-command-keys
3300 "Editing: Type \\<Info-edit-map>\\[Info-cease-edit] to return to info")))
3302 (defun Info-cease-edit ()
3303 "Finish editing Info node; switch back to Info proper."
3304 (interactive)
3305 ;; Do this first, so nothing has changed if user C-g's at query.
3306 (and (buffer-modified-p)
3307 (y-or-n-p "Save the file? ")
3308 (save-buffer))
3309 (use-local-map Info-mode-map)
3310 (setq major-mode 'Info-mode)
3311 (setq mode-name "Info")
3312 (Info-set-mode-line)
3313 (setq buffer-read-only t)
3314 (force-mode-line-update)
3315 (and (marker-position Info-tag-table-marker)
3316 (buffer-modified-p)
3317 (message "Tags may have changed. Use Info-tagify if necessary")))
3319 (defvar Info-file-list-for-emacs
3320 '("ediff" "eudc" "forms" "gnus" "info" ("Info" . "info") ("mh" . "mh-e")
3321 "sc" "message" ("dired" . "dired-x") "viper" "vip" "idlwave"
3322 ("c" . "ccmode") ("c++" . "ccmode") ("objc" . "ccmode")
3323 ("java" . "ccmode") ("idl" . "ccmode") ("pike" . "ccmode")
3324 ("skeleton" . "autotype") ("auto-insert" . "autotype")
3325 ("copyright" . "autotype") ("executable" . "autotype")
3326 ("time-stamp" . "autotype") ("quickurl" . "autotype")
3327 ("tempo" . "autotype") ("hippie-expand" . "autotype")
3328 ("cvs" . "pcl-cvs") ("ada" . "ada-mode") "calc"
3329 ("calcAlg" . "calc") ("calcDigit" . "calc") ("calcVar" . "calc")
3330 "ebrowse" "eshell" "cl" "reftex" "speedbar" "widget" "woman"
3331 ("mail-header" . "emacs-mime") ("mail-content" . "emacs-mime")
3332 ("mail-encode" . "emacs-mime") ("mail-decode" . "emacs-mime")
3333 ("rfc2045" . "emacs-mime")
3334 ("rfc2231" . "emacs-mime") ("rfc2047" . "emacs-mime")
3335 ("rfc2045" . "emacs-mime") ("rfc1843" . "emacs-mime")
3336 ("ietf-drums" . "emacs-mime") ("quoted-printable" . "emacs-mime")
3337 ("binhex" . "emacs-mime") ("uudecode" . "emacs-mime")
3338 ("mailcap" . "emacs-mime") ("mm" . "emacs-mime")
3339 ("mml" . "emacs-mime"))
3340 "List of Info files that describe Emacs commands.
3341 An element can be a file name, or a list of the form (PREFIX . FILE)
3342 where PREFIX is a name prefix and FILE is the file to look in.
3343 If the element is just a file name, the file name also serves as the prefix.")
3345 (defun Info-find-emacs-command-nodes (command)
3346 "Return a list of locations documenting COMMAND.
3347 The `info-file' property of COMMAND says which Info manual to search.
3348 If COMMAND has no property, the variable `Info-file-list-for-emacs'
3349 defines heuristics for which Info manual to try.
3350 The locations are of the format used in `Info-history', i.e.
3351 \(FILENAME NODENAME BUFFERPOS\), where BUFFERPOS is the line number
3352 in the first element of the returned list (which is treated specially in
3353 `Info-goto-emacs-command-node'), and 0 for the rest elements of a list."
3354 (let ((where '()) line-number
3355 (cmd-desc (concat "^\\* +" (regexp-quote (symbol-name command))
3356 "\\( <[0-9]+>\\)?:\\s *\\(.*\\)\\."
3357 "\\(?:[ \t\n]+(line +\\([0-9]+\\))\\)?"))
3358 (info-file "emacs")) ;default
3359 ;; Determine which info file this command is documented in.
3360 (if (get command 'info-file)
3361 (setq info-file (get command 'info-file))
3362 ;; If it doesn't say explicitly, test its name against
3363 ;; various prefixes that we know.
3364 (let ((file-list Info-file-list-for-emacs))
3365 (while file-list
3366 (let* ((elt (car file-list))
3367 (name (if (consp elt)
3368 (car elt)
3369 elt))
3370 (file (if (consp elt) (cdr elt) elt))
3371 (case-fold-search nil)
3372 (regexp (concat "\\`" (regexp-quote name)
3373 "\\(\\'\\|-\\)")))
3374 (if (string-match regexp (symbol-name command))
3375 (setq info-file file file-list nil))
3376 (setq file-list (cdr file-list))))))
3377 (Info-find-node info-file "Top")
3378 (or (and (search-forward "\n* menu:" nil t)
3379 (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t))
3380 (error "Info file `%s' appears to lack an index" info-file))
3381 (goto-char (match-beginning 1))
3382 ;; Bind Info-history to nil, to prevent the index nodes from
3383 ;; getting into the node history.
3384 (let ((Info-history nil)
3385 (Info-history-list nil)
3386 node (nodes (Info-index-nodes)))
3387 (Info-goto-node (car nodes))
3388 (while
3389 (progn
3390 (goto-char (point-min))
3391 (while (re-search-forward cmd-desc nil t)
3392 (setq where
3393 (cons (list Info-current-file
3394 (match-string-no-properties 2)
3396 where))
3397 (setq line-number (and (match-beginning 3)
3398 (string-to-number (match-string 3)))))
3399 (and (setq nodes (cdr nodes) node (car nodes))))
3400 (Info-goto-node node)))
3401 (if (and line-number where)
3402 (cons (list (nth 0 (car where)) (nth 1 (car where)) line-number)
3403 (cdr where))
3404 where)))
3406 ;;;###autoload (put 'Info-goto-emacs-command-node 'info-file "emacs")
3407 ;;;###autoload
3408 (defun Info-goto-emacs-command-node (command)
3409 "Go to the Info node in the Emacs manual for command COMMAND.
3410 The command is found by looking up in Emacs manual's indices
3411 or in another manual found via COMMAND's `info-file' property or
3412 the variable `Info-file-list-for-emacs'.
3413 COMMAND must be a symbol or string."
3414 (interactive "CFind documentation for command: ")
3415 ;; If command is given as a string, convert it to a symbol.
3416 (if (stringp command)
3417 (setq command (intern command)))
3418 (or (commandp command)
3419 (signal 'wrong-type-argument (list 'commandp command)))
3420 (let ((where (Info-find-emacs-command-nodes command)))
3421 (if where
3422 (let ((num-matches (length where)))
3423 ;; Get Info running, and pop to it in another window.
3424 (save-window-excursion
3425 (info))
3426 (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*"))
3427 ;; Bind Info-history to nil, to prevent the last Index node
3428 ;; visited by Info-find-emacs-command-nodes from being
3429 ;; pushed onto the history.
3430 (let ((Info-history nil) (Info-history-list nil)
3431 (line-number (nth 2 (car where))))
3432 (Info-find-node (nth 0 (car where)) (nth 1 (car where)))
3433 (if (and (integerp line-number) (> line-number 0))
3434 (forward-line (1- line-number))))
3435 (if (> num-matches 1)
3436 (progn
3437 ;; (car where) will be pushed onto Info-history
3438 ;; when/if they go to another node. Put the other
3439 ;; nodes that were found on the history.
3440 (setq Info-history (nconc (cdr where) Info-history))
3441 (message "Found %d other entr%s. Use %s to see %s."
3442 (1- num-matches)
3443 (if (> num-matches 2) "ies" "y")
3444 (substitute-command-keys "\\[Info-history-back]")
3445 (if (> num-matches 2) "them" "it")))))
3446 (error "Couldn't find documentation for %s" command))))
3448 ;;;###autoload (put 'Info-goto-emacs-key-command-node 'info-file "emacs")
3449 ;;;###autoload
3450 (defun Info-goto-emacs-key-command-node (key)
3451 "Go to the node in the Emacs manual which describes the command bound to KEY.
3452 KEY is a string.
3453 Interactively, if the binding is `execute-extended-command', a command is read.
3454 The command is found by looking up in Emacs manual's indices
3455 or in another manual found via COMMAND's `info-file' property or
3456 the variable `Info-file-list-for-emacs'."
3457 (interactive "kFind documentation for key: ")
3458 (let ((command (key-binding key)))
3459 (cond ((null command)
3460 (message "%s is undefined" (key-description key)))
3461 ((and (interactive-p)
3462 (eq command 'execute-extended-command))
3463 (Info-goto-emacs-command-node
3464 (read-command "Find documentation for command: ")))
3466 (Info-goto-emacs-command-node command)))))
3468 (defface Info-title-1-face
3469 '((((type tty pc) (class color)) :foreground "yellow" :weight bold)
3470 (t :height 1.2 :inherit Info-title-2-face))
3471 "Face for Info titles at level 1."
3472 :group 'info)
3474 (defface Info-title-2-face
3475 '((((type tty pc) (class color)) :foreground "lightblue" :weight bold)
3476 (t :height 1.2 :inherit Info-title-3-face))
3477 "Face for Info titles at level 2."
3478 :group 'info)
3480 (defface Info-title-3-face
3481 '((((type tty pc) (class color)) :weight bold)
3482 (t :height 1.2 :inherit Info-title-4-face))
3483 "Face for Info titles at level 3."
3484 :group 'info)
3486 (defface Info-title-4-face
3487 '((((type tty pc) (class color)) :weight bold)
3488 (t :weight bold :inherit variable-pitch))
3489 "Face for Info titles at level 4."
3490 :group 'info)
3492 (defface info-menu-header
3493 '((((type tty pc))
3494 :underline t
3495 :weight bold)
3497 :inherit variable-pitch
3498 :weight bold))
3499 "Face for headers in Info menus."
3500 :group 'info)
3502 (defun Info-escape-percent (string)
3503 "Double all occurrences of `%' in STRING.
3505 Return a new string with all `%' characters replaced by `%%'.
3506 Preserve text properties."
3507 (let ((start 0)
3508 (end (length string))
3509 mb me m matches)
3510 (save-match-data
3511 (while (and (< start end) (string-match "%" string start))
3512 (setq mb (match-beginning 0)
3513 me (1+ mb)
3514 m (substring string mb me)
3515 matches (cons m
3516 (cons m
3517 (cons (substring string start mb)
3518 matches)))
3519 start me))
3520 (push (substring string start end) matches)
3521 (apply #'concat (nreverse matches)))))
3523 (defvar Info-next-link-keymap
3524 (let ((keymap (make-sparse-keymap)))
3525 (define-key keymap [header-line mouse-1] 'Info-next)
3526 (define-key keymap [header-line mouse-2] 'Info-next)
3527 (define-key keymap [header-line down-mouse-1] 'ignore)
3528 (define-key keymap [mouse-2] 'Info-next)
3529 (define-key keymap [follow-link] 'mouse-face)
3530 keymap)
3531 "Keymap to put on the Next link in the text or the header line.")
3533 (defvar Info-prev-link-keymap
3534 (let ((keymap (make-sparse-keymap)))
3535 (define-key keymap [header-line mouse-1] 'Info-prev)
3536 (define-key keymap [header-line mouse-2] 'Info-prev)
3537 (define-key keymap [header-line down-mouse-1] 'ignore)
3538 (define-key keymap [mouse-2] 'Info-prev)
3539 (define-key keymap [follow-link] 'mouse-face)
3540 keymap)
3541 "Keymap to put on the Prev link in the text or the header line.")
3544 (defvar Info-up-link-keymap
3545 (let ((keymap (make-sparse-keymap)))
3546 (define-key keymap [header-line mouse-1] 'Info-up)
3547 (define-key keymap [header-line mouse-2] 'Info-up)
3548 (define-key keymap [header-line down-mouse-1] 'ignore)
3549 (define-key keymap [mouse-2] 'Info-up)
3550 (define-key keymap [follow-link] 'mouse-face)
3551 keymap)
3552 "Keymap to put on the Up link in the text or the header line.")
3554 (defun Info-fontify-node ()
3555 "Fontify the node."
3556 (save-excursion
3557 (let* ((inhibit-read-only t)
3558 (case-fold-search t)
3559 paragraph-markers
3560 (not-fontified-p ; the node hasn't already been fontified
3561 (not (let ((where (next-property-change (point-min))))
3562 (and where (not (= where (point-max)))))))
3563 (fontify-visited-p ; visited nodes need to be re-fontified
3564 (and Info-fontify-visited-nodes
3565 ;; Don't take time to refontify visited nodes in huge nodes
3566 (< (- (point-max) (point-min)) Info-fontify-maximum-menu-size)))
3567 rbeg rend)
3569 ;; Fontify header line
3570 (goto-char (point-min))
3571 (when (and not-fontified-p (looking-at "^\\(File: [^,: \t]+,?[ \t]+\\)?"))
3572 (goto-char (match-end 0))
3573 (while (looking-at "[ \t]*\\([^:, \t\n]+\\):[ \t]+\\([^:,\t\n]+\\),?")
3574 (goto-char (match-end 0))
3575 (let* ((nbeg (match-beginning 2))
3576 (nend (match-end 2))
3577 (tbeg (match-beginning 1))
3578 (tag (match-string 1)))
3579 (if (string-equal tag "Node")
3580 (put-text-property nbeg nend 'font-lock-face 'info-header-node)
3581 (put-text-property nbeg nend 'font-lock-face 'info-header-xref)
3582 (put-text-property tbeg nend 'mouse-face 'highlight)
3583 (put-text-property tbeg nend
3584 'help-echo
3585 (concat "mouse-2: Go to node "
3586 (buffer-substring nbeg nend)))
3587 ;; Always set up the text property keymap.
3588 ;; It will either be used in the buffer
3589 ;; or copied in the header line.
3590 (put-text-property tbeg nend 'keymap
3591 (cond
3592 ((equal tag "Prev") Info-prev-link-keymap)
3593 ((equal tag "Next") Info-next-link-keymap)
3594 ((equal tag "Up") Info-up-link-keymap))))))
3595 (when Info-use-header-line
3596 (goto-char (point-min))
3597 (let ((header-end (line-end-position))
3598 header)
3599 ;; If we find neither Next: nor Prev: link, show the entire
3600 ;; node header. Otherwise, don't show the File: and Node:
3601 ;; parts, to avoid wasting precious space on information that
3602 ;; is available in the mode line.
3603 (if (re-search-forward
3604 "\\(next\\|up\\|prev[ious]*\\): "
3605 header-end t)
3606 (progn
3607 (goto-char (match-beginning 1))
3608 (setq header (buffer-substring (point) header-end)))
3609 (if (re-search-forward "node:[ \t]*[^ \t]+[ \t]*" header-end t)
3610 (setq header
3611 (concat "No next, prev or up links -- "
3612 (buffer-substring (point) header-end)))
3613 (setq header (buffer-substring (point) header-end))))
3614 (put-text-property (point-min) (1+ (point-min))
3615 'header-line (Info-escape-percent header))
3616 ;; Hide the part of the first line
3617 ;; that is in the header, if it is just part.
3618 (unless (bobp)
3619 ;; Hide the punctuation at the end, too.
3620 (skip-chars-backward " \t,")
3621 (put-text-property (point) header-end 'invisible t)))))
3623 ;; Fontify titles
3624 (goto-char (point-min))
3625 (when not-fontified-p
3626 (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*\\*+\\|==+\\|--+\\|\\.\\.+\\)$"
3627 nil t)
3628 (let* ((c (preceding-char))
3629 (face
3630 (cond ((= c ?*) 'Info-title-1-face)
3631 ((= c ?=) 'Info-title-2-face)
3632 ((= c ?-) 'Info-title-3-face)
3633 (t 'Info-title-4-face))))
3634 (put-text-property (match-beginning 1) (match-end 1)
3635 'font-lock-face face))
3636 ;; This is a serious problem for trying to handle multiple
3637 ;; frame types at once. We want this text to be invisible
3638 ;; on frames that can display the font above.
3639 (when (memq (framep (selected-frame)) '(x pc w32 mac))
3640 (add-text-properties (1- (match-beginning 2)) (match-end 2)
3641 '(invisible t front-sticky nil rear-nonsticky t)))))
3643 ;; Fontify cross references
3644 (goto-char (point-min))
3645 (when (or not-fontified-p fontify-visited-p)
3646 (while (re-search-forward "\\(\\*Note[ \n\t]+\\)\\([^:]*\\)\\(:[ \t]*\\([^.,:(]*\\)\\(\\(([^)]*)\\)[^.,:]*\\)?[,:]?\n?\\)" nil t)
3647 (let ((start (match-beginning 0))
3648 (next (point))
3649 other-tag)
3650 (when not-fontified-p
3651 (when Info-hide-note-references
3652 (when (not (eq Info-hide-note-references 'hide))
3653 ;; *Note is often used where *note should have been
3654 (goto-char start)
3655 (skip-syntax-backward " ")
3656 (setq other-tag
3657 (cond ((memq (char-before) '(nil ?\. ?! ??))
3658 "See ")
3659 ((memq (char-before) '(?\, ?\; ?\: ?-))
3660 "see ")
3661 ((memq (char-before) '(?\( ?\[ ?\{))
3662 ;; Check whether the paren is preceded by
3663 ;; an end of sentence
3664 (skip-syntax-backward " (")
3665 (if (memq (char-before) '(nil ?\. ?! ??))
3666 "See "
3667 "see "))
3668 ((save-match-data (looking-at "\n\n"))
3669 "See "))))
3670 (goto-char next)
3671 (add-text-properties
3672 (match-beginning 1)
3673 (or (save-match-data
3674 ;; Don't hide \n after *Note
3675 (let ((start1 (match-beginning 1)))
3676 (if (string-match "\n" (match-string 1))
3677 (+ start1 (match-beginning 0)))))
3678 (match-end 1))
3679 (if other-tag
3680 `(display ,other-tag front-sticky nil rear-nonsticky t)
3681 '(invisible t front-sticky nil rear-nonsticky t))))
3682 (add-text-properties
3683 (match-beginning 2) (match-end 2)
3684 (list
3685 'help-echo (if (or (match-end 5)
3686 (not (equal (match-string 4) "")))
3687 (concat "mouse-2: go to " (or (match-string 5)
3688 (match-string 4)))
3689 "mouse-2: go to this node")
3690 'mouse-face 'highlight)))
3691 (when (or not-fontified-p fontify-visited-p)
3692 (setq rbeg (match-beginning 2)
3693 rend (match-end 2))
3694 (put-text-property
3695 rbeg rend
3696 'font-lock-face
3697 ;; Display visited nodes in a different face
3698 (if (and Info-fontify-visited-nodes
3699 (save-match-data
3700 (let* ((node (replace-regexp-in-string
3701 "^[ \t]+" ""
3702 (replace-regexp-in-string
3703 "[ \t\n]+" " "
3704 (or (match-string 5)
3705 (and (not (equal (match-string 4) ""))
3706 (match-string 4))
3707 (match-string 2)))))
3708 (file (file-name-nondirectory
3709 Info-current-file))
3710 (hl Info-history-list)
3711 res)
3712 (if (string-match "(\\([^)]+\\))\\([^)]*\\)" node)
3713 (setq file (file-name-nondirectory
3714 (match-string 1 node))
3715 node (if (equal (match-string 2 node) "")
3716 "Top"
3717 (match-string 2 node))))
3718 (while hl
3719 (if (and (string-equal node (nth 1 (car hl)))
3720 (string-equal file
3721 (file-name-nondirectory
3722 (nth 0 (car hl)))))
3723 (setq res (car hl) hl nil)
3724 (setq hl (cdr hl))))
3725 res))) 'info-xref-visited 'info-xref))
3726 ;; For multiline ref, unfontify newline and surrounding whitespace
3727 (save-excursion
3728 (goto-char rbeg)
3729 (save-match-data
3730 (while (re-search-forward "\\s-*\n\\s-*" rend t nil)
3731 (remove-text-properties (match-beginning 0)
3732 (match-end 0)
3733 '(font-lock-face t))))))
3734 (when not-fontified-p
3735 (when (memq Info-hide-note-references '(t hide))
3736 (add-text-properties (match-beginning 3) (match-end 3)
3737 '(invisible t front-sticky nil rear-nonsticky t))
3738 ;; Unhide the file name of the external reference in parens
3739 (if (and (match-string 6) (not (eq Info-hide-note-references 'hide)))
3740 (remove-text-properties (match-beginning 6) (match-end 6)
3741 '(invisible t front-sticky nil rear-nonsticky t)))
3742 ;; Unhide newline because hidden newlines cause too long lines
3743 (save-match-data
3744 (let ((beg3 (match-beginning 3))
3745 (end3 (match-end 3)))
3746 (if (and (string-match "\n[ \t]*" (match-string 3))
3747 (not (save-match-data
3748 (save-excursion
3749 (goto-char (1+ end3))
3750 (looking-at "[.)]*$")))))
3751 (remove-text-properties (+ beg3 (match-beginning 0))
3752 (+ beg3 (match-end 0))
3753 '(invisible t front-sticky nil rear-nonsticky t))))))
3754 (when (and Info-refill-paragraphs Info-hide-note-references)
3755 (push (set-marker (make-marker) start)
3756 paragraph-markers))))))
3758 ;; Refill paragraphs (experimental feature)
3759 (when (and not-fontified-p
3760 Info-refill-paragraphs
3761 paragraph-markers)
3762 (let ((fill-nobreak-invisible t)
3763 (fill-individual-varying-indent nil)
3764 (paragraph-start "\f\\|[ \t]*[-*]\\|[ \t]*$")
3765 (paragraph-separate ".*\\.[ \t]*\n[ \t]\\|[ \t]*[-*]\\|[ \t\f]*$")
3766 (adaptive-fill-mode nil))
3767 (goto-char (point-max))
3768 (while paragraph-markers
3769 (let ((m (car paragraph-markers)))
3770 (setq paragraph-markers (cdr paragraph-markers))
3771 (when (< m (point))
3772 (goto-char m)
3773 (beginning-of-line)
3774 (let ((beg (point)))
3775 (when (zerop (forward-paragraph))
3776 (fill-individual-paragraphs beg (point) nil nil)
3777 (goto-char beg))))
3778 (set-marker m nil)))))
3780 ;; Fontify menu items
3781 (goto-char (point-min))
3782 (when (and (or not-fontified-p fontify-visited-p)
3783 (search-forward "\n* Menu:" nil t)
3784 (not (Info-index-node))
3785 ;; Don't take time to annotate huge menus
3786 (< (- (point-max) (point)) Info-fontify-maximum-menu-size))
3787 (let ((n 0)
3788 cont)
3789 (while (re-search-forward
3790 (concat "^\\* +\\(" Info-menu-entry-name-re "\\)\\(:"
3791 Info-node-spec-re "\\([ \t]*\\)\\)")
3792 nil t)
3793 (when not-fontified-p
3794 (setq n (1+ n))
3795 (if (and (<= n 9) (zerop (% n 3))) ; visual aids to help with 1-9 keys
3796 (put-text-property (match-beginning 0)
3797 (1+ (match-beginning 0))
3798 'font-lock-face 'info-menu-5)))
3799 (when not-fontified-p
3800 (add-text-properties
3801 (match-beginning 1) (match-end 1)
3802 (list
3803 'help-echo (if (and (match-end 3)
3804 (not (equal (match-string 3) "")))
3805 (concat "mouse-2: go to " (match-string 3))
3806 "mouse-2: go to this node")
3807 'mouse-face 'highlight)))
3808 (when (or not-fontified-p fontify-visited-p)
3809 (add-text-properties
3810 (match-beginning 1) (match-end 1)
3811 (list
3812 'font-lock-face
3813 ;; Display visited menu items in a different face
3814 (if (and Info-fontify-visited-nodes
3815 (save-match-data
3816 (let ((node (if (equal (match-string 3) "")
3817 (match-string 1)
3818 (match-string 3)))
3819 (file (file-name-nondirectory Info-current-file))
3820 (hl Info-history-list)
3821 res)
3822 (if (string-match "(\\([^)]+\\))\\([^)]*\\)" node)
3823 (setq file (file-name-nondirectory
3824 (match-string 1 node))
3825 node (if (equal (match-string 2 node) "")
3826 "Top"
3827 (match-string 2 node))))
3828 (while hl
3829 (if (and (string-equal node (nth 1 (car hl)))
3830 (string-equal file
3831 (file-name-nondirectory
3832 (nth 0 (car hl)))))
3833 (setq res (car hl) hl nil)
3834 (setq hl (cdr hl))))
3835 res))) 'info-xref-visited 'info-xref))))
3836 (when (and not-fontified-p (memq Info-hide-note-references '(t hide)))
3837 (put-text-property (match-beginning 2) (1- (match-end 6))
3838 'invisible t)
3839 ;; Unhide the file name in parens
3840 (if (and (match-end 4) (not (eq (char-after (match-end 4)) ?.)))
3841 (remove-text-properties (match-beginning 4) (match-end 4)
3842 '(invisible t)))
3843 ;; We need a stretchable space like :align-to but with
3844 ;; a minimum value.
3845 (put-text-property (1- (match-end 6)) (match-end 6) 'display
3846 (if (>= 22 (- (match-end 1)
3847 (match-beginning 0)))
3848 '(space :align-to 24)
3849 '(space :width 2)))
3850 (setq cont (looking-at "."))
3851 (while (and (= (forward-line 1) 0)
3852 (looking-at "\\([ \t]+\\)[^*\n]"))
3853 (put-text-property (match-beginning 1) (1- (match-end 1))
3854 'invisible t)
3855 (put-text-property (1- (match-end 1)) (match-end 1)
3856 'display
3857 (if cont
3858 '(space :align-to 26)
3859 '(space :align-to 24)))
3860 (setq cont t))))))
3862 ;; Fontify menu headers
3863 ;; Add the face `info-menu-header' to any header before a menu entry
3864 (goto-char (point-min))
3865 (when (and not-fontified-p (re-search-forward "^\\* Menu:" nil t))
3866 (put-text-property (match-beginning 0) (match-end 0)
3867 'font-lock-face 'info-menu-header)
3868 (while (re-search-forward "\n\n\\([^*\n ].*\\)\n\n?[*]" nil t)
3869 (put-text-property (match-beginning 1) (match-end 1)
3870 'font-lock-face 'info-menu-header)))
3872 ;; Hide index line numbers
3873 (goto-char (point-min))
3874 (when (and not-fontified-p (Info-index-node))
3875 (while (re-search-forward "[ \t\n]*(line +[0-9]+)" nil t)
3876 (put-text-property (match-beginning 0) (match-end 0)
3877 'invisible t)))
3879 ;; Fontify http and ftp references
3880 (goto-char (point-min))
3881 (when not-fontified-p
3882 (while (re-search-forward "[hf]t?tp://[^ \t\n\"`({<>})']+" nil t)
3883 (add-text-properties (match-beginning 0) (match-end 0)
3884 '(font-lock-face info-xref
3885 mouse-face highlight
3886 help-echo "mouse-2: go to this URL"))))
3888 (set-buffer-modified-p nil))))
3891 ;; When an Info buffer is killed, make sure the associated tags buffer
3892 ;; is killed too.
3893 (defun Info-kill-buffer ()
3894 (and (eq major-mode 'Info-mode)
3895 Info-tag-table-buffer
3896 (kill-buffer Info-tag-table-buffer)))
3898 (add-hook 'kill-buffer-hook 'Info-kill-buffer)
3900 ;;; Speedbar support:
3901 ;; These functions permit speedbar to display the "tags" in the
3902 ;; current info node.
3903 (eval-when-compile (require 'speedbar))
3905 (defvar Info-speedbar-key-map nil
3906 "Keymap used when in the info display mode.")
3908 (defun Info-install-speedbar-variables ()
3909 "Install those variables used by speedbar to enhance Info."
3910 (if Info-speedbar-key-map
3912 (setq Info-speedbar-key-map (speedbar-make-specialized-keymap))
3914 ;; Basic tree features
3915 (define-key Info-speedbar-key-map "e" 'speedbar-edit-line)
3916 (define-key Info-speedbar-key-map "\C-m" 'speedbar-edit-line)
3917 (define-key Info-speedbar-key-map "+" 'speedbar-expand-line)
3918 (define-key Info-speedbar-key-map "-" 'speedbar-contract-line)
3921 (speedbar-add-expansion-list '("Info" Info-speedbar-menu-items
3922 Info-speedbar-key-map
3923 Info-speedbar-hierarchy-buttons)))
3925 (defvar Info-speedbar-menu-items
3926 '(["Browse Node" speedbar-edit-line t]
3927 ["Expand Node" speedbar-expand-line
3928 (save-excursion (beginning-of-line)
3929 (looking-at "[0-9]+: *.\\+. "))]
3930 ["Contract Node" speedbar-contract-line
3931 (save-excursion (beginning-of-line)
3932 (looking-at "[0-9]+: *.-. "))]
3934 "Additional menu-items to add to speedbar frame.")
3936 ;; Make sure our special speedbar major mode is loaded
3937 (if (featurep 'speedbar)
3938 (Info-install-speedbar-variables)
3939 (add-hook 'speedbar-load-hook 'Info-install-speedbar-variables))
3941 ;;; Info hierarchy display method
3942 ;;;###autoload
3943 (defun Info-speedbar-browser ()
3944 "Initialize speedbar to display an info node browser.
3945 This will add a speedbar major display mode."
3946 (interactive)
3947 (require 'speedbar)
3948 ;; Make sure that speedbar is active
3949 (speedbar-frame-mode 1)
3950 ;; Now, throw us into Info mode on speedbar.
3951 (speedbar-change-initial-expansion-list "Info")
3954 (eval-when-compile (defvar speedbar-attached-frame))
3956 (defun Info-speedbar-hierarchy-buttons (directory depth &optional node)
3957 "Display an Info directory hierarchy in speedbar.
3958 DIRECTORY is the current directory in the attached frame.
3959 DEPTH is the current indentation depth.
3960 NODE is an optional argument that is used to represent the
3961 specific node to expand."
3962 (if (and (not node)
3963 (save-excursion (goto-char (point-min))
3964 (let ((case-fold-search t))
3965 (looking-at "Info Nodes:"))))
3966 ;; Update our "current node" maybe?
3968 ;; We cannot use the generic list code, that depends on all leaves
3969 ;; being known at creation time.
3970 (if (not node)
3971 (speedbar-with-writable (insert "Info Nodes:\n")))
3972 (let ((completions nil)
3973 (cf (selected-frame)))
3974 (select-frame speedbar-attached-frame)
3975 (save-window-excursion
3976 (setq completions
3977 (Info-speedbar-fetch-file-nodes (or node '"(dir)top"))))
3978 (select-frame cf)
3979 (if completions
3980 (speedbar-with-writable
3981 (dolist (completion completions)
3982 (speedbar-make-tag-line 'bracket ?+ 'Info-speedbar-expand-node
3983 (cdr completion)
3984 (car completion)
3985 'Info-speedbar-goto-node
3986 (cdr completion)
3987 'info-xref depth))
3989 nil))))
3991 (defun Info-speedbar-goto-node (text node indent)
3992 "When user clicks on TEXT, go to an info NODE.
3993 The INDENT level is ignored."
3994 (select-frame speedbar-attached-frame)
3995 (let* ((buff (or (get-buffer "*info*")
3996 (progn (info) (get-buffer "*info*"))))
3997 (bwin (get-buffer-window buff 0)))
3998 (if bwin
3999 (progn
4000 (select-window bwin)
4001 (raise-frame (window-frame bwin)))
4002 (if speedbar-power-click
4003 (let ((pop-up-frames t)) (select-window (display-buffer buff)))
4004 (select-frame speedbar-attached-frame)
4005 (switch-to-buffer buff)))
4006 (if (not (string-match "^(\\([^)]+\\))\\([^.]+\\)$" node))
4007 (error "Invalid node %s" node)
4008 (Info-find-node (match-string 1 node) (match-string 2 node))
4009 ;; If we do a find-node, and we were in info mode, restore
4010 ;; the old default method. Once we are in info mode, it makes
4011 ;; sense to return to whatever method the user was using before.
4012 (if (string= speedbar-initial-expansion-list-name "Info")
4013 (speedbar-change-initial-expansion-list
4014 speedbar-previously-used-expansion-list-name)))))
4016 (defun Info-speedbar-expand-node (text token indent)
4017 "Expand the node the user clicked on.
4018 TEXT is the text of the button we clicked on, a + or - item.
4019 TOKEN is data related to this node (NAME . FILE).
4020 INDENT is the current indentation depth."
4021 (cond ((string-match "+" text) ;we have to expand this file
4022 (speedbar-change-expand-button-char ?-)
4023 (if (speedbar-with-writable
4024 (save-excursion
4025 (end-of-line) (forward-char 1)
4026 (Info-speedbar-hierarchy-buttons nil (1+ indent) token)))
4027 (speedbar-change-expand-button-char ?-)
4028 (speedbar-change-expand-button-char ??)))
4029 ((string-match "-" text) ;we have to contract this node
4030 (speedbar-change-expand-button-char ?+)
4031 (speedbar-delete-subblock indent))
4032 (t (error "Ooops... not sure what to do")))
4033 (speedbar-center-buffer-smartly))
4035 (defun Info-speedbar-fetch-file-nodes (nodespec)
4036 "Fetch the subnodes from the info NODESPEC.
4037 NODESPEC is a string of the form: (file)node.
4038 Optional THISFILE represends the filename of"
4039 (save-excursion
4040 ;; Set up a buffer we can use to fake-out Info.
4041 (set-buffer (get-buffer-create "*info-browse-tmp*"))
4042 (if (not (equal major-mode 'Info-mode))
4043 (Info-mode))
4044 ;; Get the node into this buffer
4045 (if (not (string-match "^(\\([^)]+\\))\\([^.]+\\)$" nodespec))
4046 (error "Invalid node specification %s" nodespec)
4047 (Info-find-node (match-string 1 nodespec) (match-string 2 nodespec)))
4048 ;; Scan the created buffer
4049 (goto-char (point-min))
4050 (let ((completions nil)
4051 (case-fold-search t)
4052 (thisfile (progn (string-match "^(\\([^)]+\\))" nodespec)
4053 (match-string 1 nodespec))))
4054 ;; Always skip the first one...
4055 (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
4056 (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
4057 (let ((name (match-string 1)))
4058 (push (cons name
4059 (if (looking-at " *\\(([^)]+)[^.\n]+\\)\\.")
4060 (match-string 1)
4061 (if (looking-at " *\\(([^)]+)\\)\\.")
4062 (concat (match-string 1) "Top")
4063 (concat "(" thisfile ")"
4064 (if (looking-at " \\([^.]+\\).")
4065 (match-string 1)
4066 name)))))
4067 completions)))
4068 (nreverse completions))))
4070 ;;; Info mode node listing
4071 ;; FIXME: Seems not to be used. -stef
4072 (defun Info-speedbar-buttons (buffer)
4073 "Create a speedbar display to help navigation in an Info file.
4074 BUFFER is the buffer speedbar is requesting buttons for."
4075 (if (save-excursion (goto-char (point-min))
4076 (let ((case-fold-search t))
4077 (not (looking-at "Info Nodes:"))))
4078 (erase-buffer))
4079 (Info-speedbar-hierarchy-buttons nil 0)
4082 (dolist (mess '("^First node in file$"
4083 "^No `.*' in index$"
4084 "^No cross-reference named"
4085 "^No cross.references in this node$"
4086 "^No current info node$"
4087 "^No menu in this node$"
4088 "^No more items in menu$"
4089 "^No more nodes$"
4090 "^No pointer \\(?:forward\\|backward\\) from this node$"
4091 "^No previous `i' command$"
4092 "^No previous items in menu$"
4093 "^No previous nodes$"
4094 "^No such item in menu$"
4095 "^No such node or anchor"
4096 "^Node has no"
4097 "^Point neither on reference nor in menu item description$"
4098 "^This is the \\(?:first\\|last\\) Info node you looked at$"
4099 search-failed))
4100 (add-to-list 'debug-ignored-errors mess))
4102 ;;;; Desktop support
4104 (defun Info-desktop-buffer-misc-data (desktop-dirname)
4105 "Auxiliary information to be saved in desktop file."
4106 (if (not (member Info-current-file '("apropos" "history" "toc")))
4107 (list Info-current-file Info-current-node)))
4109 ;;;###autoload
4110 (defun Info-restore-desktop-buffer (desktop-buffer-file-name
4111 desktop-buffer-name
4112 desktop-buffer-misc)
4113 "Restore an info buffer specified in a desktop file."
4114 (let ((first (nth 0 desktop-buffer-misc))
4115 (second (nth 1 desktop-buffer-misc)))
4116 (when (and first second)
4117 (when desktop-buffer-name
4118 (set-buffer (get-buffer-create desktop-buffer-name))
4119 (Info-mode))
4120 (Info-find-node first second)
4121 (current-buffer))))
4123 (provide 'info)
4125 ;;; arch-tag: f2480fe2-2139-40c1-a49b-6314991164ac
4126 ;;; info.el ends here