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 (and (zerop (buffer-size))
573 ;; If we just created the Info buffer, go to the directory.
577 (defun info-emacs-manual ()
578 "Display the Emacs manual in Info mode."
583 (defun info-standalone ()
584 "Run Emacs as a standalone Info reader.
585 Usage: emacs -f info-standalone [filename]
586 In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
587 (setq Info-standalone t
)
588 (if (and command-line-args-left
589 (not (string-match "^-" (car command-line-args-left
))))
592 (info (car command-line-args-left
))
593 (setq command-line-args-left
(cdr command-line-args-left
)))
594 (error (send-string-to-terminal
595 (format "%s\n" (if (eq (car-safe err
) 'error
)
597 (save-buffers-kill-emacs)))
600 ;; See if the accessible portion of the buffer begins with a node
601 ;; delimiter, and the node header line which follows matches REGEXP.
602 ;; Typically, this test will be followed by a loop that examines the
603 ;; rest of the buffer with (search-forward "\n\^_"), and it's a pity
604 ;; to have the overhead of this special test inside the loop.
606 ;; This function changes match-data, but supposedly the caller might
607 ;; want to use the results of re-search-backward.
609 ;; The return value is the value of point at the beginning of matching
610 ;; REGEXP, if the function succeeds, nil otherwise.
611 (defun Info-node-at-bob-matching (regexp)
612 (and (bobp) ; are we at beginning of buffer?
613 (looking-at "\^_") ; does it begin with node delimiter?
617 (forward-line 1) ; does the line after delimiter match REGEXP?
618 (re-search-backward regexp beg t
))))
620 (defun Info-find-file (filename &optional noerror
)
621 "Return expanded FILENAME, or t, if FILENAME is \"dir\".
622 Optional second argument NOERROR, if t, means if file is not found
623 just return nil (no error)."
624 ;; Convert filename to lower case if not found as specified.
626 (if (stringp filename
)
627 (let (temp temp-downcase found
)
628 (setq filename
(substitute-in-file-name filename
))
630 ((string= (downcase filename
) "dir")
632 ((string= filename
"apropos")
633 (setq found
'apropos
))
634 ((string= filename
"history")
635 (setq found
'history
))
636 ((string= filename
"toc")
639 (let ((dirs (if (string-match "^\\./" filename
)
640 ;; If specified name starts with `./'
641 ;; then just try current directory.
643 (if (file-name-absolute-p filename
)
644 ;; No point in searching for an
645 ;; absolute file name
647 (if Info-additional-directory-list
648 (append Info-directory-list
649 Info-additional-directory-list
)
650 Info-directory-list
)))))
651 ;; Search the directory list for file FILENAME.
652 (while (and dirs
(not found
))
653 (setq temp
(expand-file-name filename
(car dirs
)))
655 (expand-file-name (downcase filename
) (car dirs
)))
656 ;; Try several variants of specified name.
657 (let ((suffix-list Info-suffix-list
)
658 (lfn (if (fboundp 'msdos-long-file-names
)
659 (msdos-long-file-names)
661 (while (and suffix-list
(not found
))
662 (cond ((info-file-exists-p
663 (info-insert-file-contents-1
664 temp
(car (car suffix-list
)) lfn
))
667 (info-insert-file-contents-1
668 temp-downcase
(car (car suffix-list
)) lfn
))
669 (setq found temp-downcase
))
670 ((and (fboundp 'msdos-long-file-names
)
673 (info-insert-file-contents-1
674 temp
(car (car suffix-list
)) nil
)))
676 (setq suffix-list
(cdr suffix-list
))))
677 (setq dirs
(cdr dirs
))))))
679 (setq filename found
)
682 (error "Info file %s does not exist" filename
)))
685 (defun Info-find-node (filename nodename
&optional no-going-back
)
686 "Go to an Info node specified as separate FILENAME and NODENAME.
687 NO-GOING-BACK is non-nil if recovering from an error in this function;
688 it says do not attempt further (recursive) error recovery."
690 (setq filename
(Info-find-file filename
))
691 ;; Go into Info buffer.
692 (or (eq major-mode
'Info-mode
) (pop-to-buffer "*info*"))
693 ;; Record the node we are leaving, if we were in one.
694 (and (not no-going-back
)
697 (cons (list Info-current-file Info-current-node
(point))
699 (Info-find-node-2 filename nodename no-going-back
))
702 (defun Info-on-current-buffer (&optional nodename
)
703 "Use Info mode to browse the current Info buffer.
704 With a prefix arg, this queries for the node name to visit first;
705 otherwise, that defaults to `Top'."
707 (list (if current-prefix-arg
708 (completing-read "Node name: " (Info-build-node-completions)
710 (unless nodename
(setq nodename
"Top"))
713 (set (make-local-variable 'Info-current-file
)
715 ;; If called on a non-file buffer, make a fake file name.
716 (concat default-directory
(buffer-name))))
717 (Info-find-node-2 nil nodename
))
719 ;; It's perhaps a bit nasty to kill the *info* buffer to force a re-read,
720 ;; but at least it keeps this routine (which is only for the benefit of
721 ;; makeinfo-buffer) out of the way of normal operations.
723 (defun Info-revert-find-node (filename nodename
)
724 "Go to an Info node FILENAME and NODENAME, re-reading disk contents.
725 When *info* is already displaying FILENAME and NODENAME, the window position
726 is preserved, if possible."
727 (pop-to-buffer "*info*")
728 (let ((old-filename Info-current-file
)
729 (old-nodename Info-current-node
)
730 (pcolumn (current-column))
731 (pline (count-lines (point-min) (line-beginning-position)))
732 (wline (count-lines (point-min) (window-start)))
733 (old-history Info-history
)
734 (new-history (and Info-current-file
735 (list Info-current-file Info-current-node
(point)))))
736 (kill-buffer (current-buffer))
737 (Info-find-node filename nodename
)
738 (setq Info-history old-history
)
739 (if (and (equal old-filename Info-current-file
)
740 (equal old-nodename Info-current-node
))
742 ;; note goto-line is no good, we want to measure from point-min
743 (goto-char (point-min))
745 (set-window-start (selected-window) (point))
746 (goto-char (point-min))
748 (move-to-column pcolumn
))
749 ;; only add to the history when coming from a different file+node
751 (setq Info-history
(cons new-history Info-history
))))))
753 (defun Info-find-in-tag-table-1 (marker regexp case-fold
)
754 "Find a node in a tag table.
755 MARKER specifies the buffer and position to start searching at.
756 REGEXP is a regular expression matching nodes or references. Its first
757 group should match `Node:' or `Ref:'.
758 CASE-FOLD t means search for a case-insensitive match.
759 If a match was found, value is a list (FOUND-ANCHOR POS MODE), where
760 FOUND-ANCHOR is non-nil if a `Ref:' was matched, POS is the position
761 where the match was found, and MODE is `major-mode' of the buffer in
762 which the match was found."
763 (let ((case-fold-search case-fold
))
765 (set-buffer (marker-buffer marker
))
770 (when (re-search-forward regexp nil t
)
771 (list (string-equal "Ref:" (match-string 1))
772 (+ (point-min) (read (current-buffer)))
775 (defun Info-find-in-tag-table (marker regexp
)
776 "Find a node in a tag table.
777 MARKER specifies the buffer and position to start searching at.
778 REGEXP is a regular expression matching nodes or references. Its first
779 group should match `Node:' or `Ref:'.
780 If a match was found, value is a list (FOUND-ANCHOR POS MODE), where
781 FOUND-ANCHOR is non-nil if a `Ref:' was matched, POS is the position
782 where the match was found, and MODE is `major-mode' of the buffer in
783 which the match was found.
784 This function tries to find a case-sensitive match first, then a
785 case-insensitive match is tried."
786 (let ((result (Info-find-in-tag-table-1 marker regexp nil
)))
787 (when (null (car result
))
788 (setq result
(Info-find-in-tag-table-1 marker regexp t
)))
791 (defun Info-find-node-in-buffer-1 (regexp case-fold
)
792 "Find a node or anchor in the current buffer.
793 REGEXP is a regular expression matching nodes or references. Its first
794 group should match `Node:' or `Ref:'.
795 CASE-FOLD t means search for a case-insensitive match.
796 Value is the position at which a match was found, or nil if not found."
797 (let ((case-fold-search case-fold
)
800 (when (Info-node-at-bob-matching regexp
)
801 (setq found
(point)))
802 (while (and (not found
)
803 (search-forward "\n\^_" nil t
))
807 (when (re-search-backward regexp beg t
)
809 (setq found
(point)))))
812 (defun Info-find-node-in-buffer (regexp)
813 "Find a node or anchor in the current buffer.
814 REGEXP is a regular expression matching nodes or references. Its first
815 group should match `Node:' or `Ref:'.
816 Value is the position at which a match was found, or nil if not found.
817 This function looks for a case-sensitive match first. If none is found,
818 a case-insensitive match is tried."
819 (or (Info-find-node-in-buffer-1 regexp nil
)
820 (Info-find-node-in-buffer-1 regexp t
)))
822 (defun Info-find-node-2 (filename nodename
&optional no-going-back
)
823 (buffer-disable-undo (current-buffer))
824 (or (eq major-mode
'Info-mode
)
827 (setq Info-current-node nil
)
829 (let ((case-fold-search t
)
831 ;; Switch files if necessary
833 (equal Info-current-file filename
)
834 (let ((buffer-read-only nil
))
835 (setq Info-current-file nil
836 Info-current-subfile nil
837 Info-current-file-completions nil
838 buffer-file-name nil
)
843 ((eq filename
'apropos
)
844 (insert-buffer-substring " *info-apropos*"))
845 ((eq filename
'history
)
846 (insert-buffer-substring " *info-history*"))
848 (insert-buffer-substring " *info-toc*"))
850 (info-insert-file-contents filename nil
)
851 (setq default-directory
(file-name-directory filename
))))
852 (set-buffer-modified-p nil
)
854 ;; Check makeinfo version for index cookie support
856 (goto-char (point-min))
858 (if (and (re-search-forward
859 "makeinfo version \\([0-9]+.[0-9]+\\)"
860 (line-beginning-position 3) t
)
861 (not (version< (match-string 1) "4.7")))
864 (set (make-local-variable 'Info-file-supports-index-cookies
) found
))
866 ;; See whether file has a tag table. Record the location if yes.
867 (goto-char (point-max))
869 ;; Use string-equal, not equal, to ignore text props.
870 (if (not (or (string-equal nodename
"*")
872 (search-forward "\^_\nEnd tag table\n" nil t
))))
874 ;; We have a tag table. Find its beginning.
875 ;; Is this an indirect file?
876 (search-backward "\nTag table:\n")
880 (looking-at "(Indirect)\n"))
881 ;; It is indirect. Copy it to another buffer
882 ;; and record that the tag table is in that buffer.
883 (let ((buf (current-buffer))
885 (or Info-tag-table-buffer
886 (generate-new-buffer " *info tag table*"))))
887 (setq Info-tag-table-buffer tagbuf
)
890 (buffer-disable-undo (current-buffer))
891 (setq case-fold-search t
)
893 (insert-buffer-substring buf
))
894 (set-marker Info-tag-table-marker
895 (match-end 0) tagbuf
))
896 (set-marker Info-tag-table-marker pos
)))
897 (set-marker Info-tag-table-marker nil
))
898 (setq Info-current-file
900 ((eq filename t
) "dir")
901 ((eq filename
'apropos
) "apropos")
902 ((eq filename
'history
) "history")
903 ((eq filename
'toc
) "toc")
906 ;; Use string-equal, not equal, to ignore text props.
907 (if (string-equal nodename
"*")
908 (progn (setq Info-current-node nodename
)
909 (Info-set-mode-line))
912 ;; 1. Anchor found in tag table
913 ;; 2. Anchor *not* in tag table
915 ;; 3. Node found in tag table
916 ;; 4. Node *not* found in tag table, but found in file
917 ;; 5. Node *not* in tag table, and *not* in file
919 ;; *Or* the same, but in an indirect subfile.
921 ;; Search file for a suitable node.
922 (let ((guesspos (point-min))
923 (regexp (concat "\\(Node:\\|Ref:\\) *\\("
924 (if (stringp nodename
)
925 (regexp-quote nodename
)
927 "\\) *[,\t\n\177]")))
931 ;; First, search a tag table, if any
932 (when (marker-position Info-tag-table-marker
)
933 (let* ((m Info-tag-table-marker
)
934 (found (Info-find-in-tag-table m regexp
)))
937 ;; FOUND is (ANCHOR POS MODE).
938 (setq guesspos
(nth 1 found
))
940 ;; If this is an indirect file, determine which
941 ;; file really holds this node and read it in.
942 (unless (eq (nth 2 found
) 'Info-mode
)
943 ;; Note that the current buffer must be the
944 ;; *info* buffer on entry to
945 ;; Info-read-subfile. Thus the hackery above.
946 (setq guesspos
(Info-read-subfile guesspos
)))
950 (goto-char (setq anchorpos guesspos
))
953 ;; Else we may have a node, which we search for:
954 (goto-char (max (point-min)
955 (- (byte-to-position guesspos
) 1000)))
957 ;; Now search from our advised position (or from beg of
958 ;; buffer) to find the actual node. First, check
959 ;; whether the node is right where we are, in case the
960 ;; buffer begins with a node.
961 (let ((pos (Info-find-node-in-buffer regexp
)))
966 (when (string-match "\\([^.]+\\)\\." nodename
)
967 (let (Info-point-loc)
969 filename
(match-string 1 nodename
) no-going-back
))
973 ;; No such anchor in tag table or node in tag table or file
974 (error "No such node or anchor: %s" nodename
))
977 (goto-char (point-min))
979 (let ((new-history (list Info-current-file
980 (substring-no-properties nodename
))))
981 ;; Add anchors to the history too
982 (setq Info-history-list
984 (delete new-history Info-history-list
))))
985 (goto-char anchorpos
))
986 ((numberp Info-point-loc
)
987 (forward-line (1- Info-point-loc
))
988 (setq Info-point-loc nil
))
989 ((stringp Info-point-loc
)
990 (Info-find-index-name Info-point-loc
)
991 (setq Info-point-loc nil
))))))
992 ;; If we did not finish finding the specified node,
993 ;; go back to the previous one.
994 (or Info-current-node no-going-back
(null Info-history
)
995 (let ((hist (car Info-history
)))
996 (setq Info-history
(cdr Info-history
))
997 (Info-find-node (nth 0 hist
) (nth 1 hist
) t
)
998 (goto-char (nth 2 hist
))))))
1000 ;; Cache the contents of the (virtual) dir file, once we have merged
1001 ;; it for the first time, so we can save time subsequently.
1002 (defvar Info-dir-contents nil
)
1004 ;; Cache for the directory we decided to use for the default-directory
1005 ;; of the merged dir text.
1006 (defvar Info-dir-contents-directory nil
)
1008 ;; Record the file attributes of all the files from which we
1009 ;; constructed Info-dir-contents.
1010 (defvar Info-dir-file-attributes nil
)
1012 (defvar Info-dir-file-name nil
)
1014 ;; Construct the Info directory node by merging the files named `dir'
1015 ;; from various directories. Set the *info* buffer's
1016 ;; default-directory to the first directory we actually get any text
1018 (defun Info-insert-dir ()
1019 (if (and Info-dir-contents Info-dir-file-attributes
1020 ;; Verify that none of the files we used has changed
1021 ;; since we used it.
1023 (mapcar (lambda (elt)
1024 (let ((curr (file-attributes
1026 (file-truename (car elt
)))))
1028 ;; Don't compare the access time.
1029 (if curr
(setcar (nthcdr 4 curr
) 0))
1030 (setcar (nthcdr 4 (cdr elt
)) 0)
1031 (equal (cdr elt
) curr
)))
1032 Info-dir-file-attributes
))))
1034 (insert Info-dir-contents
)
1035 (goto-char (point-min)))
1036 (let ((dirs (if Info-additional-directory-list
1037 (append Info-directory-list
1038 Info-additional-directory-list
)
1039 Info-directory-list
))
1040 (dir-file-attrs nil
)
1041 ;; Bind this in case the user sets it to nil.
1042 (case-fold-search t
)
1043 ;; This is set non-nil if we find a problem in some input files.
1045 buffers buffer others nodes dirs-done
)
1047 ;; Search the directory list for the directory file.
1049 (let ((truename (file-truename (expand-file-name (car dirs
)))))
1050 (or (member truename dirs-done
)
1051 (member (directory-file-name truename
) dirs-done
)
1052 ;; Try several variants of specified name.
1053 ;; Try upcasing, appending `.info', or both.
1057 (progn (setq file
(expand-file-name "dir" truename
))
1058 (file-attributes file
))
1059 (progn (setq file
(expand-file-name "DIR" truename
))
1060 (file-attributes file
))
1061 (progn (setq file
(expand-file-name "dir.info" truename
))
1062 (file-attributes file
))
1063 (progn (setq file
(expand-file-name "DIR.INFO" truename
))
1064 (file-attributes file
)))))
1067 (cons (directory-file-name truename
)
1072 (message "Composing main Info directory..."))
1073 (set-buffer (generate-new-buffer " info dir"))
1076 (insert-file-contents file
)
1077 (set (make-local-variable 'Info-dir-file-name
)
1079 (push (current-buffer) buffers
)
1080 (push (cons file attrs
) dir-file-attrs
))
1081 (error (kill-buffer (current-buffer))))))))
1083 (set (make-local-variable 'Info-dir-contents-directory
)
1084 (file-name-as-directory (car dirs
))))
1085 (setq dirs
(cdr dirs
))))
1088 (error "Can't find the Info directory node"))
1090 ;; Distinguish the dir file that comes with Emacs from all the
1091 ;; others. Yes, that is really what this is supposed to do.
1092 ;; The definition of `Info-directory-list' puts it first on that
1093 ;; list and so last in `buffers' at this point.
1094 (setq buffer
(car (last buffers
))
1095 others
(delq buffer buffers
))
1097 ;; Insert the entire original dir file as a start; note that we've
1098 ;; already saved its default directory to use as the default
1099 ;; directory for the whole concatenation.
1100 (save-excursion (insert-buffer-substring buffer
))
1102 ;; Look at each of the other buffers one by one.
1103 (dolist (other others
)
1104 (let (this-buffer-nodes)
1105 ;; In each, find all the menus.
1106 (with-current-buffer other
1107 (goto-char (point-min))
1108 ;; Find each menu, and add an elt to NODES for it.
1109 (while (re-search-forward "^\\* Menu:" nil t
)
1110 (while (and (zerop (forward-line 1)) (eolp)))
1113 (re-search-backward "^\^_")
1114 (search-forward "Node: ")
1115 (setq nodename
(Info-following-node-name))
1116 (search-forward "\n\^_" nil
'move
)
1119 (push (list nodename other beg end
) this-buffer-nodes
)))
1120 (if (assoc-string "top" this-buffer-nodes t
)
1121 (setq nodes
(nconc this-buffer-nodes nodes
))
1123 (message "No `top' node in %s" Info-dir-file-name
)))))
1124 ;; Add to the main menu a menu item for each other node.
1125 (re-search-forward "^\\* Menu:")
1127 (let ((menu-items '("top"))
1128 (end (save-excursion (search-forward "\^_" nil t
) (point))))
1129 (dolist (node nodes
)
1130 (let ((nodename (car node
)))
1132 (or (member (downcase nodename
) menu-items
)
1133 (re-search-forward (concat "^\\* +"
1134 (regexp-quote nodename
)
1138 (insert "* " nodename
"::" "\n")
1139 (push nodename menu-items
)))))))
1140 ;; Now take each node of each of the other buffers
1141 ;; and merge it into the main buffer.
1142 (dolist (node nodes
)
1143 (let ((case-fold-search t
)
1144 (nodename (car node
)))
1145 (goto-char (point-min))
1146 ;; Find the like-named node in the main buffer.
1147 (if (re-search-forward (concat "^\^_.*\n.*Node: "
1148 (regexp-quote nodename
)
1152 (search-forward "\n\^_" nil
'move
)
1155 ;; If none exists, add one.
1156 (goto-char (point-max))
1157 (insert "\^_\nFile: dir\tNode: " nodename
"\n\n* Menu:\n\n"))
1158 ;; Merge the text from the other buffer's menu
1159 ;; into the menu in the like-named node in the main buffer.
1160 (apply 'insert-buffer-substring
(cdr node
))))
1161 (Info-dir-remove-duplicates)
1162 ;; Kill all the buffers we just made, including the special one excised.
1163 (mapc 'kill-buffer
(cons buffer buffers
))
1164 (goto-char (point-min))
1166 (message "Composing main Info directory...problems encountered, see `*Messages*'")
1167 (message "Composing main Info directory...done"))
1168 (set (make-local-variable 'Info-dir-contents
) (buffer-string))
1169 (set (make-local-variable 'Info-dir-file-attributes
) dir-file-attrs
)))
1170 (setq default-directory Info-dir-contents-directory
))
1172 (defvar Info-streamline-headings
1173 '(("Emacs" .
"Emacs")
1174 ("Programming" .
"Programming")
1175 ("Libraries" .
"Libraries")
1176 ("World Wide Web\\|Net Utilities" .
"Net Utilities"))
1177 "List of elements (RE . NAME) to merge headings matching RE to NAME.")
1179 (defun Info-dir-remove-duplicates ()
1181 (goto-char (point-min))
1182 ;; Remove duplicate headings in the same menu.
1183 (while (search-forward "\n* Menu:" nil t
)
1184 (setq limit
(save-excursion (search-forward "\n\^_" nil t
)))
1185 ;; Look for the next heading to unify.
1186 (while (re-search-forward "^\\(\\w.*\\)\n\\*" limit t
)
1187 (let ((name (match-string 1))
1188 (start (match-beginning 0))
1190 ;; Check whether this heading should be streamlined.
1192 (dolist (x Info-streamline-headings
)
1193 (when (string-match (car x
) name
)
1195 (setq re
(car x
)))))
1196 (if re
(replace-match name t t nil
1))
1197 (goto-char (if (re-search-forward "^[^* \n\t]" limit t
)
1199 (or limit
(point-max))))
1200 ;; Look for other headings of the same category and merge them.
1202 (while (re-search-forward "^\\(\\w.*\\)\n\\*" limit t
)
1203 (when (if re
(save-match-data (string-match re
(match-string 1)))
1204 (equal name
(match-string 1)))
1206 ;; Delete redundant heading.
1207 (delete-region (match-beginning 0) (point))
1208 ;; Push the entries onto `text'.
1210 (delete-and-extract-region
1212 (if (re-search-forward "^[^* \n\t]" nil t
)
1214 (or limit
(point-max)))) entries
))))
1215 ;; Insert the entries just found.
1216 (while (= (line-beginning-position 0) (1- (point)))
1218 (dolist (entry (nreverse entries
))
1220 (while (= (line-beginning-position 0) (1- (point)))
1221 (delete-region (1- (point)) (point))))
1223 ;; Now remove duplicate entries under the same heading.
1227 (while (re-search-forward "^* \\([^:\n]+:\\(:\\|[^.\n]+\\).\\)"
1229 ;; Fold case straight away; `member-ignore-case' here wasteful.
1230 (let ((x (downcase (match-string 1))))
1232 (delete-region (match-beginning 0)
1233 (progn (re-search-forward "^[^ \t]" nil t
)
1234 (match-beginning 0)))
1235 (push x seen
))))))))))
1237 ;; Note that on entry to this function the current-buffer must be the
1238 ;; *info* buffer; not the info tags buffer.
1239 (defun Info-read-subfile (nodepos)
1240 ;; NODEPOS is either a position (in the Info file as a whole,
1241 ;; not relative to a subfile) or the name of a subfile.
1244 (if (numberp nodepos
)
1246 (set-buffer (marker-buffer Info-tag-table-marker
))
1247 (goto-char (point-min))
1248 (or (looking-at "\^_")
1249 (search-forward "\n\^_"))
1252 (while (not (looking-at "\^_"))
1255 thisfilepos thisfilename
)
1256 (search-forward ": ")
1257 (setq thisfilename
(buffer-substring beg
(- (point) 2)))
1258 (setq thisfilepos
(+ (point-min) (read (current-buffer))))
1259 ;; read in version 19 stops at the end of number.
1260 ;; Advance to the next line.
1262 (if (> thisfilepos nodepos
)
1264 (setq lastfilename thisfilename
)
1265 (setq lastfilepos thisfilepos
))
1266 (forward-line 1)))))
1267 (setq lastfilename nodepos
)
1268 (setq lastfilepos
0))
1269 ;; Assume previous buffer is in Info-mode.
1270 ;; (set-buffer (get-buffer "*info*"))
1271 (or (equal Info-current-subfile lastfilename
)
1272 (let ((buffer-read-only nil
))
1273 (setq buffer-file-name nil
)
1276 (info-insert-file-contents lastfilename
)
1277 (set-buffer-modified-p nil
)
1278 (setq Info-current-subfile lastfilename
)))
1279 ;; Widen in case we are in the same subfile as before.
1281 (goto-char (point-min))
1282 (if (looking-at "\^_")
1284 (search-forward "\n\^_"))
1285 (if (numberp nodepos
)
1286 (+ (- nodepos lastfilepos
) (point)))))
1288 (defun Info-unescape-quotes (value)
1289 "Unescape double quotes and backslashes in VALUE."
1292 (while (string-match "[^\\\"]*\\(\\\\\\)[\\\\\"]" unquote start
)
1293 (setq unquote
(replace-match "" t t unquote
1))
1294 (setq start
(- (match-end 0) 1)))
1297 ;; As of Texinfo 4.6, makeinfo writes constructs like
1298 ;; \0\h[image param=value ...\h\0]
1299 ;; into the Info file for handling images.
1300 (defun Info-split-parameter-string (parameter-string)
1301 "Return alist of (\"KEY\" . \"VALUE\") from PARAMETER-STRING; a
1302 whitespace separated list of KEY=VALUE pairs. If VALUE contains
1303 whitespace or double quotes, it must be quoted in double quotes and
1304 any double quotes or backslashes must be escaped (\\\",\\\\)."
1307 (while (string-match
1308 "\\s *\\([^=]+\\)=\\(?:\\([^\\s \"]+\\)\\|\\(?:\"\\(\\(?:[^\\\"]\\|\\\\[\\\\\"]\\)*\\)\"\\)\\)"
1309 parameter-string start
)
1310 (setq start
(match-end 0))
1311 (push (cons (match-string 1 parameter-string
)
1312 (or (match-string 2 parameter-string
)
1313 (Info-unescape-quotes
1314 (match-string 3 parameter-string
))))
1318 (defun Info-display-images-node ()
1319 "Display images in current node."
1321 (let ((inhibit-read-only t
)
1322 (case-fold-search t
))
1323 (goto-char (point-min))
1324 (while (re-search-forward
1325 "\\(\0\b[[]image\\(\\(?:[^\b]\\|[^\0]+\b\\)*\\)\0\b[]]\\)"
1327 (let* ((start (match-beginning 1))
1328 (parameter-alist (Info-split-parameter-string (match-string 2)))
1329 (src (cdr (assoc-string "src" parameter-alist
)))
1330 (image-file (if src
(if (file-name-absolute-p src
) src
1331 (concat default-directory src
))
1333 (image (if (file-exists-p image-file
)
1334 (create-image image-file
)
1336 (if (not (get-text-property start
'display
))
1337 (add-text-properties
1338 start
(point) `(display ,image rear-nonsticky
(display)))))))
1339 (set-buffer-modified-p nil
)))
1341 ;; Texinfo 4.7 adds cookies of the form ^@^H[NAME CONTENTS ^@^H].
1342 ;; Hide any construct of the general form ^@[^@-^_][ ... ^@[^@-^_]],
1343 ;; including one optional trailing newline.
1344 (defun Info-hide-cookies-node ()
1345 "Hide unrecognized cookies in current node."
1347 (let ((inhibit-read-only t
)
1348 (case-fold-search t
))
1349 (goto-char (point-min))
1350 (while (re-search-forward
1351 "\\(\0[\0-\37][[][^\0]*\0[\0-\37][]]\n?\\)"
1353 (let* ((start (match-beginning 1)))
1354 (if (not (get-text-property start
'invisible
))
1355 (put-text-property start
(point) 'invisible t
)))))
1356 (set-buffer-modified-p nil
)))
1358 (defun Info-select-node ()
1359 "Select the Info node that point is in."
1360 ;; Bind this in case the user sets it to nil.
1361 (let ((case-fold-search t
))
1363 ;; Find beginning of node.
1364 (if (search-backward "\n\^_" nil
'move
)
1366 (if (looking-at "\^_")
1368 (signal 'search-failed
(list "\n\^_"))))
1369 ;; Get nodename spelled as it is in the node.
1370 (re-search-forward "Node:[ \t]*")
1371 (setq Info-current-node
1372 (buffer-substring-no-properties (point)
1374 (skip-chars-forward "^,\t\n")
1376 (Info-set-mode-line)
1377 ;; Find the end of it, and narrow.
1379 (let (active-expression)
1380 ;; Narrow to the node contents
1381 (narrow-to-region (point)
1382 (if (re-search-forward "\n[\^_\f]" nil t
)
1385 (if (looking-at "[\n\^_\f]*execute: ")
1387 (goto-char (match-end 0))
1388 (setq active-expression
1389 (read (current-buffer))))))
1391 (if Info-enable-active-nodes
(eval active-expression
))
1392 ;; Add a new unique history item to full history list
1393 (let ((new-history (list Info-current-file Info-current-node
)))
1394 (setq Info-history-list
1395 (cons new-history
(delete new-history Info-history-list
)))
1396 (setq Info-history-forward nil
))
1397 (if (not (eq Info-fontify-maximum-menu-size nil
))
1398 (Info-fontify-node))
1399 (Info-display-images-node)
1400 (Info-hide-cookies-node)
1401 (run-hooks 'Info-selection-hook
)))))
1403 (defvar Info-mode-line-node-keymap
1404 (let ((map (make-sparse-keymap)))
1405 (define-key map
[mode-line mouse-1
] 'Info-scroll-up
)
1406 (define-key map
[mode-line mouse-3
] 'Info-scroll-down
)
1408 "Keymap to put on the Info node name in the mode line.")
1410 (defun Info-set-mode-line ()
1411 (setq mode-line-buffer-identification
1412 (nconc (propertized-buffer-identification "%b")
1416 (if (stringp Info-current-file
)
1417 (file-name-nondirectory Info-current-file
)
1420 (if Info-current-node
1421 (propertize Info-current-node
1422 'face
'mode-line-buffer-id
1424 "mouse-1: scroll forward, mouse-3: scroll back"
1425 'mouse-face
'mode-line-highlight
1426 'local-map Info-mode-line-node-keymap
)
1429 ;; Go to an Info node specified with a filename-and-nodename string
1430 ;; of the sort that is found in pointers in nodes.
1432 ;; Don't autoload this function: the correct entry point for other packages
1433 ;; to use is `info'. --Stef
1435 (defun Info-goto-node (nodename &optional fork
)
1436 "Go to Info node named NODENAME. Give just NODENAME or (FILENAME)NODENAME.
1437 If NODENAME is of the form (FILENAME)NODENAME, the node is in the Info file
1438 FILENAME; otherwise, NODENAME should be in the current Info file (or one of
1440 Completion is available, but only for node names in the current Info file.
1441 If FORK is non-nil (interactively with a prefix arg), show the node in
1443 If FORK is a string, it is the name to use for the new buffer."
1444 (interactive (list (Info-read-node-name "Go to node: ") current-prefix-arg
))
1448 (clone-buffer (concat "*info-" (if (stringp fork
) fork nodename
) "*") t
)))
1450 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
1452 (setq filename
(if (= (match-beginning 1) (match-end 1))
1454 (match-string 2 nodename
))
1455 nodename
(match-string 3 nodename
))
1456 (let ((trim (string-match "\\s +\\'" filename
)))
1457 (if trim
(setq filename
(substring filename
0 trim
))))
1458 (let ((trim (string-match "\\s +\\'" nodename
)))
1459 (if trim
(setq nodename
(substring nodename
0 trim
))))
1460 (if transient-mark-mode
(deactivate-mark))
1461 (Info-find-node (if (equal filename
"") nil filename
)
1462 (if (equal nodename
"") "Top" nodename
))))
1464 (defvar Info-read-node-completion-table
)
1466 (defun Info-read-node-name-2 (string path-and-suffixes action
)
1467 "Virtual completion table for file names input in Info node names.
1468 PATH-AND-SUFFIXES is a pair of lists, (DIRECTORIES . SUFFIXES)."
1470 (suffixes (remove "" (cdr path-and-suffixes
)))
1471 (suffix (concat (regexp-opt suffixes t
) "\\'"))
1472 (string-dir (file-name-directory string
))
1474 (if (file-name-absolute-p string
)
1475 (list (file-name-directory string
))
1476 (car path-and-suffixes
))))
1479 (setq dir default-directory
))
1480 (if string-dir
(setq dir
(expand-file-name string-dir dir
)))
1481 (when (file-directory-p dir
)
1482 (dolist (file (file-name-all-completions
1483 (file-name-nondirectory string
) dir
))
1484 ;; If the file name has no suffix or a standard suffix,
1486 (and (or (null (file-name-extension file
))
1487 (string-match suffix file
))
1488 ;; But exclude subfiles of split Info files.
1489 (not (string-match "-[0-9]+\\'" file
))
1490 ;; And exclude backup files.
1491 (not (string-match "~\\'" file
))
1492 (push (if string-dir
(concat string-dir file
) file
) names
))
1493 ;; If the file name ends in a standard suffix,
1494 ;; add the unsuffixed name as a completion option.
1495 (when (string-match suffix file
)
1496 (setq file
(substring file
0 (match-beginning 0)))
1497 (push (if string-dir
(concat string-dir file
) file
) names
)))))
1499 ((eq action t
) (all-completions string names
))
1500 ((null action
) (try-completion string names
))
1501 (t (test-completion string names
)))))
1503 ;; This function is used as the "completion table" while reading a node name.
1504 ;; It does completion using the alist in Info-read-node-completion-table
1505 ;; unless STRING starts with an open-paren.
1506 (defun Info-read-node-name-1 (string predicate code
)
1508 ;; First complete embedded file names.
1509 ((string-match "\\`([^)]*\\'" string
)
1510 (let ((file (substring string
1)))
1513 (let ((comp (try-completion file
'Info-read-node-name-2
1514 (cons Info-directory-list
1515 (mapcar 'car Info-suffix-list
)))))
1517 ((eq comp t
) (concat string
")"))
1518 (comp (concat "(" comp
)))))
1520 (all-completions file
'Info-read-node-name-2
1521 (cons Info-directory-list
1522 (mapcar 'car Info-suffix-list
))))
1524 ;; If a file name was given, then any node is fair game.
1525 ((string-match "\\`(" string
)
1527 ((eq code nil
) string
)
1530 ;; Otherwise use Info-read-node-completion-table.
1532 (try-completion string Info-read-node-completion-table predicate
))
1534 (all-completions string Info-read-node-completion-table predicate
))
1536 (test-completion string Info-read-node-completion-table predicate
))))
1538 ;; Arrange to highlight the proper letters in the completion list buffer.
1539 (put 'Info-read-node-name-1
'completion-base-size-function
1541 (if (string-match "\\`([^)]*\\'"
1542 (or completion-common-substring
1543 (minibuffer-completion-contents)))
1547 (defun Info-read-node-name (prompt &optional default
)
1548 (let* ((completion-ignore-case t
)
1549 (Info-read-node-completion-table (Info-build-node-completions))
1550 (nodename (completing-read prompt
'Info-read-node-name-1 nil t
)))
1551 (if (equal nodename
"")
1553 (Info-read-node-name prompt
))
1556 (defun Info-build-node-completions ()
1557 (or Info-current-file-completions
1559 ;; Bind this in case the user sets it to nil.
1560 (case-fold-search t
)
1561 (node-regexp "Node: *\\([^,\n]*\\) *[,\n\t]"))
1564 (if (marker-buffer Info-tag-table-marker
)
1565 (let ((marker Info-tag-table-marker
))
1566 (set-buffer (marker-buffer marker
))
1569 (while (re-search-forward "\n\\(Node\\|Ref\\): \\(.*\\)\177" nil t
)
1571 (cons (list (match-string-no-properties 2))
1574 (goto-char (point-min))
1575 ;; If the buffer begins with a node header, process that first.
1576 (if (Info-node-at-bob-matching node-regexp
)
1577 (setq compl
(list (match-string-no-properties 1))))
1578 ;; Now for the rest of the nodes.
1579 (while (search-forward "\n\^_" nil t
)
1581 (let ((beg (point)))
1583 (if (re-search-backward node-regexp beg t
)
1585 (cons (list (match-string-no-properties 1))
1587 (setq compl
(cons '("*") compl
))
1588 (set (make-local-variable 'Info-current-file-completions
) compl
))))
1590 (defun Info-restore-point (hl)
1591 "If this node has been visited, restore the point value when we left."
1593 (if (and (equal (nth 0 (car hl
)) Info-current-file
)
1594 ;; Use string-equal, not equal, to ignore text props.
1595 (string-equal (nth 1 (car hl
)) Info-current-node
))
1597 (goto-char (nth 2 (car hl
)))
1598 (setq hl nil
)) ;terminate the while at next iter
1599 (setq hl
(cdr hl
)))))
1601 (defvar Info-search-history nil
1602 "The history list for `Info-search'.")
1604 (defvar Info-search-case-fold nil
1605 "The value of `case-fold-search' from previous `Info-search' command.")
1607 (defun Info-search (regexp &optional bound noerror count direction
)
1608 "Search for REGEXP, starting from point, and select node it's found in.
1609 If DIRECTION is `backward', search in the reverse direction."
1610 (interactive (list (read-string
1611 (if Info-search-history
1612 (format "Regexp search%s (default %s): "
1613 (if case-fold-search
"" " case-sensitively")
1614 (car Info-search-history
))
1615 (format "Regexp search%s: "
1616 (if case-fold-search
"" " case-sensitively")))
1617 nil
'Info-search-history
)))
1618 (when transient-mark-mode
1620 (when (equal regexp
"")
1621 (setq regexp
(car Info-search-history
)))
1623 (let (found beg-found give-up
1624 (backward (eq direction
'backward
))
1625 (onode Info-current-node
)
1626 (ofile Info-current-file
)
1628 (opoint-min (point-min))
1629 (opoint-max (point-max))
1630 (ostart (window-start))
1631 (osubfile Info-current-subfile
))
1632 (setq Info-search-case-fold case-fold-search
)
1637 ;; Hide Info file header for backward search
1638 (narrow-to-region (save-excursion
1639 (goto-char (point-min))
1640 (search-forward "\n\^_")
1643 (while (and (not give-up
)
1647 (isearch-range-invisible found beg-found
)
1648 (isearch-range-invisible beg-found found
))
1649 ;; Skip node header line
1650 (and (save-excursion (forward-line -
1)
1652 (forward-line (if backward -
1 1)))
1653 ;; Skip Tag Table node
1655 (and (search-backward "\^_" nil t
)
1656 (looking-at "\^_\nTag Table"))))))
1657 (let ((search-spaces-regexp Info-search-whitespace-regexp
))
1659 (re-search-backward regexp bound t
)
1660 (re-search-forward regexp bound t
))
1661 (setq found
(point) beg-found
(if backward
(match-end 0)
1662 (match-beginning 0)))
1663 (setq give-up t
))))))
1665 (when (and isearch-mode Info-isearch-search
1666 (not Info-isearch-initial-node
)
1668 (or give-up
(and found
(not (and (> found opoint-min
)
1669 (< found opoint-max
))))))
1670 (signal 'search-failed
(list regexp
"initial node")))
1672 ;; If no subfiles, give error now.
1674 (if (null Info-current-subfile
)
1675 (let ((search-spaces-regexp Info-search-whitespace-regexp
))
1677 (re-search-backward regexp
)
1678 (re-search-forward regexp
)))
1681 (if (and bound
(not found
))
1682 (signal 'search-failed
(list regexp
)))
1684 (unless (or found bound
)
1686 ;; Try other subfiles.
1689 (set-buffer (marker-buffer Info-tag-table-marker
))
1690 (goto-char (point-min))
1691 (search-forward "\n\^_\nIndirect:")
1693 (narrow-to-region (point)
1694 (progn (search-forward "\n\^_")
1696 (goto-char (point-min))
1697 ;; Find the subfile we just searched.
1698 (search-forward (concat "\n" osubfile
": "))
1700 (forward-line (if backward
0 1))
1701 (if backward
(forward-char -
1))
1702 ;; Make a list of all following subfiles.
1703 ;; Each elt has the form (VIRT-POSITION . SUBFILENAME).
1704 (while (not (if backward
(bobp) (eobp)))
1706 (re-search-backward "\\(^.*\\): [0-9]+$")
1707 (re-search-forward "\\(^.*\\): [0-9]+$"))
1708 (goto-char (+ (match-end 1) 2))
1709 (setq list
(cons (cons (+ (point-min)
1710 (read (current-buffer)))
1711 (match-string-no-properties 1))
1713 (goto-char (if backward
1714 (1- (match-beginning 0))
1715 (1+ (match-end 0)))))
1716 ;; Put in forward order
1717 (setq list
(nreverse list
))))
1719 (message "Searching subfile %s..." (cdr (car list
)))
1720 (Info-read-subfile (car (car list
)))
1722 ;; Hide Info file header for backward search
1723 (narrow-to-region (save-excursion
1724 (goto-char (point-min))
1725 (search-forward "\n\^_")
1728 (goto-char (point-max)))
1729 (setq list
(cdr list
))
1730 (setq give-up nil found nil
)
1731 (while (and (not give-up
)
1735 (isearch-range-invisible found beg-found
)
1736 (isearch-range-invisible beg-found found
))
1737 ;; Skip node header line
1738 (and (save-excursion (forward-line -
1)
1740 (forward-line (if backward -
1 1)))
1741 ;; Skip Tag Table node
1743 (and (search-backward "\^_" nil t
)
1744 (looking-at "\^_\nTag Table"))))))
1745 (let ((search-spaces-regexp Info-search-whitespace-regexp
))
1747 (re-search-backward regexp nil t
)
1748 (re-search-forward regexp nil t
))
1749 (setq found
(point) beg-found
(if backward
(match-end 0)
1750 (match-beginning 0)))
1758 (signal 'search-failed
(list regexp
))))
1760 (progn (Info-read-subfile osubfile
)
1763 (set-window-start (selected-window) ostart
)))))
1765 (if (and (string= osubfile Info-current-subfile
)
1766 (> found opoint-min
)
1767 (< found opoint-max
))
1768 ;; Search landed in the same node
1772 (save-match-data (Info-select-node)))
1774 ;; Use string-equal, not equal, to ignore text props.
1775 (or (and (string-equal onode Info-current-node
)
1776 (equal ofile Info-current-file
))
1777 (and isearch-mode isearch-wrapped
1778 (eq opoint
(if isearch-forward opoint-min opoint-max
)))
1779 (setq Info-history
(cons (list ofile onode opoint
)
1782 (defun Info-search-case-sensitively ()
1783 "Search for a regexp case-sensitively."
1785 (let ((case-fold-search nil
))
1786 (call-interactively 'Info-search
)))
1788 (defun Info-search-next ()
1789 "Search for next regexp from a previous `Info-search' command."
1791 (let ((case-fold-search Info-search-case-fold
))
1792 (if Info-search-history
1793 (Info-search (car Info-search-history
))
1794 (call-interactively 'Info-search
))))
1796 (defun Info-search-backward (regexp &optional bound noerror count
)
1797 "Search for REGEXP in the reverse direction."
1798 (interactive (list (read-string
1799 (if Info-search-history
1800 (format "Regexp search%s backward (default %s): "
1801 (if case-fold-search
"" " case-sensitively")
1802 (car Info-search-history
))
1803 (format "Regexp search%s backward: "
1804 (if case-fold-search
"" " case-sensitively")))
1805 nil
'Info-search-history
)))
1806 (Info-search regexp bound noerror count
'backward
))
1808 (defun Info-isearch-search ()
1809 (if Info-isearch-search
1810 (lambda (string &optional bound noerror count
)
1812 (Info-search (concat "\\b" (replace-regexp-in-string
1814 (replace-regexp-in-string
1815 "^\\W+\\|\\W+$" "" string
)
1819 (unless isearch-forward
'backward
))
1820 (Info-search (if isearch-regexp string
(regexp-quote string
))
1822 (unless isearch-forward
'backward
))
1824 (let ((isearch-search-fun-function nil
))
1825 (isearch-search-fun))))
1827 (defun Info-isearch-wrap ()
1828 (if Info-isearch-search
1829 (if Info-isearch-initial-node
1831 (if isearch-forward
(Info-top-node) (Info-final-node))
1832 (goto-char (if isearch-forward
(point-min) (point-max))))
1833 (setq Info-isearch-initial-node Info-current-node
)
1834 (setq isearch-wrapped nil
))
1835 (goto-char (if isearch-forward
(point-min) (point-max)))))
1837 (defun Info-isearch-push-state ()
1839 (Info-isearch-pop-state cmd
,Info-current-file
,Info-current-node
)))
1841 (defun Info-isearch-pop-state (cmd file node
)
1842 (or (and (string= Info-current-file file
)
1843 (string= Info-current-node node
))
1844 (progn (Info-find-node file node
) (sit-for 0))))
1846 (defun Info-isearch-start ()
1847 (setq Info-isearch-initial-node nil
))
1849 (defun Info-extract-pointer (name &optional errorname
)
1850 "Extract the value of the node-pointer named NAME.
1851 If there is none, use ERRORNAME in the error message;
1852 if ERRORNAME is nil, just return nil."
1853 ;; Bind this in case the user sets it to nil.
1854 (let ((case-fold-search t
))
1856 (goto-char (point-min))
1857 (let ((bound (point)))
1859 (cond ((re-search-backward
1860 (concat name
":" (Info-following-node-name-re)) bound t
)
1862 ((not (eq errorname t
))
1863 (error "Node has no %s"
1864 (capitalize (or errorname name
)))))))))
1866 (defun Info-following-node-name-re (&optional allowedchars
)
1867 "Return a regexp matching a node name.
1868 ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
1869 saying which chars may appear in the node name.
1870 Submatch 1 is the complete node name.
1871 Submatch 2 if non-nil is the parenthesized file name part of the node name.
1872 Submatch 3 is the local part of the node name.
1873 End of submatch 0, 1, and 3 are the same, so you can safely concat."
1874 (concat "[ \t]*" ;Skip leading space.
1875 "\\(\\(([^)]+)\\)?" ;Node name can start with a file name.
1876 "\\([" (or allowedchars
"^,\t\n") "]*" ;Any number of allowed chars.
1877 "[" (or allowedchars
"^,\t\n") " ]" ;The last char can't be a space.
1878 "\\|\\)\\)")) ;Allow empty node names.
1880 ;;; For compatibility; other files have used this name.
1881 (defun Info-following-node-name ()
1882 (and (looking-at (Info-following-node-name-re))
1886 "Go to the next node of this node."
1888 ;; In case another window is currently selected
1889 (save-window-excursion
1890 (or (eq major-mode
'Info-mode
) (pop-to-buffer "*info*"))
1891 (Info-goto-node (Info-extract-pointer "next"))))
1894 "Go to the previous node of this node."
1896 ;; In case another window is currently selected
1897 (save-window-excursion
1898 (or (eq major-mode
'Info-mode
) (pop-to-buffer "*info*"))
1899 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous"))))
1901 (defun Info-up (&optional same-file
)
1902 "Go to the superior node of this node.
1903 If SAME-FILE is non-nil, do not move to a different Info file."
1905 ;; In case another window is currently selected
1906 (save-window-excursion
1907 (or (eq major-mode
'Info-mode
) (pop-to-buffer "*info*"))
1908 (let ((old-node Info-current-node
)
1909 (old-file Info-current-file
)
1910 (node (Info-extract-pointer "up")) p
)
1912 (string-match "^(" node
)
1913 (error "Up node is in another Info file"))
1914 (Info-goto-node node
)
1916 (goto-char (point-min))
1917 (if (and (search-forward "\n* Menu:" nil t
)
1919 (if (string-equal old-node
"Top")
1920 (concat "\n\\*[^:]+: +(" (file-name-nondirectory old-file
) ")")
1921 (concat "\n\\* +\\(" (regexp-quote old-node
)
1922 ":\\|[^:]+: +" (regexp-quote old-node
) "\\)"))
1924 (progn (beginning-of-line) (if (looking-at "^\\* ") (forward-char 2)))
1926 (Info-restore-point Info-history
)))))
1928 (defun Info-history-back ()
1929 "Go back in the history to the last node visited."
1932 (error "This is the first Info node you looked at"))
1933 (let ((history-forward
1934 (cons (list Info-current-file Info-current-node
(point))
1935 Info-history-forward
))
1936 filename nodename opoint
)
1937 (setq filename
(car (car Info-history
)))
1938 (setq nodename
(car (cdr (car Info-history
))))
1939 (setq opoint
(car (cdr (cdr (car Info-history
)))))
1940 (setq Info-history
(cdr Info-history
))
1941 (Info-find-node filename nodename
)
1942 (setq Info-history
(cdr Info-history
))
1943 (setq Info-history-forward history-forward
)
1944 (goto-char opoint
)))
1946 (defalias 'Info-last
'Info-history-back
)
1948 (defun Info-history-forward ()
1949 "Go forward in the history of visited nodes."
1951 (or Info-history-forward
1952 (error "This is the last Info node you looked at"))
1953 (let ((history-forward (cdr Info-history-forward
))
1954 filename nodename opoint
)
1955 (setq filename
(car (car Info-history-forward
)))
1956 (setq nodename
(car (cdr (car Info-history-forward
))))
1957 (setq opoint
(car (cdr (cdr (car Info-history-forward
)))))
1958 (Info-find-node filename nodename
)
1959 (setq Info-history-forward history-forward
)
1960 (goto-char opoint
)))
1963 (defun Info-directory ()
1964 "Go to the Info directory node."
1966 (Info-find-node "dir" "top"))
1968 (defun Info-history ()
1969 "Go to a node with a menu of visited nodes."
1971 (let ((curr-file Info-current-file
)
1972 (curr-node Info-current-node
)
1974 (with-current-buffer (get-buffer-create " *info-history*")
1975 (let ((inhibit-read-only t
))
1977 (goto-char (point-min))
1978 (insert "\n\^_\nFile: history, Node: Top, Up: (dir)\n\n")
1979 (insert "Recently Visited Nodes\n**********************\n\n")
1980 (insert "* Menu:\n\n")
1981 (let ((hl (delete '("history" "Top") Info-history-list
)))
1983 (let ((file (nth 0 (car hl
)))
1984 (node (nth 1 (car hl
))))
1985 (if (and (string-equal file curr-file
)
1986 (string-equal node curr-node
))
1988 (insert "* " node
": ("
1989 (propertize (or (file-name-directory file
) "") 'invisible t
)
1990 (file-name-nondirectory file
)
1992 (setq hl
(cdr hl
))))))
1993 (Info-find-node "history" "Top")
1994 (goto-char (or p
(point-min)))))
1997 "Go to a node with table of contents of the current Info file.
1998 Table of contents is created from the tree structure of menus."
2000 (let ((curr-file (substring-no-properties Info-current-file
))
2001 (curr-node (substring-no-properties Info-current-node
))
2003 (with-current-buffer (get-buffer-create " *info-toc*")
2004 (let ((inhibit-read-only t
)
2005 (node-list (Info-build-toc curr-file
)))
2007 (goto-char (point-min))
2008 (insert "\n\^_\nFile: toc, Node: Top, Up: (dir)\n\n")
2009 (insert "Table of Contents\n*****************\n\n")
2010 (insert "*Note Top: (" curr-file
")Top.\n")
2012 (nth 2 (assoc "Top" node-list
)) ; get Top nodes
2013 node-list
0 curr-file
))
2015 (let ((Info-hide-note-references 'hide
)
2016 (Info-fontify-visited-nodes nil
))
2018 (setq Info-current-file
"toc" Info-current-node
"Top")
2019 (goto-char (point-min))
2020 (narrow-to-region (or (re-search-forward "\n[\^_\f]\n" nil t
)
2025 (goto-char (point-min))
2026 (if (setq p
(search-forward (concat "*Note " curr-node
":") nil t
))
2027 (setq p
(- p
(length curr-node
) 2))))
2028 (Info-find-node "toc" "Top")
2029 (goto-char (or p
(point-min)))))
2031 (defun Info-insert-toc (nodes node-list level curr-file
)
2032 "Insert table of contents with references to nodes."
2033 (let ((section "Top"))
2035 (let ((node (assoc (car nodes
) node-list
)))
2036 (unless (member (nth 1 node
) (list nil section
))
2037 (insert (setq section
(nth 1 node
)) "\n"))
2038 (insert (make-string level ?
\t))
2039 (insert "*Note " (car nodes
) ": (" curr-file
")" (car nodes
) ".\n")
2040 (Info-insert-toc (nth 2 node
) node-list
(1+ level
) curr-file
)
2041 (setq nodes
(cdr nodes
))))))
2043 (defun Info-build-toc (file)
2044 "Build table of contents from menus of Info FILE and its subfiles."
2046 (let* ((file (and (stringp file
) (Info-find-file file
)))
2047 (default-directory (or (and (stringp file
)
2048 (file-name-directory file
))
2050 (main-file (and (stringp file
) file
))
2051 (sections '(("Top" "Top")))
2053 (while (or main-file subfiles
)
2054 (or main-file
(message "Searching subfile %s..." (car subfiles
)))
2056 (info-insert-file-contents (or main-file
(car subfiles
)))
2057 (goto-char (point-min))
2058 (while (and (search-forward "\n\^_\nFile:" nil
'move
)
2059 (search-forward "Node: " nil
'move
))
2060 (let ((nodename (substring-no-properties (Info-following-node-name)))
2061 (bound (- (or (save-excursion (search-forward "\n\^_" nil t
))
2065 (when (and (not (Info-index-node nodename file
))
2066 (re-search-forward "^\\* Menu:" bound t
))
2069 (setq bound
(or (and (equal nodename
"Top")
2072 "^[ \t-]*The Detailed Node Listing" nil t
)))
2074 (while (< (point) bound
)
2077 ((looking-at "^\\* +[^:]+:")
2080 (let ((menu-node-name (substring-no-properties
2081 (Info-extract-menu-node-name))))
2082 (setq menu-items
(cons menu-node-name menu-items
))
2083 (if (equal nodename
"Top")
2085 (cons (list menu-node-name section
) sections
)))))
2086 ;; Other non-empty strings in the Top node are section names
2087 ((and (equal nodename
"Top")
2088 (looking-at "^\\([^ \t\n*=.-][^:\n]*\\)"))
2089 (setq section
(match-string-no-properties 1))))
2091 (beginning-of-line)))
2092 (setq nodes
(cons (list nodename
2093 (cadr (assoc nodename sections
))
2094 (nreverse menu-items
))
2099 (goto-char (point-min))
2100 (if (search-forward "\n\^_\nIndirect:" nil t
)
2101 (let ((bound (save-excursion (search-forward "\n\^_" nil t
))))
2102 (while (re-search-forward "^\\(.*\\): [0-9]+$" bound t
)
2103 (setq subfiles
(cons (match-string-no-properties 1)
2105 (setq subfiles
(nreverse subfiles
)
2107 (setq subfiles
(cdr subfiles
))))
2111 (defun Info-follow-reference (footnotename &optional fork
)
2112 "Follow cross reference named FOOTNOTENAME to the node it refers to.
2113 FOOTNOTENAME may be an abbreviation of the reference name.
2114 If FORK is non-nil (interactively with a prefix arg), show the node in
2115 a new Info buffer. If FORK is a string, it is the name to use for the
2118 (let ((completion-ignore-case t
)
2119 (case-fold-search t
)
2120 completions default alt-default
(start-point (point)) str i bol eol
)
2122 ;; Store end and beginning of line.
2128 (goto-char (point-min))
2129 (while (re-search-forward "\\*note[ \n\t]+\\([^:]*\\):" nil t
)
2130 (setq str
(match-string-no-properties 1))
2131 ;; See if this one should be the default.
2133 (<= (match-beginning 0) start-point
)
2134 (<= start-point
(point))
2136 ;; See if this one should be the alternate default.
2137 (and (null alt-default
)
2138 (and (<= bol
(match-beginning 0))
2140 (setq alt-default t
))
2142 (while (setq i
(string-match "[ \n\t]+" str i
))
2143 (setq str
(concat (substring str
0 i
) " "
2144 (substring str
(match-end 0))))
2146 ;; Record as a completion and perhaps as default.
2147 (if (eq default t
) (setq default str
))
2148 (if (eq alt-default t
) (setq alt-default str
))
2149 ;; Don't add this string if it's a duplicate.
2150 (or (assoc-string str completions t
)
2151 (push str completions
))))
2152 ;; If no good default was found, try an alternate.
2154 (setq default alt-default
))
2155 ;; If only one cross-reference found, then make it default.
2156 (if (eq (length completions
) 1)
2157 (setq default
(car completions
)))
2159 (let ((input (completing-read (if default
2161 "Follow reference named (default "
2163 "Follow reference named: ")
2164 completions nil t
)))
2165 (list (if (equal input
"")
2166 default input
) current-prefix-arg
))
2167 (error "No cross-references in this node"))))
2169 (unless footnotename
2170 (error "No reference was specified"))
2172 (let (target i
(str (concat "\\*note " (regexp-quote footnotename
)))
2173 (case-fold-search t
))
2174 (while (setq i
(string-match " " str i
))
2175 (setq str
(concat (substring str
0 i
) "[ \t\n]+" (substring str
(1+ i
))))
2178 ;; Move point to the beginning of reference if point is on reference
2179 (or (looking-at "\\*note[ \n\t]+")
2180 (and (looking-back "\\*note[ \n\t]+")
2181 (goto-char (match-beginning 0)))
2182 (if (and (save-excursion
2183 (goto-char (+ (point) 5)) ; skip a possible *note
2184 (re-search-backward "\\*note[ \n\t]+" nil t
)
2186 (<= (point) (match-end 0)))
2187 (goto-char (match-beginning 0))))
2188 ;; Go to the reference closest to point
2189 (let ((next-ref (save-excursion (and (re-search-forward str nil t
)
2190 (+ (match-beginning 0) 5))))
2191 (prev-ref (save-excursion (and (re-search-backward str nil t
)
2192 (+ (match-beginning 0) 5)))))
2193 (goto-char (cond ((and next-ref prev-ref
)
2194 (if (< (abs (- next-ref
(point)))
2195 (abs (- prev-ref
(point))))
2197 ((or next-ref prev-ref
))
2198 ((error "No cross-reference named %s" footnotename
))))
2199 (setq target
(Info-extract-menu-node-name t
))))
2200 (while (setq i
(string-match "[ \t\n]+" target i
))
2201 (setq target
(concat (substring target
0 i
) " "
2202 (substring target
(match-end 0))))
2204 (Info-goto-node target fork
)))
2206 (defconst Info-menu-entry-name-re
"\\(?:[^:]\\|:[^:,.;() \t\n]\\)*"
2207 ;; We allow newline because this is also used in Info-follow-reference,
2208 ;; where the xref name might be wrapped over two lines.
2209 "Regexp that matches a menu entry name upto but not including the colon.
2210 Because of ambiguities, this should be concatenated with something like
2211 `:' and `Info-following-node-name-re'.")
2213 (defun Info-extract-menu-node-name (&optional multi-line index-node
)
2214 (skip-chars-forward " \t\n")
2215 (when (looking-at (concat Info-menu-entry-name-re
":\\(:\\|"
2216 (Info-following-node-name-re
2218 (index-node "^,\t\n")
2219 (multi-line "^.,\t")
2223 "\\.\\(?:[ \t\n]+(line +\\([0-9]+\\))\\)?"
2226 (setq Info-point-loc
2227 (if (match-beginning 5)
2228 (string-to-number (match-string 5))
2229 (buffer-substring (match-beginning 0) (1- (match-beginning 1)))))
2230 ;;; Uncomment next line to use names of cross-references in non-index nodes:
2231 ;;; (setq Info-point-loc
2232 ;;; (buffer-substring (match-beginning 0) (1- (match-beginning 1))))
2234 (replace-regexp-in-string
2236 (or (match-string 2)
2237 ;; If the node name is the menu entry name (using `entry::').
2238 (buffer-substring (match-beginning 0) (1- (match-beginning 1)))))))
2240 ;; No one calls this.
2241 ;;(defun Info-menu-item-sequence (list)
2243 ;; (Info-menu (car list))
2244 ;; (setq list (cdr list))))
2246 (defvar Info-complete-menu-buffer
)
2247 (defvar Info-complete-next-re nil
)
2248 (defvar Info-complete-nodes nil
)
2249 (defvar Info-complete-cache nil
)
2251 (defconst Info-node-spec-re
2252 (concat (Info-following-node-name-re "^.,:") "[,:.]")
2253 "Regexp to match the text after a : until the terminating `.'.")
2255 (defun Info-complete-menu-item (string predicate action
)
2256 ;; This uses two dynamically bound variables:
2257 ;; - `Info-complete-menu-buffer' which contains the buffer in which
2258 ;; is the menu of items we're trying to complete.
2259 ;; - `Info-complete-next-re' which, if non-nil, indicates that we should
2260 ;; also look for menu items in subsequent nodes as long as those
2261 ;; nodes' names match `Info-complete-next-re'. This feature is currently
2263 ;; - `Info-complete-nodes' which, if non-nil, indicates that we should
2264 ;; also look for menu items in these nodes. This feature is currently
2265 ;; only used for completion in Info-index.
2267 ;; Note that `Info-complete-menu-buffer' could be current already,
2268 ;; so we want to save point.
2270 (set-buffer Info-complete-menu-buffer
)
2271 (let ((completion-ignore-case t
)
2272 (case-fold-search t
)
2273 (orignode Info-current-node
)
2275 (goto-char (point-min))
2276 (search-forward "\n* Menu:")
2277 (if (not (memq action
'(nil t
)))
2279 (concat "\n\\* +" (regexp-quote string
) ":") nil t
)
2280 (let ((pattern (concat "\n\\* +\\("
2281 (regexp-quote string
)
2282 Info-menu-entry-name-re
"\\):" Info-node-spec-re
))
2284 (complete-nodes Info-complete-nodes
))
2286 (if (and (equal (nth 0 Info-complete-cache
) Info-current-file
)
2287 (equal (nth 1 Info-complete-cache
) Info-current-node
)
2288 (equal (nth 2 Info-complete-cache
) Info-complete-next-re
)
2289 (equal (nth 5 Info-complete-cache
) Info-complete-nodes
)
2290 (let ((prev (nth 3 Info-complete-cache
)))
2291 (eq t
(compare-strings string
0 (length prev
)
2293 ;; We can reuse the previous list.
2294 (setq completions
(nth 4 Info-complete-cache
))
2295 ;; The cache can't be used.
2298 (while (re-search-forward pattern nil t
)
2299 (push (match-string-no-properties 1)
2301 ;; Check subsequent nodes if applicable.
2302 (or (and Info-complete-next-re
2303 (setq nextnode
(Info-extract-pointer "next" t
))
2304 (string-match Info-complete-next-re nextnode
))
2306 (setq complete-nodes
(cdr complete-nodes
)
2307 nextnode
(car complete-nodes
)))))
2308 (Info-goto-node nextnode
))
2309 ;; Go back to the start node (for the next completion).
2310 (unless (equal Info-current-node orignode
)
2311 (Info-goto-node orignode
))
2312 ;; Update the cache.
2313 (set (make-local-variable 'Info-complete-cache
)
2314 (list Info-current-file Info-current-node
2315 Info-complete-next-re string completions
2316 Info-complete-nodes
)))
2318 (all-completions string completions predicate
)
2319 (try-completion string completions predicate
)))))))
2322 (defun Info-menu (menu-item &optional fork
)
2323 "Go to the node pointed to by the menu item named (or abbreviated) MENU-ITEM.
2324 The menu item should one of those listed in the current node's menu.
2325 Completion is allowed, and the default menu item is the one point is on.
2326 If FORK is non-nil (interactively with a prefix arg), show the node in
2327 a new Info buffer. If FORK is a string, it is the name to use for the
2330 (let ((completions '())
2331 ;; If point is within a menu item, use that item as the default
2336 (case-fold-search t
))
2338 (goto-char (point-min))
2339 (if (not (search-forward "\n* menu:" nil t
))
2340 (error "No menu in this node"))
2346 (if (re-search-backward (concat "\n\\* +\\("
2347 Info-menu-entry-name-re
2349 (setq default
(match-string-no-properties 1))))))
2352 (setq item
(let ((completion-ignore-case t
)
2353 (Info-complete-menu-buffer (current-buffer)))
2354 (completing-read (if default
2355 (format "Menu item (default %s): "
2358 'Info-complete-menu-item nil t
)))
2359 ;; we rely on the fact that completing-read accepts an input
2360 ;; of "" even when the require-match argument is true and ""
2361 ;; is not a valid possibility
2362 (if (string= item
"")
2367 (list item current-prefix-arg
))))
2368 ;; there is a problem here in that if several menu items have the same
2369 ;; name you can only go to the node of the first with this command.
2370 (Info-goto-node (Info-extract-menu-item menu-item
) (if fork menu-item
)))
2372 (defun Info-extract-menu-item (menu-item)
2373 (setq menu-item
(regexp-quote menu-item
))
2374 (let ((case-fold-search t
))
2376 (let ((case-fold-search t
))
2377 (goto-char (point-min))
2378 (or (search-forward "\n* menu:" nil t
)
2379 (error "No menu in this node"))
2380 (or (re-search-forward (concat "\n\\* +" menu-item
":") nil t
)
2381 (re-search-forward (concat "\n\\* +" menu-item
) nil t
)
2382 (error "No such item in menu"))
2385 (Info-extract-menu-node-name nil
(Info-index-node))))))
2387 ;; If COUNT is nil, use the last item in the menu.
2388 (defun Info-extract-menu-counting (count)
2389 (let ((case-fold-search t
))
2391 (let ((case-fold-search t
))
2392 (goto-char (point-min))
2393 (or (search-forward "\n* menu:" nil t
)
2394 (error "No menu in this node"))
2396 (or (search-forward "\n* " nil t count
)
2397 (error "Too few items in menu"))
2398 (while (search-forward "\n* " nil t
)
2400 (Info-extract-menu-node-name nil
(Info-index-node))))))
2402 (defun Info-nth-menu-item ()
2403 "Go to the node of the Nth menu item.
2404 N is the digit argument used to invoke this command."
2407 (Info-extract-menu-counting
2408 (- (aref (this-command-keys) (1- (length (this-command-keys)))) ?
0))))
2410 (defun Info-top-node ()
2411 "Go to the Top node of this file."
2413 (Info-goto-node "Top"))
2415 (defun Info-final-node ()
2416 "Go to the final node in this file."
2418 (Info-goto-node "Top")
2419 (let ((Info-history nil
)
2420 (case-fold-search t
))
2421 ;; Go to the last node in the menu of Top.
2422 (Info-goto-node (Info-extract-menu-counting nil
))
2423 ;; If the last node in the menu is not last in pointer structure,
2424 ;; move forward until we can't go any farther.
2425 (while (Info-forward-node t t
) nil
)
2426 ;; Then keep moving down to last subnode, unless we reach an index.
2427 (while (and (not (Info-index-node))
2428 (save-excursion (search-forward "\n* Menu:" nil t
)))
2429 (Info-goto-node (Info-extract-menu-counting nil
)))))
2431 (defun Info-forward-node (&optional not-down no-error
)
2432 "Go forward one node, considering all nodes as forming one sequence."
2434 (goto-char (point-min))
2436 (let ((case-fold-search t
))
2437 ;; three possibilities, in order of priority:
2438 ;; 1. next node is in a menu in this node (but not in an index)
2439 ;; 2. next node is next at same level
2440 ;; 3. next node is up and next
2441 (cond ((and (not not-down
)
2442 (save-excursion (search-forward "\n* menu:" nil t
))
2443 (not (Info-index-node)))
2444 (Info-goto-node (Info-extract-menu-counting 1))
2446 ((save-excursion (search-backward "next:" nil t
))
2449 ((and (save-excursion (search-backward "up:" nil t
))
2450 ;; Use string-equal, not equal, to ignore text props.
2451 (not (string-equal (downcase (Info-extract-pointer "up"))
2453 (let ((old-node Info-current-node
))
2455 (let (Info-history success
)
2457 (setq success
(Info-forward-node t no-error
))
2458 (or success
(Info-goto-node old-node
))))))
2460 (t (error "No pointer forward from this node")))))
2462 (defun Info-backward-node ()
2463 "Go backward one node, considering all nodes as forming one sequence."
2465 (let ((prevnode (Info-extract-pointer "prev[ious]*" t
))
2466 (upnode (Info-extract-pointer "up" t
))
2467 (case-fold-search t
))
2468 (cond ((and upnode
(string-match "(" upnode
))
2469 (error "First node in file"))
2470 ((and upnode
(or (null prevnode
)
2471 ;; Use string-equal, not equal,
2472 ;; to ignore text properties.
2473 (string-equal (downcase prevnode
)
2474 (downcase upnode
))))
2477 ;; If we move back at the same level,
2478 ;; go down to find the last subnode*.
2481 (while (and (not (Info-index-node))
2482 (save-excursion (search-forward "\n* Menu:" nil t
)))
2483 (Info-goto-node (Info-extract-menu-counting nil
)))))
2485 (error "No pointer backward from this node")))))
2488 "Exit Info by selecting some other buffer."
2491 (save-buffers-kill-emacs)
2494 (defun Info-next-menu-item ()
2495 "Go to the node of the next menu item."
2497 ;; Bind this in case the user sets it to nil.
2498 (let* ((case-fold-search t
)
2502 (search-forward "\n* menu:" nil t
)
2503 (and (search-forward "\n* " nil t
)
2504 (Info-extract-menu-node-name)))))
2505 (if node
(Info-goto-node node
)
2506 (error "No more items in menu"))))
2508 (defun Info-last-menu-item ()
2509 "Go to the node of the previous menu item."
2513 ;; Bind this in case the user sets it to nil.
2514 (let* ((case-fold-search t
)
2515 (beg (save-excursion
2516 (and (search-backward "\n* menu:" nil t
)
2518 (or (and beg
(search-backward "\n* " beg t
))
2519 (error "No previous items in menu")))
2520 (Info-goto-node (save-excursion
2521 (goto-char (match-end 0))
2522 (Info-extract-menu-node-name)))))
2524 (defmacro Info-no-error
(&rest body
)
2525 (list 'condition-case nil
(cons 'progn
(append body
'(t))) '(error nil
)))
2527 (defun Info-next-preorder ()
2528 "Go to the next subnode or the next node, or go up a level."
2530 (cond ((Info-no-error (Info-next-menu-item)))
2531 ((Info-no-error (Info-next)))
2532 ((Info-no-error (Info-up t
))
2533 ;; Since we have already gone thru all the items in this menu,
2534 ;; go up to the end of this node.
2535 (goto-char (point-max))
2536 ;; Since logically we are done with the node with that menu,
2538 (Info-next-preorder))
2540 (error "No more nodes"))))
2542 (defun Info-last-preorder ()
2543 "Go to the last node, popping up a level if there is none."
2545 (cond ((Info-no-error
2546 (Info-last-menu-item)
2547 ;; If we go down a menu item, go to the end of the node
2548 ;; so we can scroll back through it.
2549 (goto-char (point-max)))
2550 ;; Keep going down, as long as there are nested menu nodes.
2551 (while (Info-no-error
2552 (Info-last-menu-item)
2553 ;; If we go down a menu item, go to the end of the node
2554 ;; so we can scroll back through it.
2555 (goto-char (point-max))))
2557 ((and (Info-no-error (Info-extract-pointer "prev"))
2558 (not (equal (Info-extract-pointer "up")
2559 (Info-extract-pointer "prev"))))
2560 (Info-no-error (Info-prev))
2561 (goto-char (point-max))
2562 (while (Info-no-error
2563 (Info-last-menu-item)
2564 ;; If we go down a menu item, go to the end of the node
2565 ;; so we can scroll back through it.
2566 (goto-char (point-max))))
2568 ((Info-no-error (Info-up t
))
2569 (goto-char (point-min))
2570 (let ((case-fold-search t
))
2571 (or (search-forward "\n* Menu:" nil t
)
2572 (goto-char (point-max)))))
2573 (t (error "No previous nodes"))))
2575 (defun Info-scroll-up ()
2576 "Scroll one screenful forward in Info, considering all nodes as one sequence.
2577 Once you scroll far enough in a node that its menu appears on the screen
2578 but after point, the next scroll moves into its first subnode, unless
2579 `Info-scroll-prefer-subnodes' is nil.
2581 When you scroll past the end of a node, that goes to the next node if
2582 `Info-scroll-prefer-subnodes' is non-nil and to the first subnode otherwise;
2583 if this node has no successor, it moves to the parent node's successor,
2584 and so on. If `Info-scroll-prefer-subnodes' is non-nil and point is inside
2585 the menu of a node, it moves to subnode indicated by the following menu
2586 item. (That case won't normally result from this command, but can happen
2590 (if (or (< (window-start) (point-min))
2591 (> (window-start) (point-max)))
2592 (set-window-start (selected-window) (point)))
2593 (let* ((case-fold-search t
)
2594 (virtual-end (save-excursion
2595 (goto-char (point-min))
2596 (if (and Info-scroll-prefer-subnodes
2597 (search-forward "\n* Menu:" nil t
))
2600 (if (or (< virtual-end
(window-start))
2601 (pos-visible-in-window-p virtual-end
))
2603 (Info-scroll-prefer-subnodes (Info-next-preorder))
2604 ((Info-no-error (Info-goto-node (Info-extract-menu-counting 1))))
2605 (t (Info-next-preorder)))
2608 (defun Info-scroll-down ()
2609 "Scroll one screenful back in Info, considering all nodes as one sequence.
2610 If point is within the menu of a node, and `Info-scroll-prefer-subnodes'
2611 is non-nil, this goes to its last subnode. When you scroll past the
2612 beginning of a node, that goes to the previous node or back up to the
2615 (if (or (< (window-start) (point-min))
2616 (> (window-start) (point-max)))
2617 (set-window-start (selected-window) (point)))
2618 (let* ((case-fold-search t
)
2619 (current-point (point))
2621 (and Info-scroll-prefer-subnodes
2624 (setq current-point
(point))
2625 (goto-char (point-min))
2626 (search-forward "\n* Menu:"
2630 (pos-visible-in-window-p (point-min) nil t
))
2631 (Info-last-preorder)
2634 (defun Info-next-reference (&optional recur
)
2635 "Move cursor to the next cross-reference or menu item in the node."
2637 (let ((pat "\\*note[ \n\t]+\\([^:]+\\):\\|^\\* .*:\\|[hf]t?tp://")
2639 (case-fold-search t
))
2640 (or (eobp) (forward-char 1))
2641 (or (re-search-forward pat nil t
)
2643 (goto-char (point-min))
2644 (or (re-search-forward pat nil t
)
2647 (error "No cross references in this node")))))
2648 (goto-char (or (match-beginning 1) (match-beginning 0)))
2649 (if (looking-at "\\* Menu:")
2651 (error "No cross references in this node")
2652 (Info-next-reference t
))
2653 (if (looking-at "^\\* ")
2654 (forward-char 2)))))
2656 (defun Info-prev-reference (&optional recur
)
2657 "Move cursor to the previous cross-reference or menu item in the node."
2659 (let ((pat "\\*note[ \n\t]+\\([^:]+\\):\\|^\\* .*:\\|[hf]t?tp://")
2661 (case-fold-search t
))
2662 (or (re-search-backward pat nil t
)
2664 (goto-char (point-max))
2665 (or (re-search-backward pat nil t
)
2668 (error "No cross references in this node")))))
2669 (goto-char (or (match-beginning 1) (match-beginning 0)))
2670 (if (looking-at "\\* Menu:")
2672 (error "No cross references in this node")
2673 (Info-prev-reference t
))
2674 (if (looking-at "^\\* ")
2675 (forward-char 2)))))
2677 (defvar Info-index-nodes nil
2678 "Alist of cached index node names of visited Info files.
2679 Each element has the form (INFO-FILE INDEX-NODE-NAMES-LIST).")
2681 (defun Info-index-nodes (&optional file
)
2682 "Return a list of names of all index nodes in Info FILE.
2683 If FILE is omitted, it defaults to the current Info file.
2684 First look in a list of cached index node names. Then scan Info
2685 file and its subfiles for nodes with the index cookie. Then try
2686 to find index nodes starting from the first node in the top level
2687 menu whose name contains the word \"Index\", plus any immediately
2688 following nodes whose names also contain the word \"Index\"."
2689 (or file
(setq file Info-current-file
))
2690 (or (assoc file Info-index-nodes
)
2691 ;; Skip virtual Info files
2692 (and (member file
'("dir" "history" "toc" "apropos"))
2693 (setq Info-index-nodes
(cons (cons file nil
) Info-index-nodes
)))
2694 (not (stringp file
))
2695 (if Info-file-supports-index-cookies
2696 ;; Find nodes with index cookie
2697 (let* ((default-directory (or (and (stringp file
)
2698 (file-name-directory
2699 (setq file
(Info-find-file file
))))
2701 Info-history Info-history-list Info-fontify-maximum-menu-size
2702 (main-file file
) subfiles nodes node
)
2705 (while (or main-file subfiles
)
2707 (info-insert-file-contents (or main-file
(car subfiles
)))
2708 (goto-char (point-min))
2709 (while (search-forward "\0\b[index\0\b]" nil
'move
)
2711 (re-search-backward "^\^_")
2712 (search-forward "Node: ")
2713 (setq nodes
(cons (Info-following-node-name) nodes
))))
2716 (goto-char (point-min))
2717 (if (search-forward "\n\^_\nIndirect:" nil t
)
2718 (let ((bound (save-excursion (search-forward "\n\^_" nil t
))))
2719 (while (re-search-forward "^\\(.*\\): [0-9]+$" bound t
)
2720 (setq subfiles
(cons (match-string-no-properties 1)
2722 (setq subfiles
(nreverse subfiles
)
2724 (setq subfiles
(cdr subfiles
)))))
2727 (setq nodes
(nreverse nodes
)
2728 Info-index-nodes
(cons (cons file nodes
) Info-index-nodes
)))
2730 ;; Else find nodes with the word "Index" in the node name
2731 (let ((case-fold-search t
)
2732 Info-history Info-history-list Info-fontify-maximum-menu-size
2737 (Info-find-node file
"Top")
2738 (when (and (search-forward "\n* menu:" nil t
)
2739 (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t
))
2740 (goto-char (match-beginning 1))
2741 (setq nodes
(list (Info-extract-menu-node-name)))
2742 (Info-goto-node (car nodes
))
2743 (while (and (setq node
(Info-extract-pointer "next" t
))
2744 (string-match "\\<Index\\>" node
))
2745 (setq nodes
(cons node nodes
))
2746 (Info-goto-node node
))))
2749 (setq nodes
(nreverse nodes
)
2750 Info-index-nodes
(cons (cons file nodes
) Info-index-nodes
)))
2752 ;; If file has no index nodes, still add it to the cache
2753 (setq Info-index-nodes
(cons (cons file nil
) Info-index-nodes
)))
2754 (cdr (assoc file Info-index-nodes
)))
2756 (defun Info-index-node (&optional node file
)
2757 "Return non-nil value if NODE is an index node.
2758 If NODE is nil, check the current Info node.
2759 If FILE is nil, check the current Info file."
2760 (if (or (and node
(not (equal node Info-current-node
)))
2761 (assoc (or file Info-current-file
) Info-index-nodes
))
2762 (member (or node Info-current-node
) (Info-index-nodes file
))
2763 ;; Don't search all index nodes if request is only for the current node
2764 ;; and file is not in the cache of index nodes
2765 (if Info-file-supports-index-cookies
2767 (goto-char (+ (or (save-excursion
2768 (search-backward "\n\^_" nil t
))
2770 (search-forward "\0\b[index\0\b]"
2772 (search-forward "\n\^_" nil t
))
2775 (string-match "\\<Index\\>" (or node Info-current-node
""))))))
2777 (defun Info-goto-index ()
2778 "Go to the first index node."
2779 (let ((node (car (Info-index-nodes))))
2780 (or node
(error "No index"))
2781 (Info-goto-node node
)))
2784 (defun Info-index (topic)
2785 "Look up a string TOPIC in the index for this file.
2786 If there are no exact matches to the specified topic, this chooses
2787 the first match which is a case-insensitive substring of a topic.
2788 Use the \\<Info-mode-map>\\[Info-index-next] command to see the other matches.
2789 Give a blank topic name to go to the Index node itself."
2792 (let ((Info-complete-menu-buffer (clone-buffer))
2793 (Info-complete-nodes (Info-index-nodes))
2794 (Info-history-list nil
))
2795 (if (equal Info-current-file
"dir")
2796 (error "The Info directory node has no index; use m to select a manual"))
2798 (with-current-buffer Info-complete-menu-buffer
2800 (completing-read "Index topic: " 'Info-complete-menu-item
))
2801 (kill-buffer Info-complete-menu-buffer
)))))
2802 (if (equal Info-current-file
"dir")
2803 (error "The Info directory node has no index; use m to select a manual"))
2804 (let ((orignode Info-current-node
)
2805 (pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^\n]*\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?"
2806 (regexp-quote topic
)))
2807 node
(nodes (Info-index-nodes))
2808 (ohist-list Info-history-list
)
2809 (case-fold-search t
))
2811 (or (equal topic
"")
2814 ;; We bind Info-history to nil for internal node-switches so
2815 ;; that we don't put junk in the history. In the first
2816 ;; Info-goto-index call, above, we do update the history
2817 ;; because that is what the user's previous node choice into it.
2822 (goto-char (point-min))
2823 (while (re-search-forward pattern nil t
)
2824 (push (list (match-string-no-properties 1)
2825 (match-string-no-properties 2)
2827 (string-to-number (concat "0"
2830 (setq nodes
(cdr nodes
) node
(car nodes
)))
2831 (Info-goto-node node
))
2834 (Info-goto-node orignode
)
2835 (error "No `%s' in index" topic
)))
2836 ;; Here it is a feature that assoc is case-sensitive.
2837 (while (setq found
(assoc topic matches
))
2838 (setq exact
(cons found exact
)
2839 matches
(delq found matches
)))
2840 (setq Info-history-list ohist-list
)
2841 (setq Info-index-alternatives
(nconc exact
(nreverse matches
)))
2842 (Info-index-next 0)))))
2844 (defun Info-index-next (num)
2845 "Go to the next matching index item from the last \\<Info-mode-map>\\[Info-index] command."
2847 (or Info-index-alternatives
2848 (error "No previous `i' command"))
2850 (setq num
(+ num
(length Info-index-alternatives
))))
2852 (setq Info-index-alternatives
2853 (nconc (cdr Info-index-alternatives
)
2854 (list (car Info-index-alternatives
)))
2856 (Info-goto-node (nth 1 (car Info-index-alternatives
)))
2857 (if (> (nth 3 (car Info-index-alternatives
)) 0)
2858 (forward-line (1- (nth 3 (car Info-index-alternatives
))))
2859 (forward-line 3) ; don't search in headers
2860 (let ((name (car (car Info-index-alternatives
))))
2861 (Info-find-index-name name
)))
2862 (message "Found `%s' in %s. %s"
2863 (car (car Info-index-alternatives
))
2864 (nth 2 (car Info-index-alternatives
))
2865 (if (cdr Info-index-alternatives
)
2866 (format "(%s total; use `,' for next)"
2867 (length Info-index-alternatives
))
2870 (defun Info-find-index-name (name)
2871 "Move point to the place within the current node where NAME is defined."
2872 (let ((case-fold-search t
))
2873 (if (or (re-search-forward (format
2874 "[a-zA-Z]+: %s\\( \\|$\\)"
2875 (regexp-quote name
)) nil t
)
2876 ;; Find a function definition with a return type.
2877 (re-search-forward (format
2878 "[a-zA-Z]+: [a-zA-Z0-9_ *&]+ %s\\( \\|$\\)"
2879 (regexp-quote name
)) nil t
)
2880 (search-forward (format "`%s'" name
) nil t
)
2881 (and (string-match "\\`.*\\( (.*)\\)\\'" name
)
2883 (format "`%s'" (substring name
0 (match-beginning 1)))
2885 (search-forward name nil t
)
2886 ;; Try again without the " <1>" makeinfo can append
2887 (and (string-match "\\`\\(.*\\) <[0-9]+>\\'" name
)
2888 (Info-find-index-name (match-string 1 name
))))
2889 (progn (beginning-of-line) t
) ;; non-nil for recursive call
2890 (goto-char (point-min)))))
2893 (defun info-apropos (string)
2894 "Grovel indices of all known Info files on your system for STRING.
2895 Build a menu of the possible matches."
2896 (interactive "sIndex apropos: ")
2897 (unless (string= string
"")
2898 (let ((pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^\n]+\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?"
2899 (regexp-quote string
)))
2900 (ohist Info-history
)
2901 (ohist-list Info-history-list
)
2902 (current-node Info-current-node
)
2903 (current-file Info-current-file
)
2904 manuals matches node nodes
)
2905 (let ((Info-fontify-maximum-menu-size nil
))
2907 (message "Searching indices...")
2908 (goto-char (point-min))
2909 (re-search-forward "\\* Menu: *\n" nil t
)
2910 (while (re-search-forward "\\*.*: *(\\([^)]+\\))" nil t
)
2911 (setq manuals
(cons (match-string 1) manuals
)))
2912 (dolist (manual (nreverse manuals
))
2913 (message "Searching %s" manual
)
2915 (if (setq nodes
(Info-index-nodes (Info-find-file manual
)))
2917 (Info-find-node manual
(car nodes
))
2920 (goto-char (point-min))
2921 (while (re-search-forward pattern nil t
)
2924 (match-string-no-properties 1)
2925 (match-string-no-properties 2)
2926 (match-string-no-properties 3))
2928 (setq nodes
(cdr nodes
) node
(car nodes
)))
2929 (Info-goto-node node
))))
2931 (message "%s" (if (eq (car-safe err
) 'error
)
2934 (Info-goto-node (concat "(" current-file
")" current-node
))
2935 (setq Info-history ohist
2936 Info-history-list ohist-list
)
2937 (message "Searching indices...done")
2939 (message "No matches found")
2940 (with-current-buffer (get-buffer-create " *info-apropos*")
2942 (insert "\n\^_\nFile: apropos, Node: Index, Up: (dir)\n")
2943 (insert "* Menu: \nNodes whose indices contain `" string
"':\n\n")
2944 (dolist (entry (nreverse matches
))
2946 (format "* %-38s (%s)%s.%s\n"
2947 (concat (nth 1 entry
) " [" (nth 0 entry
) "]:")
2951 (concat " (line " (nth 3 entry
) ")")
2953 (Info-find-node "apropos" "Index")
2954 (setq Info-complete-cache nil
)))))
2956 (defun Info-undefined ()
2957 "Make command be undefined in Info."
2962 "Enter the Info tutorial."
2964 (delete-other-windows)
2965 (Info-find-node "info"
2966 (if (< (window-height) 23)
2970 (defun Info-summary ()
2971 "Display a brief summary of all Info commands."
2973 (save-window-excursion
2974 (switch-to-buffer "*Help*")
2975 (setq buffer-read-only nil
)
2977 (insert (documentation 'Info-mode
))
2979 (goto-char (point-min))
2981 (while (progn (setq flag
(not (pos-visible-in-window-p (point-max))))
2982 (message (if flag
"Type Space to see more"
2983 "Type Space to return to Info"))
2984 (if (not (eq ?\s
(setq ch
(read-event))))
2985 (progn (setq unread-command-events
(list ch
)) nil
)
2988 (bury-buffer "*Help*")))
2990 (defun Info-get-token (pos start all
&optional errorstring
)
2991 "Return the token around POS.
2992 POS must be somewhere inside the token
2993 START is a regular expression which will match the
2994 beginning of the tokens delimited string
2995 ALL is a regular expression with a single
2996 parenthesized subpattern which is the token to be
2997 returned. E.g. '{\(.*\)}' would return any string
2998 enclosed in braces around POS.
2999 ERRORSTRING optional fourth argument, controls action on no match
3002 a string: signal an error, using that string."
3003 (let ((case-fold-search t
))
3006 ;; First look for a match for START that goes across POS.
3007 (while (and (not (bobp)) (> (point) (- pos
(length start
)))
3008 (not (looking-at start
)))
3010 ;; If we did not find one, search back for START
3011 ;; (this finds only matches that end at or before POS).
3012 (or (looking-at start
)
3015 (re-search-backward start
(max (point-min) (- pos
200)) 'yes
)))
3017 (while (and (re-search-forward all
(min (point-max) (+ pos
200)) 'yes
)
3018 (not (setq found
(and (<= (match-beginning 0) pos
)
3019 (> (match-end 0) pos
))))))
3020 (if (and found
(<= (match-beginning 0) pos
)
3021 (> (match-end 0) pos
))
3022 (match-string-no-properties 1)
3023 (cond ((null errorstring
)
3029 (error "No %s around position %d" errorstring pos
))))))))
3031 (defun Info-mouse-follow-nearest-node (click)
3032 "\\<Info-mode-map>Follow a node reference near point.
3033 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click.
3034 At end of the node's text, moves to the next node, or up if none."
3036 (mouse-set-point click
)
3037 (and (not (Info-try-follow-nearest-node))
3038 (save-excursion (forward-line 1) (eobp))
3039 (Info-next-preorder)))
3041 (defun Info-follow-nearest-node (&optional fork
)
3042 "Follow a node reference near point.
3043 If point is on a reference, follow that reference. Otherwise,
3044 if point is in a menu item description, follow that menu item."
3046 (or (Info-try-follow-nearest-node fork
)
3047 (when (save-excursion
3048 (search-backward "\n* menu:" nil t
))
3051 (while (not (or (bobp) (looking-at "[^ \t]\\|[ \t]*$")))
3052 (beginning-of-line 0))
3053 (when (looking-at "\\* +\\([^\t\n]*\\):")
3055 (Info-extract-menu-item (match-string-no-properties 1)) fork
)
3057 (error "Point neither on reference nor in menu item description")))
3059 ;; Common subroutine.
3060 (defun Info-try-follow-nearest-node (&optional fork
)
3061 "Follow a node reference near point. Return non-nil if successful."
3064 ((Info-get-token (point) "[hf]t?tp://" "[hf]t?tp://\\([^ \t\n\"`({<>})']+\\)")
3066 (browse-url (browse-url-url-at-point)))
3067 ((setq node
(Info-get-token (point) "\\*note[ \n\t]+"
3068 "\\*note[ \n\t]+\\([^:]*\\):\\(:\\|[ \n\t]*(\\)?"))
3069 (Info-follow-reference node fork
))
3070 ;; menu item: node name
3071 ((setq node
(Info-get-token (point) "\\* +" "\\* +\\([^:]*\\)::"))
3072 (Info-goto-node node fork
))
3073 ;; menu item: node name or index entry
3074 ((Info-get-token (point) "\\* +" "\\* +\\(.*\\): ")
3077 (setq node
(Info-extract-menu-node-name nil
(Info-index-node)))
3078 (Info-goto-node node fork
))
3079 ((setq node
(Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)"))
3080 (Info-goto-node node fork
))
3081 ((setq node
(Info-get-token (point) "Next: " "Next: \\([^,\n\t]*\\)"))
3082 (Info-goto-node node fork
))
3083 ((setq node
(Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)"))
3084 (Info-goto-node "Top" fork
))
3085 ((setq node
(Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)"))
3086 (Info-goto-node node fork
)))
3089 (defvar Info-mode-map nil
3090 "Keymap containing Info commands.")
3093 (setq Info-mode-map
(make-keymap))
3094 (suppress-keymap Info-mode-map
)
3095 (define-key Info-mode-map
"." 'beginning-of-buffer
)
3096 (define-key Info-mode-map
" " 'Info-scroll-up
)
3097 (define-key Info-mode-map
"\C-m" 'Info-follow-nearest-node
)
3098 (define-key Info-mode-map
"\t" 'Info-next-reference
)
3099 (define-key Info-mode-map
"\e\t" 'Info-prev-reference
)
3100 (define-key Info-mode-map
[(shift tab
)] 'Info-prev-reference
)
3101 (define-key Info-mode-map
[backtab] 'Info-prev-reference)
3102 (define-key Info-mode-map "1" 'Info-nth-menu-item)
3103 (define-key Info-mode-map "2" 'Info-nth-menu-item)
3104 (define-key Info-mode-map "3" 'Info-nth-menu-item)
3105 (define-key Info-mode-map "4" 'Info-nth-menu-item)
3106 (define-key Info-mode-map "5" 'Info-nth-menu-item)
3107 (define-key Info-mode-map "6" 'Info-nth-menu-item)
3108 (define-key Info-mode-map "7" 'Info-nth-menu-item)
3109 (define-key Info-mode-map "8" 'Info-nth-menu-item)
3110 (define-key Info-mode-map "9" 'Info-nth-menu-item)
3111 (define-key Info-mode-map "0" 'undefined)
3112 (define-key Info-mode-map "?" 'Info-summary)
3113 (define-key Info-mode-map "]" 'Info-forward-node)
3114 (define-key Info-mode-map "[" 'Info-backward-node)
3115 (define-key Info-mode-map "<" 'Info-top-node)
3116 (define-key Info-mode-map ">" 'Info-final-node)
3117 (define-key Info-mode-map "b" 'beginning-of-buffer)
3118 (define-key Info-mode-map "d" 'Info-directory)
3119 (define-key Info-mode-map "e" 'Info-edit)
3120 (define-key Info-mode-map "f" 'Info-follow-reference)
3121 (define-key Info-mode-map "g" 'Info-goto-node)
3122 (define-key Info-mode-map "h" 'Info-help)
3123 (define-key Info-mode-map "i" 'Info-index)
3124 (define-key Info-mode-map "l" 'Info-history-back)
3125 (define-key Info-mode-map "L" 'Info-history)
3126 (define-key Info-mode-map "m" 'Info-menu)
3127 (define-key Info-mode-map "n" 'Info-next)
3128 (define-key Info-mode-map "p" 'Info-prev)
3129 (define-key Info-mode-map "q" 'Info-exit)
3130 (define-key Info-mode-map "r" 'Info-history-forward)
3131 (define-key Info-mode-map "s" 'Info-search)
3132 (define-key Info-mode-map "S" 'Info-search-case-sensitively)
3133 ;; For consistency with Rmail.
3134 (define-key Info-mode-map "\M-s" 'Info-search)
3135 (define-key Info-mode-map "\M-n" 'clone-buffer)
3136 (define-key Info-mode-map "t" 'Info-top-node)
3137 (define-key Info-mode-map "T" 'Info-toc)
3138 (define-key Info-mode-map "u" 'Info-up)
3139 ;; `w' for consistency with `dired-copy-filename-as-kill'.
3140 (define-key Info-mode-map "w" 'Info-copy-current-node-name)
3141 (define-key Info-mode-map "c" 'Info-copy-current-node-name)
3142 ;; `^' for consistency with `dired-up-directory'.
3143 (define-key Info-mode-map "^" 'Info-up)
3144 (define-key Info-mode-map "," 'Info-index-next)
3145 (define-key Info-mode-map "\177" 'Info-scroll-down)
3146 (define-key Info-mode-map [mouse-2] 'Info-mouse-follow-nearest-node)
3147 (define-key Info-mode-map [follow-link] 'mouse-face)
3150 (defun Info-check-pointer (item)
3151 "Non-nil if ITEM is present in this node."
3153 (Info-extract-pointer item)
3157 Info-mode-menu Info-mode-map
3158 "Menu for Info files."
3160 ["Up" Info-up :active (Info-check-pointer "up")
3161 :help "Go up in the Info tree"]
3162 ["Next" Info-next :active (Info-check-pointer "next")
3163 :help "Go to the next node"]
3164 ["Previous" Info-prev :active (Info-check-pointer "prev[ious]*")
3165 :help "Go to the previous node"]
3166 ["Backward" Info-backward-node
3167 :help "Go backward one node, considering all as a sequence"]
3168 ["Forward" Info-forward-node
3169 :help "Go forward one node, considering all as a sequence"]
3170 ["Beginning" beginning-of-buffer
3171 :help "Go to beginning of this node"]
3172 ["Top" Info-top-node
3173 :help "Go to top node of file"]
3174 ["Final Node" Info-final-node
3175 :help "Go to final node in this file"]
3176 ("Menu Item" ["You should never see this" report-emacs-bug t])
3177 ("Reference" ["You should never see this" report-emacs-bug t])
3178 ["Search..." Info-search
3179 :help "Search for regular expression in this Info file"]
3180 ["Search Next" Info-search-next
3181 :help "Search for another occurrence of regular expression"]
3182 ["Go to Node..." Info-goto-node
3183 :help "Go to a named node"]
3184 ["Back in history" Info-history-back :active Info-history
3185 :help "Go back in history to the last node you were at"]
3186 ["Forward in history" Info-history-forward :active Info-history-forward
3187 :help "Go forward in history"]
3188 ["History" Info-history :active Info-history-list
3189 :help "Go to menu of visited nodes"]
3190 ["Table of Contents" Info-toc
3191 :help "Go to table of contents"]
3193 ["Lookup a String..." Info-index
3194 :help "Look for a string in the index items"]
3195 ["Next Matching Item" Info-index-next :active Info-index-alternatives
3196 :help "Look for another occurrence of previous item"]
3197 ["Lookup a string in all indices..." info-apropos
3198 :help "Look for a string in the indices of all manuals"])
3199 ["Copy Node Name" Info-copy-current-node-name
3200 :help "Copy the name of the current node into the kill ring"]
3201 ["Clone Info buffer" clone-buffer
3202 :help "Create a twin copy of the current Info buffer."]
3203 ["Exit" Info-exit :help "Stop reading Info"]))
3206 (defvar info-tool-bar-map
3207 (if (display-graphic-p)
3208 (let ((map (make-sparse-keymap)))
3209 (tool-bar-local-item-from-menu 'Info-exit "close" map Info-mode-map)
3210 (tool-bar-local-item-from-menu 'Info-history-back "left-arrow" map Info-mode-map)
3211 (tool-bar-local-item-from-menu 'Info-history-forward "right-arrow" map Info-mode-map)
3212 (tool-bar-local-item-from-menu 'Info-prev "prev-node" map Info-mode-map)
3213 (tool-bar-local-item-from-menu 'Info-next "next-node" map Info-mode-map)
3214 (tool-bar-local-item-from-menu 'Info-up "up-node" map Info-mode-map)
3215 (tool-bar-local-item-from-menu 'Info-top-node "home" map Info-mode-map)
3216 (tool-bar-local-item-from-menu 'Info-goto-node "jump-to" map Info-mode-map)
3217 (tool-bar-local-item-from-menu 'Info-index "index" map Info-mode-map)
3218 (tool-bar-local-item-from-menu 'Info-search "search" map Info-mode-map)
3221 (defvar Info-menu-last-node nil)
3222 ;; Last node the menu was created for.
3223 ;; Value is a list, (FILE-NAME NODE-NAME).
3225 (defun Info-menu-update ()
3226 "Update the Info menu for the current node."
3228 (if (or (not (eq major-mode 'Info-mode))
3229 (equal (list Info-current-file Info-current-node)
3230 Info-menu-last-node))
3232 ;; Update menu menu.
3233 (let* ((Info-complete-menu-buffer (current-buffer))
3234 (items (nreverse (condition-case nil
3235 (Info-complete-menu-item "" nil t)
3239 (while (and items (< number 9))
3240 (setq current (car items)
3243 (setq entries (cons `[,current
3244 (Info-menu ,current)
3245 :keys ,(format "%d" number)]
3248 (setq entries (cons ["Other..." Info-menu t] entries)))
3250 (setq entries (list ["No menu" nil nil] nil :active)))
3251 (easy-menu-change '("Info") "Menu Item" (nreverse entries)))
3252 ;; Update reference menu. Code stolen from `Info-follow-reference'.
3254 str i entries current
3256 (case-fold-search t))
3258 (goto-char (point-min))
3259 (while (re-search-forward "\\*note[ \n\t]+\\([^:]*\\):" nil t)
3260 (setq str (match-string 1))
3262 (while (setq i (string-match "[ \n\t]+" str i))
3263 (setq str (concat (substring str 0 i) " "
3264 (substring str (match-end 0))))
3268 (while (and items (< number 9))
3269 (setq current (car items)
3272 (setq entries (cons `[,current
3273 (Info-follow-reference ,current)
3277 (setq entries (cons ["Other..." Info-follow-reference t]
3280 (setq entries (list ["No references" nil nil] nil :active)))
3281 (easy-menu-change '("Info") "Reference" (nreverse entries)))
3282 ;; Update last seen node.
3283 (setq Info-menu-last-node (list Info-current-file Info-current-node)))
3284 ;; Try to avoid entering infinite beep mode in case of errors.
3288 (defun Info-copy-current-node-name (&optional arg)
3289 "Put the name of the current Info node into the kill ring.
3290 The name of the Info file is prepended to the node name in parentheses.
3291 With a zero prefix arg, put the name inside a function call to `info'."
3293 (unless Info-current-node
3294 (error "No current Info node"))
3295 (let ((node (concat "(" (file-name-nondirectory Info-current-file) ")"
3296 Info-current-node)))
3297 (if (zerop (prefix-numeric-value arg))
3298 (setq node (concat "(info \"" node "\")")))
3300 (message "%s" node)))
3303 ;; Info mode is suitable only for specially formatted data.
3304 (put 'Info-mode 'mode-class 'special)
3305 (put 'Info-mode 'no-clone-indirect t)
3307 (defvar tool-bar-map)
3309 ;; Autoload cookie needed by desktop.el
3312 "Info mode provides commands for browsing through the Info documentation tree.
3313 Documentation in Info is divided into \"nodes\", each of which discusses
3314 one topic and contains references to other nodes which discuss related
3315 topics. Info has commands to follow the references and show you other nodes.
3318 \\[Info-help] Invoke the Info tutorial.
3319 \\[Info-exit] Quit Info: reselect previously selected buffer.
3321 Selecting other nodes:
3322 \\[Info-mouse-follow-nearest-node]
3323 Follow a node reference you click on.
3324 This works with menu items, cross references, and
3325 the \"next\", \"previous\" and \"up\", depending on where you click.
3326 \\[Info-follow-nearest-node] Follow a node reference near point, like \\[Info-mouse-follow-nearest-node].
3327 \\[Info-next] Move to the \"next\" node of this node.
3328 \\[Info-prev] Move to the \"previous\" node of this node.
3329 \\[Info-up] Move \"up\" from this node.
3330 \\[Info-menu] Pick menu item specified by name (or abbreviation).
3331 Picking a menu item causes another node to be selected.
3332 \\[Info-directory] Go to the Info directory node.
3333 \\[Info-top-node] Go to the Top node of this file.
3334 \\[Info-final-node] Go to the final node in this file.
3335 \\[Info-backward-node] Go backward one node, considering all nodes as forming one sequence.
3336 \\[Info-forward-node] Go forward one node, considering all nodes as forming one sequence.
3337 \\[Info-next-reference] Move cursor to next cross-reference or menu item.
3338 \\[Info-prev-reference] Move cursor to previous cross-reference or menu item.
3339 \\[Info-follow-reference] Follow a cross reference. Reads name of reference.
3340 \\[Info-history-back] Move back in history to the last node you were at.
3341 \\[Info-history-forward] Move forward in history to the node you returned from after using \\[Info-history-back].
3342 \\[Info-history] Go to menu of visited nodes.
3343 \\[Info-toc] Go to table of contents of the current Info file.
3345 Moving within a node:
3346 \\[Info-scroll-up] Normally, scroll forward a full screen.
3347 Once you scroll far enough in a node that its menu appears on the
3348 screen but after point, the next scroll moves into its first
3349 subnode. When after all menu items (or if there is no menu),
3350 move up to the parent node.
3351 \\[Info-scroll-down] Normally, scroll backward. If the beginning of the buffer is
3352 already visible, try to go to the previous menu entry, or up
3354 \\[beginning-of-buffer] Go to beginning of node.
3357 \\[Info-search] Search through this Info file for specified regexp,
3358 and select the node in which the next occurrence is found.
3359 \\[Info-search-case-sensitively] Search through this Info file for specified regexp case-sensitively.
3360 \\[Info-search-next] Search for another occurrence of regexp
3361 from a previous \\<Info-mode-map>\\[Info-search] command.
3362 \\[Info-index] Look up a topic in this file's Index and move to that node.
3363 \\[Info-index-next] (comma) Move to the next match from a previous \\<Info-mode-map>\\[Info-index] command.
3364 \\[info-apropos] Look for a string in the indices of all manuals.
3365 \\[Info-goto-node] Move to node specified by name.
3366 You may include a filename as well, as (FILENAME)NODENAME.
3367 1 .. 9 Pick first ... ninth item in node's menu.
3368 Every third `*' is highlighted to help pick the right number.
3369 \\[Info-copy-current-node-name] Put name of current Info node in the kill ring.
3370 \\[clone-buffer] Select a new cloned Info buffer in another window.
3371 \\[universal-argument] \\[info] Move to new Info file with completion.
3372 \\[universal-argument] N \\[info] Select Info buffer with prefix number in the name *info*<N>."
3373 (kill-all-local-variables)
3374 (setq major-mode 'Info-mode)
3375 (setq mode-name "Info")
3377 (use-local-map Info-mode-map)
3378 (add-hook 'activate-menubar-hook 'Info-menu-update nil t)
3379 (set-syntax-table text-mode-syntax-table)
3380 (setq local-abbrev-table text-mode-abbrev-table)
3381 (setq case-fold-search t)
3382 (setq buffer-read-only t)
3383 (make-local-variable 'Info-current-file)
3384 (make-local-variable 'Info-current-subfile)
3385 (make-local-variable 'Info-current-node)
3386 (make-local-variable 'Info-tag-table-marker)
3387 (setq Info-tag-table-marker (make-marker))
3388 (make-local-variable 'Info-tag-table-buffer)
3389 (setq Info-tag-table-buffer nil)
3390 (make-local-variable 'Info-history)
3391 (make-local-variable 'Info-history-forward)
3392 (make-local-variable 'Info-index-alternatives)
3393 (setq header-line-format
3394 (if Info-use-header-line
3395 '(:eval (get-text-property (point-min) 'header-line))
3396 nil)) ; so the header line isn't displayed
3397 (set (make-local-variable 'tool-bar-map) info-tool-bar-map)
3398 ;; This is for the sake of the invisible text we use handling titles.
3399 (make-local-variable 'line-move-ignore-invisible)
3400 (setq line-move-ignore-invisible t)
3401 (make-local-variable 'desktop-save-buffer)
3402 (make-local-variable 'widen-automatically)
3403 (setq widen-automatically nil)
3404 (setq desktop-save-buffer 'Info-desktop-buffer-misc-data)
3405 (add-hook 'kill-buffer-hook 'Info-kill-buffer nil t)
3406 (add-hook 'clone-buffer-hook 'Info-clone-buffer-hook nil t)
3407 (add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
3408 (add-hook 'isearch-mode-hook 'Info-isearch-start nil t)
3409 (set (make-local-variable 'isearch-search-fun-function)
3410 'Info-isearch-search)
3411 (set (make-local-variable 'isearch-wrap-function)
3413 (set (make-local-variable 'isearch-push-state-function)
3414 'Info-isearch-push-state)
3415 (set (make-local-variable 'search-whitespace-regexp)
3416 Info-search-whitespace-regexp)
3417 (Info-set-mode-line)
3418 (run-mode-hooks 'Info-mode-hook))
3420 ;; When an Info buffer is killed, make sure the associated tags buffer
3422 (defun Info-kill-buffer ()
3423 (and (eq major-mode 'Info-mode)
3424 Info-tag-table-buffer
3425 (kill-buffer Info-tag-table-buffer)))
3427 (defun Info-clone-buffer-hook ()
3428 (when (bufferp Info-tag-table-buffer)
3429 (setq Info-tag-table-buffer
3430 (with-current-buffer Info-tag-table-buffer (clone-buffer))))
3431 (let ((m Info-tag-table-marker))
3433 (setq Info-tag-table-marker
3434 (if (and (marker-position m) (bufferp Info-tag-table-buffer))
3435 (with-current-buffer Info-tag-table-buffer
3436 (copy-marker (marker-position m)))
3439 (defvar Info-edit-map (let ((map (make-sparse-keymap)))
3440 (set-keymap-parent map text-mode-map)
3441 (define-key map "\C-c\C-c" 'Info-cease-edit)
3443 "Local keymap used within `e' command of Info.")
3445 ;; Info-edit mode is suitable only for specially formatted data.
3446 (put 'Info-edit-mode 'mode-class 'special)
3448 (defun Info-edit-mode ()
3449 "Major mode for editing the contents of an Info node.
3450 Like text mode with the addition of `Info-cease-edit'
3451 which returns to Info mode for browsing.
3453 (use-local-map Info-edit-map)
3454 (setq major-mode 'Info-edit-mode)
3455 (setq mode-name "Info Edit")
3456 (kill-local-variable 'mode-line-buffer-identification)
3457 (setq buffer-read-only nil)
3458 (force-mode-line-update)
3459 (buffer-enable-undo (current-buffer))
3460 (run-mode-hooks 'Info-edit-mode-hook))
3463 "Edit the contents of this Info node.
3464 Allowed only if variable `Info-enable-edit' is non-nil."
3466 (or Info-enable-edit
3467 (error "Editing Info nodes is not enabled"))
3469 (message "%s" (substitute-command-keys
3470 "Editing: Type \\<Info-edit-map>\\[Info-cease-edit] to return to info")))
3472 (defun Info-cease-edit ()
3473 "Finish editing Info node; switch back to Info proper."
3475 ;; Do this first, so nothing has changed if user C-g's at query.
3476 (and (buffer-modified-p)
3477 (y-or-n-p "Save the file? ")
3479 (use-local-map Info-mode-map)
3480 (setq major-mode 'Info-mode)
3481 (setq mode-name "Info")
3482 (Info-set-mode-line)
3483 (setq buffer-read-only t)
3484 (force-mode-line-update)
3485 (and (marker-position Info-tag-table-marker)
3487 (message "Tags may have changed. Use Info-tagify if necessary")))
3489 (defvar Info-file-list-for-emacs
3490 '("ediff" "eudc" "forms" "gnus" "info" ("Info" . "info") ("mh" . "mh-e")
3491 "sc" "message" ("dired" . "dired-x") "viper" "vip" "idlwave"
3492 ("c" . "ccmode") ("c++" . "ccmode") ("objc" . "ccmode")
3493 ("java" . "ccmode") ("idl" . "ccmode") ("pike" . "ccmode")
3494 ("skeleton" . "autotype") ("auto-insert" . "autotype")
3495 ("copyright" . "autotype") ("executable" . "autotype")
3496 ("time-stamp" . "autotype") ("quickurl" . "autotype")
3497 ("tempo" . "autotype") ("hippie-expand" . "autotype")
3498 ("cvs" . "pcl-cvs") ("ada" . "ada-mode") "calc"
3499 ("calcAlg" . "calc") ("calcDigit" . "calc") ("calcVar" . "calc")
3500 "ebrowse" "eshell" "cl" "reftex" "speedbar" "widget" "woman"
3501 ("mail-header" . "emacs-mime") ("mail-content" . "emacs-mime")
3502 ("mail-encode" . "emacs-mime") ("mail-decode" . "emacs-mime")
3503 ("rfc2045" . "emacs-mime")
3504 ("rfc2231" . "emacs-mime") ("rfc2047" . "emacs-mime")
3505 ("rfc2045" . "emacs-mime") ("rfc1843" . "emacs-mime")
3506 ("ietf-drums" . "emacs-mime") ("quoted-printable" . "emacs-mime")
3507 ("binhex" . "emacs-mime") ("uudecode" . "emacs-mime")
3508 ("mailcap" . "emacs-mime") ("mm" . "emacs-mime")
3509 ("mml" . "emacs-mime"))
3510 "List of Info files that describe Emacs commands.
3511 An element can be a file name, or a list of the form (PREFIX . FILE)
3512 where PREFIX is a name prefix and FILE is the file to look in.
3513 If the element is just a file name, the file name also serves as the prefix.")
3515 (defun Info-find-emacs-command-nodes (command)
3516 "Return a list of locations documenting COMMAND.
3517 The `info-file' property of COMMAND says which Info manual to search.
3518 If COMMAND has no property, the variable `Info-file-list-for-emacs'
3519 defines heuristics for which Info manual to try.
3520 The locations are of the format used in `Info-history', i.e.
3521 \(FILENAME NODENAME BUFFERPOS\), where BUFFERPOS is the line number
3522 in the first element of the returned list (which is treated specially in
3523 `Info-goto-emacs-command-node'), and 0 for the rest elements of a list."
3524 (let ((where '()) line-number
3525 (cmd-desc (concat "^\\* +" (regexp-quote (symbol-name command))
3526 "\\( <[0-9]+>\\)?:\\s *\\(.*\\)\\."
3527 "\\(?:[ \t\n]+(line +\\([0-9]+\\))\\)?"))
3528 (info-file "emacs")) ;default
3529 ;; Determine which Info file this command is documented in.
3530 (if (get command 'info-file)
3531 (setq info-file (get command 'info-file))
3532 ;; If it doesn't say explicitly, test its name against
3533 ;; various prefixes that we know.
3534 (let ((file-list Info-file-list-for-emacs))
3536 (let* ((elt (car file-list))
3537 (name (if (consp elt)
3540 (file (if (consp elt) (cdr elt) elt))
3541 (case-fold-search nil)
3542 (regexp (concat "\\`" (regexp-quote name)
3544 (if (string-match regexp (symbol-name command))
3545 (setq info-file file file-list nil))
3546 (setq file-list (cdr file-list))))))
3547 (Info-find-node info-file "Top")
3548 ;; Bind Info-history to nil, to prevent the index nodes from
3549 ;; getting into the node history.
3550 (let ((Info-history nil)
3551 (Info-history-list nil)
3552 node (nodes (Info-index-nodes)))
3553 (Info-goto-node (car nodes))
3556 (goto-char (point-min))
3557 (while (re-search-forward cmd-desc nil t)
3559 (cons (list Info-current-file
3560 (match-string-no-properties 2)
3563 (setq line-number (and (match-beginning 3)
3564 (string-to-number (match-string 3)))))
3565 (and (setq nodes (cdr nodes) node (car nodes))))
3566 (Info-goto-node node)))
3567 (if (and line-number where)
3568 (cons (list (nth 0 (car where)) (nth 1 (car where)) line-number)
3572 ;;;###autoload (put 'Info-goto-emacs-command-node 'info-file "emacs")
3574 (defun Info-goto-emacs-command-node (command)
3575 "Go to the Info node in the Emacs manual for command COMMAND.
3576 The command is found by looking up in Emacs manual's indices
3577 or in another manual found via COMMAND's `info-file' property or
3578 the variable `Info-file-list-for-emacs'.
3579 COMMAND must be a symbol or string."
3580 (interactive "CFind documentation for command: ")
3581 ;; If command is given as a string, convert it to a symbol.
3582 (if (stringp command)
3583 (setq command (intern command)))
3584 (or (commandp command)
3585 (signal 'wrong-type-argument (list 'commandp command)))
3586 (let ((where (Info-find-emacs-command-nodes command)))
3588 (let ((num-matches (length where)))
3589 ;; Get Info running, and pop to it in another window.
3590 (save-window-excursion
3592 (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*"))
3593 ;; Bind Info-history to nil, to prevent the last Index node
3594 ;; visited by Info-find-emacs-command-nodes from being
3595 ;; pushed onto the history.
3596 (let ((Info-history nil) (Info-history-list nil)
3597 (line-number (nth 2 (car where))))
3598 (Info-find-node (nth 0 (car where)) (nth 1 (car where)))
3599 (if (and (integerp line-number) (> line-number 0))
3600 (forward-line (1- line-number))))
3601 (if (> num-matches 1)
3603 ;; (car where) will be pushed onto Info-history
3604 ;; when/if they go to another node. Put the other
3605 ;; nodes that were found on the history.
3606 (setq Info-history (nconc (cdr where) Info-history))
3607 (message "Found %d other entr%s. Use %s to see %s."
3609 (if (> num-matches 2) "ies" "y")
3610 (substitute-command-keys "\\[Info-history-back]")
3611 (if (> num-matches 2) "them" "it")))))
3612 (error "Couldn't find documentation for %s" command))))
3614 ;;;###autoload (put 'Info-goto-emacs-key-command-node 'info-file "emacs")
3616 (defun Info-goto-emacs-key-command-node (key)
3617 "Go to the node in the Emacs manual which describes the command bound to KEY.
3619 Interactively, if the binding is `execute-extended-command', a command is read.
3620 The command is found by looking up in Emacs manual's indices
3621 or in another manual found via COMMAND's `info-file' property or
3622 the variable `Info-file-list-for-emacs'."
3623 (interactive "kFind documentation for key: ")
3624 (let ((command (key-binding key)))
3625 (cond ((null command)
3626 (message "%s is undefined" (key-description key)))
3627 ((and (interactive-p)
3628 (eq command 'execute-extended-command))
3629 (Info-goto-emacs-command-node
3630 (read-command "Find documentation for command: ")))
3632 (Info-goto-emacs-command-node command)))))
3634 (defvar Info-next-link-keymap
3635 (let ((keymap (make-sparse-keymap)))
3636 (define-key keymap [header-line mouse-1] 'Info-next)
3637 (define-key keymap [header-line mouse-2] 'Info-next)
3638 (define-key keymap [header-line down-mouse-1] 'ignore)
3639 (define-key keymap [mouse-2] 'Info-next)
3640 (define-key keymap [follow-link] 'mouse-face)
3642 "Keymap to put on the Next link in the text or the header line.")
3644 (defvar Info-prev-link-keymap
3645 (let ((keymap (make-sparse-keymap)))
3646 (define-key keymap [header-line mouse-1] 'Info-prev)
3647 (define-key keymap [header-line mouse-2] 'Info-prev)
3648 (define-key keymap [header-line down-mouse-1] 'ignore)
3649 (define-key keymap [mouse-2] 'Info-prev)
3650 (define-key keymap [follow-link] 'mouse-face)
3652 "Keymap to put on the Prev link in the text or the header line.")
3654 (defvar Info-up-link-keymap
3655 (let ((keymap (make-sparse-keymap)))
3656 (define-key keymap [header-line mouse-1] 'Info-up)
3657 (define-key keymap [header-line mouse-2] 'Info-up)
3658 (define-key keymap [header-line down-mouse-1] 'ignore)
3659 (define-key keymap [mouse-2] 'Info-up)
3660 (define-key keymap [follow-link] 'mouse-face)
3662 "Keymap to put on the Up link in the text or the header line.")
3664 (defun Info-fontify-node ()
3667 (let* ((inhibit-read-only t)
3668 (case-fold-search t)
3670 (not-fontified-p ; the node hasn't already been fontified
3671 (not (let ((where (next-property-change (point-min))))
3672 (and where (not (= where (point-max)))))))
3673 (fontify-visited-p ; visited nodes need to be re-fontified
3674 (and Info-fontify-visited-nodes
3675 ;; Don't take time to refontify visited nodes in huge nodes
3676 (< (- (point-max) (point-min)) Info-fontify-maximum-menu-size)))
3679 ;; Fontify header line
3680 (goto-char (point-min))
3681 (when (and not-fontified-p (looking-at "^\\(File: [^,: \t]+,?[ \t]+\\)?"))
3682 (goto-char (match-end 0))
3683 (while (looking-at "[ \t]*\\([^:, \t\n]+\\):[ \t]+\\([^:,\t\n]+\\),?")
3684 (goto-char (match-end 0))
3685 (let* ((nbeg (match-beginning 2))
3686 (nend (match-end 2))
3687 (tbeg (match-beginning 1))
3688 (tag (match-string 1)))
3689 (if (string-equal (downcase tag) "node")
3690 (put-text-property nbeg nend 'font-lock-face 'info-header-node)
3691 (put-text-property nbeg nend 'font-lock-face 'info-header-xref)
3692 (put-text-property tbeg nend 'mouse-face 'highlight)
3693 (put-text-property tbeg nend
3695 (concat "mouse-2: Go to node "
3696 (buffer-substring nbeg nend)))
3697 ;; Always set up the text property keymap.
3698 ;; It will either be used in the buffer
3699 ;; or copied in the header line.
3703 ((string-equal (downcase tag) "prev") Info-prev-link-keymap)
3704 ((string-equal (downcase tag) "next") Info-next-link-keymap)
3705 ((string-equal (downcase tag) "up" ) Info-up-link-keymap))))))
3706 (when Info-use-header-line
3707 (goto-char (point-min))
3708 (let* ((header-end (line-end-position))
3710 ;; If we find neither Next: nor Prev: link, show the entire
3711 ;; node header. Otherwise, don't show the File: and Node:
3712 ;; parts, to avoid wasting precious space on information that
3713 ;; is available in the mode line.
3714 (if (re-search-forward
3715 "\\(next\\|up\\|prev[ious]*\\): "
3718 (goto-char (match-beginning 1))
3719 (buffer-substring (point) header-end))
3720 (if (re-search-forward "node:[ \t]*[^ \t]+[ \t]*"
3722 (concat "No next, prev or up links -- "
3723 (buffer-substring (point) header-end))
3724 (buffer-substring (point) header-end)))))
3725 (put-text-property (point-min) (1+ (point-min))
3727 (replace-regexp-in-string
3729 ;; Preserve text properties on duplicated `%'.
3730 (lambda (s) (concat s s)) header))
3731 ;; Hide the part of the first line
3732 ;; that is in the header, if it is just part.
3734 ;; Hide the punctuation at the end, too.
3735 (skip-chars-backward " \t,")
3736 (put-text-property (point) header-end 'invisible t)))))
3739 (goto-char (point-min))
3740 (when (and font-lock-mode not-fontified-p)
3741 (while (and (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*\\*+\\|==+\\|--+\\|\\.\\.+\\)$"
3743 ;; Only consider it as an underlined title if the ASCII
3744 ;; underline has the same size as the text. A typical
3745 ;; counter example is when a continuation "..." is alone
3747 (= (string-width (match-string 1))
3748 (string-width (match-string 2))))
3749 (let* ((c (preceding-char))
3751 (cond ((= c ?*) 'info-title-1)
3752 ((= c ?=) 'info-title-2)
3753 ((= c ?-) 'info-title-3)
3754 (t 'info-title-4))))
3755 (put-text-property (match-beginning 1) (match-end 1)
3756 'font-lock-face face))
3757 ;; This is a serious problem for trying to handle multiple
3758 ;; frame types at once. We want this text to be invisible
3759 ;; on frames that can display the font above.
3760 (when (memq (framep (selected-frame)) '(x pc w32 mac))
3761 (add-text-properties (1- (match-beginning 2)) (match-end 2)
3762 '(invisible t front-sticky nil rear-nonsticky t)))))
3764 ;; Fontify cross references
3765 (goto-char (point-min))
3766 (when (or not-fontified-p fontify-visited-p)
3767 (while (re-search-forward "\\(\\*Note[ \n\t]+\\)\\([^:]*\\)\\(:[ \t]*\\([^.,:(]*\\)\\(\\(([^)]*)\\)[^.,:]*\\)?[,:]?\n?\\)" nil t)
3768 (let ((start (match-beginning 0))
3771 (when not-fontified-p
3772 (when Info-hide-note-references
3773 (when (not (eq Info-hide-note-references 'hide))
3774 ;; *Note is often used where *note should have been
3776 (skip-syntax-backward " ")
3777 (when (memq (char-before) '(?\( ?\[ ?\{))
3778 ;; Check whether the paren is preceded by
3779 ;; an end of sentence
3780 (skip-syntax-backward " ("))
3782 (cond ((save-match-data (looking-back "\\<see"))
3784 ((memq (char-before) '(nil ?\. ?! ??))
3788 (search-forward "\n\n" start t)))
3792 (add-text-properties
3794 (or (save-match-data
3795 ;; Don't hide \n after *Note
3796 (let ((start1 (match-beginning 1)))
3797 (if (string-match "\n" (match-string 1))
3798 (+ start1 (match-beginning 0)))))
3801 `(display ,other-tag front-sticky nil rear-nonsticky t)
3802 '(invisible t front-sticky nil rear-nonsticky t))))
3803 (add-text-properties
3804 (match-beginning 2) (match-end 2)
3806 'help-echo (if (or (match-end 5)
3807 (not (equal (match-string 4) "")))
3808 (concat "mouse-2: go to " (or (match-string 5)
3810 "mouse-2: go to this node")
3811 'mouse-face 'highlight)))
3812 (when (or not-fontified-p fontify-visited-p)
3813 (setq rbeg (match-beginning 2)
3818 ;; Display visited nodes in a different face
3819 (if (and Info-fontify-visited-nodes
3821 (let* ((node (replace-regexp-in-string
3823 (replace-regexp-in-string
3825 (or (match-string 5)
3826 (and (not (equal (match-string 4) ""))
3828 (match-string 2)))))
3830 (string-match "(\\([^)]+\\))\\([^)]*\\)" node))
3831 (file (if external-link-p
3832 (file-name-nondirectory
3833 (match-string 1 node))
3835 (hl Info-history-list)
3838 (setq node (if (equal (match-string 2 node) "")
3840 (match-string 2 node))))
3842 (if (and (string-equal node (nth 1 (car hl)))
3844 file (if external-link-p
3845 (file-name-nondirectory
3848 (setq res (car hl) hl nil)
3849 (setq hl (cdr hl))))
3850 res))) 'info-xref-visited 'info-xref))
3851 ;; For multiline ref, unfontify newline and surrounding whitespace
3855 (while (re-search-forward "\\s-*\n\\s-*" rend t nil)
3856 (remove-text-properties (match-beginning 0)
3858 '(font-lock-face t))))))
3859 (when not-fontified-p
3860 (when (memq Info-hide-note-references '(t hide))
3861 (add-text-properties (match-beginning 3) (match-end 3)
3862 '(invisible t front-sticky nil rear-nonsticky t))
3863 ;; Unhide the file name of the external reference in parens
3864 (if (and (match-string 6) (not (eq Info-hide-note-references 'hide)))
3865 (remove-text-properties (match-beginning 6) (match-end 6)
3866 '(invisible t front-sticky nil rear-nonsticky t)))
3867 ;; Unhide newline because hidden newlines cause too long lines
3869 (let ((beg3 (match-beginning 3))
3870 (end3 (match-end 3)))
3871 (if (and (string-match "\n[ \t]*" (match-string 3))
3872 (not (save-match-data
3874 (goto-char (1+ end3))
3875 (looking-at "[.)]*$")))))
3876 (remove-text-properties (+ beg3 (match-beginning 0))
3877 (+ beg3 (match-end 0))
3878 '(invisible t front-sticky nil rear-nonsticky t))))))
3879 (when (and Info-refill-paragraphs Info-hide-note-references)
3880 (push (set-marker (make-marker) start)
3881 paragraph-markers))))))
3883 ;; Refill paragraphs (experimental feature)
3884 (when (and not-fontified-p
3885 Info-refill-paragraphs
3887 (let ((fill-nobreak-invisible t)
3888 (fill-individual-varying-indent nil)
3889 (paragraph-start "\f\\|[ \t]*[-*]\\|[ \t]*$")
3890 (paragraph-separate ".*\\.[ \t]*\n[ \t]\\|[ \t]*[-*]\\|[ \t\f]*$")
3891 (adaptive-fill-mode nil))
3892 (goto-char (point-max))
3893 (dolist (m paragraph-markers)
3897 (let ((beg (point)))
3898 (when (zerop (forward-paragraph))
3899 (fill-individual-paragraphs beg (point) nil nil)
3901 (set-marker m nil))))
3903 ;; Fontify menu items
3904 (goto-char (point-min))
3905 (when (and (or not-fontified-p fontify-visited-p)
3906 (search-forward "\n* Menu:" nil t)
3907 (not (Info-index-node))
3908 ;; Don't take time to annotate huge menus
3909 (< (- (point-max) (point)) Info-fontify-maximum-menu-size))
3912 (while (re-search-forward
3913 (concat "^\\* Menu:\\|\\(?:^\\* +\\(" Info-menu-entry-name-re "\\)\\(:"
3914 Info-node-spec-re "\\([ \t]*\\)\\)\\)")
3916 (when (match-beginning 1)
3917 (when not-fontified-p
3919 (if (and (<= n 9) (zerop (% n 3))) ; visual aids to help with 1-9 keys
3920 (put-text-property (match-beginning 0)
3921 (1+ (match-beginning 0))
3922 'font-lock-face 'info-menu-star)))
3923 (when not-fontified-p
3924 (add-text-properties
3925 (match-beginning 1) (match-end 1)
3927 'help-echo (if (and (match-end 3)
3928 (not (equal (match-string 3) "")))
3929 (concat "mouse-2: go to " (match-string 3))
3930 "mouse-2: go to this node")
3931 'mouse-face 'highlight)))
3932 (when (or not-fontified-p fontify-visited-p)
3934 (match-beginning 1) (match-end 1)
3936 ;; Display visited menu items in a different face
3937 (if (and Info-fontify-visited-nodes
3939 (let* ((node (if (equal (match-string 3) "")
3943 (string-match "(\\([^)]+\\))\\([^)]*\\)" node))
3944 (file (if external-link-p
3945 (file-name-nondirectory
3946 (match-string 1 node))
3948 (hl Info-history-list)
3951 (setq node (if (equal (match-string 2 node) "")
3953 (match-string 2 node))))
3955 (if (and (string-equal node (nth 1 (car hl)))
3957 file (if external-link-p
3958 (file-name-nondirectory (caar hl))
3960 (setq res (car hl) hl nil)
3961 (setq hl (cdr hl))))
3962 res))) 'info-xref-visited 'info-xref)))
3963 (when (and not-fontified-p (memq Info-hide-note-references '(t hide)))
3964 (put-text-property (match-beginning 2) (1- (match-end 6))
3966 ;; Unhide the file name in parens
3967 (if (and (match-end 4) (not (eq (char-after (match-end 4)) ?.)))
3968 (remove-text-properties (match-beginning 4) (match-end 4)
3970 ;; We need a stretchable space like :align-to but with
3972 (put-text-property (1- (match-end 6)) (match-end 6) 'display
3973 (if (>= 22 (- (match-end 1)
3974 (match-beginning 0)))
3975 '(space :align-to 24)
3977 (setq cont (looking-at "."))
3978 (while (and (= (forward-line 1) 0)
3979 (looking-at "\\([ \t]+\\)[^*\n]"))
3980 (put-text-property (match-beginning 1) (1- (match-end 1))
3982 (put-text-property (1- (match-end 1)) (match-end 1)
3985 '(space :align-to 26)
3986 '(space :align-to 24)))
3989 ;; Fontify menu headers
3990 ;; Add the face `info-menu-header' to any header before a menu entry
3991 (goto-char (point-min))
3992 (when (and not-fontified-p (re-search-forward "^\\* Menu:" nil t))
3993 (put-text-property (match-beginning 0) (match-end 0)
3994 'font-lock-face 'info-menu-header)
3995 (while (re-search-forward "\n\n\\([^*\n ].*\\)\n\n?[*]" nil t)
3996 (put-text-property (match-beginning 1) (match-end 1)
3997 'font-lock-face 'info-menu-header)))
3999 ;; Hide index line numbers
4000 (goto-char (point-min))
4001 (when (and not-fontified-p (Info-index-node))
4002 (while (re-search-forward "[ \t\n]*(line +[0-9]+)" nil t)
4003 (put-text-property (match-beginning 0) (match-end 0)
4006 ;; Fontify http and ftp references
4007 (goto-char (point-min))
4008 (when not-fontified-p
4009 (while (re-search-forward "[hf]t?tp://[^ \t\n\"`({<>})']+" nil t)
4010 (add-text-properties (match-beginning 0) (match-end 0)
4011 '(font-lock-face info-xref
4012 mouse-face highlight
4013 help-echo "mouse-2: go to this URL"))))
4015 (set-buffer-modified-p nil))))
4017 ;;; Speedbar support:
4018 ;; These functions permit speedbar to display the "tags" in the
4019 ;; current Info node.
4020 (eval-when-compile (require 'speedbar))
4022 (defvar Info-speedbar-key-map nil
4023 "Keymap used when in the info display mode.")
4025 (defun Info-install-speedbar-variables ()
4026 "Install those variables used by speedbar to enhance Info."
4027 (if Info-speedbar-key-map
4029 (setq Info-speedbar-key-map (speedbar-make-specialized-keymap))
4031 ;; Basic tree features
4032 (define-key Info-speedbar-key-map "e" 'speedbar-edit-line)
4033 (define-key Info-speedbar-key-map "\C-m" 'speedbar-edit-line)
4034 (define-key Info-speedbar-key-map "+" 'speedbar-expand-line)
4035 (define-key Info-speedbar-key-map "-" 'speedbar-contract-line)
4038 (speedbar-add-expansion-list '("Info" Info-speedbar-menu-items
4039 Info-speedbar-key-map
4040 Info-speedbar-hierarchy-buttons)))
4042 (defvar Info-speedbar-menu-items
4043 '(["Browse Node" speedbar-edit-line t]
4044 ["Expand Node" speedbar-expand-line
4045 (save-excursion (beginning-of-line)
4046 (looking-at "[0-9]+: *.\\+. "))]
4047 ["Contract Node" speedbar-contract-line
4048 (save-excursion (beginning-of-line)
4049 (looking-at "[0-9]+: *.-. "))]
4051 "Additional menu-items to add to speedbar frame.")
4053 ;; Make sure our special speedbar major mode is loaded
4054 (if (featurep 'speedbar)
4055 (Info-install-speedbar-variables)
4056 (add-hook 'speedbar-load-hook 'Info-install-speedbar-variables))
4058 ;;; Info hierarchy display method
4060 (defun Info-speedbar-browser ()
4061 "Initialize speedbar to display an Info node browser.
4062 This will add a speedbar major display mode."
4065 ;; Make sure that speedbar is active
4066 (speedbar-frame-mode 1)
4067 ;; Now, throw us into Info mode on speedbar.
4068 (speedbar-change-initial-expansion-list "Info")
4071 (defun Info-speedbar-hierarchy-buttons (directory depth &optional node)
4072 "Display an Info directory hierarchy in speedbar.
4073 DIRECTORY is the current directory in the attached frame.
4074 DEPTH is the current indentation depth.
4075 NODE is an optional argument that is used to represent the
4076 specific node to expand."
4078 (save-excursion (goto-char (point-min))
4079 (let ((case-fold-search t))
4080 (looking-at "Info Nodes:"))))
4081 ;; Update our "current node" maybe?
4083 ;; We cannot use the generic list code, that depends on all leaves
4084 ;; being known at creation time.
4086 (speedbar-with-writable (insert "Info Nodes:\n")))
4087 (let ((completions nil))
4088 (speedbar-select-attached-frame)
4089 (save-window-excursion
4091 (Info-speedbar-fetch-file-nodes (or node '"(dir)top"))))
4092 (select-frame (speedbar-current-frame))
4094 (speedbar-with-writable
4095 (dolist (completion completions)
4096 (speedbar-make-tag-line 'bracket ?+ 'Info-speedbar-expand-node
4099 'Info-speedbar-goto-node
4105 (defun Info-speedbar-goto-node (text node indent)
4106 "When user clicks on TEXT, go to an info NODE.
4107 The INDENT level is ignored."
4108 (speedbar-select-attached-frame)
4109 (let* ((buff (or (get-buffer "*info*")
4110 (progn (info) (get-buffer "*info*"))))
4111 (bwin (get-buffer-window buff 0)))
4114 (select-window bwin)
4115 (raise-frame (window-frame bwin)))
4116 (if speedbar-power-click
4117 (let ((pop-up-frames t)) (select-window (display-buffer buff)))
4118 (speedbar-select-attached-frame)
4119 (switch-to-buffer buff)))
4120 (if (not (string-match "^(\\([^)]+\\))\\([^.]+\\)$" node))
4121 (error "Invalid node %s" node)
4122 (Info-find-node (match-string 1 node) (match-string 2 node))
4123 ;; If we do a find-node, and we were in info mode, restore
4124 ;; the old default method. Once we are in info mode, it makes
4125 ;; sense to return to whatever method the user was using before.
4126 (if (string= speedbar-initial-expansion-list-name "Info")
4127 (speedbar-change-initial-expansion-list
4128 speedbar-previously-used-expansion-list-name)))))
4130 (defun Info-speedbar-expand-node (text token indent)
4131 "Expand the node the user clicked on.
4132 TEXT is the text of the button we clicked on, a + or - item.
4133 TOKEN is data related to this node (NAME . FILE).
4134 INDENT is the current indentation depth."
4135 (cond ((string-match "+" text) ;we have to expand this file
4136 (speedbar-change-expand-button-char ?-)
4137 (if (speedbar-with-writable
4139 (end-of-line) (forward-char 1)
4140 (Info-speedbar-hierarchy-buttons nil (1+ indent) token)))
4141 (speedbar-change-expand-button-char ?-)
4142 (speedbar-change-expand-button-char ??)))
4143 ((string-match "-" text) ;we have to contract this node
4144 (speedbar-change-expand-button-char ?+)
4145 (speedbar-delete-subblock indent))
4146 (t (error "Ooops... not sure what to do")))
4147 (speedbar-center-buffer-smartly))
4149 (defun Info-speedbar-fetch-file-nodes (nodespec)
4150 "Fetch the subnodes from the info NODESPEC.
4151 NODESPEC is a string of the form: (file)node."
4153 ;; Set up a buffer we can use to fake-out Info.
4154 (set-buffer (get-buffer-create " *info-browse-tmp*"))
4155 (if (not (equal major-mode 'Info-mode))
4157 ;; Get the node into this buffer
4158 (if (not (string-match "^(\\([^)]+\\))\\([^.]+\\)$" nodespec))
4159 (error "Invalid node specification %s" nodespec)
4160 (Info-find-node (match-string 1 nodespec) (match-string 2 nodespec)))
4161 ;; Scan the created buffer
4162 (goto-char (point-min))
4163 (let ((completions nil)
4164 (case-fold-search t)
4165 (thisfile (progn (string-match "^(\\([^)]+\\))" nodespec)
4166 (match-string 1 nodespec))))
4167 ;; Always skip the first one...
4168 (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
4169 (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
4170 (let ((name (match-string 1)))
4172 (if (looking-at " *\\(([^)]+)[^.\n]+\\)\\.")
4174 (if (looking-at " *\\(([^)]+)\\)\\.")
4175 (concat (match-string 1) "Top")
4176 (concat "(" thisfile ")"
4177 (if (looking-at " \\([^.]+\\).")
4181 (nreverse completions))))
4183 ;;; Info mode node listing
4184 ;; This is called by `speedbar-add-localized-speedbar-support'
4185 (defun Info-speedbar-buttons (buffer)
4186 "Create a speedbar display to help navigation in an Info file.
4187 BUFFER is the buffer speedbar is requesting buttons for."
4188 (if (save-excursion (goto-char (point-min))
4189 (let ((case-fold-search t))
4190 (not (looking-at "Info Nodes:"))))
4192 (Info-speedbar-hierarchy-buttons nil 0))
4194 (dolist (mess '("^First node in file$"
4195 "^No `.*' in index$"
4196 "^No cross-reference named"
4197 "^No cross.references in this node$"
4198 "^No current Info node$"
4199 "^No menu in this node$"
4200 "^No more items in menu$"
4202 "^No pointer \\(?:forward\\|backward\\) from this node$"
4203 "^No previous `i' command$"
4204 "^No previous items in menu$"
4205 "^No previous nodes$"
4206 "^No such item in menu$"
4207 "^No such node or anchor"
4209 "^Point neither on reference nor in menu item description$"
4210 "^This is the \\(?:first\\|last\\) Info node you looked at$"
4212 (add-to-list 'debug-ignored-errors mess))
4214 ;;;; Desktop support
4216 (defun Info-desktop-buffer-misc-data (desktop-dirname)
4217 "Auxiliary information to be saved in desktop file."
4218 (if (not (member Info-current-file '("apropos" "history" "toc")))
4219 (list Info-current-file Info-current-node)))
4221 (defun Info-restore-desktop-buffer (desktop-buffer-file-name
4223 desktop-buffer-misc)
4224 "Restore an Info buffer specified in a desktop file."
4225 (let ((first (nth 0 desktop-buffer-misc))
4226 (second (nth 1 desktop-buffer-misc)))
4227 (when (and first second)
4228 (when desktop-buffer-name
4229 (set-buffer (get-buffer-create desktop-buffer-name))
4231 (Info-find-node first second)
4234 (add-to-list 'desktop-buffer-mode-handlers
4235 '(Info-mode . Info-restore-desktop-buffer))
4239 ;; arch-tag: f2480fe2-2139-40c1-a49b-6314991164ac
4240 ;;; info.el ends here