1 ;;; info.el --- info package for Emacs
3 ;; Copyright (C) 1985, 1986, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4 ;; 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
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)
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., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
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 ": ".
38 (eval-when-compile (require 'jka-compr
))
46 (defvar Info-history nil
47 "Stack of Info nodes user has visited.
48 Each element of the stack 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 the stack 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 the 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."
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
)
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."
80 '((((type tty pc
) (class color
) (background light
))
81 :foreground
"green" :weight bold
)
82 (((type tty pc
) (class color
) (background dark
))
83 :foreground
"yellow" :weight bold
)
84 (t :height
1.2 :inherit info-title-2
))
85 "Face for info titles at level 1."
87 ;; backward-compatibility alias
88 (put 'Info-title-1-face
'face-alias
'info-title-1
)
91 '((((type tty pc
) (class color
)) :foreground
"lightblue" :weight bold
)
92 (t :height
1.2 :inherit info-title-3
))
93 "Face for info titles at level 2."
95 ;; backward-compatibility alias
96 (put 'Info-title-2-face
'face-alias
'info-title-2
)
99 '((((type tty pc
) (class color
)) :weight bold
)
100 (t :height
1.2 :inherit info-title-4
))
101 "Face for info titles at level 3."
103 ;; backward-compatibility alias
104 (put 'Info-title-3-face
'face-alias
'info-title-3
)
106 (defface info-title-4
107 '((((type tty pc
) (class color
)) :weight bold
)
108 (t :weight bold
:inherit variable-pitch
))
109 "Face for info titles at level 4."
111 ;; backward-compatibility alias
112 (put 'Info-title-4-face
'face-alias
'info-title-4
)
114 (defface info-menu-header
119 :inherit variable-pitch
121 "Face for headers in Info menus."
124 (defface info-menu-star
125 '((((class color
)) :foreground
"red1")
127 "Face for every third `*' in an Info menu."
129 (put 'info-menu-5
'face-alias
'info-menu-star
)
133 (class color
) (background light
)) :foreground
"blue1" :underline t
)
134 (((class color
) (background light
)) :foreground
"blue" :underline t
)
136 (class color
) (background dark
)) :foreground
"cyan1" :underline t
)
137 (((class color
) (background dark
)) :foreground
"cyan" :underline t
)
139 "Face for Info cross-references."
142 (defface info-xref-visited
143 '((default :inherit info-xref
)
144 (((class color
) (background light
)) :foreground
"magenta4")
145 (((class color
) (background dark
)) :foreground
"violet"))
146 "Face for visited Info cross-references."
149 (defcustom Info-fontify-visited-nodes t
150 "*Non-nil to fontify references to visited nodes in `info-xref-visited' face."
155 (defcustom Info-fontify-maximum-menu-size
100000
156 "*Maximum size of menu to fontify if `font-lock-mode' is non-nil."
160 (defcustom Info-use-header-line t
161 "*Non-nil means to put the beginning-of-node links in an Emacs header-line.
162 A header-line does not scroll with the rest of the buffer."
166 (defface info-header-xref
167 '((t :inherit info-xref
))
168 "Face for Info cross-references in a node header."
171 (defface info-header-node
172 '((t :inherit info-node
))
173 "Face for Info nodes in a node header."
176 (defvar Info-directory-list nil
177 "List of directories to search for Info documentation files.
178 If nil, meaning not yet initialized, Info uses the environment
179 variable INFOPATH to initialize it, or `Info-default-directory-list'
180 if there is no INFOPATH variable in the environment, or the
181 concatenation of the two if INFOPATH ends with a colon.
183 When `Info-directory-list' is initialized from the value of
184 `Info-default-directory-list', and Emacs is installed in one of the
185 standard directories, the directory of Info files that come with Emacs
186 is put last (so that local Info files override standard ones).
188 When `Info-directory-list' is initialized from the value of
189 `Info-default-directory-list', and Emacs is not installed in one
190 of the standard directories, the first element of the resulting
191 list is the directory where Emacs installs the Info files that
192 come with it. This is so that Emacs's own manual, which suits the
193 version of Emacs you are using, will always be found first. This
194 is useful when you install an experimental version of Emacs without
195 removing the standard installation.
197 If you want to override the order of directories in
198 `Info-default-directory-list', set INFOPATH in the environment.
200 If you run the Emacs executable from the `src' directory in the Emacs
201 source tree, and INFOPATH is not defined, the `info' directory in the
202 source tree is used as the first element of `Info-directory-list', in
203 place of the installation Info directory. This is useful when you run
204 a version of Emacs without installing it.")
206 (defcustom Info-additional-directory-list nil
207 "List of additional directories to search for Info documentation files.
208 These directories are searched after those in `Info-directory-list'."
209 :type
'(repeat directory
)
212 (defcustom Info-scroll-prefer-subnodes nil
213 "*If non-nil, \\<Info-mode-map>\\[Info-scroll-up] in a menu visits subnodes.
215 If this is non-nil, and you scroll far enough in a node that its menu
216 appears on the screen, the next \\<Info-mode-map>\\[Info-scroll-up]
217 moves to a subnode indicated by the following menu item. This means
218 that you visit a subnode before getting to the end of the menu.
220 Setting this option to nil results in behavior similar to the stand-alone
221 Info reader program, which visits the first subnode from the menu only
222 when you hit the end of the current node."
227 (defcustom Info-hide-note-references t
228 "*If non-nil, hide the tag and section reference in *note and * menu items.
229 If value is non-nil but not `hide', also replaces the \"*note\" with \"see\".
230 If value is non-nil but not t or `hide', the reference section is still shown.
231 `nil' completely disables this feature."
233 :type
'(choice (const :tag
"No hiding" nil
)
234 (const :tag
"Replace tag and hide reference" t
)
235 (const :tag
"Hide tag and reference" hide
)
236 (other :tag
"Only replace tag" tag
))
239 (defcustom Info-refill-paragraphs nil
240 "*If non-nil, attempt to refill paragraphs with hidden references.
241 This refilling may accidentally remove explicit line breaks in the Info
242 file, so be prepared for a few surprises if you enable this feature."
247 (defcustom Info-search-whitespace-regexp
"\\s-+"
248 "*If non-nil, regular expression to match a sequence of whitespace chars.
249 This applies to Info search for regular expressions.
250 You might want to use something like \"[ \\t\\r\\n]+\" instead.
251 In the Customization buffer, that is `[' followed by a space,
252 a tab, a carriage return (control-M), a newline, and `]+'."
256 (defcustom Info-isearch-search t
257 "*If non-nil, isearch in Info searches through multiple nodes.
258 Before leaving the initial Info node, where isearch was started,
259 it fails once with the error message [initial node], and with
260 subsequent C-s/C-r continues through other nodes without failing
261 with this error message in other nodes. When isearch fails for
262 the rest of the manual, it wraps aroung the whole manual and
263 restarts the search from the top/final node depending on
266 Setting this option to nil restores the default isearch behavior
267 with wrapping around the current Info node."
272 (defvar Info-isearch-initial-node nil
)
274 (defcustom Info-mode-hook
275 ;; Try to obey obsolete Info-fontify settings.
276 (unless (and (boundp 'Info-fontify
) (null Info-fontify
))
277 '(turn-on-font-lock))
278 "Hooks run when `Info-mode' is called."
282 (defcustom Info-selection-hook nil
283 "Hooks run when `Info-select-node' is called."
287 (defvar Info-edit-mode-hook nil
288 "Hooks run when `Info-edit-mode' is called.")
290 (defvar Info-current-file nil
291 "Info file that Info is now looking at, or nil.
292 This is the name that was specified in Info, not the actual file name.
293 It doesn't contain directory names or file name extensions added by Info.")
295 (defvar Info-current-subfile nil
296 "Info subfile that is actually in the *info* buffer now.
297 nil if current Info file is not split into subfiles.")
299 (defvar Info-current-node nil
300 "Name of node that Info is now looking at, or nil.")
302 (defvar Info-tag-table-marker nil
303 "Marker pointing at beginning of current Info file's tag table.
304 Marker points nowhere if file has no tag table.")
306 (defvar Info-tag-table-buffer nil
307 "Buffer used for indirect tag tables.")
309 (defvar Info-current-file-completions nil
310 "Cached completion list for current Info file.")
312 (defvar Info-file-supports-index-cookies nil
313 "Non-nil if current Info file supports index cookies.")
315 (defvar Info-index-alternatives nil
316 "List of possible matches for last `Info-index' command.")
318 (defvar Info-point-loc nil
319 "Point location within a selected node.
320 If string, the point is moved to the proper occurrence of the
321 name of the followed cross reference within a selected node.
322 If number, the point is moved to the corresponding line.")
324 (defvar Info-standalone nil
325 "Non-nil if Emacs was started solely as an Info browser.")
327 (defvar Info-suffix-list
328 ;; The MS-DOS list should work both when long file names are
329 ;; supported (Windows 9X), and when only 8+3 file names are available.
330 (if (eq system-type
'ms-dos
)
331 '( (".gz" .
"gunzip")
333 (".bz2" .
("bzip2" "-dc"))
336 (".info.Z" .
"gunzip")
337 (".info.gz" .
"gunzip")
338 ("-info.Z" .
"gunzip")
339 ("-info.gz" .
"gunzip")
340 ("/index.gz".
"gunzip")
341 ("/index.z" .
"gunzip")
347 '( (".info.Z".
"uncompress")
348 (".info.Y".
"unyabba")
349 (".info.gz".
"gunzip")
350 (".info.z".
"gunzip")
351 (".info.bz2" .
("bzip2" "-dc"))
353 ("-info.Z".
"uncompress")
354 ("-info.Y".
"unyabba")
355 ("-info.gz".
"gunzip")
356 ("-info.bz2" .
("bzip2" "-dc"))
357 ("-info.z".
"gunzip")
359 ("/index.Z".
"uncompress")
360 ("/index.Y".
"unyabba")
361 ("/index.gz".
"gunzip")
362 ("/index.z".
"gunzip")
363 ("/index.bz2".
("bzip2" "-dc"))
369 (".bz2" .
("bzip2" "-dc"))
371 "List of file name suffixes and associated decoding commands.
372 Each entry should be (SUFFIX . STRING); the file is given to
373 the command as standard input.
375 STRING may be a list of strings. In that case, the first element is
376 the command name, and the rest are arguments to that command.
378 If STRING is nil, no decoding is done.
379 Because the SUFFIXes are tried in order, the empty string should
380 be last in the list.")
382 ;; Concatenate SUFFIX onto FILENAME. SUFFIX should start with a dot.
383 ;; First, on MS-DOS with no long file names support, delete some of
384 ;; the extension in FILENAME to make room.
385 (defun info-insert-file-contents-1 (filename suffix lfn
)
386 (if lfn
; long file names are supported
387 (concat filename suffix
)
388 (let* ((sans-exts (file-name-sans-extension filename
))
389 ;; How long is the extension in FILENAME (not counting the dot).
390 (ext-len (max 0 (- (length filename
) (length sans-exts
) 1)))
392 ;; SUFFIX starts with a dot. If FILENAME already has one,
393 ;; get rid of the one in SUFFIX (unless suffix is empty).
394 (or (and (<= ext-len
0)
395 (not (eq (aref filename
(1- (length filename
))) ?.
)))
396 (= (length suffix
) 0)
397 (setq suffix
(substring suffix
1)))
398 ;; How many chars of that extension should we keep?
399 (setq ext-left
(min ext-len
(max 0 (- 3 (length suffix
)))))
400 ;; Get rid of the rest of the extension, and add SUFFIX.
401 (concat (substring filename
0 (- (length filename
)
402 (- ext-len ext-left
)))
405 (defun info-file-exists-p (filename)
406 (and (file-exists-p filename
)
407 (not (file-directory-p filename
))))
409 (defun info-insert-file-contents (filename &optional visit
)
410 "Insert the contents of an Info file in the current buffer.
411 Do the right thing if the file has been compressed or zipped."
412 (let* ((tail Info-suffix-list
)
413 (lfn (if (fboundp 'msdos-long-file-names
)
414 (msdos-long-file-names)
416 (check-short (and (fboundp 'msdos-long-file-names
)
418 fullname decoder done
)
419 (if (info-file-exists-p filename
)
420 ;; FILENAME exists--see if that name contains a suffix.
421 ;; If so, set DECODE accordingly.
425 (concat (regexp-quote (car (car tail
))) "$")
427 (setq tail
(cdr tail
)))
428 (setq fullname filename
429 decoder
(cdr (car tail
))))
430 ;; Try adding suffixes to FILENAME and see if we can find something.
431 (while (and tail
(not done
))
432 (setq fullname
(info-insert-file-contents-1 filename
433 (car (car tail
)) lfn
))
434 (if (info-file-exists-p fullname
)
436 ;; If we found a file with a suffix, set DECODER
437 ;; according to the suffix.
438 decoder
(cdr (car tail
)))
439 ;; When the MS-DOS port runs on Windows, we need to check
440 ;; the short variant of a long file name as well.
442 (setq fullname
(info-insert-file-contents-1 filename
443 (car (car tail
)) nil
))
444 (if (info-file-exists-p fullname
)
446 decoder
(cdr (car tail
))))))
447 (setq tail
(cdr tail
)))
449 (error "Can't find %s or any compressed version of it" filename
)))
450 ;; check for conflict with jka-compr
451 (if (and (jka-compr-installed-p)
452 (jka-compr-get-compression-info fullname
))
456 (insert-file-contents-literally fullname visit
)
457 (let ((buffer-read-only nil
)
458 (coding-system-for-write 'no-conversion
)
459 (default-directory (or (file-name-directory fullname
)
462 (setq decoder
(list decoder
)))
463 (apply 'call-process-region
(point-min) (point-max)
464 (car decoder
) t t nil
(cdr decoder
))))
465 (insert-file-contents fullname visit
))))
467 (defun Info-default-dirs ()
468 (let ((source (expand-file-name "info/" source-directory
))
469 (sibling (if installation-directory
470 (expand-file-name "info/" installation-directory
)
471 (if invocation-directory
472 (let ((infodir (expand-file-name
474 invocation-directory
)))
475 (if (file-exists-p infodir
)
477 (setq infodir
(expand-file-name
479 invocation-directory
))
480 (and (file-exists-p infodir
)
484 (if (and sibling
(file-exists-p sibling
))
485 ;; Uninstalled, Emacs builddir != srcdir.
487 ;; Uninstalled, builddir == srcdir
489 (if (or (member alternative Info-default-directory-list
)
490 ;; On DOS/NT, we use movable executables always,
491 ;; and we must always find the Info dir at run time.
492 (if (memq system-type
'(ms-dos windows-nt
))
494 ;; Use invocation-directory for Info
495 ;; only if we used it for exec-directory also.
496 (not (string= exec-directory
497 (expand-file-name "lib-src/"
498 installation-directory
))))
499 (not (file-exists-p alternative
)))
500 Info-default-directory-list
501 ;; `alternative' contains the Info files that came with this
502 ;; version, so we should look there first. `Info-insert-dir'
503 ;; currently expects to find `alternative' first on the list.
505 ;; Don't drop the last part, it might contain non-Emacs stuff.
506 ;; (reverse (cdr (reverse
507 Info-default-directory-list
)))) ;; )))
509 (defun info-initialize ()
510 "Initialize `Info-directory-list', if that hasn't been done yet."
511 (unless Info-directory-list
512 (let ((path (getenv "INFOPATH")))
513 (setq Info-directory-list
514 (prune-directory-list
516 (if (string-match ":\\'" path
)
517 (append (split-string (substring path
0 -
1)
518 (regexp-quote path-separator
))
520 (split-string path
(regexp-quote path-separator
)))
521 (Info-default-dirs)))))))
524 (defun info-other-window (&optional file-or-node
)
525 "Like `info' but show the Info buffer in another window."
526 (interactive (if current-prefix-arg
527 (list (read-file-name "Info file name: " nil nil t
))))
528 (let (same-window-buffer-names same-window-regexps
)
529 (info file-or-node
)))
531 ;;;###autoload (add-hook 'same-window-regexps "\\*info\\*\\(\\|<[0-9]+>\\)")
533 ;;;###autoload (put 'info 'info-file "emacs")
535 (defun info (&optional file-or-node buffer
)
536 "Enter Info, the documentation browser.
537 Optional argument FILE-OR-NODE specifies the file to examine;
538 the default is the top-level directory of Info.
539 Called from a program, FILE-OR-NODE may specify an Info node of the form
540 `(FILENAME)NODENAME'.
541 Optional argument BUFFER specifies the Info buffer name;
542 the default buffer name is *info*. If BUFFER exists,
543 just switch to BUFFER. Otherwise, create a new buffer
544 with the top-level Info directory.
546 In interactive use, a non-numeric prefix argument directs
547 this command to read a file name from the minibuffer.
548 A numeric prefix argument selects an Info buffer with the prefix number
549 appended to the Info buffer name.
551 The search path for Info files is in the variable `Info-directory-list'.
552 The top-level Info directory is made by combining all the files named `dir'
553 in all the directories in that path."
555 (if (and current-prefix-arg
(not (numberp current-prefix-arg
)))
556 (read-file-name "Info file name: " nil nil t
))
557 (if (numberp current-prefix-arg
)
558 (format "*info*<%s>" current-prefix-arg
))))
559 (pop-to-buffer (or buffer
"*info*"))
560 (if (and buffer
(not (eq major-mode
'Info-mode
)))
563 ;; If argument already contains parentheses, don't add another set
564 ;; since the argument will then be parsed improperly. This also
565 ;; has the added benefit of allowing node names to be included
566 ;; following the parenthesized filename.
568 (if (and (stringp file-or-node
) (string-match "(.*)" file-or-node
))
570 (concat "(" file-or-node
")")))
571 (if (zerop (buffer-size))
575 (defun info-emacs-manual ()
576 "Display the Emacs manual in Info mode."
581 (defun info-standalone ()
582 "Run Emacs as a standalone Info reader.
583 Usage: emacs -f info-standalone [filename]
584 In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
585 (setq Info-standalone t
)
586 (if (and command-line-args-left
587 (not (string-match "^-" (car command-line-args-left
))))
590 (info (car command-line-args-left
))
591 (setq command-line-args-left
(cdr command-line-args-left
)))
592 (error (send-string-to-terminal
593 (format "%s\n" (if (eq (car-safe err
) 'error
)
595 (save-buffers-kill-emacs)))
598 ;; See if the accessible portion of the buffer begins with a node
599 ;; delimiter, and the node header line which follows matches REGEXP.
600 ;; Typically, this test will be followed by a loop that examines the
601 ;; rest of the buffer with (search-forward "\n\^_"), and it's a pity
602 ;; to have the overhead of this special test inside the loop.
604 ;; This function changes match-data, but supposedly the caller might
605 ;; want to use the results of re-search-backward.
607 ;; The return value is the value of point at the beginning of matching
608 ;; REGEXP, if the function succeeds, nil otherwise.
609 (defun Info-node-at-bob-matching (regexp)
610 (and (bobp) ; are we at beginning of buffer?
611 (looking-at "\^_") ; does it begin with node delimiter?
615 (forward-line 1) ; does the line after delimiter match REGEXP?
616 (re-search-backward regexp beg t
))))
618 (defun Info-find-file (filename &optional noerror
)
619 "Return expanded FILENAME, or t, if FILENAME is \"dir\".
620 Optional second argument NOERROR, if t, means if file is not found
621 just return nil (no error)."
622 ;; Convert filename to lower case if not found as specified.
624 (if (stringp filename
)
625 (let (temp temp-downcase found
)
626 (setq filename
(substitute-in-file-name filename
))
628 ((string= (downcase filename
) "dir")
630 ((string= filename
"apropos")
631 (setq found
'apropos
))
632 ((string= filename
"history")
633 (setq found
'history
))
634 ((string= filename
"toc")
637 (let ((dirs (if (string-match "^\\./" filename
)
638 ;; If specified name starts with `./'
639 ;; then just try current directory.
641 (if (file-name-absolute-p filename
)
642 ;; No point in searching for an
643 ;; absolute file name
645 (if Info-additional-directory-list
646 (append Info-directory-list
647 Info-additional-directory-list
)
648 Info-directory-list
)))))
649 ;; Search the directory list for file FILENAME.
650 (while (and dirs
(not found
))
651 (setq temp
(expand-file-name filename
(car dirs
)))
653 (expand-file-name (downcase filename
) (car dirs
)))
654 ;; Try several variants of specified name.
655 (let ((suffix-list Info-suffix-list
)
656 (lfn (if (fboundp 'msdos-long-file-names
)
657 (msdos-long-file-names)
659 (while (and suffix-list
(not found
))
660 (cond ((info-file-exists-p
661 (info-insert-file-contents-1
662 temp
(car (car suffix-list
)) lfn
))
665 (info-insert-file-contents-1
666 temp-downcase
(car (car suffix-list
)) lfn
))
667 (setq found temp-downcase
))
668 ((and (fboundp 'msdos-long-file-names
)
671 (info-insert-file-contents-1
672 temp
(car (car suffix-list
)) nil
)))
674 (setq suffix-list
(cdr suffix-list
))))
675 (setq dirs
(cdr dirs
))))))
677 (setq filename found
)
680 (error "Info file %s does not exist" filename
)))
683 (defun Info-find-node (filename nodename
&optional no-going-back
)
684 "Go to an Info node specified as separate FILENAME and NODENAME.
685 NO-GOING-BACK is non-nil if recovering from an error in this function;
686 it says do not attempt further (recursive) error recovery."
688 (setq filename
(Info-find-file filename
))
689 ;; Go into Info buffer.
690 (or (eq major-mode
'Info-mode
) (pop-to-buffer "*info*"))
691 ;; Record the node we are leaving.
692 (if (not no-going-back
)
694 (cons (list Info-current-file Info-current-node
(point))
696 (Info-find-node-2 filename nodename no-going-back
))
699 (defun Info-on-current-buffer (&optional nodename
)
700 "Use Info mode to browse the current Info buffer.
701 With a prefix arg, this queries for the node name to visit first;
702 otherwise, that defaults to `Top'."
704 (list (if current-prefix-arg
705 (completing-read "Node name: " (Info-build-node-completions)
707 (unless nodename
(setq nodename
"Top"))
710 (set (make-local-variable 'Info-current-file
)
712 ;; If called on a non-file buffer, make a fake file name.
713 (concat default-directory
(buffer-name))))
714 (Info-find-node-2 nil nodename
))
716 ;; It's perhaps a bit nasty to kill the *info* buffer to force a re-read,
717 ;; but at least it keeps this routine (which is only for the benefit of
718 ;; makeinfo-buffer) out of the way of normal operations.
720 (defun Info-revert-find-node (filename nodename
)
721 "Go to an Info node FILENAME and NODENAME, re-reading disk contents.
722 When *info* is already displaying FILENAME and NODENAME, the window position
723 is preserved, if possible."
724 (pop-to-buffer "*info*")
725 (let ((old-filename Info-current-file
)
726 (old-nodename Info-current-node
)
727 (pcolumn (current-column))
728 (pline (count-lines (point-min) (line-beginning-position)))
729 (wline (count-lines (point-min) (window-start)))
730 (old-history Info-history
)
731 (new-history (list Info-current-file Info-current-node
(point))))
732 (kill-buffer (current-buffer))
733 (Info-find-node filename nodename
)
734 (setq Info-history old-history
)
735 (if (and (equal old-filename Info-current-file
)
736 (equal old-nodename Info-current-node
))
738 ;; note goto-line is no good, we want to measure from point-min
739 (goto-char (point-min))
741 (set-window-start (selected-window) (point))
742 (goto-char (point-min))
744 (move-to-column pcolumn
))
745 ;; only add to the history when coming from a different file+node
747 (setq Info-history
(cons new-history Info-history
))))))
749 (defun Info-find-in-tag-table-1 (marker regexp case-fold
)
750 "Find a node in a tag table.
751 MARKER specifies the buffer and position to start searching at.
752 REGEXP is a regular expression matching nodes or references. Its first
753 group should match `Node:' or `Ref:'.
754 CASE-FOLD t means search for a case-insensitive match.
755 If a match was found, value is a list (FOUND-ANCHOR POS MODE), where
756 FOUND-ANCHOR is non-nil if a `Ref:' was matched, POS is the position
757 where the match was found, and MODE is `major-mode' of the buffer in
758 which the match was found."
759 (let ((case-fold-search case-fold
))
761 (set-buffer (marker-buffer marker
))
766 (when (re-search-forward regexp nil t
)
767 (list (string-equal "Ref:" (match-string 1))
768 (+ (point-min) (read (current-buffer)))
771 (defun Info-find-in-tag-table (marker regexp
)
772 "Find a node in a tag table.
773 MARKER specifies the buffer and position to start searching at.
774 REGEXP is a regular expression matching nodes or references. Its first
775 group should match `Node:' or `Ref:'.
776 If a match was found, value is a list (FOUND-ANCHOR POS MODE), where
777 FOUND-ANCHOR is non-nil if a `Ref:' was matched, POS is the position
778 where the match was found, and MODE is `major-mode' of the buffer in
779 which the match was found.
780 This function tries to find a case-sensitive match first, then a
781 case-insensitive match is tried."
782 (let ((result (Info-find-in-tag-table-1 marker regexp nil
)))
783 (when (null (car result
))
784 (setq result
(Info-find-in-tag-table-1 marker regexp t
)))
787 (defun Info-find-node-in-buffer-1 (regexp case-fold
)
788 "Find a node or anchor in the current buffer.
789 REGEXP is a regular expression matching nodes or references. Its first
790 group should match `Node:' or `Ref:'.
791 CASE-FOLD t means search for a case-insensitive match.
792 Value is the position at which a match was found, or nil if not found."
793 (let ((case-fold-search case-fold
)
796 (when (Info-node-at-bob-matching regexp
)
797 (setq found
(point)))
798 (while (and (not found
)
799 (search-forward "\n\^_" nil t
))
803 (when (re-search-backward regexp beg t
)
805 (setq found
(point)))))
808 (defun Info-find-node-in-buffer (regexp)
809 "Find a node or anchor in the current buffer.
810 REGEXP is a regular expression matching nodes or references. Its first
811 group should match `Node:' or `Ref:'.
812 Value is the position at which a match was found, or nil if not found.
813 This function looks for a case-sensitive match first. If none is found,
814 a case-insensitive match is tried."
815 (or (Info-find-node-in-buffer-1 regexp nil
)
816 (Info-find-node-in-buffer-1 regexp t
)))
818 (defun Info-find-node-2 (filename nodename
&optional no-going-back
)
819 (buffer-disable-undo (current-buffer))
820 (or (eq major-mode
'Info-mode
)
823 (setq Info-current-node nil
)
825 (let ((case-fold-search t
)
827 ;; Switch files if necessary
829 (equal Info-current-file filename
)
830 (let ((buffer-read-only nil
))
831 (setq Info-current-file nil
832 Info-current-subfile nil
833 Info-current-file-completions nil
834 buffer-file-name nil
)
839 ((eq filename
'apropos
)
840 (insert-buffer-substring " *info-apropos*"))
841 ((eq filename
'history
)
842 (insert-buffer-substring " *info-history*"))
844 (insert-buffer-substring " *info-toc*"))
846 (info-insert-file-contents filename nil
)
847 (setq default-directory
(file-name-directory filename
))))
848 (set-buffer-modified-p nil
)
850 ;; Check makeinfo version for index cookie support
852 (goto-char (point-min))
854 (if (and (re-search-forward
855 "makeinfo version \\([0-9]+.[0-9]+\\)"
856 (line-beginning-position 3) t
)
857 (not (version< (match-string 1) "4.7")))
860 (set (make-local-variable 'Info-file-supports-index-cookies
) found
))
862 ;; See whether file has a tag table. Record the location if yes.
863 (goto-char (point-max))
865 ;; Use string-equal, not equal, to ignore text props.
866 (if (not (or (string-equal nodename
"*")
868 (search-forward "\^_\nEnd tag table\n" nil t
))))
870 ;; We have a tag table. Find its beginning.
871 ;; Is this an indirect file?
872 (search-backward "\nTag table:\n")
876 (looking-at "(Indirect)\n"))
877 ;; It is indirect. Copy it to another buffer
878 ;; and record that the tag table is in that buffer.
879 (let ((buf (current-buffer))
881 (or Info-tag-table-buffer
882 (generate-new-buffer " *info tag table*"))))
883 (setq Info-tag-table-buffer tagbuf
)
886 (buffer-disable-undo (current-buffer))
887 (setq case-fold-search t
)
889 (insert-buffer-substring buf
))
890 (set-marker Info-tag-table-marker
891 (match-end 0) tagbuf
))
892 (set-marker Info-tag-table-marker pos
)))
893 (set-marker Info-tag-table-marker nil
))
894 (setq Info-current-file
896 ((eq filename t
) "dir")
897 ((eq filename
'apropos
) "apropos")
898 ((eq filename
'history
) "history")
899 ((eq filename
'toc
) "toc")
902 ;; Use string-equal, not equal, to ignore text props.
903 (if (string-equal nodename
"*")
904 (progn (setq Info-current-node nodename
)
905 (Info-set-mode-line))
908 ;; 1. Anchor found in tag table
909 ;; 2. Anchor *not* in tag table
911 ;; 3. Node found in tag table
912 ;; 4. Node *not* found in tag table, but found in file
913 ;; 5. Node *not* in tag table, and *not* in file
915 ;; *Or* the same, but in an indirect subfile.
917 ;; Search file for a suitable node.
918 (let ((guesspos (point-min))
919 (regexp (concat "\\(Node:\\|Ref:\\) *\\("
920 (if (stringp nodename
)
921 (regexp-quote nodename
)
923 "\\) *[,\t\n\177]")))
927 ;; First, search a tag table, if any
928 (when (marker-position Info-tag-table-marker
)
929 (let* ((m Info-tag-table-marker
)
930 (found (Info-find-in-tag-table m regexp
)))
933 ;; FOUND is (ANCHOR POS MODE).
934 (setq guesspos
(nth 1 found
))
936 ;; If this is an indirect file, determine which
937 ;; file really holds this node and read it in.
938 (unless (eq (nth 2 found
) 'Info-mode
)
939 ;; Note that the current buffer must be the
940 ;; *info* buffer on entry to
941 ;; Info-read-subfile. Thus the hackery above.
942 (setq guesspos
(Info-read-subfile guesspos
)))
946 (goto-char (setq anchorpos guesspos
))
949 ;; Else we may have a node, which we search for:
950 (goto-char (max (point-min)
951 (- (byte-to-position guesspos
) 1000)))
953 ;; Now search from our advised position (or from beg of
954 ;; buffer) to find the actual node. First, check
955 ;; whether the node is right where we are, in case the
956 ;; buffer begins with a node.
957 (let ((pos (Info-find-node-in-buffer regexp
)))
962 (when (string-match "\\([^.]+\\)\\." nodename
)
963 (let (Info-point-loc)
965 filename
(match-string 1 nodename
) no-going-back
))
969 ;; No such anchor in tag table or node in tag table or file
970 (error "No such node or anchor: %s" nodename
))
973 (goto-char (point-min))
975 (let ((new-history (list Info-current-file
976 (substring-no-properties nodename
))))
977 ;; Add anchors to the history too
978 (setq Info-history-list
980 (delete new-history Info-history-list
))))
981 (goto-char anchorpos
))
982 ((numberp Info-point-loc
)
983 (forward-line (1- Info-point-loc
))
984 (setq Info-point-loc nil
))
985 ((stringp Info-point-loc
)
986 (Info-find-index-name Info-point-loc
)
987 (setq Info-point-loc nil
))))))
988 ;; If we did not finish finding the specified node,
989 ;; go back to the previous one.
990 (or Info-current-node no-going-back
(null Info-history
)
991 (let ((hist (car Info-history
)))
992 (setq Info-history
(cdr Info-history
))
993 (Info-find-node (nth 0 hist
) (nth 1 hist
) t
)
994 (goto-char (nth 2 hist
))))))
996 ;; Cache the contents of the (virtual) dir file, once we have merged
997 ;; it for the first time, so we can save time subsequently.
998 (defvar Info-dir-contents nil
)
1000 ;; Cache for the directory we decided to use for the default-directory
1001 ;; of the merged dir text.
1002 (defvar Info-dir-contents-directory nil
)
1004 ;; Record the file attributes of all the files from which we
1005 ;; constructed Info-dir-contents.
1006 (defvar Info-dir-file-attributes nil
)
1008 (defvar Info-dir-file-name nil
)
1010 ;; Construct the Info directory node by merging the files named `dir'
1011 ;; from various directories. Set the *info* buffer's
1012 ;; default-directory to the first directory we actually get any text
1014 (defun Info-insert-dir ()
1015 (if (and Info-dir-contents Info-dir-file-attributes
1016 ;; Verify that none of the files we used has changed
1017 ;; since we used it.
1019 (mapcar (lambda (elt)
1020 (let ((curr (file-attributes
1022 (file-truename (car elt
)))))
1024 ;; Don't compare the access time.
1025 (if curr
(setcar (nthcdr 4 curr
) 0))
1026 (setcar (nthcdr 4 (cdr elt
)) 0)
1027 (equal (cdr elt
) curr
)))
1028 Info-dir-file-attributes
))))
1030 (insert Info-dir-contents
)
1031 (goto-char (point-min)))
1032 (let ((dirs (if Info-additional-directory-list
1033 (append Info-directory-list
1034 Info-additional-directory-list
)
1035 Info-directory-list
))
1036 (dir-file-attrs nil
)
1037 ;; Bind this in case the user sets it to nil.
1038 (case-fold-search t
)
1039 ;; This is set non-nil if we find a problem in some input files.
1041 buffers buffer others nodes dirs-done
)
1043 ;; Search the directory list for the directory file.
1045 (let ((truename (file-truename (expand-file-name (car dirs
)))))
1046 (or (member truename dirs-done
)
1047 (member (directory-file-name truename
) dirs-done
)
1048 ;; Try several variants of specified name.
1049 ;; Try upcasing, appending `.info', or both.
1053 (progn (setq file
(expand-file-name "dir" truename
))
1054 (file-attributes file
))
1055 (progn (setq file
(expand-file-name "DIR" truename
))
1056 (file-attributes file
))
1057 (progn (setq file
(expand-file-name "dir.info" truename
))
1058 (file-attributes file
))
1059 (progn (setq file
(expand-file-name "DIR.INFO" truename
))
1060 (file-attributes file
)))))
1063 (cons (directory-file-name truename
)
1068 (message "Composing main Info directory..."))
1069 (set-buffer (generate-new-buffer " info dir"))
1072 (insert-file-contents file
)
1073 (set (make-local-variable 'Info-dir-file-name
)
1075 (push (current-buffer) buffers
)
1076 (push (cons file attrs
) dir-file-attrs
))
1077 (error (kill-buffer (current-buffer))))))))
1079 (set (make-local-variable 'Info-dir-contents-directory
)
1080 (file-name-as-directory (car dirs
))))
1081 (setq dirs
(cdr dirs
))))
1084 (error "Can't find the Info directory node"))
1086 ;; Distinguish the dir file that comes with Emacs from all the
1087 ;; others. Yes, that is really what this is supposed to do.
1088 ;; The definition of `Info-directory-list' puts it first on that
1089 ;; list and so last in `buffers' at this point.
1090 (setq buffer
(car (last buffers
))
1091 others
(delq buffer buffers
))
1093 ;; Insert the entire original dir file as a start; note that we've
1094 ;; already saved its default directory to use as the default
1095 ;; directory for the whole concatenation.
1096 (save-excursion (insert-buffer-substring buffer
))
1098 ;; Look at each of the other buffers one by one.
1099 (dolist (other others
)
1100 (let (this-buffer-nodes)
1101 ;; In each, find all the menus.
1102 (with-current-buffer other
1103 (goto-char (point-min))
1104 ;; Find each menu, and add an elt to NODES for it.
1105 (while (re-search-forward "^\\* Menu:" nil t
)
1106 (while (and (zerop (forward-line 1)) (eolp)))
1109 (re-search-backward "^\^_")
1110 (search-forward "Node: ")
1111 (setq nodename
(Info-following-node-name))
1112 (search-forward "\n\^_" nil
'move
)
1115 (push (list nodename other beg end
) this-buffer-nodes
)))
1116 (if (assoc-string "top" this-buffer-nodes t
)
1117 (setq nodes
(nconc this-buffer-nodes nodes
))
1119 (message "No `top' node in %s" Info-dir-file-name
)))))
1120 ;; Add to the main menu a menu item for each other node.
1121 (re-search-forward "^\\* Menu:")
1123 (let ((menu-items '("top"))
1124 (end (save-excursion (search-forward "\^_" nil t
) (point))))
1125 (dolist (node nodes
)
1126 (let ((nodename (car node
)))
1128 (or (member (downcase nodename
) menu-items
)
1129 (re-search-forward (concat "^\\* +"
1130 (regexp-quote nodename
)
1134 (insert "* " nodename
"::" "\n")
1135 (push nodename menu-items
)))))))
1136 ;; Now take each node of each of the other buffers
1137 ;; and merge it into the main buffer.
1138 (dolist (node nodes
)
1139 (let ((case-fold-search t
)
1140 (nodename (car node
)))
1141 (goto-char (point-min))
1142 ;; Find the like-named node in the main buffer.
1143 (if (re-search-forward (concat "^\^_.*\n.*Node: "
1144 (regexp-quote nodename
)
1148 (search-forward "\n\^_" nil
'move
)
1151 ;; If none exists, add one.
1152 (goto-char (point-max))
1153 (insert "\^_\nFile: dir\tNode: " nodename
"\n\n* Menu:\n\n"))
1154 ;; Merge the text from the other buffer's menu
1155 ;; into the menu in the like-named node in the main buffer.
1156 (apply 'insert-buffer-substring
(cdr node
))))
1157 (Info-dir-remove-duplicates)
1158 ;; Kill all the buffers we just made, including the special one excised.
1159 (mapc 'kill-buffer
(cons buffer buffers
))
1160 (goto-char (point-min))
1162 (message "Composing main Info directory...problems encountered, see `*Messages*'")
1163 (message "Composing main Info directory...done"))
1164 (set (make-local-variable 'Info-dir-contents
) (buffer-string))
1165 (set (make-local-variable 'Info-dir-file-attributes
) dir-file-attrs
)))
1166 (setq default-directory Info-dir-contents-directory
))
1168 (defvar Info-streamline-headings
1169 '(("Emacs" .
"Emacs")
1170 ("Programming" .
"Programming")
1171 ("Libraries" .
"Libraries")
1172 ("World Wide Web\\|Net Utilities" .
"Net Utilities"))
1173 "List of elements (RE . NAME) to merge headings matching RE to NAME.")
1175 (defun Info-dir-remove-duplicates ()
1177 (goto-char (point-min))
1178 ;; Remove duplicate headings in the same menu.
1179 (while (search-forward "\n* Menu:" nil t
)
1180 (setq limit
(save-excursion (search-forward "\n\^_" nil t
)))
1181 ;; Look for the next heading to unify.
1182 (while (re-search-forward "^\\(\\w.*\\)\n\\*" limit t
)
1183 (let ((name (match-string 1))
1184 (start (match-beginning 0))
1186 ;; Check whether this heading should be streamlined.
1188 (dolist (x Info-streamline-headings
)
1189 (when (string-match (car x
) name
)
1191 (setq re
(car x
)))))
1192 (if re
(replace-match name t t nil
1))
1193 (goto-char (if (re-search-forward "^[^* \n\t]" limit t
)
1195 (or limit
(point-max))))
1196 ;; Look for other headings of the same category and merge them.
1198 (while (re-search-forward "^\\(\\w.*\\)\n\\*" limit t
)
1199 (when (if re
(save-match-data (string-match re
(match-string 1)))
1200 (equal name
(match-string 1)))
1202 ;; Delete redundant heading.
1203 (delete-region (match-beginning 0) (point))
1204 ;; Push the entries onto `text'.
1206 (delete-and-extract-region
1208 (if (re-search-forward "^[^* \n\t]" nil t
)
1210 (or limit
(point-max)))) entries
))))
1211 ;; Insert the entries just found.
1212 (while (= (line-beginning-position 0) (1- (point)))
1214 (dolist (entry (nreverse entries
))
1216 (while (= (line-beginning-position 0) (1- (point)))
1217 (delete-region (1- (point)) (point))))
1219 ;; Now remove duplicate entries under the same heading.
1223 (while (re-search-forward "^* \\([^:\n]+:\\(:\\|[^.\n]+\\).\\)"
1225 ;; Fold case straight away; `member-ignore-case' here wasteful.
1226 (let ((x (downcase (match-string 1))))
1228 (delete-region (match-beginning 0)
1229 (progn (re-search-forward "^[^ \t]" nil t
)
1230 (match-beginning 0)))
1231 (push x seen
))))))))))
1233 ;; Note that on entry to this function the current-buffer must be the
1234 ;; *info* buffer; not the info tags buffer.
1235 (defun Info-read-subfile (nodepos)
1236 ;; NODEPOS is either a position (in the Info file as a whole,
1237 ;; not relative to a subfile) or the name of a subfile.
1240 (if (numberp nodepos
)
1242 (set-buffer (marker-buffer Info-tag-table-marker
))
1243 (goto-char (point-min))
1244 (or (looking-at "\^_")
1245 (search-forward "\n\^_"))
1248 (while (not (looking-at "\^_"))
1251 thisfilepos thisfilename
)
1252 (search-forward ": ")
1253 (setq thisfilename
(buffer-substring beg
(- (point) 2)))
1254 (setq thisfilepos
(+ (point-min) (read (current-buffer))))
1255 ;; read in version 19 stops at the end of number.
1256 ;; Advance to the next line.
1258 (if (> thisfilepos nodepos
)
1260 (setq lastfilename thisfilename
)
1261 (setq lastfilepos thisfilepos
))
1262 (forward-line 1)))))
1263 (setq lastfilename nodepos
)
1264 (setq lastfilepos
0))
1265 ;; Assume previous buffer is in Info-mode.
1266 ;; (set-buffer (get-buffer "*info*"))
1267 (or (equal Info-current-subfile lastfilename
)
1268 (let ((buffer-read-only nil
))
1269 (setq buffer-file-name nil
)
1272 (info-insert-file-contents lastfilename
)
1273 (set-buffer-modified-p nil
)
1274 (setq Info-current-subfile lastfilename
)))
1275 ;; Widen in case we are in the same subfile as before.
1277 (goto-char (point-min))
1278 (if (looking-at "\^_")
1280 (search-forward "\n\^_"))
1281 (if (numberp nodepos
)
1282 (+ (- nodepos lastfilepos
) (point)))))
1284 (defun Info-unescape-quotes (value)
1285 "Unescape double quotes and backslashes in VALUE."
1288 (while (string-match "[^\\\"]*\\(\\\\\\)[\\\\\"]" unquote start
)
1289 (setq unquote
(replace-match "" t t unquote
1))
1290 (setq start
(- (match-end 0) 1)))
1293 ;; As of Texinfo 4.6, makeinfo writes constructs like
1294 ;; \0\h[image param=value ...\h\0]
1295 ;; into the Info file for handling images.
1296 (defun Info-split-parameter-string (parameter-string)
1297 "Return alist of (\"KEY\" . \"VALUE\") from PARAMETER-STRING; a
1298 whitespace separated list of KEY=VALUE pairs. If VALUE contains
1299 whitespace or double quotes, it must be quoted in double quotes and
1300 any double quotes or backslashes must be escaped (\\\",\\\\)."
1303 (while (string-match
1304 "\\s *\\([^=]+\\)=\\(?:\\([^\\s \"]+\\)\\|\\(?:\"\\(\\(?:[^\\\"]\\|\\\\[\\\\\"]\\)*\\)\"\\)\\)"
1305 parameter-string start
)
1306 (setq start
(match-end 0))
1307 (push (cons (match-string 1 parameter-string
)
1308 (or (match-string 2 parameter-string
)
1309 (Info-unescape-quotes
1310 (match-string 3 parameter-string
))))
1314 (defun Info-display-images-node ()
1315 "Display images in current node."
1317 (let ((inhibit-read-only t
)
1318 (case-fold-search t
))
1319 (goto-char (point-min))
1320 (while (re-search-forward
1321 "\\(\0\b[[]image\\(\\(?:[^\b]\\|[^\0]+\b\\)*\\)\0\b[]]\\)"
1323 (let* ((start (match-beginning 1))
1324 (parameter-alist (Info-split-parameter-string (match-string 2)))
1325 (src (cdr (assoc-string "src" parameter-alist
)))
1326 (image-file (if src
(if (file-name-absolute-p src
) src
1327 (concat default-directory src
))
1329 (image (if (file-exists-p image-file
)
1330 (create-image image-file
)
1332 (if (not (get-text-property start
'display
))
1333 (add-text-properties
1334 start
(point) `(display ,image rear-nonsticky
(display)))))))
1335 (set-buffer-modified-p nil
)))
1337 ;; Texinfo 4.7 adds cookies of the form ^@^H[NAME CONTENTS ^@^H].
1338 ;; Hide any construct of the general form ^@[^@-^_][ ... ^@[^@-^_]],
1339 ;; including one optional trailing newline.
1340 (defun Info-hide-cookies-node ()
1341 "Hide unrecognized cookies in current node."
1343 (let ((inhibit-read-only t
)
1344 (case-fold-search t
))
1345 (goto-char (point-min))
1346 (while (re-search-forward
1347 "\\(\0[\0-\37][[][^\0]*\0[\0-\37][]]\n?\\)"
1349 (let* ((start (match-beginning 1)))
1350 (if (not (get-text-property start
'invisible
))
1351 (put-text-property start
(point) 'invisible t
)))))
1352 (set-buffer-modified-p nil
)))
1354 (defun Info-select-node ()
1355 "Select the Info node that point is in."
1356 ;; Bind this in case the user sets it to nil.
1357 (let ((case-fold-search t
))
1359 ;; Find beginning of node.
1360 (if (search-backward "\n\^_" nil
'move
)
1362 (if (looking-at "\^_")
1364 (signal 'search-failed
(list "\n\^_"))))
1365 ;; Get nodename spelled as it is in the node.
1366 (re-search-forward "Node:[ \t]*")
1367 (setq Info-current-node
1368 (buffer-substring-no-properties (point)
1370 (skip-chars-forward "^,\t\n")
1372 (Info-set-mode-line)
1373 ;; Find the end of it, and narrow.
1375 (let (active-expression)
1376 ;; Narrow to the node contents
1377 (narrow-to-region (point)
1378 (if (re-search-forward "\n[\^_\f]" nil t
)
1381 (if (looking-at "[\n\^_\f]*execute: ")
1383 (goto-char (match-end 0))
1384 (setq active-expression
1385 (read (current-buffer))))))
1387 (if Info-enable-active-nodes
(eval active-expression
))
1388 ;; Add a new unique history item to full history list
1389 (let ((new-history (list Info-current-file Info-current-node
)))
1390 (setq Info-history-list
1391 (cons new-history
(delete new-history Info-history-list
)))
1392 (setq Info-history-forward nil
))
1393 (if (not (eq Info-fontify-maximum-menu-size nil
))
1394 (Info-fontify-node))
1395 (Info-display-images-node)
1396 (Info-hide-cookies-node)
1397 (run-hooks 'Info-selection-hook
)))))
1399 (defun Info-set-mode-line ()
1400 (setq mode-line-buffer-identification
1401 (nconc (propertized-buffer-identification "%b")
1404 (if Info-current-file
1405 (file-name-nondirectory Info-current-file
)
1407 ") " (or Info-current-node
""))))))
1409 ;; Go to an Info node specified with a filename-and-nodename string
1410 ;; of the sort that is found in pointers in nodes.
1412 ;; Don't autoload this function: the correct entry point for other packages
1413 ;; to use is `info'. --Stef
1415 (defun Info-goto-node (nodename &optional fork
)
1416 "Go to Info node named NODENAME. Give just NODENAME or (FILENAME)NODENAME.
1417 If NODENAME is of the form (FILENAME)NODENAME, the node is in the Info file
1418 FILENAME; otherwise, NODENAME should be in the current Info file (or one of
1420 Completion is available, but only for node names in the current Info file.
1421 If FORK is non-nil (interactively with a prefix arg), show the node in
1423 If FORK is a string, it is the name to use for the new buffer."
1424 (interactive (list (Info-read-node-name "Go to node: ") current-prefix-arg
))
1428 (clone-buffer (concat "*info-" (if (stringp fork
) fork nodename
) "*") t
)))
1430 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
1432 (setq filename
(if (= (match-beginning 1) (match-end 1))
1434 (match-string 2 nodename
))
1435 nodename
(match-string 3 nodename
))
1436 (let ((trim (string-match "\\s +\\'" filename
)))
1437 (if trim
(setq filename
(substring filename
0 trim
))))
1438 (let ((trim (string-match "\\s +\\'" nodename
)))
1439 (if trim
(setq nodename
(substring nodename
0 trim
))))
1440 (if transient-mark-mode
(deactivate-mark))
1441 (Info-find-node (if (equal filename
"") nil filename
)
1442 (if (equal nodename
"") "Top" nodename
))))
1444 (defvar Info-read-node-completion-table
)
1446 (defun Info-read-node-name-2 (string path-and-suffixes action
)
1447 "Virtual completion table for file names input in Info node names.
1448 PATH-AND-SUFFIXES is a pair of lists, (DIRECTORIES . SUFFIXES)."
1450 (suffixes (remove "" (cdr path-and-suffixes
)))
1451 (suffix (concat (regexp-opt suffixes t
) "\\'"))
1452 (string-dir (file-name-directory string
))
1454 (if (file-name-absolute-p string
)
1455 (list (file-name-directory string
))
1456 (car path-and-suffixes
))))
1459 (setq dir default-directory
))
1460 (if string-dir
(setq dir
(expand-file-name string-dir dir
)))
1461 (when (file-directory-p dir
)
1462 (dolist (file (file-name-all-completions
1463 (file-name-nondirectory string
) dir
))
1464 ;; If the file name has no suffix or a standard suffix,
1466 (and (or (null (file-name-extension file
))
1467 (string-match suffix file
))
1468 ;; But exclude subfiles of split Info files.
1469 (not (string-match "-[0-9]+\\'" file
))
1470 ;; And exclude backup files.
1471 (not (string-match "~\\'" file
))
1472 (push (if string-dir
(concat string-dir file
) file
) names
))
1473 ;; If the file name ends in a standard suffix,
1474 ;; add the unsuffixed name as a completion option.
1475 (when (string-match suffix file
)
1476 (setq file
(substring file
0 (match-beginning 0)))
1477 (push (if string-dir
(concat string-dir file
) file
) names
)))))
1479 ((eq action t
) (all-completions string names
))
1480 ((null action
) (try-completion string names
))
1481 (t (test-completion string names
)))))
1483 ;; This function is used as the "completion table" while reading a node name.
1484 ;; It does completion using the alist in Info-read-node-completion-table
1485 ;; unless STRING starts with an open-paren.
1486 (defun Info-read-node-name-1 (string predicate code
)
1488 ;; First complete embedded file names.
1489 ((string-match "\\`([^)]*\\'" string
)
1490 (let ((file (substring string
1)))
1493 (let ((comp (try-completion file
'Info-read-node-name-2
1494 (cons Info-directory-list
1495 (mapcar 'car Info-suffix-list
)))))
1497 ((eq comp t
) (concat string
")"))
1498 (comp (concat "(" comp
)))))
1500 (all-completions file
'Info-read-node-name-2
1501 (cons Info-directory-list
1502 (mapcar 'car Info-suffix-list
))))
1504 ;; If a file name was given, then any node is fair game.
1505 ((string-match "\\`(" string
)
1507 ((eq code nil
) string
)
1510 ;; Otherwise use Info-read-node-completion-table.
1512 (try-completion string Info-read-node-completion-table predicate
))
1514 (all-completions string Info-read-node-completion-table predicate
))
1516 (test-completion string Info-read-node-completion-table predicate
))))
1518 ;; Arrange to highlight the proper letters in the completion list buffer.
1519 (put 'Info-read-node-name-1
'completion-base-size-function
1521 (if (string-match "\\`([^)]*\\'"
1522 (or completion-common-substring
1523 (minibuffer-completion-contents)))
1527 (defun Info-read-node-name (prompt &optional default
)
1528 (let* ((completion-ignore-case t
)
1529 (Info-read-node-completion-table (Info-build-node-completions))
1530 (nodename (completing-read prompt
'Info-read-node-name-1 nil t
)))
1531 (if (equal nodename
"")
1533 (Info-read-node-name prompt
))
1536 (defun Info-build-node-completions ()
1537 (or Info-current-file-completions
1539 ;; Bind this in case the user sets it to nil.
1540 (case-fold-search t
)
1541 (node-regexp "Node: *\\([^,\n]*\\) *[,\n\t]"))
1544 (if (marker-buffer Info-tag-table-marker
)
1545 (let ((marker Info-tag-table-marker
))
1546 (set-buffer (marker-buffer marker
))
1549 (while (re-search-forward "\n\\(Node\\|Ref\\): \\(.*\\)\177" nil t
)
1551 (cons (list (match-string-no-properties 2))
1554 (goto-char (point-min))
1555 ;; If the buffer begins with a node header, process that first.
1556 (if (Info-node-at-bob-matching node-regexp
)
1557 (setq compl
(list (match-string-no-properties 1))))
1558 ;; Now for the rest of the nodes.
1559 (while (search-forward "\n\^_" nil t
)
1561 (let ((beg (point)))
1563 (if (re-search-backward node-regexp beg t
)
1565 (cons (list (match-string-no-properties 1))
1567 (setq compl
(cons '("*") compl
))
1568 (set (make-local-variable 'Info-current-file-completions
) compl
))))
1570 (defun Info-restore-point (hl)
1571 "If this node has been visited, restore the point value when we left."
1573 (if (and (equal (nth 0 (car hl
)) Info-current-file
)
1574 ;; Use string-equal, not equal, to ignore text props.
1575 (string-equal (nth 1 (car hl
)) Info-current-node
))
1577 (goto-char (nth 2 (car hl
)))
1578 (setq hl nil
)) ;terminate the while at next iter
1579 (setq hl
(cdr hl
)))))
1581 (defvar Info-search-history nil
1582 "The history list for `Info-search'.")
1584 (defvar Info-search-case-fold nil
1585 "The value of `case-fold-search' from previous `Info-search' command.")
1587 (defun Info-search (regexp &optional bound noerror count direction
)
1588 "Search for REGEXP, starting from point, and select node it's found in.
1589 If DIRECTION is `backward', search in the reverse direction."
1590 (interactive (list (read-string
1591 (if Info-search-history
1592 (format "Regexp search%s (default %s): "
1593 (if case-fold-search
"" " case-sensitively")
1594 (car Info-search-history
))
1595 (format "Regexp search%s: "
1596 (if case-fold-search
"" " case-sensitively")))
1597 nil
'Info-search-history
)))
1598 (when transient-mark-mode
1600 (when (equal regexp
"")
1601 (setq regexp
(car Info-search-history
)))
1603 (let (found beg-found give-up
1604 (backward (eq direction
'backward
))
1605 (onode Info-current-node
)
1606 (ofile Info-current-file
)
1608 (opoint-min (point-min))
1609 (opoint-max (point-max))
1610 (ostart (window-start))
1611 (osubfile Info-current-subfile
))
1612 (setq Info-search-case-fold case-fold-search
)
1617 ;; Hide Info file header for backward search
1618 (narrow-to-region (save-excursion
1619 (goto-char (point-min))
1620 (search-forward "\n\^_")
1623 (while (and (not give-up
)
1627 (isearch-range-invisible found beg-found
)
1628 (isearch-range-invisible beg-found found
))
1629 ;; Skip node header line
1630 (and (save-excursion (forward-line -
1)
1632 (forward-line (if backward -
1 1)))
1633 ;; Skip Tag Table node
1635 (and (search-backward "\^_" nil t
)
1636 (looking-at "\^_\nTag Table"))))))
1637 (let ((search-spaces-regexp Info-search-whitespace-regexp
))
1639 (re-search-backward regexp bound t
)
1640 (re-search-forward regexp bound t
))
1641 (setq found
(point) beg-found
(if backward
(match-end 0)
1642 (match-beginning 0)))
1643 (setq give-up t
))))))
1645 (when (and isearch-mode Info-isearch-search
1646 (not Info-isearch-initial-node
)
1648 (or give-up
(and found
(not (and (> found opoint-min
)
1649 (< found opoint-max
))))))
1650 (signal 'search-failed
(list regexp
"initial node")))
1652 ;; If no subfiles, give error now.
1654 (if (null Info-current-subfile
)
1655 (let ((search-spaces-regexp Info-search-whitespace-regexp
))
1657 (re-search-backward regexp
)
1658 (re-search-forward regexp
)))
1661 (if (and bound
(not found
))
1662 (signal 'search-failed
(list regexp
)))
1664 (unless (or found bound
)
1666 ;; Try other subfiles.
1669 (set-buffer (marker-buffer Info-tag-table-marker
))
1670 (goto-char (point-min))
1671 (search-forward "\n\^_\nIndirect:")
1673 (narrow-to-region (point)
1674 (progn (search-forward "\n\^_")
1676 (goto-char (point-min))
1677 ;; Find the subfile we just searched.
1678 (search-forward (concat "\n" osubfile
": "))
1680 (forward-line (if backward
0 1))
1681 (if backward
(forward-char -
1))
1682 ;; Make a list of all following subfiles.
1683 ;; Each elt has the form (VIRT-POSITION . SUBFILENAME).
1684 (while (not (if backward
(bobp) (eobp)))
1686 (re-search-backward "\\(^.*\\): [0-9]+$")
1687 (re-search-forward "\\(^.*\\): [0-9]+$"))
1688 (goto-char (+ (match-end 1) 2))
1689 (setq list
(cons (cons (+ (point-min)
1690 (read (current-buffer)))
1691 (match-string-no-properties 1))
1693 (goto-char (if backward
1694 (1- (match-beginning 0))
1695 (1+ (match-end 0)))))
1696 ;; Put in forward order
1697 (setq list
(nreverse list
))))
1699 (message "Searching subfile %s..." (cdr (car list
)))
1700 (Info-read-subfile (car (car list
)))
1702 ;; Hide Info file header for backward search
1703 (narrow-to-region (save-excursion
1704 (goto-char (point-min))
1705 (search-forward "\n\^_")
1708 (goto-char (point-max)))
1709 (setq list
(cdr list
))
1710 (setq give-up nil found nil
)
1711 (while (and (not give-up
)
1715 (isearch-range-invisible found beg-found
)
1716 (isearch-range-invisible beg-found found
))
1717 ;; Skip node header line
1718 (and (save-excursion (forward-line -
1)
1720 (forward-line (if backward -
1 1)))
1721 ;; Skip Tag Table node
1723 (and (search-backward "\^_" nil t
)
1724 (looking-at "\^_\nTag Table"))))))
1725 (let ((search-spaces-regexp Info-search-whitespace-regexp
))
1727 (re-search-backward regexp nil t
)
1728 (re-search-forward regexp nil t
))
1729 (setq found
(point) beg-found
(if backward
(match-end 0)
1730 (match-beginning 0)))
1738 (signal 'search-failed
(list regexp
))))
1740 (progn (Info-read-subfile osubfile
)
1743 (set-window-start (selected-window) ostart
)))))
1745 (if (and (string= osubfile Info-current-subfile
)
1746 (> found opoint-min
)
1747 (< found opoint-max
))
1748 ;; Search landed in the same node
1752 (save-match-data (Info-select-node)))
1754 ;; Use string-equal, not equal, to ignore text props.
1755 (or (and (string-equal onode Info-current-node
)
1756 (equal ofile Info-current-file
))
1757 (and isearch-mode isearch-wrapped
1758 (eq opoint
(if isearch-forward opoint-min opoint-max
)))
1759 (setq Info-history
(cons (list ofile onode opoint
)
1762 (defun Info-search-case-sensitively ()
1763 "Search for a regexp case-sensitively."
1765 (let ((case-fold-search nil
))
1766 (call-interactively 'Info-search
)))
1768 (defun Info-search-next ()
1769 "Search for next regexp from a previous `Info-search' command."
1771 (let ((case-fold-search Info-search-case-fold
))
1772 (if Info-search-history
1773 (Info-search (car Info-search-history
))
1774 (call-interactively 'Info-search
))))
1776 (defun Info-search-backward (regexp &optional bound noerror count
)
1777 "Search for REGEXP in the reverse direction."
1778 (interactive (list (read-string
1779 (if Info-search-history
1780 (format "Regexp search%s backward (default %s): "
1781 (if case-fold-search
"" " case-sensitively")
1782 (car Info-search-history
))
1783 (format "Regexp search%s backward: "
1784 (if case-fold-search
"" " case-sensitively")))
1785 nil
'Info-search-history
)))
1786 (Info-search regexp bound noerror count
'backward
))
1788 (defun Info-isearch-search ()
1789 (if Info-isearch-search
1790 (lambda (string &optional bound noerror count
)
1792 (Info-search (concat "\\b" (replace-regexp-in-string
1794 (replace-regexp-in-string
1795 "^\\W+\\|\\W+$" "" string
)
1799 (unless isearch-forward
'backward
))
1800 (Info-search (if isearch-regexp string
(regexp-quote string
))
1802 (unless isearch-forward
'backward
))
1804 (let ((isearch-search-fun-function nil
))
1805 (isearch-search-fun))))
1807 (defun Info-isearch-wrap ()
1808 (if Info-isearch-search
1809 (if Info-isearch-initial-node
1811 (if isearch-forward
(Info-top-node) (Info-final-node))
1812 (goto-char (if isearch-forward
(point-min) (point-max))))
1813 (setq Info-isearch-initial-node Info-current-node
)
1814 (setq isearch-wrapped nil
))
1815 (goto-char (if isearch-forward
(point-min) (point-max)))))
1817 (defun Info-isearch-push-state ()
1819 (Info-isearch-pop-state cmd
,Info-current-file
,Info-current-node
)))
1821 (defun Info-isearch-pop-state (cmd file node
)
1822 (or (and (string= Info-current-file file
)
1823 (string= Info-current-node node
))
1824 (progn (Info-find-node file node
) (sit-for 0))))
1826 (defun Info-isearch-start ()
1827 (setq Info-isearch-initial-node nil
))
1829 (defun Info-extract-pointer (name &optional errorname
)
1830 "Extract the value of the node-pointer named NAME.
1831 If there is none, use ERRORNAME in the error message;
1832 if ERRORNAME is nil, just return nil."
1833 ;; Bind this in case the user sets it to nil.
1834 (let ((case-fold-search t
))
1836 (goto-char (point-min))
1837 (let ((bound (point)))
1839 (cond ((re-search-backward
1840 (concat name
":" (Info-following-node-name-re)) bound t
)
1842 ((not (eq errorname t
))
1843 (error "Node has no %s"
1844 (capitalize (or errorname name
)))))))))
1846 (defun Info-following-node-name-re (&optional allowedchars
)
1847 "Return a regexp matching a node name.
1848 ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
1849 saying which chars may appear in the node name.
1850 Submatch 1 is the complete node name.
1851 Submatch 2 if non-nil is the parenthesized file name part of the node name.
1852 Submatch 3 is the local part of the node name.
1853 End of submatch 0, 1, and 3 are the same, so you can safely concat."
1854 (concat "[ \t]*" ;Skip leading space.
1855 "\\(\\(([^)]+)\\)?" ;Node name can start with a file name.
1856 "\\([" (or allowedchars
"^,\t\n") "]*" ;Any number of allowed chars.
1857 "[" (or allowedchars
"^,\t\n") " ]" ;The last char can't be a space.
1858 "\\|\\)\\)")) ;Allow empty node names.
1860 ;;; For compatibility; other files have used this name.
1861 (defun Info-following-node-name ()
1862 (and (looking-at (Info-following-node-name-re))
1866 "Go to the next node of this node."
1868 ;; In case another window is currently selected
1869 (save-window-excursion
1870 (or (eq major-mode
'Info-mode
) (pop-to-buffer "*info*"))
1871 (Info-goto-node (Info-extract-pointer "next"))))
1874 "Go to the previous node of this node."
1876 ;; In case another window is currently selected
1877 (save-window-excursion
1878 (or (eq major-mode
'Info-mode
) (pop-to-buffer "*info*"))
1879 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous"))))
1881 (defun Info-up (&optional same-file
)
1882 "Go to the superior node of this node.
1883 If SAME-FILE is non-nil, do not move to a different Info file."
1885 ;; In case another window is currently selected
1886 (save-window-excursion
1887 (or (eq major-mode
'Info-mode
) (pop-to-buffer "*info*"))
1888 (let ((old-node Info-current-node
)
1889 (old-file Info-current-file
)
1890 (node (Info-extract-pointer "up")) p
)
1892 (string-match "^(" node
)
1893 (error "Up node is in another Info file"))
1894 (Info-goto-node node
)
1896 (goto-char (point-min))
1897 (if (and (search-forward "\n* Menu:" nil t
)
1899 (if (string-equal old-node
"Top")
1900 (concat "\n\\*[^:]+: +(" (file-name-nondirectory old-file
) ")")
1901 (concat "\n\\* +\\(" (regexp-quote old-node
)
1902 ":\\|[^:]+: +" (regexp-quote old-node
) "\\)"))
1904 (progn (beginning-of-line) (if (looking-at "^\\* ") (forward-char 2)))
1906 (Info-restore-point Info-history
)))))
1908 (defun Info-history-back ()
1909 "Go back in the history to the last node visited."
1912 (error "This is the first Info node you looked at"))
1913 (let ((history-forward
1914 (cons (list Info-current-file Info-current-node
(point))
1915 Info-history-forward
))
1916 filename nodename opoint
)
1917 (setq filename
(car (car Info-history
)))
1918 (setq nodename
(car (cdr (car Info-history
))))
1919 (setq opoint
(car (cdr (cdr (car Info-history
)))))
1920 (setq Info-history
(cdr Info-history
))
1921 (Info-find-node filename nodename
)
1922 (setq Info-history
(cdr Info-history
))
1923 (setq Info-history-forward history-forward
)
1924 (goto-char opoint
)))
1926 (defalias 'Info-last
'Info-history-back
)
1928 (defun Info-history-forward ()
1929 "Go forward in the history of visited nodes."
1931 (or Info-history-forward
1932 (error "This is the last Info node you looked at"))
1933 (let ((history-forward (cdr Info-history-forward
))
1934 filename nodename opoint
)
1935 (setq filename
(car (car Info-history-forward
)))
1936 (setq nodename
(car (cdr (car Info-history-forward
))))
1937 (setq opoint
(car (cdr (cdr (car Info-history-forward
)))))
1938 (Info-find-node filename nodename
)
1939 (setq Info-history-forward history-forward
)
1940 (goto-char opoint
)))
1943 (defun Info-directory ()
1944 "Go to the Info directory node."
1946 (Info-find-node "dir" "top"))
1948 (defun Info-history ()
1949 "Go to a node with a menu of visited nodes."
1951 (let ((curr-file Info-current-file
)
1952 (curr-node Info-current-node
)
1954 (with-current-buffer (get-buffer-create " *info-history*")
1955 (let ((inhibit-read-only t
))
1957 (goto-char (point-min))
1958 (insert "\n\^_\nFile: history, Node: Top, Up: (dir)\n\n")
1959 (insert "Recently Visited Nodes\n**********************\n\n")
1960 (insert "* Menu:\n\n")
1961 (let ((hl (delete '("history" "Top") Info-history-list
)))
1963 (let ((file (nth 0 (car hl
)))
1964 (node (nth 1 (car hl
))))
1965 (if (and (string-equal file curr-file
)
1966 (string-equal node curr-node
))
1968 (insert "* " node
": ("
1969 (propertize (or (file-name-directory file
) "") 'invisible t
)
1970 (file-name-nondirectory file
)
1972 (setq hl
(cdr hl
))))))
1973 (Info-find-node "history" "Top")
1974 (goto-char (or p
(point-min)))))
1977 "Go to a node with table of contents of the current Info file.
1978 Table of contents is created from the tree structure of menus."
1980 (let ((curr-file (substring-no-properties Info-current-file
))
1981 (curr-node (substring-no-properties Info-current-node
))
1983 (with-current-buffer (get-buffer-create " *info-toc*")
1984 (let ((inhibit-read-only t
)
1985 (node-list (Info-build-toc curr-file
)))
1987 (goto-char (point-min))
1988 (insert "\n\^_\nFile: toc, Node: Top, Up: (dir)\n\n")
1989 (insert "Table of Contents\n*****************\n\n")
1990 (insert "*Note Top: (" curr-file
")Top.\n")
1992 (nth 2 (assoc "Top" node-list
)) ; get Top nodes
1993 node-list
0 curr-file
))
1995 (let ((Info-hide-note-references 'hide
)
1996 (Info-fontify-visited-nodes nil
))
1998 (setq Info-current-file
"toc" Info-current-node
"Top")
1999 (goto-char (point-min))
2000 (narrow-to-region (or (re-search-forward "\n[\^_\f]\n" nil t
)
2005 (goto-char (point-min))
2006 (if (setq p
(search-forward (concat "*Note " curr-node
":") nil t
))
2007 (setq p
(- p
(length curr-node
) 2))))
2008 (Info-find-node "toc" "Top")
2009 (goto-char (or p
(point-min)))))
2011 (defun Info-insert-toc (nodes node-list level curr-file
)
2012 "Insert table of contents with references to nodes."
2013 (let ((section "Top"))
2015 (let ((node (assoc (car nodes
) node-list
)))
2016 (unless (member (nth 1 node
) (list nil section
))
2017 (insert (setq section
(nth 1 node
)) "\n"))
2018 (insert (make-string level ?
\t))
2019 (insert "*Note " (car nodes
) ": (" curr-file
")" (car nodes
) ".\n")
2020 (Info-insert-toc (nth 2 node
) node-list
(1+ level
) curr-file
)
2021 (setq nodes
(cdr nodes
))))))
2023 (defun Info-build-toc (file)
2024 "Build table of contents from menus of Info FILE and its subfiles."
2026 (let* ((file (and (stringp file
) (Info-find-file file
)))
2027 (default-directory (or (and (stringp file
)
2028 (file-name-directory file
))
2030 (main-file (and (stringp file
) file
))
2031 (sections '(("Top" "Top")))
2033 (while (or main-file subfiles
)
2034 (or main-file
(message "Searching subfile %s..." (car subfiles
)))
2036 (info-insert-file-contents (or main-file
(car subfiles
)))
2037 (goto-char (point-min))
2038 (while (and (search-forward "\n\^_\nFile:" nil
'move
)
2039 (search-forward "Node: " nil
'move
))
2040 (let ((nodename (substring-no-properties (Info-following-node-name)))
2041 (bound (- (or (save-excursion (search-forward "\n\^_" nil t
))
2045 (when (and (not (Info-index-node nodename file
))
2046 (re-search-forward "^\\* Menu:" bound t
))
2049 (setq bound
(or (and (equal nodename
"Top")
2052 "^[ \t-]*The Detailed Node Listing" nil t
)))
2054 (while (< (point) bound
)
2057 ((looking-at "^\\* +[^:]+:")
2060 (let ((menu-node-name (substring-no-properties
2061 (Info-extract-menu-node-name))))
2062 (setq menu-items
(cons menu-node-name menu-items
))
2063 (if (equal nodename
"Top")
2065 (cons (list menu-node-name section
) sections
)))))
2066 ;; Other non-empty strings in the Top node are section names
2067 ((and (equal nodename
"Top")
2068 (looking-at "^\\([^ \t\n*=.-][^:\n]*\\)"))
2069 (setq section
(match-string-no-properties 1))))
2071 (beginning-of-line)))
2072 (setq nodes
(cons (list nodename
2073 (cadr (assoc nodename sections
))
2074 (nreverse menu-items
))
2079 (goto-char (point-min))
2080 (if (search-forward "\n\^_\nIndirect:" nil t
)
2081 (let ((bound (save-excursion (search-forward "\n\^_" nil t
))))
2082 (while (re-search-forward "^\\(.*\\): [0-9]+$" bound t
)
2083 (setq subfiles
(cons (match-string-no-properties 1)
2085 (setq subfiles
(nreverse subfiles
)
2087 (setq subfiles
(cdr subfiles
))))
2091 (defun Info-follow-reference (footnotename &optional fork
)
2092 "Follow cross reference named FOOTNOTENAME to the node it refers to.
2093 FOOTNOTENAME may be an abbreviation of the reference name.
2094 If FORK is non-nil (interactively with a prefix arg), show the node in
2095 a new Info buffer. If FORK is a string, it is the name to use for the
2098 (let ((completion-ignore-case t
)
2099 (case-fold-search t
)
2100 completions default alt-default
(start-point (point)) str i bol eol
)
2102 ;; Store end and beginning of line.
2108 (goto-char (point-min))
2109 (while (re-search-forward "\\*note[ \n\t]+\\([^:]*\\):" nil t
)
2110 (setq str
(match-string-no-properties 1))
2111 ;; See if this one should be the default.
2113 (<= (match-beginning 0) start-point
)
2114 (<= start-point
(point))
2116 ;; See if this one should be the alternate default.
2117 (and (null alt-default
)
2118 (and (<= bol
(match-beginning 0))
2120 (setq alt-default t
))
2122 (while (setq i
(string-match "[ \n\t]+" str i
))
2123 (setq str
(concat (substring str
0 i
) " "
2124 (substring str
(match-end 0))))
2126 ;; Record as a completion and perhaps as default.
2127 (if (eq default t
) (setq default str
))
2128 (if (eq alt-default t
) (setq alt-default str
))
2129 ;; Don't add this string if it's a duplicate.
2130 (or (assoc-string str completions t
)
2131 (push str completions
))))
2132 ;; If no good default was found, try an alternate.
2134 (setq default alt-default
))
2135 ;; If only one cross-reference found, then make it default.
2136 (if (eq (length completions
) 1)
2137 (setq default
(car completions
)))
2139 (let ((input (completing-read (if default
2141 "Follow reference named (default "
2143 "Follow reference named: ")
2144 completions nil t
)))
2145 (list (if (equal input
"")
2146 default input
) current-prefix-arg
))
2147 (error "No cross-references in this node"))))
2149 (unless footnotename
2150 (error "No reference was specified"))
2152 (let (target i
(str (concat "\\*note " (regexp-quote footnotename
)))
2153 (case-fold-search t
))
2154 (while (setq i
(string-match " " str i
))
2155 (setq str
(concat (substring str
0 i
) "[ \t\n]+" (substring str
(1+ i
))))
2158 ;; Move point to the beginning of reference if point is on reference
2159 (or (looking-at "\\*note[ \n\t]+")
2160 (and (looking-back "\\*note[ \n\t]+")
2161 (goto-char (match-beginning 0)))
2162 (if (and (save-excursion
2163 (goto-char (+ (point) 5)) ; skip a possible *note
2164 (re-search-backward "\\*note[ \n\t]+" nil t
)
2166 (<= (point) (match-end 0)))
2167 (goto-char (match-beginning 0))))
2168 ;; Go to the reference closest to point
2169 (let ((next-ref (save-excursion (and (re-search-forward str nil t
)
2170 (+ (match-beginning 0) 5))))
2171 (prev-ref (save-excursion (and (re-search-backward str nil t
)
2172 (+ (match-beginning 0) 5)))))
2173 (goto-char (cond ((and next-ref prev-ref
)
2174 (if (< (abs (- next-ref
(point)))
2175 (abs (- prev-ref
(point))))
2177 ((or next-ref prev-ref
))
2178 ((error "No cross-reference named %s" footnotename
))))
2179 (setq target
(Info-extract-menu-node-name t
))))
2180 (while (setq i
(string-match "[ \t\n]+" target i
))
2181 (setq target
(concat (substring target
0 i
) " "
2182 (substring target
(match-end 0))))
2184 (Info-goto-node target fork
)))
2186 (defconst Info-menu-entry-name-re
"\\(?:[^:]\\|:[^:,.;() \t\n]\\)*"
2187 ;; We allow newline because this is also used in Info-follow-reference,
2188 ;; where the xref name might be wrapped over two lines.
2189 "Regexp that matches a menu entry name upto but not including the colon.
2190 Because of ambiguities, this should be concatenated with something like
2191 `:' and `Info-following-node-name-re'.")
2193 (defun Info-extract-menu-node-name (&optional multi-line index-node
)
2194 (skip-chars-forward " \t\n")
2195 (when (looking-at (concat Info-menu-entry-name-re
":\\(:\\|"
2196 (Info-following-node-name-re
2198 (index-node "^,\t\n")
2199 (multi-line "^.,\t")
2203 "\\.\\(?:[ \t\n]+(line +\\([0-9]+\\))\\)?"
2206 (setq Info-point-loc
2207 (if (match-beginning 5)
2208 (string-to-number (match-string 5))
2209 (buffer-substring (match-beginning 0) (1- (match-beginning 1)))))
2210 ;;; Uncomment next line to use names of cross-references in non-index nodes:
2211 ;;; (setq Info-point-loc
2212 ;;; (buffer-substring (match-beginning 0) (1- (match-beginning 1))))
2214 (replace-regexp-in-string
2216 (or (match-string 2)
2217 ;; If the node name is the menu entry name (using `entry::').
2218 (buffer-substring (match-beginning 0) (1- (match-beginning 1)))))))
2220 ;; No one calls this.
2221 ;;(defun Info-menu-item-sequence (list)
2223 ;; (Info-menu (car list))
2224 ;; (setq list (cdr list))))
2226 (defvar Info-complete-menu-buffer
)
2227 (defvar Info-complete-next-re nil
)
2228 (defvar Info-complete-nodes nil
)
2229 (defvar Info-complete-cache nil
)
2231 (defconst Info-node-spec-re
2232 (concat (Info-following-node-name-re "^.,:") "[,:.]")
2233 "Regexp to match the text after a : until the terminating `.'.")
2235 (defun Info-complete-menu-item (string predicate action
)
2236 ;; This uses two dynamically bound variables:
2237 ;; - `Info-complete-menu-buffer' which contains the buffer in which
2238 ;; is the menu of items we're trying to complete.
2239 ;; - `Info-complete-next-re' which, if non-nil, indicates that we should
2240 ;; also look for menu items in subsequent nodes as long as those
2241 ;; nodes' names match `Info-complete-next-re'. This feature is currently
2243 ;; - `Info-complete-nodes' which, if non-nil, indicates that we should
2244 ;; also look for menu items in these nodes. This feature is currently
2245 ;; only used for completion in Info-index.
2247 ;; Note that `Info-complete-menu-buffer' could be current already,
2248 ;; so we want to save point.
2250 (set-buffer Info-complete-menu-buffer
)
2251 (let ((completion-ignore-case t
)
2252 (case-fold-search t
)
2253 (orignode Info-current-node
)
2255 (goto-char (point-min))
2256 (search-forward "\n* Menu:")
2257 (if (not (memq action
'(nil t
)))
2259 (concat "\n\\* +" (regexp-quote string
) ":") nil t
)
2260 (let ((pattern (concat "\n\\* +\\("
2261 (regexp-quote string
)
2262 Info-menu-entry-name-re
"\\):" Info-node-spec-re
))
2264 (complete-nodes Info-complete-nodes
))
2266 (if (and (equal (nth 0 Info-complete-cache
) Info-current-file
)
2267 (equal (nth 1 Info-complete-cache
) Info-current-node
)
2268 (equal (nth 2 Info-complete-cache
) Info-complete-next-re
)
2269 (equal (nth 5 Info-complete-cache
) Info-complete-nodes
)
2270 (let ((prev (nth 3 Info-complete-cache
)))
2271 (eq t
(compare-strings string
0 (length prev
)
2273 ;; We can reuse the previous list.
2274 (setq completions
(nth 4 Info-complete-cache
))
2275 ;; The cache can't be used.
2278 (while (re-search-forward pattern nil t
)
2279 (push (match-string-no-properties 1)
2281 ;; Check subsequent nodes if applicable.
2282 (or (and Info-complete-next-re
2283 (setq nextnode
(Info-extract-pointer "next" t
))
2284 (string-match Info-complete-next-re nextnode
))
2286 (setq complete-nodes
(cdr complete-nodes
)
2287 nextnode
(car complete-nodes
)))))
2288 (Info-goto-node nextnode
))
2289 ;; Go back to the start node (for the next completion).
2290 (unless (equal Info-current-node orignode
)
2291 (Info-goto-node orignode
))
2292 ;; Update the cache.
2293 (set (make-local-variable 'Info-complete-cache
)
2294 (list Info-current-file Info-current-node
2295 Info-complete-next-re string completions
2296 Info-complete-nodes
)))
2298 (all-completions string completions predicate
)
2299 (try-completion string completions predicate
)))))))
2302 (defun Info-menu (menu-item &optional fork
)
2303 "Go to the node pointed to by the menu item named (or abbreviated) MENU-ITEM.
2304 The menu item should one of those listed in the current node's menu.
2305 Completion is allowed, and the default menu item is the one point is on.
2306 If FORK is non-nil (interactively with a prefix arg), show the node in
2307 a new Info buffer. If FORK is a string, it is the name to use for the
2310 (let ((completions '())
2311 ;; If point is within a menu item, use that item as the default
2316 (case-fold-search t
))
2318 (goto-char (point-min))
2319 (if (not (search-forward "\n* menu:" nil t
))
2320 (error "No menu in this node"))
2326 (if (re-search-backward (concat "\n\\* +\\("
2327 Info-menu-entry-name-re
2329 (setq default
(match-string-no-properties 1))))))
2332 (setq item
(let ((completion-ignore-case t
)
2333 (Info-complete-menu-buffer (current-buffer)))
2334 (completing-read (if default
2335 (format "Menu item (default %s): "
2338 'Info-complete-menu-item nil t
)))
2339 ;; we rely on the fact that completing-read accepts an input
2340 ;; of "" even when the require-match argument is true and ""
2341 ;; is not a valid possibility
2342 (if (string= item
"")
2347 (list item current-prefix-arg
))))
2348 ;; there is a problem here in that if several menu items have the same
2349 ;; name you can only go to the node of the first with this command.
2350 (Info-goto-node (Info-extract-menu-item menu-item
) (if fork menu-item
)))
2352 (defun Info-extract-menu-item (menu-item)
2353 (setq menu-item
(regexp-quote menu-item
))
2354 (let ((case-fold-search t
))
2356 (let ((case-fold-search t
))
2357 (goto-char (point-min))
2358 (or (search-forward "\n* menu:" nil t
)
2359 (error "No menu in this node"))
2360 (or (re-search-forward (concat "\n\\* +" menu-item
":") nil t
)
2361 (re-search-forward (concat "\n\\* +" menu-item
) nil t
)
2362 (error "No such item in menu"))
2365 (Info-extract-menu-node-name nil
(Info-index-node))))))
2367 ;; If COUNT is nil, use the last item in the menu.
2368 (defun Info-extract-menu-counting (count)
2369 (let ((case-fold-search t
))
2371 (let ((case-fold-search t
))
2372 (goto-char (point-min))
2373 (or (search-forward "\n* menu:" nil t
)
2374 (error "No menu in this node"))
2376 (or (search-forward "\n* " nil t count
)
2377 (error "Too few items in menu"))
2378 (while (search-forward "\n* " nil t
)
2380 (Info-extract-menu-node-name nil
(Info-index-node))))))
2382 (defun Info-nth-menu-item ()
2383 "Go to the node of the Nth menu item.
2384 N is the digit argument used to invoke this command."
2387 (Info-extract-menu-counting
2388 (- (aref (this-command-keys) (1- (length (this-command-keys)))) ?
0))))
2390 (defun Info-top-node ()
2391 "Go to the Top node of this file."
2393 (Info-goto-node "Top"))
2395 (defun Info-final-node ()
2396 "Go to the final node in this file."
2398 (Info-goto-node "Top")
2399 (let ((Info-history nil
)
2400 (case-fold-search t
))
2401 ;; Go to the last node in the menu of Top.
2402 (Info-goto-node (Info-extract-menu-counting nil
))
2403 ;; If the last node in the menu is not last in pointer structure,
2404 ;; move forward until we can't go any farther.
2405 (while (Info-forward-node t t
) nil
)
2406 ;; Then keep moving down to last subnode, unless we reach an index.
2407 (while (and (not (Info-index-node))
2408 (save-excursion (search-forward "\n* Menu:" nil t
)))
2409 (Info-goto-node (Info-extract-menu-counting nil
)))))
2411 (defun Info-forward-node (&optional not-down no-error
)
2412 "Go forward one node, considering all nodes as forming one sequence."
2414 (goto-char (point-min))
2416 (let ((case-fold-search t
))
2417 ;; three possibilities, in order of priority:
2418 ;; 1. next node is in a menu in this node (but not in an index)
2419 ;; 2. next node is next at same level
2420 ;; 3. next node is up and next
2421 (cond ((and (not not-down
)
2422 (save-excursion (search-forward "\n* menu:" nil t
))
2423 (not (Info-index-node)))
2424 (Info-goto-node (Info-extract-menu-counting 1))
2426 ((save-excursion (search-backward "next:" nil t
))
2429 ((and (save-excursion (search-backward "up:" nil t
))
2430 ;; Use string-equal, not equal, to ignore text props.
2431 (not (string-equal (downcase (Info-extract-pointer "up"))
2433 (let ((old-node Info-current-node
))
2435 (let (Info-history success
)
2437 (setq success
(Info-forward-node t no-error
))
2438 (or success
(Info-goto-node old-node
))))))
2440 (t (error "No pointer forward from this node")))))
2442 (defun Info-backward-node ()
2443 "Go backward one node, considering all nodes as forming one sequence."
2445 (let ((prevnode (Info-extract-pointer "prev[ious]*" t
))
2446 (upnode (Info-extract-pointer "up" t
))
2447 (case-fold-search t
))
2448 (cond ((and upnode
(string-match "(" upnode
))
2449 (error "First node in file"))
2450 ((and upnode
(or (null prevnode
)
2451 ;; Use string-equal, not equal,
2452 ;; to ignore text properties.
2453 (string-equal (downcase prevnode
)
2454 (downcase upnode
))))
2457 ;; If we move back at the same level,
2458 ;; go down to find the last subnode*.
2461 (while (and (not (Info-index-node))
2462 (save-excursion (search-forward "\n* Menu:" nil t
)))
2463 (Info-goto-node (Info-extract-menu-counting nil
)))))
2465 (error "No pointer backward from this node")))))
2468 "Exit Info by selecting some other buffer."
2471 (save-buffers-kill-emacs)
2474 (defun Info-next-menu-item ()
2475 "Go to the node of the next menu item."
2477 ;; Bind this in case the user sets it to nil.
2478 (let* ((case-fold-search t
)
2482 (search-forward "\n* menu:" nil t
)
2483 (and (search-forward "\n* " nil t
)
2484 (Info-extract-menu-node-name)))))
2485 (if node
(Info-goto-node node
)
2486 (error "No more items in menu"))))
2488 (defun Info-last-menu-item ()
2489 "Go to the node of the previous menu item."
2493 ;; Bind this in case the user sets it to nil.
2494 (let* ((case-fold-search t
)
2495 (beg (save-excursion
2496 (and (search-backward "\n* menu:" nil t
)
2498 (or (and beg
(search-backward "\n* " beg t
))
2499 (error "No previous items in menu")))
2500 (Info-goto-node (save-excursion
2501 (goto-char (match-end 0))
2502 (Info-extract-menu-node-name)))))
2504 (defmacro Info-no-error
(&rest body
)
2505 (list 'condition-case nil
(cons 'progn
(append body
'(t))) '(error nil
)))
2507 (defun Info-next-preorder ()
2508 "Go to the next subnode or the next node, or go up a level."
2510 (cond ((Info-no-error (Info-next-menu-item)))
2511 ((Info-no-error (Info-next)))
2512 ((Info-no-error (Info-up t
))
2513 ;; Since we have already gone thru all the items in this menu,
2514 ;; go up to the end of this node.
2515 (goto-char (point-max))
2516 ;; Since logically we are done with the node with that menu,
2518 (Info-next-preorder))
2520 (error "No more nodes"))))
2522 (defun Info-last-preorder ()
2523 "Go to the last node, popping up a level if there is none."
2525 (cond ((Info-no-error
2526 (Info-last-menu-item)
2527 ;; If we go down a menu item, go to the end of the node
2528 ;; so we can scroll back through it.
2529 (goto-char (point-max)))
2530 ;; Keep going down, as long as there are nested menu nodes.
2531 (while (Info-no-error
2532 (Info-last-menu-item)
2533 ;; If we go down a menu item, go to the end of the node
2534 ;; so we can scroll back through it.
2535 (goto-char (point-max))))
2537 ((and (Info-no-error (Info-extract-pointer "prev"))
2538 (not (equal (Info-extract-pointer "up")
2539 (Info-extract-pointer "prev"))))
2540 (Info-no-error (Info-prev))
2541 (goto-char (point-max))
2542 (while (Info-no-error
2543 (Info-last-menu-item)
2544 ;; If we go down a menu item, go to the end of the node
2545 ;; so we can scroll back through it.
2546 (goto-char (point-max))))
2548 ((Info-no-error (Info-up t
))
2549 (goto-char (point-min))
2550 (let ((case-fold-search t
))
2551 (or (search-forward "\n* Menu:" nil t
)
2552 (goto-char (point-max)))))
2553 (t (error "No previous nodes"))))
2555 (defun Info-scroll-up ()
2556 "Scroll one screenful forward in Info, considering all nodes as one sequence.
2557 Once you scroll far enough in a node that its menu appears on the screen
2558 but after point, the next scroll moves into its first subnode, unless
2559 `Info-scroll-prefer-subnodes' is nil.
2561 When you scroll past the end of a node, that goes to the next node if
2562 `Info-scroll-prefer-subnodes' is non-nil and to the first subnode otherwise;
2563 if this node has no successor, it moves to the parent node's successor,
2564 and so on. If `Info-scroll-prefer-subnodes' is non-nil and point is inside
2565 the menu of a node, it moves to subnode indicated by the following menu
2566 item. (That case won't normally result from this command, but can happen
2570 (if (or (< (window-start) (point-min))
2571 (> (window-start) (point-max)))
2572 (set-window-start (selected-window) (point)))
2573 (let* ((case-fold-search t
)
2574 (virtual-end (save-excursion
2575 (goto-char (point-min))
2576 (if (and Info-scroll-prefer-subnodes
2577 (search-forward "\n* Menu:" nil t
))
2580 (if (or (< virtual-end
(window-start))
2581 (pos-visible-in-window-p virtual-end
))
2583 (Info-scroll-prefer-subnodes (Info-next-preorder))
2584 ((Info-no-error (Info-goto-node (Info-extract-menu-counting 1))))
2585 (t (Info-next-preorder)))
2588 (defun Info-scroll-down ()
2589 "Scroll one screenful back in Info, considering all nodes as one sequence.
2590 If point is within the menu of a node, and `Info-scroll-prefer-subnodes'
2591 is non-nil, this goes to its last subnode. When you scroll past the
2592 beginning of a node, that goes to the previous node or back up to the
2595 (if (or (< (window-start) (point-min))
2596 (> (window-start) (point-max)))
2597 (set-window-start (selected-window) (point)))
2598 (let* ((case-fold-search t
)
2599 (current-point (point))
2601 (and Info-scroll-prefer-subnodes
2604 (setq current-point
(point))
2605 (goto-char (point-min))
2606 (search-forward "\n* Menu:"
2610 (pos-visible-in-window-p (point-min) nil t
))
2611 (Info-last-preorder)
2614 (defun Info-next-reference (&optional recur
)
2615 "Move cursor to the next cross-reference or menu item in the node."
2617 (let ((pat "\\*note[ \n\t]+\\([^:]+\\):\\|^\\* .*:\\|[hf]t?tp://")
2619 (case-fold-search t
))
2620 (or (eobp) (forward-char 1))
2621 (or (re-search-forward pat nil t
)
2623 (goto-char (point-min))
2624 (or (re-search-forward pat nil t
)
2627 (error "No cross references in this node")))))
2628 (goto-char (or (match-beginning 1) (match-beginning 0)))
2629 (if (looking-at "\\* Menu:")
2631 (error "No cross references in this node")
2632 (Info-next-reference t
))
2633 (if (looking-at "^\\* ")
2634 (forward-char 2)))))
2636 (defun Info-prev-reference (&optional recur
)
2637 "Move cursor to the previous cross-reference or menu item in the node."
2639 (let ((pat "\\*note[ \n\t]+\\([^:]+\\):\\|^\\* .*:\\|[hf]t?tp://")
2641 (case-fold-search t
))
2642 (or (re-search-backward pat nil t
)
2644 (goto-char (point-max))
2645 (or (re-search-backward pat nil t
)
2648 (error "No cross references in this node")))))
2649 (goto-char (or (match-beginning 1) (match-beginning 0)))
2650 (if (looking-at "\\* Menu:")
2652 (error "No cross references in this node")
2653 (Info-prev-reference t
))
2654 (if (looking-at "^\\* ")
2655 (forward-char 2)))))
2657 (defvar Info-index-nodes nil
2658 "Alist of cached index node names of visited Info files.
2659 Each element has the form (INFO-FILE INDEX-NODE-NAMES-LIST).")
2661 (defun Info-index-nodes (&optional file
)
2662 "Return a list of names of all index nodes in Info FILE.
2663 If FILE is omitted, it defaults to the current Info file.
2664 First look in a list of cached index node names. Then scan Info
2665 file and its subfiles for nodes with the index cookie. Then try
2666 to find index nodes starting from the first node in the top level
2667 menu whose name contains the word \"Index\", plus any immediately
2668 following nodes whose names also contain the word \"Index\"."
2669 (or file
(setq file Info-current-file
))
2670 (or (assoc file Info-index-nodes
)
2671 ;; Skip virtual Info files
2672 (and (member file
'("dir" "history" "toc" "apropos"))
2673 (setq Info-index-nodes
(cons (cons file nil
) Info-index-nodes
)))
2674 (not (stringp file
))
2675 (if Info-file-supports-index-cookies
2676 ;; Find nodes with index cookie
2677 (let* ((default-directory (or (and (stringp file
)
2678 (file-name-directory
2679 (setq file
(Info-find-file file
))))
2681 Info-history Info-history-list Info-fontify-maximum-menu-size
2682 (main-file file
) subfiles nodes node
)
2685 (while (or main-file subfiles
)
2687 (info-insert-file-contents (or main-file
(car subfiles
)))
2688 (goto-char (point-min))
2689 (while (search-forward "\0\b[index\0\b]" nil
'move
)
2691 (re-search-backward "^\^_")
2692 (search-forward "Node: ")
2693 (setq nodes
(cons (Info-following-node-name) nodes
))))
2696 (goto-char (point-min))
2697 (if (search-forward "\n\^_\nIndirect:" nil t
)
2698 (let ((bound (save-excursion (search-forward "\n\^_" nil t
))))
2699 (while (re-search-forward "^\\(.*\\): [0-9]+$" bound t
)
2700 (setq subfiles
(cons (match-string-no-properties 1)
2702 (setq subfiles
(nreverse subfiles
)
2704 (setq subfiles
(cdr subfiles
)))))
2707 (setq nodes
(nreverse nodes
)
2708 Info-index-nodes
(cons (cons file nodes
) Info-index-nodes
)))
2710 ;; Else find nodes with the word "Index" in the node name
2711 (let ((case-fold-search t
)
2712 Info-history Info-history-list Info-fontify-maximum-menu-size
2717 (Info-find-node file
"Top")
2718 (when (and (search-forward "\n* menu:" nil t
)
2719 (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t
))
2720 (goto-char (match-beginning 1))
2721 (setq nodes
(list (Info-extract-menu-node-name)))
2722 (Info-goto-node (car nodes
))
2723 (while (and (setq node
(Info-extract-pointer "next" t
))
2724 (string-match "\\<Index\\>" node
))
2725 (setq nodes
(cons node nodes
))
2726 (Info-goto-node node
))))
2729 (setq nodes
(nreverse nodes
)
2730 Info-index-nodes
(cons (cons file nodes
) Info-index-nodes
)))
2732 ;; If file has no index nodes, still add it to the cache
2733 (setq Info-index-nodes
(cons (cons file nil
) Info-index-nodes
)))
2734 (cdr (assoc file Info-index-nodes
)))
2736 (defun Info-index-node (&optional node file
)
2737 "Return non-nil value if NODE is an index node.
2738 If NODE is nil, check the current Info node.
2739 If FILE is nil, check the current Info file."
2740 (if (or (and node
(not (equal node Info-current-node
)))
2741 (assoc (or file Info-current-file
) Info-index-nodes
))
2742 (member (or node Info-current-node
) (Info-index-nodes file
))
2743 ;; Don't search all index nodes if request is only for the current node
2744 ;; and file is not in the cache of index nodes
2745 (if Info-file-supports-index-cookies
2747 (goto-char (+ (or (save-excursion
2748 (search-backward "\n\^_" nil t
))
2750 (search-forward "\0\b[index\0\b]"
2752 (search-forward "\n\^_" nil t
))
2755 (string-match "\\<Index\\>" (or node Info-current-node
""))))))
2757 (defun Info-goto-index ()
2758 "Go to the first index node."
2759 (let ((node (car (Info-index-nodes))))
2760 (or node
(error "No index"))
2761 (Info-goto-node node
)))
2764 (defun Info-index (topic)
2765 "Look up a string TOPIC in the index for this file.
2766 If there are no exact matches to the specified topic, this chooses
2767 the first match which is a case-insensitive substring of a topic.
2768 Use the \\<Info-mode-map>\\[Info-index-next] command to see the other matches.
2769 Give a blank topic name to go to the Index node itself."
2772 (let ((Info-complete-menu-buffer (clone-buffer))
2773 (Info-complete-nodes (Info-index-nodes))
2774 (Info-history-list nil
))
2775 (if (equal Info-current-file
"dir")
2776 (error "The Info directory node has no index; use m to select a manual"))
2778 (with-current-buffer Info-complete-menu-buffer
2780 (completing-read "Index topic: " 'Info-complete-menu-item
))
2781 (kill-buffer Info-complete-menu-buffer
)))))
2782 (if (equal Info-current-file
"dir")
2783 (error "The Info directory node has no index; use m to select a manual"))
2784 (let ((orignode Info-current-node
)
2785 (pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^\n]*\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?"
2786 (regexp-quote topic
)))
2787 node
(nodes (Info-index-nodes))
2788 (ohist-list Info-history-list
)
2789 (case-fold-search t
))
2791 (or (equal topic
"")
2794 ;; We bind Info-history to nil for internal node-switches so
2795 ;; that we don't put junk in the history. In the first
2796 ;; Info-goto-index call, above, we do update the history
2797 ;; because that is what the user's previous node choice into it.
2802 (goto-char (point-min))
2803 (while (re-search-forward pattern nil t
)
2804 (push (list (match-string-no-properties 1)
2805 (match-string-no-properties 2)
2807 (string-to-number (concat "0"
2810 (setq nodes
(cdr nodes
) node
(car nodes
)))
2811 (Info-goto-node node
))
2814 (Info-goto-node orignode
)
2815 (error "No `%s' in index" topic
)))
2816 ;; Here it is a feature that assoc is case-sensitive.
2817 (while (setq found
(assoc topic matches
))
2818 (setq exact
(cons found exact
)
2819 matches
(delq found matches
)))
2820 (setq Info-history-list ohist-list
)
2821 (setq Info-index-alternatives
(nconc exact
(nreverse matches
)))
2822 (Info-index-next 0)))))
2824 (defun Info-index-next (num)
2825 "Go to the next matching index item from the last \\<Info-mode-map>\\[Info-index] command."
2827 (or Info-index-alternatives
2828 (error "No previous `i' command"))
2830 (setq num
(+ num
(length Info-index-alternatives
))))
2832 (setq Info-index-alternatives
2833 (nconc (cdr Info-index-alternatives
)
2834 (list (car Info-index-alternatives
)))
2836 (Info-goto-node (nth 1 (car Info-index-alternatives
)))
2837 (if (> (nth 3 (car Info-index-alternatives
)) 0)
2838 (forward-line (1- (nth 3 (car Info-index-alternatives
))))
2839 (forward-line 3) ; don't search in headers
2840 (let ((name (car (car Info-index-alternatives
))))
2841 (Info-find-index-name name
)))
2842 (message "Found `%s' in %s. %s"
2843 (car (car Info-index-alternatives
))
2844 (nth 2 (car Info-index-alternatives
))
2845 (if (cdr Info-index-alternatives
)
2846 (format "(%s total; use `,' for next)"
2847 (length Info-index-alternatives
))
2850 (defun Info-find-index-name (name)
2851 "Move point to the place within the current node where NAME is defined."
2852 (let ((case-fold-search t
))
2853 (if (or (re-search-forward (format
2854 "[a-zA-Z]+: %s\\( \\|$\\)"
2855 (regexp-quote name
)) nil t
)
2856 ;; Find a function definition with a return type.
2857 (re-search-forward (format
2858 "[a-zA-Z]+: [a-zA-Z0-9_ *&]+ %s\\( \\|$\\)"
2859 (regexp-quote name
)) nil t
)
2860 (search-forward (format "`%s'" name
) nil t
)
2861 (and (string-match "\\`.*\\( (.*)\\)\\'" name
)
2863 (format "`%s'" (substring name
0 (match-beginning 1)))
2865 (search-forward name nil t
)
2866 ;; Try again without the " <1>" makeinfo can append
2867 (and (string-match "\\`\\(.*\\) <[0-9]+>\\'" name
)
2868 (Info-find-index-name (match-string 1 name
))))
2869 (progn (beginning-of-line) t
) ;; non-nil for recursive call
2870 (goto-char (point-min)))))
2873 (defun info-apropos (string)
2874 "Grovel indices of all known Info files on your system for STRING.
2875 Build a menu of the possible matches."
2876 (interactive "sIndex apropos: ")
2877 (unless (string= string
"")
2878 (let ((pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^\n]+\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?"
2879 (regexp-quote string
)))
2880 (ohist Info-history
)
2881 (ohist-list Info-history-list
)
2882 (current-node Info-current-node
)
2883 (current-file Info-current-file
)
2884 manuals matches node nodes
)
2885 (let ((Info-fontify-maximum-menu-size nil
))
2887 (message "Searching indices...")
2888 (goto-char (point-min))
2889 (re-search-forward "\\* Menu: *\n" nil t
)
2890 (while (re-search-forward "\\*.*: *(\\([^)]+\\))" nil t
)
2891 (setq manuals
(cons (match-string 1) manuals
)))
2892 (dolist (manual (nreverse manuals
))
2893 (message "Searching %s" manual
)
2895 (if (setq nodes
(Info-index-nodes (Info-find-file manual
)))
2897 (Info-find-node manual
(car nodes
))
2900 (goto-char (point-min))
2901 (while (re-search-forward pattern nil t
)
2904 (match-string-no-properties 1)
2905 (match-string-no-properties 2)
2906 (match-string-no-properties 3))
2908 (setq nodes
(cdr nodes
) node
(car nodes
)))
2909 (Info-goto-node node
))))
2911 (message "%s" (if (eq (car-safe err
) 'error
)
2914 (Info-goto-node (concat "(" current-file
")" current-node
))
2915 (setq Info-history ohist
2916 Info-history-list ohist-list
)
2917 (message "Searching indices...done")
2919 (message "No matches found")
2920 (with-current-buffer (get-buffer-create " *info-apropos*")
2922 (insert "\n\^_\nFile: apropos, Node: Index, Up: (dir)\n")
2923 (insert "* Menu: \nNodes whose indices contain `" string
"':\n\n")
2924 (dolist (entry (nreverse matches
))
2926 (format "* %-38s (%s)%s.%s\n"
2927 (concat (nth 1 entry
) " [" (nth 0 entry
) "]:")
2931 (concat " (line " (nth 3 entry
) ")")
2933 (Info-find-node "apropos" "Index")
2934 (setq Info-complete-cache nil
)))))
2936 (defun Info-undefined ()
2937 "Make command be undefined in Info."
2942 "Enter the Info tutorial."
2944 (delete-other-windows)
2945 (Info-find-node "info"
2946 (if (< (window-height) 23)
2950 (defun Info-summary ()
2951 "Display a brief summary of all Info commands."
2953 (save-window-excursion
2954 (switch-to-buffer "*Help*")
2955 (setq buffer-read-only nil
)
2957 (insert (documentation 'Info-mode
))
2959 (goto-char (point-min))
2961 (while (progn (setq flag
(not (pos-visible-in-window-p (point-max))))
2962 (message (if flag
"Type Space to see more"
2963 "Type Space to return to Info"))
2964 (if (not (eq ?\s
(setq ch
(read-event))))
2965 (progn (setq unread-command-events
(list ch
)) nil
)
2968 (bury-buffer "*Help*")))
2970 (defun Info-get-token (pos start all
&optional errorstring
)
2971 "Return the token around POS.
2972 POS must be somewhere inside the token
2973 START is a regular expression which will match the
2974 beginning of the tokens delimited string
2975 ALL is a regular expression with a single
2976 parenthesized subpattern which is the token to be
2977 returned. E.g. '{\(.*\)}' would return any string
2978 enclosed in braces around POS.
2979 ERRORSTRING optional fourth argument, controls action on no match
2982 a string: signal an error, using that string."
2983 (let ((case-fold-search t
))
2986 ;; First look for a match for START that goes across POS.
2987 (while (and (not (bobp)) (> (point) (- pos
(length start
)))
2988 (not (looking-at start
)))
2990 ;; If we did not find one, search back for START
2991 ;; (this finds only matches that end at or before POS).
2992 (or (looking-at start
)
2995 (re-search-backward start
(max (point-min) (- pos
200)) 'yes
)))
2997 (while (and (re-search-forward all
(min (point-max) (+ pos
200)) 'yes
)
2998 (not (setq found
(and (<= (match-beginning 0) pos
)
2999 (> (match-end 0) pos
))))))
3000 (if (and found
(<= (match-beginning 0) pos
)
3001 (> (match-end 0) pos
))
3002 (match-string-no-properties 1)
3003 (cond ((null errorstring
)
3009 (error "No %s around position %d" errorstring pos
))))))))
3011 (defun Info-mouse-follow-nearest-node (click)
3012 "\\<Info-mode-map>Follow a node reference near point.
3013 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click.
3014 At end of the node's text, moves to the next node, or up if none."
3016 (mouse-set-point click
)
3017 (and (not (Info-try-follow-nearest-node))
3018 (save-excursion (forward-line 1) (eobp))
3019 (Info-next-preorder)))
3021 (defun Info-follow-nearest-node (&optional fork
)
3022 "Follow a node reference near point.
3023 If point is on a reference, follow that reference. Otherwise,
3024 if point is in a menu item description, follow that menu item."
3026 (or (Info-try-follow-nearest-node fork
)
3027 (when (save-excursion
3028 (search-backward "\n* menu:" nil t
))
3031 (while (not (or (bobp) (looking-at "[^ \t]\\|[ \t]*$")))
3032 (beginning-of-line 0))
3033 (when (looking-at "\\* +\\([^\t\n]*\\):")
3035 (Info-extract-menu-item (match-string-no-properties 1)) fork
)
3037 (error "Point neither on reference nor in menu item description")))
3039 ;; Common subroutine.
3040 (defun Info-try-follow-nearest-node (&optional fork
)
3041 "Follow a node reference near point. Return non-nil if successful."
3044 ((Info-get-token (point) "[hf]t?tp://" "[hf]t?tp://\\([^ \t\n\"`({<>})']+\\)")
3046 (browse-url (browse-url-url-at-point)))
3047 ((setq node
(Info-get-token (point) "\\*note[ \n\t]+"
3048 "\\*note[ \n\t]+\\([^:]*\\):\\(:\\|[ \n\t]*(\\)?"))
3049 (Info-follow-reference node fork
))
3050 ;; menu item: node name
3051 ((setq node
(Info-get-token (point) "\\* +" "\\* +\\([^:]*\\)::"))
3052 (Info-goto-node node fork
))
3053 ;; menu item: node name or index entry
3054 ((Info-get-token (point) "\\* +" "\\* +\\(.*\\): ")
3057 (setq node
(Info-extract-menu-node-name nil
(Info-index-node)))
3058 (Info-goto-node node fork
))
3059 ((setq node
(Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)"))
3060 (Info-goto-node node fork
))
3061 ((setq node
(Info-get-token (point) "Next: " "Next: \\([^,\n\t]*\\)"))
3062 (Info-goto-node node fork
))
3063 ((setq node
(Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)"))
3064 (Info-goto-node "Top" fork
))
3065 ((setq node
(Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)"))
3066 (Info-goto-node node fork
)))
3069 (defvar Info-mode-map nil
3070 "Keymap containing Info commands.")
3073 (setq Info-mode-map
(make-keymap))
3074 (suppress-keymap Info-mode-map
)
3075 (define-key Info-mode-map
"." 'beginning-of-buffer
)
3076 (define-key Info-mode-map
" " 'Info-scroll-up
)
3077 (define-key Info-mode-map
"\C-m" 'Info-follow-nearest-node
)
3078 (define-key Info-mode-map
"\t" 'Info-next-reference
)
3079 (define-key Info-mode-map
"\e\t" 'Info-prev-reference
)
3080 (define-key Info-mode-map
[(shift tab
)] 'Info-prev-reference
)
3081 (define-key Info-mode-map
[backtab] 'Info-prev-reference)
3082 (define-key Info-mode-map "1" 'Info-nth-menu-item)
3083 (define-key Info-mode-map "2" 'Info-nth-menu-item)
3084 (define-key Info-mode-map "3" 'Info-nth-menu-item)
3085 (define-key Info-mode-map "4" 'Info-nth-menu-item)
3086 (define-key Info-mode-map "5" 'Info-nth-menu-item)
3087 (define-key Info-mode-map "6" 'Info-nth-menu-item)
3088 (define-key Info-mode-map "7" 'Info-nth-menu-item)
3089 (define-key Info-mode-map "8" 'Info-nth-menu-item)
3090 (define-key Info-mode-map "9" 'Info-nth-menu-item)
3091 (define-key Info-mode-map "0" 'undefined)
3092 (define-key Info-mode-map "?" 'Info-summary)
3093 (define-key Info-mode-map "]" 'Info-forward-node)
3094 (define-key Info-mode-map "[" 'Info-backward-node)
3095 (define-key Info-mode-map "<" 'Info-top-node)
3096 (define-key Info-mode-map ">" 'Info-final-node)
3097 (define-key Info-mode-map "b" 'beginning-of-buffer)
3098 (define-key Info-mode-map "d" 'Info-directory)
3099 (define-key Info-mode-map "e" 'Info-edit)
3100 (define-key Info-mode-map "f" 'Info-follow-reference)
3101 (define-key Info-mode-map "g" 'Info-goto-node)
3102 (define-key Info-mode-map "h" 'Info-help)
3103 (define-key Info-mode-map "i" 'Info-index)
3104 (define-key Info-mode-map "l" 'Info-history-back)
3105 (define-key Info-mode-map "L" 'Info-history)
3106 (define-key Info-mode-map "m" 'Info-menu)
3107 (define-key Info-mode-map "n" 'Info-next)
3108 (define-key Info-mode-map "p" 'Info-prev)
3109 (define-key Info-mode-map "q" 'Info-exit)
3110 (define-key Info-mode-map "r" 'Info-history-forward)
3111 (define-key Info-mode-map "s" 'Info-search)
3112 (define-key Info-mode-map "S" 'Info-search-case-sensitively)
3113 ;; For consistency with Rmail.
3114 (define-key Info-mode-map "\M-s" 'Info-search)
3115 (define-key Info-mode-map "\M-n" 'clone-buffer)
3116 (define-key Info-mode-map "t" 'Info-top-node)
3117 (define-key Info-mode-map "T" 'Info-toc)
3118 (define-key Info-mode-map "u" 'Info-up)
3119 ;; `w' for consistency with `dired-copy-filename-as-kill'.
3120 (define-key Info-mode-map "w" 'Info-copy-current-node-name)
3121 (define-key Info-mode-map "c" 'Info-copy-current-node-name)
3122 ;; `^' for consistency with `dired-up-directory'.
3123 (define-key Info-mode-map "^" 'Info-up)
3124 (define-key Info-mode-map "," 'Info-index-next)
3125 (define-key Info-mode-map "\177" 'Info-scroll-down)
3126 (define-key Info-mode-map [mouse-2] 'Info-mouse-follow-nearest-node)
3127 (define-key Info-mode-map [follow-link] 'mouse-face)
3130 (defun Info-check-pointer (item)
3131 "Non-nil if ITEM is present in this node."
3133 (Info-extract-pointer item)
3137 Info-mode-menu Info-mode-map
3138 "Menu for Info files."
3140 ["Up" Info-up :active (Info-check-pointer "up")
3141 :help "Go up in the Info tree"]
3142 ["Next" Info-next :active (Info-check-pointer "next")
3143 :help "Go to the next node"]
3144 ["Previous" Info-prev :active (Info-check-pointer "prev[ious]*")
3145 :help "Go to the previous node"]
3146 ["Backward" Info-backward-node
3147 :help "Go backward one node, considering all as a sequence"]
3148 ["Forward" Info-forward-node
3149 :help "Go forward one node, considering all as a sequence"]
3150 ["Beginning" beginning-of-buffer
3151 :help "Go to beginning of this node"]
3152 ["Top" Info-top-node
3153 :help "Go to top node of file"]
3154 ["Final Node" Info-final-node
3155 :help "Go to final node in this file"]
3156 ("Menu Item" ["You should never see this" report-emacs-bug t])
3157 ("Reference" ["You should never see this" report-emacs-bug t])
3158 ["Search..." Info-search
3159 :help "Search for regular expression in this Info file"]
3160 ["Search Next" Info-search-next
3161 :help "Search for another occurrence of regular expression"]
3162 ["Go to Node..." Info-goto-node
3163 :help "Go to a named node"]
3164 ["Back in history" Info-history-back :active Info-history
3165 :help "Go back in history to the last node you were at"]
3166 ["Forward in history" Info-history-forward :active Info-history-forward
3167 :help "Go forward in history"]
3168 ["History" Info-history :active Info-history-list
3169 :help "Go to menu of visited nodes"]
3170 ["Table of Contents" Info-toc
3171 :help "Go to table of contents"]
3173 ["Lookup a String..." Info-index
3174 :help "Look for a string in the index items"]
3175 ["Next Matching Item" Info-index-next :active Info-index-alternatives
3176 :help "Look for another occurrence of previous item"]
3177 ["Lookup a string in all indices..." info-apropos
3178 :help "Look for a string in the indices of all manuals"])
3179 ["Copy Node Name" Info-copy-current-node-name
3180 :help "Copy the name of the current node into the kill ring"]
3181 ["Clone Info buffer" clone-buffer
3182 :help "Create a twin copy of the current Info buffer."]
3183 ["Exit" Info-exit :help "Stop reading Info"]))
3186 (defvar info-tool-bar-map
3187 (if (display-graphic-p)
3188 (let ((map (make-sparse-keymap)))
3189 (tool-bar-local-item-from-menu 'Info-exit "close" map Info-mode-map)
3190 (tool-bar-local-item-from-menu 'Info-history-back "left-arrow" map Info-mode-map)
3191 (tool-bar-local-item-from-menu 'Info-history-forward "right-arrow" map Info-mode-map)
3192 (tool-bar-local-item-from-menu 'Info-prev "prev-node" map Info-mode-map)
3193 (tool-bar-local-item-from-menu 'Info-next "next-node" map Info-mode-map)
3194 (tool-bar-local-item-from-menu 'Info-up "up-node" map Info-mode-map)
3195 (tool-bar-local-item-from-menu 'Info-top-node "home" map Info-mode-map)
3196 (tool-bar-local-item-from-menu 'Info-goto-node "jump-to" map Info-mode-map)
3197 (tool-bar-local-item-from-menu 'Info-index "index" map Info-mode-map)
3198 (tool-bar-local-item-from-menu 'Info-search "search" map Info-mode-map)
3201 (defvar Info-menu-last-node nil)
3202 ;; Last node the menu was created for.
3203 ;; Value is a list, (FILE-NAME NODE-NAME).
3205 (defun Info-menu-update ()
3206 "Update the Info menu for the current node."
3208 (if (or (not (eq major-mode 'Info-mode))
3209 (equal (list Info-current-file Info-current-node)
3210 Info-menu-last-node))
3212 ;; Update menu menu.
3213 (let* ((Info-complete-menu-buffer (current-buffer))
3214 (items (nreverse (condition-case nil
3215 (Info-complete-menu-item "" nil t)
3219 (while (and items (< number 9))
3220 (setq current (car items)
3223 (setq entries (cons `[,current
3224 (Info-menu ,current)
3225 :keys ,(format "%d" number)]
3228 (setq entries (cons ["Other..." Info-menu t] entries)))
3230 (setq entries (list ["No menu" nil nil] nil :active)))
3231 (easy-menu-change '("Info") "Menu Item" (nreverse entries)))
3232 ;; Update reference menu. Code stolen from `Info-follow-reference'.
3234 str i entries current
3236 (case-fold-search t))
3238 (goto-char (point-min))
3239 (while (re-search-forward "\\*note[ \n\t]+\\([^:]*\\):" nil t)
3240 (setq str (match-string 1))
3242 (while (setq i (string-match "[ \n\t]+" str i))
3243 (setq str (concat (substring str 0 i) " "
3244 (substring str (match-end 0))))
3248 (while (and items (< number 9))
3249 (setq current (car items)
3252 (setq entries (cons `[,current
3253 (Info-follow-reference ,current)
3257 (setq entries (cons ["Other..." Info-follow-reference t]
3260 (setq entries (list ["No references" nil nil] nil :active)))
3261 (easy-menu-change '("Info") "Reference" (nreverse entries)))
3262 ;; Update last seen node.
3263 (setq Info-menu-last-node (list Info-current-file Info-current-node)))
3264 ;; Try to avoid entering infinite beep mode in case of errors.
3268 (defun Info-copy-current-node-name (&optional arg)
3269 "Put the name of the current Info node into the kill ring.
3270 The name of the Info file is prepended to the node name in parentheses.
3271 With a zero prefix arg, put the name inside a function call to `info'."
3273 (unless Info-current-node
3274 (error "No current Info node"))
3275 (let ((node (concat "(" (file-name-nondirectory Info-current-file) ")"
3276 Info-current-node)))
3277 (if (zerop (prefix-numeric-value arg))
3278 (setq node (concat "(info \"" node "\")")))
3280 (message "%s" node)))
3283 ;; Info mode is suitable only for specially formatted data.
3284 (put 'Info-mode 'mode-class 'special)
3285 (put 'Info-mode 'no-clone-indirect t)
3287 (defvar tool-bar-map)
3289 ;; Autoload cookie needed by desktop.el
3292 "Info mode provides commands for browsing through the Info documentation tree.
3293 Documentation in Info is divided into \"nodes\", each of which discusses
3294 one topic and contains references to other nodes which discuss related
3295 topics. Info has commands to follow the references and show you other nodes.
3298 \\[Info-help] Invoke the Info tutorial.
3299 \\[Info-exit] Quit Info: reselect previously selected buffer.
3301 Selecting other nodes:
3302 \\[Info-mouse-follow-nearest-node]
3303 Follow a node reference you click on.
3304 This works with menu items, cross references, and
3305 the \"next\", \"previous\" and \"up\", depending on where you click.
3306 \\[Info-follow-nearest-node] Follow a node reference near point, like \\[Info-mouse-follow-nearest-node].
3307 \\[Info-next] Move to the \"next\" node of this node.
3308 \\[Info-prev] Move to the \"previous\" node of this node.
3309 \\[Info-up] Move \"up\" from this node.
3310 \\[Info-menu] Pick menu item specified by name (or abbreviation).
3311 Picking a menu item causes another node to be selected.
3312 \\[Info-directory] Go to the Info directory node.
3313 \\[Info-top-node] Go to the Top node of this file.
3314 \\[Info-final-node] Go to the final node in this file.
3315 \\[Info-backward-node] Go backward one node, considering all nodes as forming one sequence.
3316 \\[Info-forward-node] Go forward one node, considering all nodes as forming one sequence.
3317 \\[Info-next-reference] Move cursor to next cross-reference or menu item.
3318 \\[Info-prev-reference] Move cursor to previous cross-reference or menu item.
3319 \\[Info-follow-reference] Follow a cross reference. Reads name of reference.
3320 \\[Info-history-back] Move back in history to the last node you were at.
3321 \\[Info-history-forward] Move forward in history to the node you returned from after using \\[Info-history-back].
3322 \\[Info-history] Go to menu of visited nodes.
3323 \\[Info-toc] Go to table of contents of the current Info file.
3325 Moving within a node:
3326 \\[Info-scroll-up] Normally, scroll forward a full screen.
3327 Once you scroll far enough in a node that its menu appears on the
3328 screen but after point, the next scroll moves into its first
3329 subnode. When after all menu items (or if there is no menu),
3330 move up to the parent node.
3331 \\[Info-scroll-down] Normally, scroll backward. If the beginning of the buffer is
3332 already visible, try to go to the previous menu entry, or up
3334 \\[beginning-of-buffer] Go to beginning of node.
3337 \\[Info-search] Search through this Info file for specified regexp,
3338 and select the node in which the next occurrence is found.
3339 \\[Info-search-case-sensitively] Search through this Info file for specified regexp case-sensitively.
3340 \\[Info-search-next] Search for another occurrence of regexp
3341 from a previous \\<Info-mode-map>\\[Info-search] command.
3342 \\[Info-index] Look up a topic in this file's Index and move to that node.
3343 \\[Info-index-next] (comma) Move to the next match from a previous \\<Info-mode-map>\\[Info-index] command.
3344 \\[info-apropos] Look for a string in the indices of all manuals.
3345 \\[Info-goto-node] Move to node specified by name.
3346 You may include a filename as well, as (FILENAME)NODENAME.
3347 1 .. 9 Pick first ... ninth item in node's menu.
3348 Every third `*' is highlighted to help pick the right number.
3349 \\[Info-copy-current-node-name] Put name of current Info node in the kill ring.
3350 \\[clone-buffer] Select a new cloned Info buffer in another window.
3351 \\[universal-argument] \\[info] Move to new Info file with completion.
3352 \\[universal-argument] N \\[info] Select Info buffer with prefix number in the name *info*<N>."
3353 (kill-all-local-variables)
3354 (setq major-mode 'Info-mode)
3355 (setq mode-name "Info")
3357 (use-local-map Info-mode-map)
3358 (add-hook 'activate-menubar-hook 'Info-menu-update nil t)
3359 (set-syntax-table text-mode-syntax-table)
3360 (setq local-abbrev-table text-mode-abbrev-table)
3361 (setq case-fold-search t)
3362 (setq buffer-read-only t)
3363 (make-local-variable 'Info-current-file)
3364 (make-local-variable 'Info-current-subfile)
3365 (make-local-variable 'Info-current-node)
3366 (make-local-variable 'Info-tag-table-marker)
3367 (setq Info-tag-table-marker (make-marker))
3368 (make-local-variable 'Info-tag-table-buffer)
3369 (setq Info-tag-table-buffer nil)
3370 (make-local-variable 'Info-history)
3371 (make-local-variable 'Info-history-forward)
3372 (make-local-variable 'Info-index-alternatives)
3373 (setq header-line-format
3374 (if Info-use-header-line
3375 '(:eval (get-text-property (point-min) 'header-line))
3376 nil)) ; so the header line isn't displayed
3377 (set (make-local-variable 'tool-bar-map) info-tool-bar-map)
3378 ;; This is for the sake of the invisible text we use handling titles.
3379 (make-local-variable 'line-move-ignore-invisible)
3380 (setq line-move-ignore-invisible t)
3381 (make-local-variable 'desktop-save-buffer)
3382 (make-local-variable 'widen-automatically)
3383 (setq widen-automatically nil)
3384 (setq desktop-save-buffer 'Info-desktop-buffer-misc-data)
3385 (add-hook 'kill-buffer-hook 'Info-kill-buffer nil t)
3386 (add-hook 'clone-buffer-hook 'Info-clone-buffer-hook nil t)
3387 (add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
3388 (add-hook 'isearch-mode-hook 'Info-isearch-start nil t)
3389 (set (make-local-variable 'isearch-search-fun-function)
3390 'Info-isearch-search)
3391 (set (make-local-variable 'isearch-wrap-function)
3393 (set (make-local-variable 'isearch-push-state-function)
3394 'Info-isearch-push-state)
3395 (set (make-local-variable 'search-whitespace-regexp)
3396 Info-search-whitespace-regexp)
3397 (Info-set-mode-line)
3398 (run-mode-hooks 'Info-mode-hook))
3400 ;; When an Info buffer is killed, make sure the associated tags buffer
3402 (defun Info-kill-buffer ()
3403 (and (eq major-mode 'Info-mode)
3404 Info-tag-table-buffer
3405 (kill-buffer Info-tag-table-buffer)))
3407 (defun Info-clone-buffer-hook ()
3408 (when (bufferp Info-tag-table-buffer)
3409 (setq Info-tag-table-buffer
3410 (with-current-buffer Info-tag-table-buffer (clone-buffer))))
3411 (let ((m Info-tag-table-marker))
3413 (setq Info-tag-table-marker
3414 (if (and (marker-position m) (bufferp Info-tag-table-buffer))
3415 (with-current-buffer Info-tag-table-buffer
3416 (copy-marker (marker-position m)))
3419 (defvar Info-edit-map (let ((map (make-sparse-keymap)))
3420 (set-keymap-parent map text-mode-map)
3421 (define-key map "\C-c\C-c" 'Info-cease-edit)
3423 "Local keymap used within `e' command of Info.")
3425 ;; Info-edit mode is suitable only for specially formatted data.
3426 (put 'Info-edit-mode 'mode-class 'special)
3428 (defun Info-edit-mode ()
3429 "Major mode for editing the contents of an Info node.
3430 Like text mode with the addition of `Info-cease-edit'
3431 which returns to Info mode for browsing.
3433 (use-local-map Info-edit-map)
3434 (setq major-mode 'Info-edit-mode)
3435 (setq mode-name "Info Edit")
3436 (kill-local-variable 'mode-line-buffer-identification)
3437 (setq buffer-read-only nil)
3438 (force-mode-line-update)
3439 (buffer-enable-undo (current-buffer))
3440 (run-mode-hooks 'Info-edit-mode-hook))
3443 "Edit the contents of this Info node.
3444 Allowed only if variable `Info-enable-edit' is non-nil."
3446 (or Info-enable-edit
3447 (error "Editing Info nodes is not enabled"))
3449 (message "%s" (substitute-command-keys
3450 "Editing: Type \\<Info-edit-map>\\[Info-cease-edit] to return to info")))
3452 (defun Info-cease-edit ()
3453 "Finish editing Info node; switch back to Info proper."
3455 ;; Do this first, so nothing has changed if user C-g's at query.
3456 (and (buffer-modified-p)
3457 (y-or-n-p "Save the file? ")
3459 (use-local-map Info-mode-map)
3460 (setq major-mode 'Info-mode)
3461 (setq mode-name "Info")
3462 (Info-set-mode-line)
3463 (setq buffer-read-only t)
3464 (force-mode-line-update)
3465 (and (marker-position Info-tag-table-marker)
3467 (message "Tags may have changed. Use Info-tagify if necessary")))
3469 (defvar Info-file-list-for-emacs
3470 '("ediff" "eudc" "forms" "gnus" "info" ("Info" . "info") ("mh" . "mh-e")
3471 "sc" "message" ("dired" . "dired-x") "viper" "vip" "idlwave"
3472 ("c" . "ccmode") ("c++" . "ccmode") ("objc" . "ccmode")
3473 ("java" . "ccmode") ("idl" . "ccmode") ("pike" . "ccmode")
3474 ("skeleton" . "autotype") ("auto-insert" . "autotype")
3475 ("copyright" . "autotype") ("executable" . "autotype")
3476 ("time-stamp" . "autotype") ("quickurl" . "autotype")
3477 ("tempo" . "autotype") ("hippie-expand" . "autotype")
3478 ("cvs" . "pcl-cvs") ("ada" . "ada-mode") "calc"
3479 ("calcAlg" . "calc") ("calcDigit" . "calc") ("calcVar" . "calc")
3480 "ebrowse" "eshell" "cl" "reftex" "speedbar" "widget" "woman"
3481 ("mail-header" . "emacs-mime") ("mail-content" . "emacs-mime")
3482 ("mail-encode" . "emacs-mime") ("mail-decode" . "emacs-mime")
3483 ("rfc2045" . "emacs-mime")
3484 ("rfc2231" . "emacs-mime") ("rfc2047" . "emacs-mime")
3485 ("rfc2045" . "emacs-mime") ("rfc1843" . "emacs-mime")
3486 ("ietf-drums" . "emacs-mime") ("quoted-printable" . "emacs-mime")
3487 ("binhex" . "emacs-mime") ("uudecode" . "emacs-mime")
3488 ("mailcap" . "emacs-mime") ("mm" . "emacs-mime")
3489 ("mml" . "emacs-mime"))
3490 "List of Info files that describe Emacs commands.
3491 An element can be a file name, or a list of the form (PREFIX . FILE)
3492 where PREFIX is a name prefix and FILE is the file to look in.
3493 If the element is just a file name, the file name also serves as the prefix.")
3495 (defun Info-find-emacs-command-nodes (command)
3496 "Return a list of locations documenting COMMAND.
3497 The `info-file' property of COMMAND says which Info manual to search.
3498 If COMMAND has no property, the variable `Info-file-list-for-emacs'
3499 defines heuristics for which Info manual to try.
3500 The locations are of the format used in `Info-history', i.e.
3501 \(FILENAME NODENAME BUFFERPOS\), where BUFFERPOS is the line number
3502 in the first element of the returned list (which is treated specially in
3503 `Info-goto-emacs-command-node'), and 0 for the rest elements of a list."
3504 (let ((where '()) line-number
3505 (cmd-desc (concat "^\\* +" (regexp-quote (symbol-name command))
3506 "\\( <[0-9]+>\\)?:\\s *\\(.*\\)\\."
3507 "\\(?:[ \t\n]+(line +\\([0-9]+\\))\\)?"))
3508 (info-file "emacs")) ;default
3509 ;; Determine which Info file this command is documented in.
3510 (if (get command 'info-file)
3511 (setq info-file (get command 'info-file))
3512 ;; If it doesn't say explicitly, test its name against
3513 ;; various prefixes that we know.
3514 (let ((file-list Info-file-list-for-emacs))
3516 (let* ((elt (car file-list))
3517 (name (if (consp elt)
3520 (file (if (consp elt) (cdr elt) elt))
3521 (case-fold-search nil)
3522 (regexp (concat "\\`" (regexp-quote name)
3524 (if (string-match regexp (symbol-name command))
3525 (setq info-file file file-list nil))
3526 (setq file-list (cdr file-list))))))
3527 (Info-find-node info-file "Top")
3528 ;; Bind Info-history to nil, to prevent the index nodes from
3529 ;; getting into the node history.
3530 (let ((Info-history nil)
3531 (Info-history-list nil)
3532 node (nodes (Info-index-nodes)))
3533 (Info-goto-node (car nodes))
3536 (goto-char (point-min))
3537 (while (re-search-forward cmd-desc nil t)
3539 (cons (list Info-current-file
3540 (match-string-no-properties 2)
3543 (setq line-number (and (match-beginning 3)
3544 (string-to-number (match-string 3)))))
3545 (and (setq nodes (cdr nodes) node (car nodes))))
3546 (Info-goto-node node)))
3547 (if (and line-number where)
3548 (cons (list (nth 0 (car where)) (nth 1 (car where)) line-number)
3552 ;;;###autoload (put 'Info-goto-emacs-command-node 'info-file "emacs")
3554 (defun Info-goto-emacs-command-node (command)
3555 "Go to the Info node in the Emacs manual for command COMMAND.
3556 The command is found by looking up in Emacs manual's indices
3557 or in another manual found via COMMAND's `info-file' property or
3558 the variable `Info-file-list-for-emacs'.
3559 COMMAND must be a symbol or string."
3560 (interactive "CFind documentation for command: ")
3561 ;; If command is given as a string, convert it to a symbol.
3562 (if (stringp command)
3563 (setq command (intern command)))
3564 (or (commandp command)
3565 (signal 'wrong-type-argument (list 'commandp command)))
3566 (let ((where (Info-find-emacs-command-nodes command)))
3568 (let ((num-matches (length where)))
3569 ;; Get Info running, and pop to it in another window.
3570 (save-window-excursion
3572 (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*"))
3573 ;; Bind Info-history to nil, to prevent the last Index node
3574 ;; visited by Info-find-emacs-command-nodes from being
3575 ;; pushed onto the history.
3576 (let ((Info-history nil) (Info-history-list nil)
3577 (line-number (nth 2 (car where))))
3578 (Info-find-node (nth 0 (car where)) (nth 1 (car where)))
3579 (if (and (integerp line-number) (> line-number 0))
3580 (forward-line (1- line-number))))
3581 (if (> num-matches 1)
3583 ;; (car where) will be pushed onto Info-history
3584 ;; when/if they go to another node. Put the other
3585 ;; nodes that were found on the history.
3586 (setq Info-history (nconc (cdr where) Info-history))
3587 (message "Found %d other entr%s. Use %s to see %s."
3589 (if (> num-matches 2) "ies" "y")
3590 (substitute-command-keys "\\[Info-history-back]")
3591 (if (> num-matches 2) "them" "it")))))
3592 (error "Couldn't find documentation for %s" command))))
3594 ;;;###autoload (put 'Info-goto-emacs-key-command-node 'info-file "emacs")
3596 (defun Info-goto-emacs-key-command-node (key)
3597 "Go to the node in the Emacs manual which describes the command bound to KEY.
3599 Interactively, if the binding is `execute-extended-command', a command is read.
3600 The command is found by looking up in Emacs manual's indices
3601 or in another manual found via COMMAND's `info-file' property or
3602 the variable `Info-file-list-for-emacs'."
3603 (interactive "kFind documentation for key: ")
3604 (let ((command (key-binding key)))
3605 (cond ((null command)
3606 (message "%s is undefined" (key-description key)))
3607 ((and (interactive-p)
3608 (eq command 'execute-extended-command))
3609 (Info-goto-emacs-command-node
3610 (read-command "Find documentation for command: ")))
3612 (Info-goto-emacs-command-node command)))))
3614 (defvar Info-next-link-keymap
3615 (let ((keymap (make-sparse-keymap)))
3616 (define-key keymap [header-line mouse-1] 'Info-next)
3617 (define-key keymap [header-line mouse-2] 'Info-next)
3618 (define-key keymap [header-line down-mouse-1] 'ignore)
3619 (define-key keymap [mouse-2] 'Info-next)
3620 (define-key keymap [follow-link] 'mouse-face)
3622 "Keymap to put on the Next link in the text or the header line.")
3624 (defvar Info-prev-link-keymap
3625 (let ((keymap (make-sparse-keymap)))
3626 (define-key keymap [header-line mouse-1] 'Info-prev)
3627 (define-key keymap [header-line mouse-2] 'Info-prev)
3628 (define-key keymap [header-line down-mouse-1] 'ignore)
3629 (define-key keymap [mouse-2] 'Info-prev)
3630 (define-key keymap [follow-link] 'mouse-face)
3632 "Keymap to put on the Prev link in the text or the header line.")
3634 (defvar Info-up-link-keymap
3635 (let ((keymap (make-sparse-keymap)))
3636 (define-key keymap [header-line mouse-1] 'Info-up)
3637 (define-key keymap [header-line mouse-2] 'Info-up)
3638 (define-key keymap [header-line down-mouse-1] 'ignore)
3639 (define-key keymap [mouse-2] 'Info-up)
3640 (define-key keymap [follow-link] 'mouse-face)
3642 "Keymap to put on the Up link in the text or the header line.")
3644 (defun Info-fontify-node ()
3647 (let* ((inhibit-read-only t)
3648 (case-fold-search t)
3650 (not-fontified-p ; the node hasn't already been fontified
3651 (not (let ((where (next-property-change (point-min))))
3652 (and where (not (= where (point-max)))))))
3653 (fontify-visited-p ; visited nodes need to be re-fontified
3654 (and Info-fontify-visited-nodes
3655 ;; Don't take time to refontify visited nodes in huge nodes
3656 (< (- (point-max) (point-min)) Info-fontify-maximum-menu-size)))
3659 ;; Fontify header line
3660 (goto-char (point-min))
3661 (when (and not-fontified-p (looking-at "^\\(File: [^,: \t]+,?[ \t]+\\)?"))
3662 (goto-char (match-end 0))
3663 (while (looking-at "[ \t]*\\([^:, \t\n]+\\):[ \t]+\\([^:,\t\n]+\\),?")
3664 (goto-char (match-end 0))
3665 (let* ((nbeg (match-beginning 2))
3666 (nend (match-end 2))
3667 (tbeg (match-beginning 1))
3668 (tag (match-string 1)))
3669 (if (string-equal (downcase tag) "node")
3670 (put-text-property nbeg nend 'font-lock-face 'info-header-node)
3671 (put-text-property nbeg nend 'font-lock-face 'info-header-xref)
3672 (put-text-property tbeg nend 'mouse-face 'highlight)
3673 (put-text-property tbeg nend
3675 (concat "mouse-2: Go to node "
3676 (buffer-substring nbeg nend)))
3677 ;; Always set up the text property keymap.
3678 ;; It will either be used in the buffer
3679 ;; or copied in the header line.
3683 ((string-equal (downcase tag) "prev") Info-prev-link-keymap)
3684 ((string-equal (downcase tag) "next") Info-next-link-keymap)
3685 ((string-equal (downcase tag) "up" ) Info-up-link-keymap))))))
3686 (when Info-use-header-line
3687 (goto-char (point-min))
3688 (let* ((header-end (line-end-position))
3690 ;; If we find neither Next: nor Prev: link, show the entire
3691 ;; node header. Otherwise, don't show the File: and Node:
3692 ;; parts, to avoid wasting precious space on information that
3693 ;; is available in the mode line.
3694 (if (re-search-forward
3695 "\\(next\\|up\\|prev[ious]*\\): "
3698 (goto-char (match-beginning 1))
3699 (buffer-substring (point) header-end))
3700 (if (re-search-forward "node:[ \t]*[^ \t]+[ \t]*"
3702 (concat "No next, prev or up links -- "
3703 (buffer-substring (point) header-end))
3704 (buffer-substring (point) header-end)))))
3705 (put-text-property (point-min) (1+ (point-min))
3707 (replace-regexp-in-string
3709 ;; Preserve text properties on duplicated `%'.
3710 (lambda (s) (concat s s)) header))
3711 ;; Hide the part of the first line
3712 ;; that is in the header, if it is just part.
3714 ;; Hide the punctuation at the end, too.
3715 (skip-chars-backward " \t,")
3716 (put-text-property (point) header-end 'invisible t)))))
3719 (goto-char (point-min))
3720 (when (and font-lock-mode not-fontified-p)
3721 (while (and (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*\\*+\\|==+\\|--+\\|\\.\\.+\\)$"
3723 ;; Only consider it as an underlined title if the ASCII
3724 ;; underline has the same size as the text. A typical
3725 ;; counter example is when a continuation "..." is alone
3727 (= (string-width (match-string 1))
3728 (string-width (match-string 2))))
3729 (let* ((c (preceding-char))
3731 (cond ((= c ?*) 'info-title-1)
3732 ((= c ?=) 'info-title-2)
3733 ((= c ?-) 'info-title-3)
3734 (t 'info-title-4))))
3735 (put-text-property (match-beginning 1) (match-end 1)
3736 'font-lock-face face))
3737 ;; This is a serious problem for trying to handle multiple
3738 ;; frame types at once. We want this text to be invisible
3739 ;; on frames that can display the font above.
3740 (when (memq (framep (selected-frame)) '(x pc w32 mac))
3741 (add-text-properties (1- (match-beginning 2)) (match-end 2)
3742 '(invisible t front-sticky nil rear-nonsticky t)))))
3744 ;; Fontify cross references
3745 (goto-char (point-min))
3746 (when (or not-fontified-p fontify-visited-p)
3747 (while (re-search-forward "\\(\\*Note[ \n\t]+\\)\\([^:]*\\)\\(:[ \t]*\\([^.,:(]*\\)\\(\\(([^)]*)\\)[^.,:]*\\)?[,:]?\n?\\)" nil t)
3748 (let ((start (match-beginning 0))
3751 (when not-fontified-p
3752 (when Info-hide-note-references
3753 (when (not (eq Info-hide-note-references 'hide))
3754 ;; *Note is often used where *note should have been
3756 (skip-syntax-backward " ")
3757 (when (memq (char-before) '(?\( ?\[ ?\{))
3758 ;; Check whether the paren is preceded by
3759 ;; an end of sentence
3760 (skip-syntax-backward " ("))
3762 (cond ((save-match-data (looking-back "\\<see"))
3764 ((memq (char-before) '(nil ?\. ?! ??))
3768 (search-forward "\n\n" start t)))
3772 (add-text-properties
3774 (or (save-match-data
3775 ;; Don't hide \n after *Note
3776 (let ((start1 (match-beginning 1)))
3777 (if (string-match "\n" (match-string 1))
3778 (+ start1 (match-beginning 0)))))
3781 `(display ,other-tag front-sticky nil rear-nonsticky t)
3782 '(invisible t front-sticky nil rear-nonsticky t))))
3783 (add-text-properties
3784 (match-beginning 2) (match-end 2)
3786 'help-echo (if (or (match-end 5)
3787 (not (equal (match-string 4) "")))
3788 (concat "mouse-2: go to " (or (match-string 5)
3790 "mouse-2: go to this node")
3791 'mouse-face 'highlight)))
3792 (when (or not-fontified-p fontify-visited-p)
3793 (setq rbeg (match-beginning 2)
3798 ;; Display visited nodes in a different face
3799 (if (and Info-fontify-visited-nodes
3801 (let* ((node (replace-regexp-in-string
3803 (replace-regexp-in-string
3805 (or (match-string 5)
3806 (and (not (equal (match-string 4) ""))
3808 (match-string 2)))))
3810 (string-match "(\\([^)]+\\))\\([^)]*\\)" node))
3811 (file (if external-link-p
3812 (file-name-nondirectory
3813 (match-string 1 node))
3815 (hl Info-history-list)
3818 (setq node (if (equal (match-string 2 node) "")
3820 (match-string 2 node))))
3822 (if (and (string-equal node (nth 1 (car hl)))
3824 file (if external-link-p
3825 (file-name-nondirectory
3828 (setq res (car hl) hl nil)
3829 (setq hl (cdr hl))))
3830 res))) 'info-xref-visited 'info-xref))
3831 ;; For multiline ref, unfontify newline and surrounding whitespace
3835 (while (re-search-forward "\\s-*\n\\s-*" rend t nil)
3836 (remove-text-properties (match-beginning 0)
3838 '(font-lock-face t))))))
3839 (when not-fontified-p
3840 (when (memq Info-hide-note-references '(t hide))
3841 (add-text-properties (match-beginning 3) (match-end 3)
3842 '(invisible t front-sticky nil rear-nonsticky t))
3843 ;; Unhide the file name of the external reference in parens
3844 (if (and (match-string 6) (not (eq Info-hide-note-references 'hide)))
3845 (remove-text-properties (match-beginning 6) (match-end 6)
3846 '(invisible t front-sticky nil rear-nonsticky t)))
3847 ;; Unhide newline because hidden newlines cause too long lines
3849 (let ((beg3 (match-beginning 3))
3850 (end3 (match-end 3)))
3851 (if (and (string-match "\n[ \t]*" (match-string 3))
3852 (not (save-match-data
3854 (goto-char (1+ end3))
3855 (looking-at "[.)]*$")))))
3856 (remove-text-properties (+ beg3 (match-beginning 0))
3857 (+ beg3 (match-end 0))
3858 '(invisible t front-sticky nil rear-nonsticky t))))))
3859 (when (and Info-refill-paragraphs Info-hide-note-references)
3860 (push (set-marker (make-marker) start)
3861 paragraph-markers))))))
3863 ;; Refill paragraphs (experimental feature)
3864 (when (and not-fontified-p
3865 Info-refill-paragraphs
3867 (let ((fill-nobreak-invisible t)
3868 (fill-individual-varying-indent nil)
3869 (paragraph-start "\f\\|[ \t]*[-*]\\|[ \t]*$")
3870 (paragraph-separate ".*\\.[ \t]*\n[ \t]\\|[ \t]*[-*]\\|[ \t\f]*$")
3871 (adaptive-fill-mode nil))
3872 (goto-char (point-max))
3873 (dolist (m paragraph-markers)
3877 (let ((beg (point)))
3878 (when (zerop (forward-paragraph))
3879 (fill-individual-paragraphs beg (point) nil nil)
3881 (set-marker m nil))))
3883 ;; Fontify menu items
3884 (goto-char (point-min))
3885 (when (and (or not-fontified-p fontify-visited-p)
3886 (search-forward "\n* Menu:" nil t)
3887 (not (Info-index-node))
3888 ;; Don't take time to annotate huge menus
3889 (< (- (point-max) (point)) Info-fontify-maximum-menu-size))
3892 (while (re-search-forward
3893 (concat "^\\* Menu:\\|\\(?:^\\* +\\(" Info-menu-entry-name-re "\\)\\(:"
3894 Info-node-spec-re "\\([ \t]*\\)\\)\\)")
3896 (when (match-beginning 1)
3897 (when not-fontified-p
3899 (if (and (<= n 9) (zerop (% n 3))) ; visual aids to help with 1-9 keys
3900 (put-text-property (match-beginning 0)
3901 (1+ (match-beginning 0))
3902 'font-lock-face 'info-menu-star)))
3903 (when not-fontified-p
3904 (add-text-properties
3905 (match-beginning 1) (match-end 1)
3907 'help-echo (if (and (match-end 3)
3908 (not (equal (match-string 3) "")))
3909 (concat "mouse-2: go to " (match-string 3))
3910 "mouse-2: go to this node")
3911 'mouse-face 'highlight)))
3912 (when (or not-fontified-p fontify-visited-p)
3914 (match-beginning 1) (match-end 1)
3916 ;; Display visited menu items in a different face
3917 (if (and Info-fontify-visited-nodes
3919 (let* ((node (if (equal (match-string 3) "")
3923 (string-match "(\\([^)]+\\))\\([^)]*\\)" node))
3924 (file (if external-link-p
3925 (file-name-nondirectory
3926 (match-string 1 node))
3928 (hl Info-history-list)
3931 (setq node (if (equal (match-string 2 node) "")
3933 (match-string 2 node))))
3935 (if (and (string-equal node (nth 1 (car hl)))
3937 file (if external-link-p
3938 (file-name-nondirectory (caar hl))
3940 (setq res (car hl) hl nil)
3941 (setq hl (cdr hl))))
3942 res))) 'info-xref-visited 'info-xref)))
3943 (when (and not-fontified-p (memq Info-hide-note-references '(t hide)))
3944 (put-text-property (match-beginning 2) (1- (match-end 6))
3946 ;; Unhide the file name in parens
3947 (if (and (match-end 4) (not (eq (char-after (match-end 4)) ?.)))
3948 (remove-text-properties (match-beginning 4) (match-end 4)
3950 ;; We need a stretchable space like :align-to but with
3952 (put-text-property (1- (match-end 6)) (match-end 6) 'display
3953 (if (>= 22 (- (match-end 1)
3954 (match-beginning 0)))
3955 '(space :align-to 24)
3957 (setq cont (looking-at "."))
3958 (while (and (= (forward-line 1) 0)
3959 (looking-at "\\([ \t]+\\)[^*\n]"))
3960 (put-text-property (match-beginning 1) (1- (match-end 1))
3962 (put-text-property (1- (match-end 1)) (match-end 1)
3965 '(space :align-to 26)
3966 '(space :align-to 24)))
3969 ;; Fontify menu headers
3970 ;; Add the face `info-menu-header' to any header before a menu entry
3971 (goto-char (point-min))
3972 (when (and not-fontified-p (re-search-forward "^\\* Menu:" nil t))
3973 (put-text-property (match-beginning 0) (match-end 0)
3974 'font-lock-face 'info-menu-header)
3975 (while (re-search-forward "\n\n\\([^*\n ].*\\)\n\n?[*]" nil t)
3976 (put-text-property (match-beginning 1) (match-end 1)
3977 'font-lock-face 'info-menu-header)))
3979 ;; Hide index line numbers
3980 (goto-char (point-min))
3981 (when (and not-fontified-p (Info-index-node))
3982 (while (re-search-forward "[ \t\n]*(line +[0-9]+)" nil t)
3983 (put-text-property (match-beginning 0) (match-end 0)
3986 ;; Fontify http and ftp references
3987 (goto-char (point-min))
3988 (when not-fontified-p
3989 (while (re-search-forward "[hf]t?tp://[^ \t\n\"`({<>})']+" nil t)
3990 (add-text-properties (match-beginning 0) (match-end 0)
3991 '(font-lock-face info-xref
3992 mouse-face highlight
3993 help-echo "mouse-2: go to this URL"))))
3995 (set-buffer-modified-p nil))))
3997 ;;; Speedbar support:
3998 ;; These functions permit speedbar to display the "tags" in the
3999 ;; current Info node.
4000 (eval-when-compile (require 'speedbar))
4002 (defvar Info-speedbar-key-map nil
4003 "Keymap used when in the info display mode.")
4005 (defun Info-install-speedbar-variables ()
4006 "Install those variables used by speedbar to enhance Info."
4007 (if Info-speedbar-key-map
4009 (setq Info-speedbar-key-map (speedbar-make-specialized-keymap))
4011 ;; Basic tree features
4012 (define-key Info-speedbar-key-map "e" 'speedbar-edit-line)
4013 (define-key Info-speedbar-key-map "\C-m" 'speedbar-edit-line)
4014 (define-key Info-speedbar-key-map "+" 'speedbar-expand-line)
4015 (define-key Info-speedbar-key-map "-" 'speedbar-contract-line)
4018 (speedbar-add-expansion-list '("Info" Info-speedbar-menu-items
4019 Info-speedbar-key-map
4020 Info-speedbar-hierarchy-buttons)))
4022 (defvar Info-speedbar-menu-items
4023 '(["Browse Node" speedbar-edit-line t]
4024 ["Expand Node" speedbar-expand-line
4025 (save-excursion (beginning-of-line)
4026 (looking-at "[0-9]+: *.\\+. "))]
4027 ["Contract Node" speedbar-contract-line
4028 (save-excursion (beginning-of-line)
4029 (looking-at "[0-9]+: *.-. "))]
4031 "Additional menu-items to add to speedbar frame.")
4033 ;; Make sure our special speedbar major mode is loaded
4034 (if (featurep 'speedbar)
4035 (Info-install-speedbar-variables)
4036 (add-hook 'speedbar-load-hook 'Info-install-speedbar-variables))
4038 ;;; Info hierarchy display method
4040 (defun Info-speedbar-browser ()
4041 "Initialize speedbar to display an Info node browser.
4042 This will add a speedbar major display mode."
4045 ;; Make sure that speedbar is active
4046 (speedbar-frame-mode 1)
4047 ;; Now, throw us into Info mode on speedbar.
4048 (speedbar-change-initial-expansion-list "Info")
4051 (defun Info-speedbar-hierarchy-buttons (directory depth &optional node)
4052 "Display an Info directory hierarchy in speedbar.
4053 DIRECTORY is the current directory in the attached frame.
4054 DEPTH is the current indentation depth.
4055 NODE is an optional argument that is used to represent the
4056 specific node to expand."
4058 (save-excursion (goto-char (point-min))
4059 (let ((case-fold-search t))
4060 (looking-at "Info Nodes:"))))
4061 ;; Update our "current node" maybe?
4063 ;; We cannot use the generic list code, that depends on all leaves
4064 ;; being known at creation time.
4066 (speedbar-with-writable (insert "Info Nodes:\n")))
4067 (let ((completions nil))
4068 (speedbar-select-attached-frame)
4069 (save-window-excursion
4071 (Info-speedbar-fetch-file-nodes (or node '"(dir)top"))))
4072 (select-frame (speedbar-current-frame))
4074 (speedbar-with-writable
4075 (dolist (completion completions)
4076 (speedbar-make-tag-line 'bracket ?+ 'Info-speedbar-expand-node
4079 'Info-speedbar-goto-node
4085 (defun Info-speedbar-goto-node (text node indent)
4086 "When user clicks on TEXT, go to an info NODE.
4087 The INDENT level is ignored."
4088 (speedbar-select-attached-frame)
4089 (let* ((buff (or (get-buffer "*info*")
4090 (progn (info) (get-buffer "*info*"))))
4091 (bwin (get-buffer-window buff 0)))
4094 (select-window bwin)
4095 (raise-frame (window-frame bwin)))
4096 (if speedbar-power-click
4097 (let ((pop-up-frames t)) (select-window (display-buffer buff)))
4098 (speedbar-select-attached-frame)
4099 (switch-to-buffer buff)))
4100 (if (not (string-match "^(\\([^)]+\\))\\([^.]+\\)$" node))
4101 (error "Invalid node %s" node)
4102 (Info-find-node (match-string 1 node) (match-string 2 node))
4103 ;; If we do a find-node, and we were in info mode, restore
4104 ;; the old default method. Once we are in info mode, it makes
4105 ;; sense to return to whatever method the user was using before.
4106 (if (string= speedbar-initial-expansion-list-name "Info")
4107 (speedbar-change-initial-expansion-list
4108 speedbar-previously-used-expansion-list-name)))))
4110 (defun Info-speedbar-expand-node (text token indent)
4111 "Expand the node the user clicked on.
4112 TEXT is the text of the button we clicked on, a + or - item.
4113 TOKEN is data related to this node (NAME . FILE).
4114 INDENT is the current indentation depth."
4115 (cond ((string-match "+" text) ;we have to expand this file
4116 (speedbar-change-expand-button-char ?-)
4117 (if (speedbar-with-writable
4119 (end-of-line) (forward-char 1)
4120 (Info-speedbar-hierarchy-buttons nil (1+ indent) token)))
4121 (speedbar-change-expand-button-char ?-)
4122 (speedbar-change-expand-button-char ??)))
4123 ((string-match "-" text) ;we have to contract this node
4124 (speedbar-change-expand-button-char ?+)
4125 (speedbar-delete-subblock indent))
4126 (t (error "Ooops... not sure what to do")))
4127 (speedbar-center-buffer-smartly))
4129 (defun Info-speedbar-fetch-file-nodes (nodespec)
4130 "Fetch the subnodes from the info NODESPEC.
4131 NODESPEC is a string of the form: (file)node."
4133 ;; Set up a buffer we can use to fake-out Info.
4134 (set-buffer (get-buffer-create " *info-browse-tmp*"))
4135 (if (not (equal major-mode 'Info-mode))
4137 ;; Get the node into this buffer
4138 (if (not (string-match "^(\\([^)]+\\))\\([^.]+\\)$" nodespec))
4139 (error "Invalid node specification %s" nodespec)
4140 (Info-find-node (match-string 1 nodespec) (match-string 2 nodespec)))
4141 ;; Scan the created buffer
4142 (goto-char (point-min))
4143 (let ((completions nil)
4144 (case-fold-search t)
4145 (thisfile (progn (string-match "^(\\([^)]+\\))" nodespec)
4146 (match-string 1 nodespec))))
4147 ;; Always skip the first one...
4148 (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
4149 (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
4150 (let ((name (match-string 1)))
4152 (if (looking-at " *\\(([^)]+)[^.\n]+\\)\\.")
4154 (if (looking-at " *\\(([^)]+)\\)\\.")
4155 (concat (match-string 1) "Top")
4156 (concat "(" thisfile ")"
4157 (if (looking-at " \\([^.]+\\).")
4161 (nreverse completions))))
4163 ;;; Info mode node listing
4164 ;; This is called by `speedbar-add-localized-speedbar-support'
4165 (defun Info-speedbar-buttons (buffer)
4166 "Create a speedbar display to help navigation in an Info file.
4167 BUFFER is the buffer speedbar is requesting buttons for."
4168 (if (save-excursion (goto-char (point-min))
4169 (let ((case-fold-search t))
4170 (not (looking-at "Info Nodes:"))))
4172 (Info-speedbar-hierarchy-buttons nil 0))
4174 (dolist (mess '("^First node in file$"
4175 "^No `.*' in index$"
4176 "^No cross-reference named"
4177 "^No cross.references in this node$"
4178 "^No current Info node$"
4179 "^No menu in this node$"
4180 "^No more items in menu$"
4182 "^No pointer \\(?:forward\\|backward\\) from this node$"
4183 "^No previous `i' command$"
4184 "^No previous items in menu$"
4185 "^No previous nodes$"
4186 "^No such item in menu$"
4187 "^No such node or anchor"
4189 "^Point neither on reference nor in menu item description$"
4190 "^This is the \\(?:first\\|last\\) Info node you looked at$"
4192 (add-to-list 'debug-ignored-errors mess))
4194 ;;;; Desktop support
4196 (defun Info-desktop-buffer-misc-data (desktop-dirname)
4197 "Auxiliary information to be saved in desktop file."
4198 (if (not (member Info-current-file '("apropos" "history" "toc")))
4199 (list Info-current-file Info-current-node)))
4201 (defun Info-restore-desktop-buffer (desktop-buffer-file-name
4203 desktop-buffer-misc)
4204 "Restore an Info buffer specified in a desktop file."
4205 (let ((first (nth 0 desktop-buffer-misc))
4206 (second (nth 1 desktop-buffer-misc)))
4207 (when (and first second)
4208 (when desktop-buffer-name
4209 (set-buffer (get-buffer-create desktop-buffer-name))
4211 (Info-find-node first second)
4214 (add-to-list 'desktop-buffer-mode-handlers
4215 '(Info-mode . Info-restore-desktop-buffer))
4219 ;; arch-tag: f2480fe2-2139-40c1-a49b-6314991164ac
4220 ;;; info.el ends here