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, 2006 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 "Face for unvisited Info cross-references."
136 (defface info-xref-visited
137 '((t :inherit
(link-visited info-xref
)))
138 "Face for visited Info cross-references."
142 (defcustom Info-fontify-visited-nodes t
143 "*Non-nil to fontify references to visited nodes in `info-xref-visited' face."
148 (defcustom Info-fontify-maximum-menu-size
100000
149 "*Maximum size of menu to fontify if `font-lock-mode' is non-nil."
153 (defcustom Info-use-header-line t
154 "*Non-nil means to put the beginning-of-node links in an Emacs header-line.
155 A header-line does not scroll with the rest of the buffer."
159 (defface info-header-xref
160 '((t :inherit info-xref
))
161 "Face for Info cross-references in a node header."
164 (defface info-header-node
165 '((t :inherit info-node
))
166 "Face for Info nodes in a node header."
169 (defvar Info-directory-list nil
170 "List of directories to search for Info documentation files.
171 If nil, meaning not yet initialized, Info uses the environment
172 variable INFOPATH to initialize it, or `Info-default-directory-list'
173 if there is no INFOPATH variable in the environment, or the
174 concatenation of the two if INFOPATH ends with a colon.
176 When `Info-directory-list' is initialized from the value of
177 `Info-default-directory-list', and Emacs is installed in one of the
178 standard directories, the directory of Info files that come with Emacs
179 is put last (so that local Info files override standard ones).
181 When `Info-directory-list' is initialized from the value of
182 `Info-default-directory-list', and Emacs is not installed in one
183 of the standard directories, the first element of the resulting
184 list is the directory where Emacs installs the Info files that
185 come with it. This is so that Emacs's own manual, which suits the
186 version of Emacs you are using, will always be found first. This
187 is useful when you install an experimental version of Emacs without
188 removing the standard installation.
190 If you want to override the order of directories in
191 `Info-default-directory-list', set INFOPATH in the environment.
193 If you run the Emacs executable from the `src' directory in the Emacs
194 source tree, and INFOPATH is not defined, the `info' directory in the
195 source tree is used as the first element of `Info-directory-list', in
196 place of the installation Info directory. This is useful when you run
197 a version of Emacs without installing it.")
199 (defcustom Info-additional-directory-list nil
200 "List of additional directories to search for Info documentation files.
201 These directories are searched after those in `Info-directory-list'."
202 :type
'(repeat directory
)
205 (defcustom Info-scroll-prefer-subnodes nil
206 "*If non-nil, \\<Info-mode-map>\\[Info-scroll-up] in a menu visits subnodes.
208 If this is non-nil, and you scroll far enough in a node that its menu
209 appears on the screen, the next \\<Info-mode-map>\\[Info-scroll-up]
210 moves to a subnode indicated by the following menu item. This means
211 that you visit a subnode before getting to the end of the menu.
213 Setting this option to nil results in behavior similar to the stand-alone
214 Info reader program, which visits the first subnode from the menu only
215 when you hit the end of the current node."
220 (defcustom Info-hide-note-references t
221 "*If non-nil, hide the tag and section reference in *note and * menu items.
222 If value is non-nil but not `hide', also replaces the \"*note\" with \"see\".
223 If value is non-nil but not t or `hide', the reference section is still shown.
224 `nil' completely disables this feature."
226 :type
'(choice (const :tag
"No hiding" nil
)
227 (const :tag
"Replace tag and hide reference" t
)
228 (const :tag
"Hide tag and reference" hide
)
229 (other :tag
"Only replace tag" tag
))
232 (defcustom Info-refill-paragraphs nil
233 "*If non-nil, attempt to refill paragraphs with hidden references.
234 This refilling may accidentally remove explicit line breaks in the Info
235 file, so be prepared for a few surprises if you enable this feature."
240 (defcustom Info-search-whitespace-regexp
"\\s-+"
241 "*If non-nil, regular expression to match a sequence of whitespace chars.
242 This applies to Info search for regular expressions.
243 You might want to use something like \"[ \\t\\r\\n]+\" instead.
244 In the Customization buffer, that is `[' followed by a space,
245 a tab, a carriage return (control-M), a newline, and `]+'."
249 (defcustom Info-isearch-search t
250 "*If non-nil, isearch in Info searches through multiple nodes.
251 Before leaving the initial Info node, where isearch was started,
252 it fails once with the error message [initial node], and with
253 subsequent C-s/C-r continues through other nodes without failing
254 with this error message in other nodes. When isearch fails for
255 the rest of the manual, it wraps aroung the whole manual and
256 restarts the search from the top/final node depending on
259 Setting this option to nil restores the default isearch behavior
260 with wrapping around the current Info node."
265 (defvar Info-isearch-initial-node nil
)
267 (defcustom Info-mode-hook
268 ;; Try to obey obsolete Info-fontify settings.
269 (unless (and (boundp 'Info-fontify
) (null Info-fontify
))
270 '(turn-on-font-lock))
271 "Hooks run when `Info-mode' is called."
275 (defcustom Info-selection-hook nil
276 "Hooks run when `Info-select-node' is called."
280 (defvar Info-edit-mode-hook nil
281 "Hooks run when `Info-edit-mode' is called.")
283 (defvar Info-current-file nil
284 "Info file that Info is now looking at, or nil.
285 This is the name that was specified in Info, not the actual file name.
286 It doesn't contain directory names or file name extensions added by Info.")
288 (defvar Info-current-subfile nil
289 "Info subfile that is actually in the *info* buffer now.
290 nil if current Info file is not split into subfiles.")
292 (defvar Info-current-node nil
293 "Name of node that Info is now looking at, or nil.")
295 (defvar Info-tag-table-marker nil
296 "Marker pointing at beginning of current Info file's tag table.
297 Marker points nowhere if file has no tag table.")
299 (defvar Info-tag-table-buffer nil
300 "Buffer used for indirect tag tables.")
302 (defvar Info-current-file-completions nil
303 "Cached completion list for current Info file.")
305 (defvar Info-file-supports-index-cookies nil
306 "Non-nil if current Info file supports index cookies.")
308 (defvar Info-index-alternatives nil
309 "List of possible matches for last `Info-index' command.")
311 (defvar Info-point-loc nil
312 "Point location within a selected node.
313 If string, the point is moved to the proper occurrence of the
314 name of the followed cross reference within a selected node.
315 If number, the point is moved to the corresponding line.")
317 (defvar Info-standalone nil
318 "Non-nil if Emacs was started solely as an Info browser.")
320 (defvar Info-suffix-list
321 ;; The MS-DOS list should work both when long file names are
322 ;; supported (Windows 9X), and when only 8+3 file names are available.
323 (if (eq system-type
'ms-dos
)
324 '( (".gz" .
"gunzip")
326 (".bz2" .
("bzip2" "-dc"))
329 (".info.Z" .
"gunzip")
330 (".info.gz" .
"gunzip")
331 ("-info.Z" .
"gunzip")
332 ("-info.gz" .
"gunzip")
333 ("/index.gz".
"gunzip")
334 ("/index.z" .
"gunzip")
340 '( (".info.Z".
"uncompress")
341 (".info.Y".
"unyabba")
342 (".info.gz".
"gunzip")
343 (".info.z".
"gunzip")
344 (".info.bz2" .
("bzip2" "-dc"))
346 ("-info.Z".
"uncompress")
347 ("-info.Y".
"unyabba")
348 ("-info.gz".
"gunzip")
349 ("-info.bz2" .
("bzip2" "-dc"))
350 ("-info.z".
"gunzip")
352 ("/index.Z".
"uncompress")
353 ("/index.Y".
"unyabba")
354 ("/index.gz".
"gunzip")
355 ("/index.z".
"gunzip")
356 ("/index.bz2".
("bzip2" "-dc"))
362 (".bz2" .
("bzip2" "-dc"))
364 "List of file name suffixes and associated decoding commands.
365 Each entry should be (SUFFIX . STRING); the file is given to
366 the command as standard input.
368 STRING may be a list of strings. In that case, the first element is
369 the command name, and the rest are arguments to that command.
371 If STRING is nil, no decoding is done.
372 Because the SUFFIXes are tried in order, the empty string should
373 be last in the list.")
375 ;; Concatenate SUFFIX onto FILENAME. SUFFIX should start with a dot.
376 ;; First, on MS-DOS with no long file names support, delete some of
377 ;; the extension in FILENAME to make room.
378 (defun info-insert-file-contents-1 (filename suffix lfn
)
379 (if lfn
; long file names are supported
380 (concat filename suffix
)
381 (let* ((sans-exts (file-name-sans-extension filename
))
382 ;; How long is the extension in FILENAME (not counting the dot).
383 (ext-len (max 0 (- (length filename
) (length sans-exts
) 1)))
385 ;; SUFFIX starts with a dot. If FILENAME already has one,
386 ;; get rid of the one in SUFFIX (unless suffix is empty).
387 (or (and (<= ext-len
0)
388 (not (eq (aref filename
(1- (length filename
))) ?.
)))
389 (= (length suffix
) 0)
390 (setq suffix
(substring suffix
1)))
391 ;; How many chars of that extension should we keep?
392 (setq ext-left
(min ext-len
(max 0 (- 3 (length suffix
)))))
393 ;; Get rid of the rest of the extension, and add SUFFIX.
394 (concat (substring filename
0 (- (length filename
)
395 (- ext-len ext-left
)))
398 (defun info-file-exists-p (filename)
399 (and (file-exists-p filename
)
400 (not (file-directory-p filename
))))
402 (defun info-insert-file-contents (filename &optional visit
)
403 "Insert the contents of an Info file in the current buffer.
404 Do the right thing if the file has been compressed or zipped."
405 (let* ((tail Info-suffix-list
)
406 (lfn (if (fboundp 'msdos-long-file-names
)
407 (msdos-long-file-names)
409 (check-short (and (fboundp 'msdos-long-file-names
)
411 fullname decoder done
)
412 (if (info-file-exists-p filename
)
413 ;; FILENAME exists--see if that name contains a suffix.
414 ;; If so, set DECODE accordingly.
418 (concat (regexp-quote (car (car tail
))) "$")
420 (setq tail
(cdr tail
)))
421 (setq fullname filename
422 decoder
(cdr (car tail
))))
423 ;; Try adding suffixes to FILENAME and see if we can find something.
424 (while (and tail
(not done
))
425 (setq fullname
(info-insert-file-contents-1 filename
426 (car (car tail
)) lfn
))
427 (if (info-file-exists-p fullname
)
429 ;; If we found a file with a suffix, set DECODER
430 ;; according to the suffix.
431 decoder
(cdr (car tail
)))
432 ;; When the MS-DOS port runs on Windows, we need to check
433 ;; the short variant of a long file name as well.
435 (setq fullname
(info-insert-file-contents-1 filename
436 (car (car tail
)) nil
))
437 (if (info-file-exists-p fullname
)
439 decoder
(cdr (car tail
))))))
440 (setq tail
(cdr tail
)))
442 (error "Can't find %s or any compressed version of it" filename
)))
443 ;; check for conflict with jka-compr
444 (if (and (jka-compr-installed-p)
445 (jka-compr-get-compression-info fullname
))
449 (insert-file-contents-literally fullname visit
)
450 (let ((buffer-read-only nil
)
451 (coding-system-for-write 'no-conversion
)
452 (default-directory (or (file-name-directory fullname
)
455 (setq decoder
(list decoder
)))
456 (apply 'call-process-region
(point-min) (point-max)
457 (car decoder
) t t nil
(cdr decoder
))))
458 (insert-file-contents fullname visit
))))
460 (defun Info-default-dirs ()
461 (let ((source (expand-file-name "info/" source-directory
))
462 (sibling (if installation-directory
463 (expand-file-name "info/" installation-directory
)
464 (if invocation-directory
465 (let ((infodir (expand-file-name
467 invocation-directory
)))
468 (if (file-exists-p infodir
)
470 (setq infodir
(expand-file-name
472 invocation-directory
))
473 (and (file-exists-p infodir
)
477 (if (and sibling
(file-exists-p sibling
))
478 ;; Uninstalled, Emacs builddir != srcdir.
480 ;; Uninstalled, builddir == srcdir
482 (if (or (member alternative Info-default-directory-list
)
483 ;; On DOS/NT, we use movable executables always,
484 ;; and we must always find the Info dir at run time.
485 (if (memq system-type
'(ms-dos windows-nt
))
487 ;; Use invocation-directory for Info
488 ;; only if we used it for exec-directory also.
489 (not (string= exec-directory
490 (expand-file-name "lib-src/"
491 installation-directory
))))
492 (not (file-exists-p alternative
)))
493 Info-default-directory-list
494 ;; `alternative' contains the Info files that came with this
495 ;; version, so we should look there first. `Info-insert-dir'
496 ;; currently expects to find `alternative' first on the list.
498 ;; Don't drop the last part, it might contain non-Emacs stuff.
499 ;; (reverse (cdr (reverse
500 Info-default-directory-list
)))) ;; )))
502 (defun info-initialize ()
503 "Initialize `Info-directory-list', if that hasn't been done yet."
504 (unless Info-directory-list
505 (let ((path (getenv "INFOPATH")))
506 (setq Info-directory-list
507 (prune-directory-list
509 (if (string-match ":\\'" path
)
510 (append (split-string (substring path
0 -
1)
511 (regexp-quote path-separator
))
513 (split-string path
(regexp-quote path-separator
)))
514 (Info-default-dirs)))))))
517 (defun info-other-window (&optional file-or-node
)
518 "Like `info' but show the Info buffer in another window."
519 (interactive (if current-prefix-arg
520 (list (read-file-name "Info file name: " nil nil t
))))
521 (let (same-window-buffer-names same-window-regexps
)
522 (info file-or-node
)))
524 ;;;###autoload (add-hook 'same-window-regexps "\\*info\\*\\(\\|<[0-9]+>\\)")
526 ;;;###autoload (put 'info 'info-file "emacs")
528 (defun info (&optional file-or-node buffer
)
529 "Enter Info, the documentation browser.
530 Optional argument FILE-OR-NODE specifies the file to examine;
531 the default is the top-level directory of Info.
532 Called from a program, FILE-OR-NODE may specify an Info node of the form
533 `(FILENAME)NODENAME'.
534 Optional argument BUFFER specifies the Info buffer name;
535 the default buffer name is *info*. If BUFFER exists,
536 just switch to BUFFER. Otherwise, create a new buffer
537 with the top-level Info directory.
539 In interactive use, a non-numeric prefix argument directs
540 this command to read a file name from the minibuffer.
541 A numeric prefix argument selects an Info buffer with the prefix number
542 appended to the Info buffer name.
544 The search path for Info files is in the variable `Info-directory-list'.
545 The top-level Info directory is made by combining all the files named `dir'
546 in all the directories in that path."
548 (if (and current-prefix-arg
(not (numberp current-prefix-arg
)))
549 (read-file-name "Info file name: " nil nil t
))
550 (if (numberp current-prefix-arg
)
551 (format "*info*<%s>" current-prefix-arg
))))
552 (pop-to-buffer (or buffer
"*info*"))
553 (if (and buffer
(not (eq major-mode
'Info-mode
)))
556 ;; If argument already contains parentheses, don't add another set
557 ;; since the argument will then be parsed improperly. This also
558 ;; has the added benefit of allowing node names to be included
559 ;; following the parenthesized filename.
561 (if (and (stringp file-or-node
) (string-match "(.*)" file-or-node
))
563 (concat "(" file-or-node
")")))
564 (if (and (zerop (buffer-size))
566 ;; If we just created the Info buffer, go to the directory.
570 (defun info-emacs-manual ()
571 "Display the Emacs manual in Info mode."
576 (defun info-standalone ()
577 "Run Emacs as a standalone Info reader.
578 Usage: emacs -f info-standalone [filename]
579 In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
580 (setq Info-standalone t
)
581 (if (and command-line-args-left
582 (not (string-match "^-" (car command-line-args-left
))))
585 (info (car command-line-args-left
))
586 (setq command-line-args-left
(cdr command-line-args-left
)))
587 (error (send-string-to-terminal
588 (format "%s\n" (if (eq (car-safe err
) 'error
)
590 (save-buffers-kill-emacs)))
593 ;; See if the accessible portion of the buffer begins with a node
594 ;; delimiter, and the node header line which follows matches REGEXP.
595 ;; Typically, this test will be followed by a loop that examines the
596 ;; rest of the buffer with (search-forward "\n\^_"), and it's a pity
597 ;; to have the overhead of this special test inside the loop.
599 ;; This function changes match-data, but supposedly the caller might
600 ;; want to use the results of re-search-backward.
602 ;; The return value is the value of point at the beginning of matching
603 ;; REGEXP, if the function succeeds, nil otherwise.
604 (defun Info-node-at-bob-matching (regexp)
605 (and (bobp) ; are we at beginning of buffer?
606 (looking-at "\^_") ; does it begin with node delimiter?
610 (forward-line 1) ; does the line after delimiter match REGEXP?
611 (re-search-backward regexp beg t
))))
613 (defun Info-find-file (filename &optional noerror
)
614 "Return expanded FILENAME, or t, if FILENAME is \"dir\".
615 Optional second argument NOERROR, if t, means if file is not found
616 just return nil (no error)."
617 ;; Convert filename to lower case if not found as specified.
619 (if (stringp filename
)
620 (let (temp temp-downcase found
)
621 (setq filename
(substitute-in-file-name filename
))
623 ((string= (downcase filename
) "dir")
626 (let ((dirs (if (string-match "^\\./" filename
)
627 ;; If specified name starts with `./'
628 ;; then just try current directory.
630 (if (file-name-absolute-p filename
)
631 ;; No point in searching for an
632 ;; absolute file name
634 (if Info-additional-directory-list
635 (append Info-directory-list
636 Info-additional-directory-list
)
637 Info-directory-list
)))))
638 ;; Search the directory list for file FILENAME.
639 (while (and dirs
(not found
))
640 (setq temp
(expand-file-name filename
(car dirs
)))
642 (expand-file-name (downcase filename
) (car dirs
)))
643 ;; Try several variants of specified name.
644 (let ((suffix-list Info-suffix-list
)
645 (lfn (if (fboundp 'msdos-long-file-names
)
646 (msdos-long-file-names)
648 (while (and suffix-list
(not found
))
649 (cond ((info-file-exists-p
650 (info-insert-file-contents-1
651 temp
(car (car suffix-list
)) lfn
))
654 (info-insert-file-contents-1
655 temp-downcase
(car (car suffix-list
)) lfn
))
656 (setq found temp-downcase
))
657 ((and (fboundp 'msdos-long-file-names
)
660 (info-insert-file-contents-1
661 temp
(car (car suffix-list
)) nil
)))
663 (setq suffix-list
(cdr suffix-list
))))
664 (setq dirs
(cdr dirs
))))))
666 (setq filename found
)
669 (error "Info file %s does not exist" filename
)))
671 (and (member filename
'(apropos history toc
)) filename
)))
673 (defun Info-find-node (filename nodename
&optional no-going-back
)
674 "Go to an Info node specified as separate FILENAME and NODENAME.
675 NO-GOING-BACK is non-nil if recovering from an error in this function;
676 it says do not attempt further (recursive) error recovery."
678 (setq filename
(Info-find-file filename
))
679 ;; Go into Info buffer.
680 (or (eq major-mode
'Info-mode
) (pop-to-buffer "*info*"))
681 ;; Record the node we are leaving, if we were in one.
682 (and (not no-going-back
)
685 (cons (list Info-current-file Info-current-node
(point))
687 (Info-find-node-2 filename nodename no-going-back
))
690 (defun Info-on-current-buffer (&optional nodename
)
691 "Use Info mode to browse the current Info buffer.
692 With a prefix arg, this queries for the node name to visit first;
693 otherwise, that defaults to `Top'."
695 (list (if current-prefix-arg
696 (completing-read "Node name: " (Info-build-node-completions)
698 (unless nodename
(setq nodename
"Top"))
701 (set (make-local-variable 'Info-current-file
)
703 ;; If called on a non-file buffer, make a fake file name.
704 (concat default-directory
(buffer-name))))
705 (Info-find-node-2 nil nodename
))
707 ;; It's perhaps a bit nasty to kill the *info* buffer to force a re-read,
708 ;; but at least it keeps this routine (which is only for the benefit of
709 ;; makeinfo-buffer) out of the way of normal operations.
711 (defun Info-revert-find-node (filename nodename
)
712 "Go to an Info node FILENAME and NODENAME, re-reading disk contents.
713 When *info* is already displaying FILENAME and NODENAME, the window position
714 is preserved, if possible."
715 (pop-to-buffer "*info*")
716 (let ((old-filename Info-current-file
)
717 (old-nodename Info-current-node
)
718 (pcolumn (current-column))
719 (pline (count-lines (point-min) (line-beginning-position)))
720 (wline (count-lines (point-min) (window-start)))
721 (old-history Info-history
)
722 (new-history (and Info-current-file
723 (list Info-current-file Info-current-node
(point)))))
724 (kill-buffer (current-buffer))
725 (Info-find-node filename nodename
)
726 (setq Info-history old-history
)
727 (if (and (equal old-filename Info-current-file
)
728 (equal old-nodename Info-current-node
))
730 ;; note goto-line is no good, we want to measure from point-min
731 (goto-char (point-min))
733 (set-window-start (selected-window) (point))
734 (goto-char (point-min))
736 (move-to-column pcolumn
))
737 ;; only add to the history when coming from a different file+node
739 (setq Info-history
(cons new-history Info-history
))))))
741 (defun Info-find-in-tag-table-1 (marker regexp case-fold
)
742 "Find a node in a tag table.
743 MARKER specifies the buffer and position to start searching at.
744 REGEXP is a regular expression matching nodes or references. Its first
745 group should match `Node:' or `Ref:'.
746 CASE-FOLD t means search for a case-insensitive match.
747 If a match was found, value is a list (FOUND-ANCHOR POS MODE), where
748 FOUND-ANCHOR is non-nil if a `Ref:' was matched, POS is the position
749 where the match was found, and MODE is `major-mode' of the buffer in
750 which the match was found."
751 (let ((case-fold-search case-fold
))
753 (set-buffer (marker-buffer marker
))
758 (when (re-search-forward regexp nil t
)
759 (list (string-equal "Ref:" (match-string 1))
760 (+ (point-min) (read (current-buffer)))
763 (defun Info-find-in-tag-table (marker regexp
)
764 "Find a node in a tag table.
765 MARKER specifies the buffer and position to start searching at.
766 REGEXP is a regular expression matching nodes or references. Its first
767 group should match `Node:' or `Ref:'.
768 If a match was found, value is a list (FOUND-ANCHOR POS MODE), where
769 FOUND-ANCHOR is non-nil if a `Ref:' was matched, POS is the position
770 where the match was found, and MODE is `major-mode' of the buffer in
771 which the match was found.
772 This function tries to find a case-sensitive match first, then a
773 case-insensitive match is tried."
774 (let ((result (Info-find-in-tag-table-1 marker regexp nil
)))
775 (when (null (car result
))
776 (setq result
(Info-find-in-tag-table-1 marker regexp t
)))
779 (defun Info-find-node-in-buffer-1 (regexp case-fold
)
780 "Find a node or anchor in the current buffer.
781 REGEXP is a regular expression matching nodes or references. Its first
782 group should match `Node:' or `Ref:'.
783 CASE-FOLD t means search for a case-insensitive match.
784 Value is the position at which a match was found, or nil if not found."
785 (let ((case-fold-search case-fold
)
788 (when (Info-node-at-bob-matching regexp
)
789 (setq found
(point)))
790 (while (and (not found
)
791 (search-forward "\n\^_" nil t
))
795 (when (re-search-backward regexp beg t
)
797 (setq found
(point)))))
800 (defun Info-find-node-in-buffer (regexp)
801 "Find a node or anchor in the current buffer.
802 REGEXP is a regular expression matching nodes or references. Its first
803 group should match `Node:' or `Ref:'.
804 Value is the position at which a match was found, or nil if not found.
805 This function looks for a case-sensitive match first. If none is found,
806 a case-insensitive match is tried."
807 (or (Info-find-node-in-buffer-1 regexp nil
)
808 (Info-find-node-in-buffer-1 regexp t
)))
810 (defun Info-find-node-2 (filename nodename
&optional no-going-back
)
811 (buffer-disable-undo (current-buffer))
812 (or (eq major-mode
'Info-mode
)
815 (setq Info-current-node nil
)
817 (let ((case-fold-search t
)
819 ;; Switch files if necessary
821 (equal Info-current-file filename
)
822 (let ((buffer-read-only nil
))
823 (setq Info-current-file nil
824 Info-current-subfile nil
825 Info-current-file-completions nil
826 buffer-file-name nil
)
831 ((eq filename
'apropos
)
832 (insert-buffer-substring " *info-apropos*"))
833 ((eq filename
'history
)
834 (insert-buffer-substring " *info-history*"))
836 (insert-buffer-substring " *info-toc*"))
838 (info-insert-file-contents filename nil
)
839 (setq default-directory
(file-name-directory filename
))))
840 (set-buffer-modified-p nil
)
842 ;; Check makeinfo version for index cookie support
844 (goto-char (point-min))
846 (if (and (re-search-forward
847 "makeinfo version \\([0-9]+.[0-9]+\\)"
848 (line-beginning-position 3) t
)
849 (not (version< (match-string 1) "4.7")))
852 (set (make-local-variable 'Info-file-supports-index-cookies
) found
))
854 ;; See whether file has a tag table. Record the location if yes.
855 (goto-char (point-max))
857 ;; Use string-equal, not equal, to ignore text props.
858 (if (not (or (string-equal nodename
"*")
860 (search-forward "\^_\nEnd tag table\n" nil t
))))
862 ;; We have a tag table. Find its beginning.
863 ;; Is this an indirect file?
864 (search-backward "\nTag table:\n")
868 (looking-at "(Indirect)\n"))
869 ;; It is indirect. Copy it to another buffer
870 ;; and record that the tag table is in that buffer.
871 (let ((buf (current-buffer))
873 (or Info-tag-table-buffer
874 (generate-new-buffer " *info tag table*"))))
875 (setq Info-tag-table-buffer tagbuf
)
878 (buffer-disable-undo (current-buffer))
879 (setq case-fold-search t
)
881 (insert-buffer-substring buf
))
882 (set-marker Info-tag-table-marker
883 (match-end 0) tagbuf
))
884 (set-marker Info-tag-table-marker pos
)))
885 (set-marker Info-tag-table-marker nil
))
886 (setq Info-current-file
888 ((eq filename t
) "dir")
891 ;; Use string-equal, not equal, to ignore text props.
892 (if (string-equal nodename
"*")
893 (progn (setq Info-current-node nodename
)
894 (Info-set-mode-line))
897 ;; 1. Anchor found in tag table
898 ;; 2. Anchor *not* in tag table
900 ;; 3. Node found in tag table
901 ;; 4. Node *not* found in tag table, but found in file
902 ;; 5. Node *not* in tag table, and *not* in file
904 ;; *Or* the same, but in an indirect subfile.
906 ;; Search file for a suitable node.
907 (let ((guesspos (point-min))
908 (regexp (concat "\\(Node:\\|Ref:\\) *\\("
909 (if (stringp nodename
)
910 (regexp-quote nodename
)
912 "\\) *[,\t\n\177]")))
916 ;; First, search a tag table, if any
917 (when (marker-position Info-tag-table-marker
)
918 (let* ((m Info-tag-table-marker
)
919 (found (Info-find-in-tag-table m regexp
)))
922 ;; FOUND is (ANCHOR POS MODE).
923 (setq guesspos
(nth 1 found
))
925 ;; If this is an indirect file, determine which
926 ;; file really holds this node and read it in.
927 (unless (eq (nth 2 found
) 'Info-mode
)
928 ;; Note that the current buffer must be the
929 ;; *info* buffer on entry to
930 ;; Info-read-subfile. Thus the hackery above.
931 (setq guesspos
(Info-read-subfile guesspos
)))
935 (goto-char (setq anchorpos guesspos
))
938 ;; Else we may have a node, which we search for:
939 (goto-char (max (point-min)
940 (- (byte-to-position guesspos
) 1000)))
942 ;; Now search from our advised position (or from beg of
943 ;; buffer) to find the actual node. First, check
944 ;; whether the node is right where we are, in case the
945 ;; buffer begins with a node.
946 (let ((pos (Info-find-node-in-buffer regexp
)))
951 (when (string-match "\\([^.]+\\)\\." nodename
)
952 (let (Info-point-loc)
954 filename
(match-string 1 nodename
) no-going-back
))
958 ;; No such anchor in tag table or node in tag table or file
959 (error "No such node or anchor: %s" nodename
))
962 (goto-char (point-min))
964 (let ((new-history (list Info-current-file
965 (substring-no-properties nodename
))))
966 ;; Add anchors to the history too
967 (setq Info-history-list
969 (delete new-history Info-history-list
))))
970 (goto-char anchorpos
))
971 ((numberp Info-point-loc
)
972 (forward-line (1- Info-point-loc
))
973 (setq Info-point-loc nil
))
974 ((stringp Info-point-loc
)
975 (Info-find-index-name Info-point-loc
)
976 (setq Info-point-loc nil
))))))
977 ;; If we did not finish finding the specified node,
978 ;; go back to the previous one.
979 (or Info-current-node no-going-back
(null Info-history
)
980 (let ((hist (car Info-history
)))
981 (setq Info-history
(cdr Info-history
))
982 (Info-find-node (nth 0 hist
) (nth 1 hist
) t
)
983 (goto-char (nth 2 hist
))))))
985 ;; Cache the contents of the (virtual) dir file, once we have merged
986 ;; it for the first time, so we can save time subsequently.
987 (defvar Info-dir-contents nil
)
989 ;; Cache for the directory we decided to use for the default-directory
990 ;; of the merged dir text.
991 (defvar Info-dir-contents-directory nil
)
993 ;; Record the file attributes of all the files from which we
994 ;; constructed Info-dir-contents.
995 (defvar Info-dir-file-attributes nil
)
997 (defvar Info-dir-file-name nil
)
999 ;; Construct the Info directory node by merging the files named `dir'
1000 ;; from various directories. Set the *info* buffer's
1001 ;; default-directory to the first directory we actually get any text
1003 (defun Info-insert-dir ()
1004 (if (and Info-dir-contents Info-dir-file-attributes
1005 ;; Verify that none of the files we used has changed
1006 ;; since we used it.
1008 (mapcar (lambda (elt)
1009 (let ((curr (file-attributes
1011 (file-truename (car elt
)))))
1013 ;; Don't compare the access time.
1014 (if curr
(setcar (nthcdr 4 curr
) 0))
1015 (setcar (nthcdr 4 (cdr elt
)) 0)
1016 (equal (cdr elt
) curr
)))
1017 Info-dir-file-attributes
))))
1019 (insert Info-dir-contents
)
1020 (goto-char (point-min)))
1021 (let ((dirs (if Info-additional-directory-list
1022 (append Info-directory-list
1023 Info-additional-directory-list
)
1024 Info-directory-list
))
1025 (dir-file-attrs nil
)
1026 ;; Bind this in case the user sets it to nil.
1027 (case-fold-search t
)
1028 ;; This is set non-nil if we find a problem in some input files.
1030 buffers buffer others nodes dirs-done
)
1032 ;; Search the directory list for the directory file.
1034 (let ((truename (file-truename (expand-file-name (car dirs
)))))
1035 (or (member truename dirs-done
)
1036 (member (directory-file-name truename
) dirs-done
)
1037 ;; Try several variants of specified name.
1038 ;; Try upcasing, appending `.info', or both.
1042 (progn (setq file
(expand-file-name "dir" truename
))
1043 (file-attributes file
))
1044 (progn (setq file
(expand-file-name "DIR" truename
))
1045 (file-attributes file
))
1046 (progn (setq file
(expand-file-name "dir.info" truename
))
1047 (file-attributes file
))
1048 (progn (setq file
(expand-file-name "DIR.INFO" truename
))
1049 (file-attributes file
)))))
1052 (cons (directory-file-name truename
)
1057 (message "Composing main Info directory..."))
1058 (set-buffer (generate-new-buffer " info dir"))
1061 (insert-file-contents file
)
1062 (set (make-local-variable 'Info-dir-file-name
)
1064 (push (current-buffer) buffers
)
1065 (push (cons file attrs
) dir-file-attrs
))
1066 (error (kill-buffer (current-buffer))))))))
1068 (set (make-local-variable 'Info-dir-contents-directory
)
1069 (file-name-as-directory (car dirs
))))
1070 (setq dirs
(cdr dirs
))))
1073 (error "Can't find the Info directory node"))
1075 ;; Distinguish the dir file that comes with Emacs from all the
1076 ;; others. Yes, that is really what this is supposed to do.
1077 ;; The definition of `Info-directory-list' puts it first on that
1078 ;; list and so last in `buffers' at this point.
1079 (setq buffer
(car (last buffers
))
1080 others
(delq buffer buffers
))
1082 ;; Insert the entire original dir file as a start; note that we've
1083 ;; already saved its default directory to use as the default
1084 ;; directory for the whole concatenation.
1085 (save-excursion (insert-buffer-substring buffer
))
1087 ;; Look at each of the other buffers one by one.
1088 (dolist (other others
)
1089 (let (this-buffer-nodes)
1090 ;; In each, find all the menus.
1091 (with-current-buffer other
1092 (goto-char (point-min))
1093 ;; Find each menu, and add an elt to NODES for it.
1094 (while (re-search-forward "^\\* Menu:" nil t
)
1095 (while (and (zerop (forward-line 1)) (eolp)))
1098 (re-search-backward "^\^_")
1099 (search-forward "Node: ")
1100 (setq nodename
(Info-following-node-name))
1101 (search-forward "\n\^_" nil
'move
)
1104 (push (list nodename other beg end
) this-buffer-nodes
)))
1105 (if (assoc-string "top" this-buffer-nodes t
)
1106 (setq nodes
(nconc this-buffer-nodes nodes
))
1108 (message "No `top' node in %s" Info-dir-file-name
)))))
1109 ;; Add to the main menu a menu item for each other node.
1110 (re-search-forward "^\\* Menu:")
1112 (let ((menu-items '("top"))
1113 (end (save-excursion (search-forward "\^_" nil t
) (point))))
1114 (dolist (node nodes
)
1115 (let ((nodename (car node
)))
1117 (or (member (downcase nodename
) menu-items
)
1118 (re-search-forward (concat "^\\* +"
1119 (regexp-quote nodename
)
1123 (insert "* " nodename
"::" "\n")
1124 (push nodename menu-items
)))))))
1125 ;; Now take each node of each of the other buffers
1126 ;; and merge it into the main buffer.
1127 (dolist (node nodes
)
1128 (let ((case-fold-search t
)
1129 (nodename (car node
)))
1130 (goto-char (point-min))
1131 ;; Find the like-named node in the main buffer.
1132 (if (re-search-forward (concat "^\^_.*\n.*Node: "
1133 (regexp-quote nodename
)
1137 (search-forward "\n\^_" nil
'move
)
1140 ;; If none exists, add one.
1141 (goto-char (point-max))
1142 (insert "\^_\nFile: dir\tNode: " nodename
"\n\n* Menu:\n\n"))
1143 ;; Merge the text from the other buffer's menu
1144 ;; into the menu in the like-named node in the main buffer.
1145 (apply 'insert-buffer-substring
(cdr node
))))
1146 (Info-dir-remove-duplicates)
1147 ;; Kill all the buffers we just made, including the special one excised.
1148 (mapc 'kill-buffer
(cons buffer buffers
))
1149 (goto-char (point-min))
1151 (message "Composing main Info directory...problems encountered, see `*Messages*'")
1152 (message "Composing main Info directory...done"))
1153 (set (make-local-variable 'Info-dir-contents
) (buffer-string))
1154 (set (make-local-variable 'Info-dir-file-attributes
) dir-file-attrs
)))
1155 (setq default-directory Info-dir-contents-directory
))
1157 (defvar Info-streamline-headings
1158 '(("Emacs" .
"Emacs")
1159 ("Programming" .
"Programming")
1160 ("Libraries" .
"Libraries")
1161 ("World Wide Web\\|Net Utilities" .
"Net Utilities"))
1162 "List of elements (RE . NAME) to merge headings matching RE to NAME.")
1164 (defun Info-dir-remove-duplicates ()
1166 (goto-char (point-min))
1167 ;; Remove duplicate headings in the same menu.
1168 (while (search-forward "\n* Menu:" nil t
)
1169 (setq limit
(save-excursion (search-forward "\n\^_" nil t
)))
1170 ;; Look for the next heading to unify.
1171 (while (re-search-forward "^\\(\\w.*\\)\n\\*" limit t
)
1172 (let ((name (match-string 1))
1173 (start (match-beginning 0))
1175 ;; Check whether this heading should be streamlined.
1177 (dolist (x Info-streamline-headings
)
1178 (when (string-match (car x
) name
)
1180 (setq re
(car x
)))))
1181 (if re
(replace-match name t t nil
1))
1182 (goto-char (if (re-search-forward "^[^* \n\t]" limit t
)
1184 (or limit
(point-max))))
1185 ;; Look for other headings of the same category and merge them.
1187 (while (re-search-forward "^\\(\\w.*\\)\n\\*" limit t
)
1188 (when (if re
(save-match-data (string-match re
(match-string 1)))
1189 (equal name
(match-string 1)))
1191 ;; Delete redundant heading.
1192 (delete-region (match-beginning 0) (point))
1193 ;; Push the entries onto `text'.
1195 (delete-and-extract-region
1197 (if (re-search-forward "^[^* \n\t]" nil t
)
1199 (or limit
(point-max)))) entries
))))
1200 ;; Insert the entries just found.
1201 (while (= (line-beginning-position 0) (1- (point)))
1203 (dolist (entry (nreverse entries
))
1205 (while (= (line-beginning-position 0) (1- (point)))
1206 (delete-region (1- (point)) (point))))
1208 ;; Now remove duplicate entries under the same heading.
1212 (while (re-search-forward "^* \\([^:\n]+:\\(:\\|[^.\n]+\\).\\)"
1214 ;; Fold case straight away; `member-ignore-case' here wasteful.
1215 (let ((x (downcase (match-string 1))))
1217 (delete-region (match-beginning 0)
1218 (progn (re-search-forward "^[^ \t]" nil t
)
1219 (match-beginning 0)))
1220 (push x seen
))))))))))
1222 ;; Note that on entry to this function the current-buffer must be the
1223 ;; *info* buffer; not the info tags buffer.
1224 (defun Info-read-subfile (nodepos)
1225 ;; NODEPOS is either a position (in the Info file as a whole,
1226 ;; not relative to a subfile) or the name of a subfile.
1229 (if (numberp nodepos
)
1231 (set-buffer (marker-buffer Info-tag-table-marker
))
1232 (goto-char (point-min))
1233 (or (looking-at "\^_")
1234 (search-forward "\n\^_"))
1237 (while (not (looking-at "\^_"))
1240 thisfilepos thisfilename
)
1241 (search-forward ": ")
1242 (setq thisfilename
(buffer-substring beg
(- (point) 2)))
1243 (setq thisfilepos
(+ (point-min) (read (current-buffer))))
1244 ;; read in version 19 stops at the end of number.
1245 ;; Advance to the next line.
1247 (if (> thisfilepos nodepos
)
1249 (setq lastfilename thisfilename
)
1250 (setq lastfilepos thisfilepos
))
1251 (forward-line 1)))))
1252 (setq lastfilename nodepos
)
1253 (setq lastfilepos
0))
1254 ;; Assume previous buffer is in Info-mode.
1255 ;; (set-buffer (get-buffer "*info*"))
1256 (or (equal Info-current-subfile lastfilename
)
1257 (let ((buffer-read-only nil
))
1258 (setq buffer-file-name nil
)
1261 (info-insert-file-contents lastfilename
)
1262 (set-buffer-modified-p nil
)
1263 (setq Info-current-subfile lastfilename
)))
1264 ;; Widen in case we are in the same subfile as before.
1266 (goto-char (point-min))
1267 (if (looking-at "\^_")
1269 (search-forward "\n\^_"))
1270 (if (numberp nodepos
)
1271 (+ (- nodepos lastfilepos
) (point)))))
1273 (defun Info-unescape-quotes (value)
1274 "Unescape double quotes and backslashes in VALUE."
1277 (while (string-match "[^\\\"]*\\(\\\\\\)[\\\\\"]" unquote start
)
1278 (setq unquote
(replace-match "" t t unquote
1))
1279 (setq start
(- (match-end 0) 1)))
1282 ;; As of Texinfo 4.6, makeinfo writes constructs like
1283 ;; \0\h[image param=value ...\h\0]
1284 ;; into the Info file for handling images.
1285 (defun Info-split-parameter-string (parameter-string)
1286 "Return alist of (\"KEY\" . \"VALUE\") from PARAMETER-STRING; a
1287 whitespace separated list of KEY=VALUE pairs. If VALUE contains
1288 whitespace or double quotes, it must be quoted in double quotes and
1289 any double quotes or backslashes must be escaped (\\\",\\\\)."
1292 (while (string-match
1293 "\\s *\\([^=]+\\)=\\(?:\\([^\\s \"]+\\)\\|\\(?:\"\\(\\(?:[^\\\"]\\|\\\\[\\\\\"]\\)*\\)\"\\)\\)"
1294 parameter-string start
)
1295 (setq start
(match-end 0))
1296 (push (cons (match-string 1 parameter-string
)
1297 (or (match-string 2 parameter-string
)
1298 (Info-unescape-quotes
1299 (match-string 3 parameter-string
))))
1303 (defun Info-display-images-node ()
1304 "Display images in current node."
1306 (let ((inhibit-read-only t
)
1307 (case-fold-search t
))
1308 (goto-char (point-min))
1309 (while (re-search-forward
1310 "\\(\0\b[[]image\\(\\(?:[^\b]\\|[^\0]+\b\\)*\\)\0\b[]]\\)"
1312 (let* ((start (match-beginning 1))
1313 (parameter-alist (Info-split-parameter-string (match-string 2)))
1314 (src (cdr (assoc-string "src" parameter-alist
)))
1315 (image-file (if src
(if (file-name-absolute-p src
) src
1316 (concat default-directory src
))
1318 (image (if (file-exists-p image-file
)
1319 (create-image image-file
)
1321 (if (not (get-text-property start
'display
))
1322 (add-text-properties
1323 start
(point) `(display ,image rear-nonsticky
(display)))))))
1324 (set-buffer-modified-p nil
)))
1326 ;; Texinfo 4.7 adds cookies of the form ^@^H[NAME CONTENTS ^@^H].
1327 ;; Hide any construct of the general form ^@[^@-^_][ ... ^@[^@-^_]],
1328 ;; including one optional trailing newline.
1329 (defun Info-hide-cookies-node ()
1330 "Hide unrecognized cookies in current node."
1332 (let ((inhibit-read-only t
)
1333 (case-fold-search t
))
1334 (goto-char (point-min))
1335 (while (re-search-forward
1336 "\\(\0[\0-\37][[][^\0]*\0[\0-\37][]]\n?\\)"
1338 (let* ((start (match-beginning 1)))
1339 (if (not (get-text-property start
'invisible
))
1340 (put-text-property start
(point) 'invisible t
)))))
1341 (set-buffer-modified-p nil
)))
1343 (defun Info-select-node ()
1344 "Select the Info node that point is in."
1345 ;; Bind this in case the user sets it to nil.
1346 (let ((case-fold-search t
))
1348 ;; Find beginning of node.
1349 (if (search-backward "\n\^_" nil
'move
)
1351 (if (looking-at "\^_")
1353 (signal 'search-failed
(list "\n\^_"))))
1354 ;; Get nodename spelled as it is in the node.
1355 (re-search-forward "Node:[ \t]*")
1356 (setq Info-current-node
1357 (buffer-substring-no-properties (point)
1359 (skip-chars-forward "^,\t\n")
1361 (Info-set-mode-line)
1362 ;; Find the end of it, and narrow.
1364 (let (active-expression)
1365 ;; Narrow to the node contents
1366 (narrow-to-region (point)
1367 (if (re-search-forward "\n[\^_\f]" nil t
)
1370 (if (looking-at "[\n\^_\f]*execute: ")
1372 (goto-char (match-end 0))
1373 (setq active-expression
1374 (read (current-buffer))))))
1376 (if Info-enable-active-nodes
(eval active-expression
))
1377 ;; Add a new unique history item to full history list
1378 (let ((new-history (list Info-current-file Info-current-node
)))
1379 (setq Info-history-list
1380 (cons new-history
(delete new-history Info-history-list
)))
1381 (setq Info-history-forward nil
))
1382 (if (not (eq Info-fontify-maximum-menu-size nil
))
1383 (Info-fontify-node))
1384 (Info-display-images-node)
1385 (Info-hide-cookies-node)
1386 (run-hooks 'Info-selection-hook
)))))
1388 (defvar Info-mode-line-node-keymap
1389 (let ((map (make-sparse-keymap)))
1390 (define-key map
[mode-line mouse-1
] 'Info-scroll-up
)
1391 (define-key map
[mode-line mouse-3
] 'Info-scroll-down
)
1393 "Keymap to put on the Info node name in the mode line.")
1395 (defun Info-set-mode-line ()
1396 (setq mode-line-buffer-identification
1397 (nconc (propertized-buffer-identification "%b")
1401 (if (stringp Info-current-file
)
1402 (replace-regexp-in-string
1403 "%" "%%" (file-name-nondirectory Info-current-file
))
1404 (format "*%S*" Info-current-file
))
1406 (if Info-current-node
1407 (propertize (replace-regexp-in-string
1408 "%" "%%" Info-current-node
)
1409 'face
'mode-line-buffer-id
1411 "mouse-1: scroll forward, mouse-3: scroll back"
1412 'mouse-face
'mode-line-highlight
1413 'local-map Info-mode-line-node-keymap
)
1416 ;; Go to an Info node specified with a filename-and-nodename string
1417 ;; of the sort that is found in pointers in nodes.
1419 ;; Don't autoload this function: the correct entry point for other packages
1420 ;; to use is `info'. --Stef
1422 (defun Info-goto-node (nodename &optional fork
)
1423 "Go to Info node named NODENAME. Give just NODENAME or (FILENAME)NODENAME.
1424 If NODENAME is of the form (FILENAME)NODENAME, the node is in the Info file
1425 FILENAME; otherwise, NODENAME should be in the current Info file (or one of
1427 Completion is available, but only for node names in the current Info file.
1428 If FORK is non-nil (interactively with a prefix arg), show the node in
1430 If FORK is a string, it is the name to use for the new buffer."
1431 (interactive (list (Info-read-node-name "Go to node: ") current-prefix-arg
))
1435 (clone-buffer (concat "*info-" (if (stringp fork
) fork nodename
) "*") t
)))
1437 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
1439 (setq filename
(if (= (match-beginning 1) (match-end 1))
1441 (match-string 2 nodename
))
1442 nodename
(match-string 3 nodename
))
1443 (let ((trim (string-match "\\s +\\'" filename
)))
1444 (if trim
(setq filename
(substring filename
0 trim
))))
1445 (let ((trim (string-match "\\s +\\'" nodename
)))
1446 (if trim
(setq nodename
(substring nodename
0 trim
))))
1447 (if transient-mark-mode
(deactivate-mark))
1448 (Info-find-node (if (equal filename
"") nil filename
)
1449 (if (equal nodename
"") "Top" nodename
))))
1451 (defvar Info-read-node-completion-table
)
1453 (defun Info-read-node-name-2 (string path-and-suffixes action
)
1454 "Virtual completion table for file names input in Info node names.
1455 PATH-AND-SUFFIXES is a pair of lists, (DIRECTORIES . SUFFIXES)."
1457 (suffixes (remove "" (cdr path-and-suffixes
)))
1458 (suffix (concat (regexp-opt suffixes t
) "\\'"))
1459 (string-dir (file-name-directory string
))
1461 (if (file-name-absolute-p string
)
1462 (list (file-name-directory string
))
1463 (car path-and-suffixes
))))
1466 (setq dir default-directory
))
1467 (if string-dir
(setq dir
(expand-file-name string-dir dir
)))
1468 (when (file-directory-p dir
)
1469 (dolist (file (file-name-all-completions
1470 (file-name-nondirectory string
) dir
))
1471 ;; If the file name has no suffix or a standard suffix,
1473 (and (or (null (file-name-extension file
))
1474 (string-match suffix file
))
1475 ;; But exclude subfiles of split Info files.
1476 (not (string-match "-[0-9]+\\'" file
))
1477 ;; And exclude backup files.
1478 (not (string-match "~\\'" file
))
1479 (push (if string-dir
(concat string-dir file
) file
) names
))
1480 ;; If the file name ends in a standard suffix,
1481 ;; add the unsuffixed name as a completion option.
1482 (when (string-match suffix file
)
1483 (setq file
(substring file
0 (match-beginning 0)))
1484 (push (if string-dir
(concat string-dir file
) file
) names
)))))
1486 ((eq action t
) (all-completions string names
))
1487 ((null action
) (try-completion string names
))
1488 (t (test-completion string names
)))))
1490 ;; This function is used as the "completion table" while reading a node name.
1491 ;; It does completion using the alist in Info-read-node-completion-table
1492 ;; unless STRING starts with an open-paren.
1493 (defun Info-read-node-name-1 (string predicate code
)
1495 ;; First complete embedded file names.
1496 ((string-match "\\`([^)]*\\'" string
)
1497 (let ((file (substring string
1)))
1500 (let ((comp (try-completion file
'Info-read-node-name-2
1501 (cons Info-directory-list
1502 (mapcar 'car Info-suffix-list
)))))
1504 ((eq comp t
) (concat string
")"))
1505 (comp (concat "(" comp
)))))
1507 (all-completions file
'Info-read-node-name-2
1508 (cons Info-directory-list
1509 (mapcar 'car Info-suffix-list
))))
1511 ;; If a file name was given, then any node is fair game.
1512 ((string-match "\\`(" string
)
1514 ((eq code nil
) string
)
1517 ;; Otherwise use Info-read-node-completion-table.
1519 (try-completion string Info-read-node-completion-table predicate
))
1521 (all-completions string Info-read-node-completion-table predicate
))
1523 (test-completion string Info-read-node-completion-table predicate
))))
1525 ;; Arrange to highlight the proper letters in the completion list buffer.
1526 (put 'Info-read-node-name-1
'completion-base-size-function
1528 (if (string-match "\\`([^)]*\\'"
1529 (or completion-common-substring
1530 (minibuffer-completion-contents)))
1534 (defun Info-read-node-name (prompt &optional default
)
1535 (let* ((completion-ignore-case t
)
1536 (Info-read-node-completion-table (Info-build-node-completions))
1537 (nodename (completing-read prompt
'Info-read-node-name-1 nil t
)))
1538 (if (equal nodename
"")
1540 (Info-read-node-name prompt
))
1543 (defun Info-build-node-completions ()
1544 (or Info-current-file-completions
1546 ;; Bind this in case the user sets it to nil.
1547 (case-fold-search t
)
1548 (node-regexp "Node: *\\([^,\n]*\\) *[,\n\t]"))
1551 (if (marker-buffer Info-tag-table-marker
)
1552 (let ((marker Info-tag-table-marker
))
1553 (set-buffer (marker-buffer marker
))
1556 (while (re-search-forward "\n\\(Node\\|Ref\\): \\(.*\\)\177" nil t
)
1558 (cons (list (match-string-no-properties 2))
1561 (goto-char (point-min))
1562 ;; If the buffer begins with a node header, process that first.
1563 (if (Info-node-at-bob-matching node-regexp
)
1564 (setq compl
(list (match-string-no-properties 1))))
1565 ;; Now for the rest of the nodes.
1566 (while (search-forward "\n\^_" nil t
)
1568 (let ((beg (point)))
1570 (if (re-search-backward node-regexp beg t
)
1572 (cons (list (match-string-no-properties 1))
1574 (setq compl
(cons '("*") compl
))
1575 (set (make-local-variable 'Info-current-file-completions
) compl
))))
1577 (defun Info-restore-point (hl)
1578 "If this node has been visited, restore the point value when we left."
1580 (if (and (equal (nth 0 (car hl
)) Info-current-file
)
1581 ;; Use string-equal, not equal, to ignore text props.
1582 (string-equal (nth 1 (car hl
)) Info-current-node
))
1584 (goto-char (nth 2 (car hl
)))
1585 (setq hl nil
)) ;terminate the while at next iter
1586 (setq hl
(cdr hl
)))))
1588 (defvar Info-search-history nil
1589 "The history list for `Info-search'.")
1591 (defvar Info-search-case-fold nil
1592 "The value of `case-fold-search' from previous `Info-search' command.")
1594 (defun Info-search (regexp &optional bound noerror count direction
)
1595 "Search for REGEXP, starting from point, and select node it's found in.
1596 If DIRECTION is `backward', search in the reverse direction."
1597 (interactive (list (read-string
1598 (if Info-search-history
1599 (format "Regexp search%s (default %s): "
1600 (if case-fold-search
"" " case-sensitively")
1601 (car Info-search-history
))
1602 (format "Regexp search%s: "
1603 (if case-fold-search
"" " case-sensitively")))
1604 nil
'Info-search-history
)))
1605 (when transient-mark-mode
1607 (when (equal regexp
"")
1608 (setq regexp
(car Info-search-history
)))
1610 (let (found beg-found give-up
1611 (backward (eq direction
'backward
))
1612 (onode Info-current-node
)
1613 (ofile Info-current-file
)
1615 (opoint-min (point-min))
1616 (opoint-max (point-max))
1617 (ostart (window-start))
1618 (osubfile Info-current-subfile
))
1619 (setq Info-search-case-fold case-fold-search
)
1624 ;; Hide Info file header for backward search
1625 (narrow-to-region (save-excursion
1626 (goto-char (point-min))
1627 (search-forward "\n\^_")
1630 (while (and (not give-up
)
1634 (isearch-range-invisible found beg-found
)
1635 (isearch-range-invisible beg-found found
))
1636 ;; Skip node header line
1637 (and (save-excursion (forward-line -
1)
1639 (forward-line (if backward -
1 1)))
1640 ;; Skip Tag Table node
1642 (and (search-backward "\^_" nil t
)
1644 "\^_\n\\(Tag Table\\|Local Variables\\)"))))))
1645 (let ((search-spaces-regexp Info-search-whitespace-regexp
))
1647 (re-search-backward regexp bound t
)
1648 (re-search-forward regexp bound t
))
1649 (setq found
(point) beg-found
(if backward
(match-end 0)
1650 (match-beginning 0)))
1651 (setq give-up t
))))))
1653 (when (and isearch-mode Info-isearch-search
1654 (not Info-isearch-initial-node
)
1656 (or give-up
(and found
(not (and (> found opoint-min
)
1657 (< found opoint-max
))))))
1658 (signal 'search-failed
(list regexp
"initial node")))
1660 ;; If no subfiles, give error now.
1662 (if (null Info-current-subfile
)
1663 (let ((search-spaces-regexp Info-search-whitespace-regexp
))
1665 (re-search-backward regexp
)
1666 (re-search-forward regexp
)))
1669 (if (and bound
(not found
))
1670 (signal 'search-failed
(list regexp
)))
1672 (unless (or found bound
)
1674 ;; Try other subfiles.
1677 (set-buffer (marker-buffer Info-tag-table-marker
))
1678 (goto-char (point-min))
1679 (search-forward "\n\^_\nIndirect:")
1681 (narrow-to-region (point)
1682 (progn (search-forward "\n\^_")
1684 (goto-char (point-min))
1685 ;; Find the subfile we just searched.
1686 (search-forward (concat "\n" osubfile
": "))
1688 (forward-line (if backward
0 1))
1689 (if backward
(forward-char -
1))
1690 ;; Make a list of all following subfiles.
1691 ;; Each elt has the form (VIRT-POSITION . SUBFILENAME).
1692 (while (not (if backward
(bobp) (eobp)))
1694 (re-search-backward "\\(^.*\\): [0-9]+$")
1695 (re-search-forward "\\(^.*\\): [0-9]+$"))
1696 (goto-char (+ (match-end 1) 2))
1697 (setq list
(cons (cons (+ (point-min)
1698 (read (current-buffer)))
1699 (match-string-no-properties 1))
1701 (goto-char (if backward
1702 (1- (match-beginning 0))
1703 (1+ (match-end 0)))))
1704 ;; Put in forward order
1705 (setq list
(nreverse list
))))
1707 (message "Searching subfile %s..." (cdr (car list
)))
1708 (Info-read-subfile (car (car list
)))
1710 ;; Hide Info file header for backward search
1711 (narrow-to-region (save-excursion
1712 (goto-char (point-min))
1713 (search-forward "\n\^_")
1716 (goto-char (point-max)))
1717 (setq list
(cdr list
))
1718 (setq give-up nil found nil
)
1719 (while (and (not give-up
)
1723 (isearch-range-invisible found beg-found
)
1724 (isearch-range-invisible beg-found found
))
1725 ;; Skip node header line
1726 (and (save-excursion (forward-line -
1)
1728 (forward-line (if backward -
1 1)))
1729 ;; Skip Tag Table node
1731 (and (search-backward "\^_" nil t
)
1733 "\^_\n\\(Tag Table\\|Local Variables\\)"))))))
1734 (let ((search-spaces-regexp Info-search-whitespace-regexp
))
1736 (re-search-backward regexp nil t
)
1737 (re-search-forward regexp nil t
))
1738 (setq found
(point) beg-found
(if backward
(match-end 0)
1739 (match-beginning 0)))
1747 (signal 'search-failed
(list regexp
))))
1749 (progn (Info-read-subfile osubfile
)
1752 (set-window-start (selected-window) ostart
)))))
1754 (if (and (string= osubfile Info-current-subfile
)
1755 (> found opoint-min
)
1756 (< found opoint-max
))
1757 ;; Search landed in the same node
1761 (save-match-data (Info-select-node)))
1763 ;; Use string-equal, not equal, to ignore text props.
1764 (or (and (string-equal onode Info-current-node
)
1765 (equal ofile Info-current-file
))
1766 (and isearch-mode isearch-wrapped
1767 (eq opoint
(if isearch-forward opoint-min opoint-max
)))
1768 (setq Info-history
(cons (list ofile onode opoint
)
1771 (defun Info-search-case-sensitively ()
1772 "Search for a regexp case-sensitively."
1774 (let ((case-fold-search nil
))
1775 (call-interactively 'Info-search
)))
1777 (defun Info-search-next ()
1778 "Search for next regexp from a previous `Info-search' command."
1780 (let ((case-fold-search Info-search-case-fold
))
1781 (if Info-search-history
1782 (Info-search (car Info-search-history
))
1783 (call-interactively 'Info-search
))))
1785 (defun Info-search-backward (regexp &optional bound noerror count
)
1786 "Search for REGEXP in the reverse direction."
1787 (interactive (list (read-string
1788 (if Info-search-history
1789 (format "Regexp search%s backward (default %s): "
1790 (if case-fold-search
"" " case-sensitively")
1791 (car Info-search-history
))
1792 (format "Regexp search%s backward: "
1793 (if case-fold-search
"" " case-sensitively")))
1794 nil
'Info-search-history
)))
1795 (Info-search regexp bound noerror count
'backward
))
1797 (defun Info-isearch-search ()
1798 (if Info-isearch-search
1799 (lambda (string &optional bound noerror count
)
1801 (Info-search (concat "\\b" (replace-regexp-in-string
1803 (replace-regexp-in-string
1804 "^\\W+\\|\\W+$" "" string
)
1808 (unless isearch-forward
'backward
))
1809 (Info-search (if isearch-regexp string
(regexp-quote string
))
1811 (unless isearch-forward
'backward
))
1813 (let ((isearch-search-fun-function nil
))
1814 (isearch-search-fun))))
1816 (defun Info-isearch-wrap ()
1817 (if Info-isearch-search
1818 (if Info-isearch-initial-node
1820 (if isearch-forward
(Info-top-node) (Info-final-node))
1821 (goto-char (if isearch-forward
(point-min) (point-max))))
1822 (setq Info-isearch-initial-node Info-current-node
)
1823 (setq isearch-wrapped nil
))
1824 (goto-char (if isearch-forward
(point-min) (point-max)))))
1826 (defun Info-isearch-push-state ()
1828 (Info-isearch-pop-state cmd
',Info-current-file
',Info-current-node
)))
1830 (defun Info-isearch-pop-state (cmd file node
)
1831 (or (and (equal Info-current-file file
)
1832 (equal Info-current-node node
))
1833 (progn (Info-find-node file node
) (sit-for 0))))
1835 (defun Info-isearch-start ()
1836 (setq Info-isearch-initial-node nil
))
1838 (defun Info-extract-pointer (name &optional errorname
)
1839 "Extract the value of the node-pointer named NAME.
1840 If there is none, use ERRORNAME in the error message;
1841 if ERRORNAME is nil, just return nil."
1842 ;; Bind this in case the user sets it to nil.
1843 (let ((case-fold-search t
))
1845 (goto-char (point-min))
1846 (let ((bound (point)))
1848 (cond ((re-search-backward
1849 (concat name
":" (Info-following-node-name-re)) bound t
)
1850 (match-string-no-properties 1))
1851 ((not (eq errorname t
))
1852 (error "Node has no %s"
1853 (capitalize (or errorname name
)))))))))
1855 (defun Info-following-node-name-re (&optional allowedchars
)
1856 "Return a regexp matching a node name.
1857 ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
1858 saying which chars may appear in the node name.
1859 Submatch 1 is the complete node name.
1860 Submatch 2 if non-nil is the parenthesized file name part of the node name.
1861 Submatch 3 is the local part of the node name.
1862 End of submatch 0, 1, and 3 are the same, so you can safely concat."
1863 (concat "[ \t]*" ;Skip leading space.
1864 "\\(\\(([^)]+)\\)?" ;Node name can start with a file name.
1865 "\\([" (or allowedchars
"^,\t\n") "]*" ;Any number of allowed chars.
1866 "[" (or allowedchars
"^,\t\n") " ]" ;The last char can't be a space.
1867 "\\|\\)\\)")) ;Allow empty node names.
1869 ;;; For compatibility; other files have used this name.
1870 (defun Info-following-node-name ()
1871 (and (looking-at (Info-following-node-name-re))
1872 (match-string-no-properties 1)))
1875 "Go to the next node of this node."
1877 ;; In case another window is currently selected
1878 (save-window-excursion
1879 (or (eq major-mode
'Info-mode
) (pop-to-buffer "*info*"))
1880 (Info-goto-node (Info-extract-pointer "next"))))
1883 "Go to the previous node of this node."
1885 ;; In case another window is currently selected
1886 (save-window-excursion
1887 (or (eq major-mode
'Info-mode
) (pop-to-buffer "*info*"))
1888 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous"))))
1890 (defun Info-up (&optional same-file
)
1891 "Go to the superior node of this node.
1892 If SAME-FILE is non-nil, do not move to a different Info file."
1894 ;; In case another window is currently selected
1895 (save-window-excursion
1896 (or (eq major-mode
'Info-mode
) (pop-to-buffer "*info*"))
1897 (let ((old-node Info-current-node
)
1898 (old-file Info-current-file
)
1899 (node (Info-extract-pointer "up")) p
)
1901 (string-match "^(" node
)
1902 (error "Up node is in another Info file"))
1903 (Info-goto-node node
)
1905 (goto-char (point-min))
1906 (if (and (stringp old-file
)
1907 (search-forward "\n* Menu:" nil t
)
1909 (if (string-equal old-node
"Top")
1910 (concat "\n\\*[^:]+: +(" (file-name-nondirectory old-file
) ")")
1911 (concat "\n\\* +\\(" (regexp-quote old-node
)
1912 ":\\|[^:]+: +" (regexp-quote old-node
) "\\)"))
1914 (progn (beginning-of-line) (if (looking-at "^\\* ") (forward-char 2)))
1916 (Info-restore-point Info-history
)))))
1918 (defun Info-history-back ()
1919 "Go back in the history to the last node visited."
1922 (error "This is the first Info node you looked at"))
1923 (let ((history-forward
1924 (cons (list Info-current-file Info-current-node
(point))
1925 Info-history-forward
))
1926 filename nodename opoint
)
1927 (setq filename
(car (car Info-history
)))
1928 (setq nodename
(car (cdr (car Info-history
))))
1929 (setq opoint
(car (cdr (cdr (car Info-history
)))))
1930 (setq Info-history
(cdr Info-history
))
1931 (Info-find-node filename nodename
)
1932 (setq Info-history
(cdr Info-history
))
1933 (setq Info-history-forward history-forward
)
1934 (goto-char opoint
)))
1936 (defalias 'Info-last
'Info-history-back
)
1938 (defun Info-history-forward ()
1939 "Go forward in the history of visited nodes."
1941 (or Info-history-forward
1942 (error "This is the last Info node you looked at"))
1943 (let ((history-forward (cdr Info-history-forward
))
1944 filename nodename opoint
)
1945 (setq filename
(car (car Info-history-forward
)))
1946 (setq nodename
(car (cdr (car Info-history-forward
))))
1947 (setq opoint
(car (cdr (cdr (car Info-history-forward
)))))
1948 (Info-find-node filename nodename
)
1949 (setq Info-history-forward history-forward
)
1950 (goto-char opoint
)))
1953 (defun Info-directory ()
1954 "Go to the Info directory node."
1956 (Info-find-node "dir" "top"))
1958 (defun Info-history ()
1959 "Go to a node with a menu of visited nodes."
1961 (let ((curr-file Info-current-file
)
1962 (curr-node Info-current-node
)
1964 (with-current-buffer (get-buffer-create " *info-history*")
1965 (let ((inhibit-read-only t
))
1967 (goto-char (point-min))
1968 (insert "\n\^_\nFile: history, Node: Top, Up: (dir)\n\n")
1969 (insert "Recently Visited Nodes\n**********************\n\n")
1970 (insert "* Menu:\n\n")
1971 (let ((hl (delete '("history" "Top") Info-history-list
)))
1973 (let ((file (nth 0 (car hl
)))
1974 (node (nth 1 (car hl
))))
1975 (if (and (equal file curr-file
)
1976 (equal node curr-node
))
1979 (insert "* " node
": ("
1980 (propertize (or (file-name-directory file
) "") 'invisible t
)
1981 (file-name-nondirectory file
)
1983 (setq hl
(cdr hl
))))))
1984 (Info-find-node 'history
"Top")
1985 (goto-char (or p
(point-min)))))
1988 "Go to a node with table of contents of the current Info file.
1989 Table of contents is created from the tree structure of menus."
1991 (if (stringp Info-current-file
)
1992 (let ((curr-file (substring-no-properties Info-current-file
))
1993 (curr-node (substring-no-properties Info-current-node
))
1995 (with-current-buffer (get-buffer-create " *info-toc*")
1996 (let ((inhibit-read-only t
)
1997 (node-list (Info-build-toc curr-file
)))
1999 (goto-char (point-min))
2000 (insert "\n\^_\nFile: toc, Node: Top, Up: (dir)\n\n")
2001 (insert "Table of Contents\n*****************\n\n")
2002 (insert "*Note Top: (" curr-file
")Top.\n")
2004 (nth 2 (assoc "Top" node-list
)) ; get Top nodes
2005 node-list
0 curr-file
))
2007 (let ((Info-hide-note-references 'hide
)
2008 (Info-fontify-visited-nodes nil
))
2010 (setq Info-current-file
'toc Info-current-node
"Top")
2011 (goto-char (point-min))
2012 (narrow-to-region (or (re-search-forward "\n[\^_\f]\n" nil t
)
2017 (goto-char (point-min))
2018 (if (setq p
(search-forward (concat "*Note " curr-node
":") nil t
))
2019 (setq p
(- p
(length curr-node
) 2))))
2020 (Info-find-node 'toc
"Top")
2021 (goto-char (or p
(point-min))))))
2023 (defun Info-insert-toc (nodes node-list level curr-file
)
2024 "Insert table of contents with references to nodes."
2025 (let ((section "Top"))
2027 (let ((node (assoc (car nodes
) node-list
)))
2028 (unless (member (nth 1 node
) (list nil section
))
2029 (insert (setq section
(nth 1 node
)) "\n"))
2030 (insert (make-string level ?
\t))
2031 (insert "*Note " (car nodes
) ": (" curr-file
")" (car nodes
) ".\n")
2032 (Info-insert-toc (nth 2 node
) node-list
(1+ level
) curr-file
)
2033 (setq nodes
(cdr nodes
))))))
2035 (defun Info-build-toc (file)
2036 "Build table of contents from menus of Info FILE and its subfiles."
2038 (let* ((file (and (stringp file
) (Info-find-file file
)))
2039 (default-directory (or (and (stringp file
)
2040 (file-name-directory file
))
2042 (main-file (and (stringp file
) file
))
2043 (sections '(("Top" "Top")))
2045 (while (or main-file subfiles
)
2046 (or main-file
(message "Searching subfile %s..." (car subfiles
)))
2048 (info-insert-file-contents (or main-file
(car subfiles
)))
2049 (goto-char (point-min))
2050 (while (and (search-forward "\n\^_\nFile:" nil
'move
)
2051 (search-forward "Node: " nil
'move
))
2052 (let ((nodename (substring-no-properties (Info-following-node-name)))
2053 (bound (- (or (save-excursion (search-forward "\n\^_" nil t
))
2057 (when (and (not (Info-index-node nodename file
))
2058 (re-search-forward "^\\* Menu:" bound t
))
2061 (setq bound
(or (and (equal nodename
"Top")
2064 "^[ \t-]*The Detailed Node Listing" nil t
)))
2066 (while (< (point) bound
)
2069 ((looking-at "^\\* +[^:]+:")
2072 (let ((menu-node-name (substring-no-properties
2073 (Info-extract-menu-node-name))))
2074 (setq menu-items
(cons menu-node-name menu-items
))
2075 (if (equal nodename
"Top")
2077 (cons (list menu-node-name section
) sections
)))))
2078 ;; Other non-empty strings in the Top node are section names
2079 ((and (equal nodename
"Top")
2080 (looking-at "^\\([^ \t\n*=.-][^:\n]*\\)"))
2081 (setq section
(match-string-no-properties 1))))
2083 (beginning-of-line)))
2084 (setq nodes
(cons (list nodename
2085 (cadr (assoc nodename sections
))
2086 (nreverse menu-items
))
2091 (goto-char (point-min))
2092 (if (search-forward "\n\^_\nIndirect:" nil t
)
2093 (let ((bound (save-excursion (search-forward "\n\^_" nil t
))))
2094 (while (re-search-forward "^\\(.*\\): [0-9]+$" bound t
)
2095 (setq subfiles
(cons (match-string-no-properties 1)
2097 (setq subfiles
(nreverse subfiles
)
2099 (setq subfiles
(cdr subfiles
))))
2103 (defun Info-follow-reference (footnotename &optional fork
)
2104 "Follow cross reference named FOOTNOTENAME to the node it refers to.
2105 FOOTNOTENAME may be an abbreviation of the reference name.
2106 If FORK is non-nil (interactively with a prefix arg), show the node in
2107 a new Info buffer. If FORK is a string, it is the name to use for the
2110 (let ((completion-ignore-case t
)
2111 (case-fold-search t
)
2112 completions default alt-default
(start-point (point)) str i bol eol
)
2114 ;; Store end and beginning of line.
2120 (goto-char (point-min))
2121 (while (re-search-forward "\\*note[ \n\t]+\\([^:]*\\):" nil t
)
2122 (setq str
(match-string-no-properties 1))
2123 ;; See if this one should be the default.
2125 (<= (match-beginning 0) start-point
)
2126 (<= start-point
(point))
2128 ;; See if this one should be the alternate default.
2129 (and (null alt-default
)
2130 (and (<= bol
(match-beginning 0))
2132 (setq alt-default t
))
2134 (while (setq i
(string-match "[ \n\t]+" str i
))
2135 (setq str
(concat (substring str
0 i
) " "
2136 (substring str
(match-end 0))))
2138 ;; Record as a completion and perhaps as default.
2139 (if (eq default t
) (setq default str
))
2140 (if (eq alt-default t
) (setq alt-default str
))
2141 ;; Don't add this string if it's a duplicate.
2142 (or (assoc-string str completions t
)
2143 (push str completions
))))
2144 ;; If no good default was found, try an alternate.
2146 (setq default alt-default
))
2147 ;; If only one cross-reference found, then make it default.
2148 (if (eq (length completions
) 1)
2149 (setq default
(car completions
)))
2151 (let ((input (completing-read (if default
2153 "Follow reference named (default "
2155 "Follow reference named: ")
2156 completions nil t
)))
2157 (list (if (equal input
"")
2158 default input
) current-prefix-arg
))
2159 (error "No cross-references in this node"))))
2161 (unless footnotename
2162 (error "No reference was specified"))
2164 (let (target i
(str (concat "\\*note " (regexp-quote footnotename
)))
2165 (case-fold-search t
))
2166 (while (setq i
(string-match " " str i
))
2167 (setq str
(concat (substring str
0 i
) "[ \t\n]+" (substring str
(1+ i
))))
2170 ;; Move point to the beginning of reference if point is on reference
2171 (or (looking-at "\\*note[ \n\t]+")
2172 (and (looking-back "\\*note[ \n\t]+")
2173 (goto-char (match-beginning 0)))
2174 (if (and (save-excursion
2175 (goto-char (+ (point) 5)) ; skip a possible *note
2176 (re-search-backward "\\*note[ \n\t]+" nil t
)
2178 (<= (point) (match-end 0)))
2179 (goto-char (match-beginning 0))))
2180 ;; Go to the reference closest to point
2181 (let ((next-ref (save-excursion (and (re-search-forward str nil t
)
2182 (+ (match-beginning 0) 5))))
2183 (prev-ref (save-excursion (and (re-search-backward str nil t
)
2184 (+ (match-beginning 0) 5)))))
2185 (goto-char (cond ((and next-ref prev-ref
)
2186 (if (< (abs (- next-ref
(point)))
2187 (abs (- prev-ref
(point))))
2189 ((or next-ref prev-ref
))
2190 ((error "No cross-reference named %s" footnotename
))))
2191 (setq target
(Info-extract-menu-node-name t
))))
2192 (while (setq i
(string-match "[ \t\n]+" target i
))
2193 (setq target
(concat (substring target
0 i
) " "
2194 (substring target
(match-end 0))))
2196 (Info-goto-node target fork
)))
2198 (defconst Info-menu-entry-name-re
"\\(?:[^:]\\|:[^:,.;() \t\n]\\)*"
2199 ;; We allow newline because this is also used in Info-follow-reference,
2200 ;; where the xref name might be wrapped over two lines.
2201 "Regexp that matches a menu entry name upto but not including the colon.
2202 Because of ambiguities, this should be concatenated with something like
2203 `:' and `Info-following-node-name-re'.")
2205 (defun Info-extract-menu-node-name (&optional multi-line index-node
)
2206 (skip-chars-forward " \t\n")
2207 (when (looking-at (concat Info-menu-entry-name-re
":\\(:\\|"
2208 (Info-following-node-name-re
2210 (index-node "^,\t\n")
2211 (multi-line "^.,\t")
2215 "\\.\\(?:[ \t\n]+(line +\\([0-9]+\\))\\)?"
2218 (setq Info-point-loc
2219 (if (match-beginning 5)
2220 (string-to-number (match-string 5))
2221 (buffer-substring-no-properties
2222 (match-beginning 0) (1- (match-beginning 1)))))
2223 ;;; Uncomment next line to use names of cross-references in non-index nodes:
2224 ;;; (setq Info-point-loc
2225 ;;; (buffer-substring (match-beginning 0) (1- (match-beginning 1))))
2227 (replace-regexp-in-string
2229 (or (match-string-no-properties 2)
2230 ;; If the node name is the menu entry name (using `entry::').
2231 (buffer-substring-no-properties
2232 (match-beginning 0) (1- (match-beginning 1)))))))
2234 ;; No one calls this.
2235 ;;(defun Info-menu-item-sequence (list)
2237 ;; (Info-menu (car list))
2238 ;; (setq list (cdr list))))
2240 (defvar Info-complete-menu-buffer
)
2241 (defvar Info-complete-next-re nil
)
2242 (defvar Info-complete-nodes nil
)
2243 (defvar Info-complete-cache nil
)
2245 (defconst Info-node-spec-re
2246 (concat (Info-following-node-name-re "^.,:") "[,:.]")
2247 "Regexp to match the text after a : until the terminating `.'.")
2249 (defun Info-complete-menu-item (string predicate action
)
2250 ;; This uses two dynamically bound variables:
2251 ;; - `Info-complete-menu-buffer' which contains the buffer in which
2252 ;; is the menu of items we're trying to complete.
2253 ;; - `Info-complete-next-re' which, if non-nil, indicates that we should
2254 ;; also look for menu items in subsequent nodes as long as those
2255 ;; nodes' names match `Info-complete-next-re'. This feature is currently
2257 ;; - `Info-complete-nodes' which, if non-nil, indicates that we should
2258 ;; also look for menu items in these nodes. This feature is currently
2259 ;; only used for completion in Info-index.
2261 ;; Note that `Info-complete-menu-buffer' could be current already,
2262 ;; so we want to save point.
2264 (set-buffer Info-complete-menu-buffer
)
2265 (let ((completion-ignore-case t
)
2266 (case-fold-search t
)
2267 (orignode Info-current-node
)
2269 (goto-char (point-min))
2270 (search-forward "\n* Menu:")
2271 (if (not (memq action
'(nil t
)))
2273 (concat "\n\\* +" (regexp-quote string
) ":") nil t
)
2274 (let ((pattern (concat "\n\\* +\\("
2275 (regexp-quote string
)
2276 Info-menu-entry-name-re
"\\):" Info-node-spec-re
))
2278 (complete-nodes Info-complete-nodes
))
2280 (if (and (equal (nth 0 Info-complete-cache
) Info-current-file
)
2281 (equal (nth 1 Info-complete-cache
) Info-current-node
)
2282 (equal (nth 2 Info-complete-cache
) Info-complete-next-re
)
2283 (equal (nth 5 Info-complete-cache
) Info-complete-nodes
)
2284 (let ((prev (nth 3 Info-complete-cache
)))
2285 (eq t
(compare-strings string
0 (length prev
)
2287 ;; We can reuse the previous list.
2288 (setq completions
(nth 4 Info-complete-cache
))
2289 ;; The cache can't be used.
2292 (while (re-search-forward pattern nil t
)
2293 (push (match-string-no-properties 1)
2295 ;; Check subsequent nodes if applicable.
2296 (or (and Info-complete-next-re
2297 (setq nextnode
(Info-extract-pointer "next" t
))
2298 (string-match Info-complete-next-re nextnode
))
2300 (setq complete-nodes
(cdr complete-nodes
)
2301 nextnode
(car complete-nodes
)))))
2302 (Info-goto-node nextnode
))
2303 ;; Go back to the start node (for the next completion).
2304 (unless (equal Info-current-node orignode
)
2305 (Info-goto-node orignode
))
2306 ;; Update the cache.
2307 (set (make-local-variable 'Info-complete-cache
)
2308 (list Info-current-file Info-current-node
2309 Info-complete-next-re string completions
2310 Info-complete-nodes
)))
2312 (all-completions string completions predicate
)
2313 (try-completion string completions predicate
)))))))
2316 (defun Info-menu (menu-item &optional fork
)
2317 "Go to the node pointed to by the menu item named (or abbreviated) MENU-ITEM.
2318 The menu item should one of those listed in the current node's menu.
2319 Completion is allowed, and the default menu item is the one point is on.
2320 If FORK is non-nil (interactively with a prefix arg), show the node in
2321 a new Info buffer. If FORK is a string, it is the name to use for the
2324 (let ((completions '())
2325 ;; If point is within a menu item, use that item as the default
2330 (case-fold-search t
))
2332 (goto-char (point-min))
2333 (if (not (search-forward "\n* menu:" nil t
))
2334 (error "No menu in this node"))
2340 (if (re-search-backward (concat "\n\\* +\\("
2341 Info-menu-entry-name-re
2343 (setq default
(match-string-no-properties 1))))))
2346 (setq item
(let ((completion-ignore-case t
)
2347 (Info-complete-menu-buffer (current-buffer)))
2348 (completing-read (if default
2349 (format "Menu item (default %s): "
2352 'Info-complete-menu-item nil t
)))
2353 ;; we rely on the fact that completing-read accepts an input
2354 ;; of "" even when the require-match argument is true and ""
2355 ;; is not a valid possibility
2356 (if (string= item
"")
2361 (list item current-prefix-arg
))))
2362 ;; there is a problem here in that if several menu items have the same
2363 ;; name you can only go to the node of the first with this command.
2364 (Info-goto-node (Info-extract-menu-item menu-item
) (if fork menu-item
)))
2366 (defun Info-extract-menu-item (menu-item)
2367 (setq menu-item
(regexp-quote menu-item
))
2368 (let ((case-fold-search t
))
2370 (let ((case-fold-search t
))
2371 (goto-char (point-min))
2372 (or (search-forward "\n* menu:" nil t
)
2373 (error "No menu in this node"))
2374 (or (re-search-forward (concat "\n\\* +" menu-item
":") nil t
)
2375 (re-search-forward (concat "\n\\* +" menu-item
) nil t
)
2376 (error "No such item in menu"))
2379 (Info-extract-menu-node-name nil
(Info-index-node))))))
2381 ;; If COUNT is nil, use the last item in the menu.
2382 (defun Info-extract-menu-counting (count)
2383 (let ((case-fold-search t
))
2385 (let ((case-fold-search t
))
2386 (goto-char (point-min))
2387 (or (search-forward "\n* menu:" nil t
)
2388 (error "No menu in this node"))
2390 (or (search-forward "\n* " nil t count
)
2391 (error "Too few items in menu"))
2392 (while (search-forward "\n* " nil t
)
2394 (Info-extract-menu-node-name nil
(Info-index-node))))))
2396 (defun Info-nth-menu-item ()
2397 "Go to the node of the Nth menu item.
2398 N is the digit argument used to invoke this command."
2401 (Info-extract-menu-counting
2402 (- (aref (this-command-keys) (1- (length (this-command-keys)))) ?
0))))
2404 (defun Info-top-node ()
2405 "Go to the Top node of this file."
2407 (Info-goto-node "Top"))
2409 (defun Info-final-node ()
2410 "Go to the final node in this file."
2412 (Info-goto-node "Top")
2413 (let ((Info-history nil
)
2414 (case-fold-search t
))
2415 ;; Go to the last node in the menu of Top.
2416 (Info-goto-node (Info-extract-menu-counting nil
))
2417 ;; If the last node in the menu is not last in pointer structure,
2418 ;; move forward until we can't go any farther.
2419 (while (Info-forward-node t t
) nil
)
2420 ;; Then keep moving down to last subnode, unless we reach an index.
2421 (while (and (not (Info-index-node))
2422 (save-excursion (search-forward "\n* Menu:" nil t
)))
2423 (Info-goto-node (Info-extract-menu-counting nil
)))))
2425 (defun Info-forward-node (&optional not-down no-error
)
2426 "Go forward one node, considering all nodes as forming one sequence."
2428 (goto-char (point-min))
2430 (let ((case-fold-search t
))
2431 ;; three possibilities, in order of priority:
2432 ;; 1. next node is in a menu in this node (but not in an index)
2433 ;; 2. next node is next at same level
2434 ;; 3. next node is up and next
2435 (cond ((and (not not-down
)
2436 (save-excursion (search-forward "\n* menu:" nil t
))
2437 (not (Info-index-node)))
2438 (Info-goto-node (Info-extract-menu-counting 1))
2440 ((save-excursion (search-backward "next:" nil t
))
2443 ((and (save-excursion (search-backward "up:" nil t
))
2444 ;; Use string-equal, not equal, to ignore text props.
2445 (not (string-equal (downcase (Info-extract-pointer "up"))
2447 (let ((old-node Info-current-node
))
2449 (let (Info-history success
)
2451 (setq success
(Info-forward-node t no-error
))
2452 (or success
(Info-goto-node old-node
))))))
2454 (t (error "No pointer forward from this node")))))
2456 (defun Info-backward-node ()
2457 "Go backward one node, considering all nodes as forming one sequence."
2459 (let ((prevnode (Info-extract-pointer "prev[ious]*" t
))
2460 (upnode (Info-extract-pointer "up" t
))
2461 (case-fold-search t
))
2462 (cond ((and upnode
(string-match "(" upnode
))
2463 (error "First node in file"))
2464 ((and upnode
(or (null prevnode
)
2465 ;; Use string-equal, not equal,
2466 ;; to ignore text properties.
2467 (string-equal (downcase prevnode
)
2468 (downcase upnode
))))
2471 ;; If we move back at the same level,
2472 ;; go down to find the last subnode*.
2475 (while (and (not (Info-index-node))
2476 (save-excursion (search-forward "\n* Menu:" nil t
)))
2477 (Info-goto-node (Info-extract-menu-counting nil
)))))
2479 (error "No pointer backward from this node")))))
2482 "Exit Info by selecting some other buffer."
2485 (save-buffers-kill-emacs)
2488 (defun Info-next-menu-item ()
2489 "Go to the node of the next menu item."
2491 ;; Bind this in case the user sets it to nil.
2492 (let* ((case-fold-search t
)
2496 (search-forward "\n* menu:" nil t
)
2497 (and (search-forward "\n* " nil t
)
2498 (Info-extract-menu-node-name)))))
2499 (if node
(Info-goto-node node
)
2500 (error "No more items in menu"))))
2502 (defun Info-last-menu-item ()
2503 "Go to the node of the previous menu item."
2507 ;; Bind this in case the user sets it to nil.
2508 (let* ((case-fold-search t
)
2509 (beg (save-excursion
2510 (and (search-backward "\n* menu:" nil t
)
2512 (or (and beg
(search-backward "\n* " beg t
))
2513 (error "No previous items in menu")))
2514 (Info-goto-node (save-excursion
2515 (goto-char (match-end 0))
2516 (Info-extract-menu-node-name)))))
2518 (defmacro Info-no-error
(&rest body
)
2519 (list 'condition-case nil
(cons 'progn
(append body
'(t))) '(error nil
)))
2521 (defun Info-next-preorder ()
2522 "Go to the next subnode or the next node, or go up a level."
2524 (cond ((Info-no-error (Info-next-menu-item)))
2525 ((Info-no-error (Info-next)))
2526 ((Info-no-error (Info-up t
))
2527 ;; Since we have already gone thru all the items in this menu,
2528 ;; go up to the end of this node.
2529 (goto-char (point-max))
2530 ;; Since logically we are done with the node with that menu,
2532 (Info-next-preorder))
2534 (error "No more nodes"))))
2536 (defun Info-last-preorder ()
2537 "Go to the last node, popping up a level if there is none."
2539 (cond ((Info-no-error
2540 (Info-last-menu-item)
2541 ;; If we go down a menu item, go to the end of the node
2542 ;; so we can scroll back through it.
2543 (goto-char (point-max)))
2544 ;; Keep going down, as long as there are nested menu nodes.
2545 (while (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))))
2551 ((and (Info-no-error (Info-extract-pointer "prev"))
2552 (not (equal (Info-extract-pointer "up")
2553 (Info-extract-pointer "prev"))))
2554 (Info-no-error (Info-prev))
2555 (goto-char (point-max))
2556 (while (Info-no-error
2557 (Info-last-menu-item)
2558 ;; If we go down a menu item, go to the end of the node
2559 ;; so we can scroll back through it.
2560 (goto-char (point-max))))
2562 ((Info-no-error (Info-up t
))
2563 (goto-char (point-min))
2564 (let ((case-fold-search t
))
2565 (or (search-forward "\n* Menu:" nil t
)
2566 (goto-char (point-max)))))
2567 (t (error "No previous nodes"))))
2569 (defun Info-scroll-up ()
2570 "Scroll one screenful forward in Info, considering all nodes as one sequence.
2571 Once you scroll far enough in a node that its menu appears on the screen
2572 but after point, the next scroll moves into its first subnode, unless
2573 `Info-scroll-prefer-subnodes' is nil.
2575 When you scroll past the end of a node, that goes to the next node if
2576 `Info-scroll-prefer-subnodes' is non-nil and to the first subnode otherwise;
2577 if this node has no successor, it moves to the parent node's successor,
2578 and so on. If `Info-scroll-prefer-subnodes' is non-nil and point is inside
2579 the menu of a node, it moves to subnode indicated by the following menu
2580 item. (That case won't normally result from this command, but can happen
2584 (if (or (< (window-start) (point-min))
2585 (> (window-start) (point-max)))
2586 (set-window-start (selected-window) (point)))
2587 (let* ((case-fold-search t
)
2588 (virtual-end (save-excursion
2589 (goto-char (point-min))
2590 (if (and Info-scroll-prefer-subnodes
2591 (search-forward "\n* Menu:" nil t
))
2594 (if (or (< virtual-end
(window-start))
2595 (pos-visible-in-window-p virtual-end
))
2597 (Info-scroll-prefer-subnodes (Info-next-preorder))
2598 ((Info-no-error (Info-goto-node (Info-extract-menu-counting 1))))
2599 (t (Info-next-preorder)))
2602 (defun Info-scroll-down ()
2603 "Scroll one screenful back in Info, considering all nodes as one sequence.
2604 If point is within the menu of a node, and `Info-scroll-prefer-subnodes'
2605 is non-nil, this goes to its last subnode. When you scroll past the
2606 beginning of a node, that goes to the previous node or back up to the
2609 (if (or (< (window-start) (point-min))
2610 (> (window-start) (point-max)))
2611 (set-window-start (selected-window) (point)))
2612 (let* ((case-fold-search t
)
2613 (current-point (point))
2615 (and Info-scroll-prefer-subnodes
2618 (setq current-point
(point))
2619 (goto-char (point-min))
2620 (search-forward "\n* Menu:"
2624 (pos-visible-in-window-p (point-min) nil t
))
2625 (Info-last-preorder)
2628 (defun Info-next-reference (&optional recur
)
2629 "Move cursor to the next cross-reference or menu item in the node."
2631 (let ((pat "\\*note[ \n\t]+\\([^:]+\\):\\|^\\* .*:\\|[hf]t?tp://")
2633 (case-fold-search t
))
2634 (or (eobp) (forward-char 1))
2635 (or (re-search-forward pat nil t
)
2637 (goto-char (point-min))
2638 (or (re-search-forward pat nil t
)
2641 (error "No cross references in this node")))))
2642 (goto-char (or (match-beginning 1) (match-beginning 0)))
2643 (if (looking-at "\\* Menu:")
2645 (error "No cross references in this node")
2646 (Info-next-reference t
))
2647 (if (looking-at "^\\* ")
2648 (forward-char 2)))))
2650 (defun Info-prev-reference (&optional recur
)
2651 "Move cursor to the previous cross-reference or menu item in the node."
2653 (let ((pat "\\*note[ \n\t]+\\([^:]+\\):\\|^\\* .*:\\|[hf]t?tp://")
2655 (case-fold-search t
))
2656 (or (re-search-backward pat nil t
)
2658 (goto-char (point-max))
2659 (or (re-search-backward pat nil t
)
2662 (error "No cross references in this node")))))
2663 (goto-char (or (match-beginning 1) (match-beginning 0)))
2664 (if (looking-at "\\* Menu:")
2666 (error "No cross references in this node")
2667 (Info-prev-reference t
))
2668 (if (looking-at "^\\* ")
2669 (forward-char 2)))))
2671 (defvar Info-index-nodes nil
2672 "Alist of cached index node names of visited Info files.
2673 Each element has the form (INFO-FILE INDEX-NODE-NAMES-LIST).")
2675 (defun Info-index-nodes (&optional file
)
2676 "Return a list of names of all index nodes in Info FILE.
2677 If FILE is omitted, it defaults to the current Info file.
2678 First look in a list of cached index node names. Then scan Info
2679 file and its subfiles for nodes with the index cookie. Then try
2680 to find index nodes starting from the first node in the top level
2681 menu whose name contains the word \"Index\", plus any immediately
2682 following nodes whose names also contain the word \"Index\"."
2683 (or file
(setq file Info-current-file
))
2684 (or (assoc file Info-index-nodes
)
2685 ;; Skip virtual Info files
2686 (and (member file
'("dir" apropos history toc
))
2687 (setq Info-index-nodes
(cons (cons file nil
) Info-index-nodes
)))
2688 (not (stringp file
))
2689 (if Info-file-supports-index-cookies
2690 ;; Find nodes with index cookie
2691 (let* ((default-directory (or (and (stringp file
)
2692 (file-name-directory
2693 (setq file
(Info-find-file file
))))
2695 Info-history Info-history-list Info-fontify-maximum-menu-size
2696 (main-file file
) subfiles nodes node
)
2699 (while (or main-file subfiles
)
2701 (info-insert-file-contents (or main-file
(car subfiles
)))
2702 (goto-char (point-min))
2703 (while (search-forward "\0\b[index\0\b]" nil
'move
)
2705 (re-search-backward "^\^_")
2706 (search-forward "Node: ")
2707 (setq nodes
(cons (Info-following-node-name) nodes
))))
2710 (goto-char (point-min))
2711 (if (search-forward "\n\^_\nIndirect:" nil t
)
2712 (let ((bound (save-excursion (search-forward "\n\^_" nil t
))))
2713 (while (re-search-forward "^\\(.*\\): [0-9]+$" bound t
)
2714 (setq subfiles
(cons (match-string-no-properties 1)
2716 (setq subfiles
(nreverse subfiles
)
2718 (setq subfiles
(cdr subfiles
)))))
2721 (setq nodes
(nreverse nodes
)
2722 Info-index-nodes
(cons (cons file nodes
) Info-index-nodes
)))
2724 ;; Else find nodes with the word "Index" in the node name
2725 (let ((case-fold-search t
)
2726 Info-history Info-history-list Info-fontify-maximum-menu-size
2731 (Info-find-node file
"Top")
2732 (when (and (search-forward "\n* menu:" nil t
)
2733 (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t
))
2734 (goto-char (match-beginning 1))
2735 (setq nodes
(list (Info-extract-menu-node-name)))
2736 (Info-goto-node (car nodes
))
2737 (while (and (setq node
(Info-extract-pointer "next" t
))
2738 (string-match "\\<Index\\>" node
))
2739 (setq nodes
(cons node nodes
))
2740 (Info-goto-node node
))))
2743 (setq nodes
(nreverse nodes
)
2744 Info-index-nodes
(cons (cons file nodes
) Info-index-nodes
)))
2746 ;; If file has no index nodes, still add it to the cache
2747 (setq Info-index-nodes
(cons (cons file nil
) Info-index-nodes
)))
2748 (cdr (assoc file Info-index-nodes
)))
2750 (defun Info-index-node (&optional node file
)
2751 "Return non-nil value if NODE is an index node.
2752 If NODE is nil, check the current Info node.
2753 If FILE is nil, check the current Info file."
2754 (if (or (and node
(not (equal node Info-current-node
)))
2755 (assoc (or file Info-current-file
) Info-index-nodes
))
2756 (member (or node Info-current-node
) (Info-index-nodes file
))
2757 ;; Don't search all index nodes if request is only for the current node
2758 ;; and file is not in the cache of index nodes
2759 (if Info-file-supports-index-cookies
2761 (goto-char (+ (or (save-excursion
2762 (search-backward "\n\^_" nil t
))
2764 (search-forward "\0\b[index\0\b]"
2766 (search-forward "\n\^_" nil t
))
2769 (string-match "\\<Index\\>" (or node Info-current-node
""))))))
2771 (defun Info-goto-index ()
2772 "Go to the first index node."
2773 (let ((node (car (Info-index-nodes))))
2774 (or node
(error "No index"))
2775 (Info-goto-node node
)))
2778 (defun Info-index (topic)
2779 "Look up a string TOPIC in the index for this manual and go to that entry.
2780 If there are no exact matches to the specified topic, this chooses
2781 the first match which is a case-insensitive substring of a topic.
2782 Use the \\<Info-mode-map>\\[Info-index-next] command to see the other matches.
2783 Give an empty topic name to go to the Index node itself."
2786 (let ((Info-complete-menu-buffer (clone-buffer))
2787 (Info-complete-nodes (Info-index-nodes))
2788 (Info-history-list nil
))
2789 (if (equal Info-current-file
"dir")
2790 (error "The Info directory node has no index; use m to select a manual"))
2792 (with-current-buffer Info-complete-menu-buffer
2794 (completing-read "Index topic: " 'Info-complete-menu-item
))
2795 (kill-buffer Info-complete-menu-buffer
)))))
2796 (if (equal Info-current-file
"dir")
2797 (error "The Info directory node has no index; use m to select a manual"))
2798 (let ((orignode Info-current-node
)
2799 (pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^\n]*\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?"
2800 (regexp-quote topic
)))
2801 node
(nodes (Info-index-nodes))
2802 (ohist-list Info-history-list
)
2803 (case-fold-search t
))
2805 (or (equal topic
"")
2808 ;; We bind Info-history to nil for internal node-switches so
2809 ;; that we don't put junk in the history. In the first
2810 ;; Info-goto-index call, above, we do update the history
2811 ;; because that is what the user's previous node choice into it.
2816 (goto-char (point-min))
2817 (while (re-search-forward pattern nil t
)
2818 (push (list (match-string-no-properties 1)
2819 (match-string-no-properties 2)
2821 (string-to-number (concat "0"
2824 (setq nodes
(cdr nodes
) node
(car nodes
)))
2825 (Info-goto-node node
))
2828 (Info-goto-node orignode
)
2829 (error "No `%s' in index" topic
)))
2830 ;; Here it is a feature that assoc is case-sensitive.
2831 (while (setq found
(assoc topic matches
))
2832 (setq exact
(cons found exact
)
2833 matches
(delq found matches
)))
2834 (setq Info-history-list ohist-list
)
2835 (setq Info-index-alternatives
(nconc exact
(nreverse matches
)))
2836 (Info-index-next 0)))))
2838 (defun Info-index-next (num)
2839 "Go to the next matching index item from the last \\<Info-mode-map>\\[Info-index] command."
2841 (or Info-index-alternatives
2842 (error "No previous `i' command"))
2844 (setq num
(+ num
(length Info-index-alternatives
))))
2846 (setq Info-index-alternatives
2847 (nconc (cdr Info-index-alternatives
)
2848 (list (car Info-index-alternatives
)))
2850 (Info-goto-node (nth 1 (car Info-index-alternatives
)))
2851 (if (> (nth 3 (car Info-index-alternatives
)) 0)
2852 (forward-line (1- (nth 3 (car Info-index-alternatives
))))
2853 (forward-line 3) ; don't search in headers
2854 (let ((name (car (car Info-index-alternatives
))))
2855 (Info-find-index-name name
)))
2856 (message "Found `%s' in %s. %s"
2857 (car (car Info-index-alternatives
))
2858 (nth 2 (car Info-index-alternatives
))
2859 (if (cdr Info-index-alternatives
)
2860 (format "(%s total; use `,' for next)"
2861 (length Info-index-alternatives
))
2864 (defun Info-find-index-name (name)
2865 "Move point to the place within the current node where NAME is defined."
2866 (let ((case-fold-search t
))
2867 (if (or (re-search-forward (format
2868 "[a-zA-Z]+: %s\\( \\|$\\)"
2869 (regexp-quote name
)) nil t
)
2870 ;; Find a function definition with a return type.
2871 (re-search-forward (format
2872 "[a-zA-Z]+: [a-zA-Z0-9_ *&]+ %s\\( \\|$\\)"
2873 (regexp-quote name
)) nil t
)
2874 (search-forward (format "`%s'" name
) nil t
)
2875 (and (string-match "\\`.*\\( (.*)\\)\\'" name
)
2877 (format "`%s'" (substring name
0 (match-beginning 1)))
2879 (search-forward name nil t
)
2880 ;; Try again without the " <1>" makeinfo can append
2881 (and (string-match "\\`\\(.*\\) <[0-9]+>\\'" name
)
2882 (Info-find-index-name (match-string 1 name
))))
2883 (progn (beginning-of-line) t
) ;; non-nil for recursive call
2884 (goto-char (point-min)))))
2887 (defun info-apropos (string)
2888 "Grovel indices of all known Info files on your system for STRING.
2889 Build a menu of the possible matches."
2890 (interactive "sIndex apropos: ")
2891 (unless (string= string
"")
2892 (let ((pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^\n]+\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?"
2893 (regexp-quote string
)))
2894 (ohist Info-history
)
2895 (ohist-list Info-history-list
)
2896 (current-node Info-current-node
)
2897 (current-file Info-current-file
)
2898 manuals matches node nodes
)
2899 (let ((Info-fontify-maximum-menu-size nil
))
2901 (message "Searching indices...")
2902 (goto-char (point-min))
2903 (re-search-forward "\\* Menu: *\n" nil t
)
2904 (while (re-search-forward "\\*.*: *(\\([^)]+\\))" nil t
)
2905 (setq manuals
(cons (match-string 1) manuals
)))
2906 (dolist (manual (nreverse manuals
))
2907 (message "Searching %s" manual
)
2909 (if (setq nodes
(Info-index-nodes (Info-find-file manual
)))
2911 (Info-find-node manual
(car nodes
))
2914 (goto-char (point-min))
2915 (while (re-search-forward pattern nil t
)
2918 (match-string-no-properties 1)
2919 (match-string-no-properties 2)
2920 (match-string-no-properties 3))
2922 (setq nodes
(cdr nodes
) node
(car nodes
)))
2923 (Info-goto-node node
))))
2925 (message "%s" (if (eq (car-safe err
) 'error
)
2928 (Info-find-node current-file current-node
)
2929 (setq Info-history ohist
2930 Info-history-list ohist-list
)
2931 (message "Searching indices...done")
2933 (message "No matches found")
2934 (with-current-buffer (get-buffer-create " *info-apropos*")
2936 (insert "\n\^_\nFile: apropos, Node: Index, Up: (dir)\n")
2937 (insert "* Menu: \nNodes whose indices contain `" string
"':\n\n")
2938 (dolist (entry (nreverse matches
))
2940 (format "* %-38s (%s)%s.%s\n"
2941 (concat (nth 1 entry
) " [" (nth 0 entry
) "]:")
2945 (concat " (line " (nth 3 entry
) ")")
2947 (Info-find-node 'apropos
"Index")
2948 (setq Info-complete-cache nil
)))))
2950 (defun Info-undefined ()
2951 "Make command be undefined in Info."
2956 "Enter the Info tutorial."
2958 (delete-other-windows)
2959 (Info-find-node "info"
2960 (if (< (window-height) 23)
2964 (defun Info-summary ()
2965 "Display a brief summary of all Info commands."
2967 (save-window-excursion
2968 (switch-to-buffer "*Help*")
2969 (setq buffer-read-only nil
)
2971 (insert (documentation 'Info-mode
))
2973 (goto-char (point-min))
2975 (while (progn (setq flag
(not (pos-visible-in-window-p (point-max))))
2976 (message (if flag
"Type Space to see more"
2977 "Type Space to return to Info"))
2978 (if (not (eq ?\s
(setq ch
(read-event))))
2979 (progn (setq unread-command-events
(list ch
)) nil
)
2982 (bury-buffer "*Help*")))
2984 (defun Info-get-token (pos start all
&optional errorstring
)
2985 "Return the token around POS.
2986 POS must be somewhere inside the token
2987 START is a regular expression which will match the
2988 beginning of the tokens delimited string
2989 ALL is a regular expression with a single
2990 parenthesized subpattern which is the token to be
2991 returned. E.g. '{\(.*\)}' would return any string
2992 enclosed in braces around POS.
2993 ERRORSTRING optional fourth argument, controls action on no match
2996 a string: signal an error, using that string."
2997 (let ((case-fold-search t
))
3000 ;; First look for a match for START that goes across POS.
3001 (while (and (not (bobp)) (> (point) (- pos
(length start
)))
3002 (not (looking-at start
)))
3004 ;; If we did not find one, search back for START
3005 ;; (this finds only matches that end at or before POS).
3006 (or (looking-at start
)
3009 (re-search-backward start
(max (point-min) (- pos
200)) 'yes
)))
3011 (while (and (re-search-forward all
(min (point-max) (+ pos
200)) 'yes
)
3012 (not (setq found
(and (<= (match-beginning 0) pos
)
3013 (> (match-end 0) pos
))))))
3014 (if (and found
(<= (match-beginning 0) pos
)
3015 (> (match-end 0) pos
))
3016 (match-string-no-properties 1)
3017 (cond ((null errorstring
)
3023 (error "No %s around position %d" errorstring pos
))))))))
3025 (defun Info-mouse-follow-nearest-node (click)
3026 "\\<Info-mode-map>Follow a node reference near point.
3027 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click.
3028 At end of the node's text, moves to the next node, or up if none."
3030 (mouse-set-point click
)
3031 (and (not (Info-try-follow-nearest-node))
3032 (save-excursion (forward-line 1) (eobp))
3033 (Info-next-preorder)))
3035 (defun Info-follow-nearest-node (&optional fork
)
3036 "Follow a node reference near point.
3037 If point is on a reference, follow that reference. Otherwise,
3038 if point is in a menu item description, follow that menu item."
3040 (or (Info-try-follow-nearest-node fork
)
3041 (when (save-excursion
3042 (search-backward "\n* menu:" nil t
))
3045 (while (not (or (bobp) (looking-at "[^ \t]\\|[ \t]*$")))
3046 (beginning-of-line 0))
3047 (when (looking-at "\\* +\\([^\t\n]*\\):")
3049 (Info-extract-menu-item (match-string-no-properties 1)) fork
)
3051 (error "Point neither on reference nor in menu item description")))
3053 ;; Common subroutine.
3054 (defun Info-try-follow-nearest-node (&optional fork
)
3055 "Follow a node reference near point. Return non-nil if successful."
3058 ((Info-get-token (point) "[hf]t?tp://" "[hf]t?tp://\\([^ \t\n\"`({<>})']+\\)")
3060 (browse-url (browse-url-url-at-point)))
3061 ((setq node
(Info-get-token (point) "\\*note[ \n\t]+"
3062 "\\*note[ \n\t]+\\([^:]*\\):\\(:\\|[ \n\t]*(\\)?"))
3063 (Info-follow-reference node fork
))
3064 ;; menu item: node name
3065 ((setq node
(Info-get-token (point) "\\* +" "\\* +\\([^:]*\\)::"))
3066 (Info-goto-node node fork
))
3067 ;; menu item: node name or index entry
3068 ((Info-get-token (point) "\\* +" "\\* +\\(.*\\): ")
3071 (setq node
(Info-extract-menu-node-name nil
(Info-index-node)))
3072 (Info-goto-node node fork
))
3073 ((setq node
(Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)"))
3074 (Info-goto-node node fork
))
3075 ((setq node
(Info-get-token (point) "Next: " "Next: \\([^,\n\t]*\\)"))
3076 (Info-goto-node node fork
))
3077 ((setq node
(Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)"))
3078 (Info-goto-node "Top" fork
))
3079 ((setq node
(Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)"))
3080 (Info-goto-node node fork
)))
3083 (defvar Info-mode-map nil
3084 "Keymap containing Info commands.")
3087 (setq Info-mode-map
(make-keymap))
3088 (suppress-keymap Info-mode-map
)
3089 (define-key Info-mode-map
"." 'beginning-of-buffer
)
3090 (define-key Info-mode-map
" " 'Info-scroll-up
)
3091 (define-key Info-mode-map
"\C-m" 'Info-follow-nearest-node
)
3092 (define-key Info-mode-map
"\t" 'Info-next-reference
)
3093 (define-key Info-mode-map
"\e\t" 'Info-prev-reference
)
3094 (define-key Info-mode-map
[(shift tab
)] 'Info-prev-reference
)
3095 (define-key Info-mode-map
[backtab] 'Info-prev-reference)
3096 (define-key Info-mode-map "1" 'Info-nth-menu-item)
3097 (define-key Info-mode-map "2" 'Info-nth-menu-item)
3098 (define-key Info-mode-map "3" 'Info-nth-menu-item)
3099 (define-key Info-mode-map "4" 'Info-nth-menu-item)
3100 (define-key Info-mode-map "5" 'Info-nth-menu-item)
3101 (define-key Info-mode-map "6" 'Info-nth-menu-item)
3102 (define-key Info-mode-map "7" 'Info-nth-menu-item)
3103 (define-key Info-mode-map "8" 'Info-nth-menu-item)
3104 (define-key Info-mode-map "9" 'Info-nth-menu-item)
3105 (define-key Info-mode-map "0" 'undefined)
3106 (define-key Info-mode-map "?" 'Info-summary)
3107 (define-key Info-mode-map "]" 'Info-forward-node)
3108 (define-key Info-mode-map "[" 'Info-backward-node)
3109 (define-key Info-mode-map "<" 'Info-top-node)
3110 (define-key Info-mode-map ">" 'Info-final-node)
3111 (define-key Info-mode-map "b" 'beginning-of-buffer)
3112 (define-key Info-mode-map "d" 'Info-directory)
3113 (define-key Info-mode-map "e" 'Info-edit)
3114 (define-key Info-mode-map "f" 'Info-follow-reference)
3115 (define-key Info-mode-map "g" 'Info-goto-node)
3116 (define-key Info-mode-map "h" 'Info-help)
3117 (define-key Info-mode-map "i" 'Info-index)
3118 (define-key Info-mode-map "l" 'Info-history-back)
3119 (define-key Info-mode-map "L" 'Info-history)
3120 (define-key Info-mode-map "m" 'Info-menu)
3121 (define-key Info-mode-map "n" 'Info-next)
3122 (define-key Info-mode-map "p" 'Info-prev)
3123 (define-key Info-mode-map "q" 'Info-exit)
3124 (define-key Info-mode-map "r" 'Info-history-forward)
3125 (define-key Info-mode-map "s" 'Info-search)
3126 (define-key Info-mode-map "S" 'Info-search-case-sensitively)
3127 ;; For consistency with Rmail.
3128 (define-key Info-mode-map "\M-s" 'Info-search)
3129 (define-key Info-mode-map "\M-n" 'clone-buffer)
3130 (define-key Info-mode-map "t" 'Info-top-node)
3131 (define-key Info-mode-map "T" 'Info-toc)
3132 (define-key Info-mode-map "u" 'Info-up)
3133 ;; `w' for consistency with `dired-copy-filename-as-kill'.
3134 (define-key Info-mode-map "w" 'Info-copy-current-node-name)
3135 (define-key Info-mode-map "c" 'Info-copy-current-node-name)
3136 ;; `^' for consistency with `dired-up-directory'.
3137 (define-key Info-mode-map "^" 'Info-up)
3138 (define-key Info-mode-map "," 'Info-index-next)
3139 (define-key Info-mode-map "\177" 'Info-scroll-down)
3140 (define-key Info-mode-map [mouse-2] 'Info-mouse-follow-nearest-node)
3141 (define-key Info-mode-map [follow-link] 'mouse-face)
3144 (defun Info-check-pointer (item)
3145 "Non-nil if ITEM is present in this node."
3147 (Info-extract-pointer item)
3151 Info-mode-menu Info-mode-map
3152 "Menu for Info files."
3154 ["Up" Info-up :active (Info-check-pointer "up")
3155 :help "Go up in the Info tree"]
3156 ["Next" Info-next :active (Info-check-pointer "next")
3157 :help "Go to the next node"]
3158 ["Previous" Info-prev :active (Info-check-pointer "prev[ious]*")
3159 :help "Go to the previous node"]
3160 ["Backward" Info-backward-node
3161 :help "Go backward one node, considering all as a sequence"]
3162 ["Forward" Info-forward-node
3163 :help "Go forward one node, considering all as a sequence"]
3164 ["Beginning" beginning-of-buffer
3165 :help "Go to beginning of this node"]
3166 ["Top" Info-top-node
3167 :help "Go to top node of file"]
3168 ["Final Node" Info-final-node
3169 :help "Go to final node in this file"]
3170 ("Menu Item" ["You should never see this" report-emacs-bug t])
3171 ("Reference" ["You should never see this" report-emacs-bug t])
3172 ["Search..." Info-search
3173 :help "Search for regular expression in this Info file"]
3174 ["Search Next" Info-search-next
3175 :help "Search for another occurrence of regular expression"]
3176 ["Go to Node..." Info-goto-node
3177 :help "Go to a named node"]
3178 ["Back in history" Info-history-back :active Info-history
3179 :help "Go back in history to the last node you were at"]
3180 ["Forward in history" Info-history-forward :active Info-history-forward
3181 :help "Go forward in history"]
3182 ["History" Info-history :active Info-history-list
3183 :help "Go to menu of visited nodes"]
3184 ["Table of Contents" Info-toc
3185 :help "Go to table of contents"]
3187 ["Lookup a String..." Info-index
3188 :help "Look for a string in the index items"]
3189 ["Next Matching Item" Info-index-next :active Info-index-alternatives
3190 :help "Look for another occurrence of previous item"]
3191 ["Lookup a string in all indices..." info-apropos
3192 :help "Look for a string in the indices of all manuals"])
3193 ["Copy Node Name" Info-copy-current-node-name
3194 :help "Copy the name of the current node into the kill ring"]
3195 ["Clone Info buffer" clone-buffer
3196 :help "Create a twin copy of the current Info buffer."]
3197 ["Exit" Info-exit :help "Stop reading Info"]))
3200 (defvar info-tool-bar-map
3201 (if (display-graphic-p)
3202 (let ((map (make-sparse-keymap)))
3203 (tool-bar-local-item-from-menu 'Info-exit "close" map Info-mode-map)
3204 (tool-bar-local-item-from-menu 'Info-history-back "left-arrow" map Info-mode-map)
3205 (tool-bar-local-item-from-menu 'Info-history-forward "right-arrow" map Info-mode-map)
3206 (tool-bar-local-item-from-menu 'Info-prev "prev-node" map Info-mode-map)
3207 (tool-bar-local-item-from-menu 'Info-next "next-node" map Info-mode-map)
3208 (tool-bar-local-item-from-menu 'Info-up "up-node" map Info-mode-map)
3209 (tool-bar-local-item-from-menu 'Info-top-node "home" map Info-mode-map)
3210 (tool-bar-local-item-from-menu 'Info-goto-node "jump-to" map Info-mode-map)
3211 (tool-bar-local-item-from-menu 'Info-index "index" map Info-mode-map)
3212 (tool-bar-local-item-from-menu 'Info-search "search" map Info-mode-map)
3215 (defvar Info-menu-last-node nil)
3216 ;; Last node the menu was created for.
3217 ;; Value is a list, (FILE-NAME NODE-NAME).
3219 (defun Info-menu-update ()
3220 "Update the Info menu for the current node."
3222 (if (or (not (eq major-mode 'Info-mode))
3223 (equal (list Info-current-file Info-current-node)
3224 Info-menu-last-node))
3226 ;; Update menu menu.
3227 (let* ((Info-complete-menu-buffer (current-buffer))
3228 (items (nreverse (condition-case nil
3229 (Info-complete-menu-item "" nil t)
3233 (while (and items (< number 9))
3234 (setq current (car items)
3237 (setq entries (cons `[,current
3238 (Info-menu ,current)
3239 :keys ,(format "%d" number)]
3242 (setq entries (cons ["Other..." Info-menu t] entries)))
3244 (setq entries (list ["No menu" nil nil] nil :active)))
3245 (easy-menu-change '("Info") "Menu Item" (nreverse entries)))
3246 ;; Update reference menu. Code stolen from `Info-follow-reference'.
3248 str i entries current
3250 (case-fold-search t))
3252 (goto-char (point-min))
3253 (while (re-search-forward "\\*note[ \n\t]+\\([^:]*\\):" nil t)
3254 (setq str (match-string 1))
3256 (while (setq i (string-match "[ \n\t]+" str i))
3257 (setq str (concat (substring str 0 i) " "
3258 (substring str (match-end 0))))
3262 (while (and items (< number 9))
3263 (setq current (car items)
3266 (setq entries (cons `[,current
3267 (Info-follow-reference ,current)
3271 (setq entries (cons ["Other..." Info-follow-reference t]
3274 (setq entries (list ["No references" nil nil] nil :active)))
3275 (easy-menu-change '("Info") "Reference" (nreverse entries)))
3276 ;; Update last seen node.
3277 (setq Info-menu-last-node (list Info-current-file Info-current-node)))
3278 ;; Try to avoid entering infinite beep mode in case of errors.
3282 (defun Info-copy-current-node-name (&optional arg)
3283 "Put the name of the current Info node into the kill ring.
3284 The name of the Info file is prepended to the node name in parentheses.
3285 With a zero prefix arg, put the name inside a function call to `info'."
3287 (unless Info-current-node
3288 (error "No current Info node"))
3289 (let ((node (if (stringp Info-current-file)
3290 (concat "(" (file-name-nondirectory Info-current-file) ")"
3291 Info-current-node))))
3292 (if (zerop (prefix-numeric-value arg))
3293 (setq node (concat "(info \"" node "\")")))
3294 (unless (stringp Info-current-file)
3295 (setq node (format "(Info-find-node '%S '%S)"
3296 Info-current-file Info-current-node)))
3298 (message "%s" node)))
3301 ;; Info mode is suitable only for specially formatted data.
3302 (put 'Info-mode 'mode-class 'special)
3303 (put 'Info-mode 'no-clone-indirect t)
3305 (defvar tool-bar-map)
3307 ;; Autoload cookie needed by desktop.el
3310 "Info mode provides commands for browsing through the Info documentation tree.
3311 Documentation in Info is divided into \"nodes\", each of which discusses
3312 one topic and contains references to other nodes which discuss related
3313 topics. Info has commands to follow the references and show you other nodes.
3316 \\[Info-help] Invoke the Info tutorial.
3317 \\[Info-exit] Quit Info: reselect previously selected buffer.
3319 Selecting other nodes:
3320 \\[Info-mouse-follow-nearest-node]
3321 Follow a node reference you click on.
3322 This works with menu items, cross references, and
3323 the \"next\", \"previous\" and \"up\", depending on where you click.
3324 \\[Info-follow-nearest-node] Follow a node reference near point, like \\[Info-mouse-follow-nearest-node].
3325 \\[Info-next] Move to the \"next\" node of this node.
3326 \\[Info-prev] Move to the \"previous\" node of this node.
3327 \\[Info-up] Move \"up\" from this node.
3328 \\[Info-menu] Pick menu item specified by name (or abbreviation).
3329 Picking a menu item causes another node to be selected.
3330 \\[Info-directory] Go to the Info directory node.
3331 \\[Info-top-node] Go to the Top node of this file.
3332 \\[Info-final-node] Go to the final node in this file.
3333 \\[Info-backward-node] Go backward one node, considering all nodes as forming one sequence.
3334 \\[Info-forward-node] Go forward one node, considering all nodes as forming one sequence.
3335 \\[Info-next-reference] Move cursor to next cross-reference or menu item.
3336 \\[Info-prev-reference] Move cursor to previous cross-reference or menu item.
3337 \\[Info-follow-reference] Follow a cross reference. Reads name of reference.
3338 \\[Info-history-back] Move back in history to the last node you were at.
3339 \\[Info-history-forward] Move forward in history to the node you returned from after using \\[Info-history-back].
3340 \\[Info-history] Go to menu of visited nodes.
3341 \\[Info-toc] Go to table of contents of the current Info file.
3343 Moving within a node:
3344 \\[Info-scroll-up] Normally, scroll forward a full screen.
3345 Once you scroll far enough in a node that its menu appears on the
3346 screen but after point, the next scroll moves into its first
3347 subnode. When after all menu items (or if there is no menu),
3348 move up to the parent node.
3349 \\[Info-scroll-down] Normally, scroll backward. If the beginning of the buffer is
3350 already visible, try to go to the previous menu entry, or up
3352 \\[beginning-of-buffer] Go to beginning of node.
3355 \\[Info-search] Search through this Info file for specified regexp,
3356 and select the node in which the next occurrence is found.
3357 \\[Info-search-case-sensitively] Search through this Info file for specified regexp case-sensitively.
3358 \\[Info-search-next] Search for another occurrence of regexp
3359 from a previous \\<Info-mode-map>\\[Info-search] command.
3360 \\[Info-index] Search for a topic in this manual's Index and go to index entry.
3361 \\[Info-index-next] (comma) Move to the next match from a previous \\<Info-mode-map>\\[Info-index] command.
3362 \\[info-apropos] Look for a string in the indices of all manuals.
3363 \\[Info-goto-node] Move to node specified by name.
3364 You may include a filename as well, as (FILENAME)NODENAME.
3365 1 .. 9 Pick first ... ninth item in node's menu.
3366 Every third `*' is highlighted to help pick the right number.
3367 \\[Info-copy-current-node-name] Put name of current Info node in the kill ring.
3368 \\[clone-buffer] Select a new cloned Info buffer in another window.
3369 \\[universal-argument] \\[info] Move to new Info file with completion.
3370 \\[universal-argument] N \\[info] Select Info buffer with prefix number in the name *info*<N>."
3371 (kill-all-local-variables)
3372 (setq major-mode 'Info-mode)
3373 (setq mode-name "Info")
3375 (use-local-map Info-mode-map)
3376 (add-hook 'activate-menubar-hook 'Info-menu-update nil t)
3377 (set-syntax-table text-mode-syntax-table)
3378 (setq local-abbrev-table text-mode-abbrev-table)
3379 (setq case-fold-search t)
3380 (setq buffer-read-only t)
3381 (make-local-variable 'Info-current-file)
3382 (make-local-variable 'Info-current-subfile)
3383 (make-local-variable 'Info-current-node)
3384 (make-local-variable 'Info-tag-table-marker)
3385 (setq Info-tag-table-marker (make-marker))
3386 (make-local-variable 'Info-tag-table-buffer)
3387 (setq Info-tag-table-buffer nil)
3388 (make-local-variable 'Info-history)
3389 (make-local-variable 'Info-history-forward)
3390 (make-local-variable 'Info-index-alternatives)
3391 (setq header-line-format
3392 (if Info-use-header-line
3393 '(:eval (get-text-property (point-min) 'header-line))
3394 nil)) ; so the header line isn't displayed
3395 (set (make-local-variable 'tool-bar-map) info-tool-bar-map)
3396 ;; This is for the sake of the invisible text we use handling titles.
3397 (make-local-variable 'line-move-ignore-invisible)
3398 (setq line-move-ignore-invisible t)
3399 (make-local-variable 'desktop-save-buffer)
3400 (make-local-variable 'widen-automatically)
3401 (setq widen-automatically nil)
3402 (setq desktop-save-buffer 'Info-desktop-buffer-misc-data)
3403 (add-hook 'kill-buffer-hook 'Info-kill-buffer nil t)
3404 (add-hook 'clone-buffer-hook 'Info-clone-buffer-hook nil t)
3405 (add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
3406 (add-hook 'isearch-mode-hook 'Info-isearch-start nil t)
3407 (set (make-local-variable 'isearch-search-fun-function)
3408 'Info-isearch-search)
3409 (set (make-local-variable 'isearch-wrap-function)
3411 (set (make-local-variable 'isearch-push-state-function)
3412 'Info-isearch-push-state)
3413 (set (make-local-variable 'search-whitespace-regexp)
3414 Info-search-whitespace-regexp)
3415 (Info-set-mode-line)
3416 (run-mode-hooks 'Info-mode-hook))
3418 ;; When an Info buffer is killed, make sure the associated tags buffer
3420 (defun Info-kill-buffer ()
3421 (and (eq major-mode 'Info-mode)
3422 Info-tag-table-buffer
3423 (kill-buffer Info-tag-table-buffer)))
3425 (defun Info-clone-buffer-hook ()
3426 (when (bufferp Info-tag-table-buffer)
3427 (setq Info-tag-table-buffer
3428 (with-current-buffer Info-tag-table-buffer (clone-buffer))))
3429 (let ((m Info-tag-table-marker))
3431 (setq Info-tag-table-marker
3432 (if (and (marker-position m) (bufferp Info-tag-table-buffer))
3433 (with-current-buffer Info-tag-table-buffer
3434 (copy-marker (marker-position m)))
3437 (defvar Info-edit-map (let ((map (make-sparse-keymap)))
3438 (set-keymap-parent map text-mode-map)
3439 (define-key map "\C-c\C-c" 'Info-cease-edit)
3441 "Local keymap used within `e' command of Info.")
3443 ;; Info-edit mode is suitable only for specially formatted data.
3444 (put 'Info-edit-mode 'mode-class 'special)
3446 (defun Info-edit-mode ()
3447 "Major mode for editing the contents of an Info node.
3448 Like text mode with the addition of `Info-cease-edit'
3449 which returns to Info mode for browsing.
3451 (use-local-map Info-edit-map)
3452 (setq major-mode 'Info-edit-mode)
3453 (setq mode-name "Info Edit")
3454 (kill-local-variable 'mode-line-buffer-identification)
3455 (setq buffer-read-only nil)
3456 (force-mode-line-update)
3457 (buffer-enable-undo (current-buffer))
3458 (run-mode-hooks 'Info-edit-mode-hook))
3461 "Edit the contents of this Info node.
3462 Allowed only if variable `Info-enable-edit' is non-nil."
3464 (or Info-enable-edit
3465 (error "Editing Info nodes is not enabled"))
3467 (message "%s" (substitute-command-keys
3468 "Editing: Type \\<Info-edit-map>\\[Info-cease-edit] to return to info")))
3470 (defun Info-cease-edit ()
3471 "Finish editing Info node; switch back to Info proper."
3473 ;; Do this first, so nothing has changed if user C-g's at query.
3474 (and (buffer-modified-p)
3475 (y-or-n-p "Save the file? ")
3477 (use-local-map Info-mode-map)
3478 (setq major-mode 'Info-mode)
3479 (setq mode-name "Info")
3480 (Info-set-mode-line)
3481 (setq buffer-read-only t)
3482 (force-mode-line-update)
3483 (and (marker-position Info-tag-table-marker)
3485 (message "Tags may have changed. Use Info-tagify if necessary")))
3487 (defvar Info-file-list-for-emacs
3488 '("ediff" "eudc" "forms" "gnus" "info" ("Info" . "info") ("mh" . "mh-e")
3489 "sc" "message" ("dired" . "dired-x") "viper" "vip" "idlwave"
3490 ("c" . "ccmode") ("c++" . "ccmode") ("objc" . "ccmode")
3491 ("java" . "ccmode") ("idl" . "ccmode") ("pike" . "ccmode")
3492 ("skeleton" . "autotype") ("auto-insert" . "autotype")
3493 ("copyright" . "autotype") ("executable" . "autotype")
3494 ("time-stamp" . "autotype") ("quickurl" . "autotype")
3495 ("tempo" . "autotype") ("hippie-expand" . "autotype")
3496 ("cvs" . "pcl-cvs") ("ada" . "ada-mode") "calc"
3497 ("calcAlg" . "calc") ("calcDigit" . "calc") ("calcVar" . "calc")
3498 "ebrowse" "eshell" "cl" "reftex" "speedbar" "widget" "woman"
3499 ("mail-header" . "emacs-mime") ("mail-content" . "emacs-mime")
3500 ("mail-encode" . "emacs-mime") ("mail-decode" . "emacs-mime")
3501 ("rfc2045" . "emacs-mime")
3502 ("rfc2231" . "emacs-mime") ("rfc2047" . "emacs-mime")
3503 ("rfc2045" . "emacs-mime") ("rfc1843" . "emacs-mime")
3504 ("ietf-drums" . "emacs-mime") ("quoted-printable" . "emacs-mime")
3505 ("binhex" . "emacs-mime") ("uudecode" . "emacs-mime")
3506 ("mailcap" . "emacs-mime") ("mm" . "emacs-mime")
3507 ("mml" . "emacs-mime"))
3508 "List of Info files that describe Emacs commands.
3509 An element can be a file name, or a list of the form (PREFIX . FILE)
3510 where PREFIX is a name prefix and FILE is the file to look in.
3511 If the element is just a file name, the file name also serves as the prefix.")
3513 (defun Info-find-emacs-command-nodes (command)
3514 "Return a list of locations documenting COMMAND.
3515 The `info-file' property of COMMAND says which Info manual to search.
3516 If COMMAND has no property, the variable `Info-file-list-for-emacs'
3517 defines heuristics for which Info manual to try.
3518 The locations are of the format used in `Info-history', i.e.
3519 \(FILENAME NODENAME BUFFERPOS\), where BUFFERPOS is the line number
3520 in the first element of the returned list (which is treated specially in
3521 `Info-goto-emacs-command-node'), and 0 for the rest elements of a list."
3522 (let ((where '()) line-number
3523 (cmd-desc (concat "^\\* +" (regexp-quote (symbol-name command))
3524 "\\( <[0-9]+>\\)?:\\s *\\(.*\\)\\."
3525 "\\(?:[ \t\n]+(line +\\([0-9]+\\))\\)?"))
3526 (info-file "emacs")) ;default
3527 ;; Determine which Info file this command is documented in.
3528 (if (get command 'info-file)
3529 (setq info-file (get command 'info-file))
3530 ;; If it doesn't say explicitly, test its name against
3531 ;; various prefixes that we know.
3532 (let ((file-list Info-file-list-for-emacs))
3534 (let* ((elt (car file-list))
3535 (name (if (consp elt)
3538 (file (if (consp elt) (cdr elt) elt))
3539 (case-fold-search nil)
3540 (regexp (concat "\\`" (regexp-quote name)
3542 (if (string-match regexp (symbol-name command))
3543 (setq info-file file file-list nil))
3544 (setq file-list (cdr file-list))))))
3545 (Info-find-node info-file "Top")
3546 ;; Bind Info-history to nil, to prevent the index nodes from
3547 ;; getting into the node history.
3548 (let ((Info-history nil)
3549 (Info-history-list nil)
3550 node (nodes (Info-index-nodes)))
3551 (Info-goto-node (car nodes))
3554 (goto-char (point-min))
3555 (while (re-search-forward cmd-desc nil t)
3557 (cons (list Info-current-file
3558 (match-string-no-properties 2)
3561 (setq line-number (and (match-beginning 3)
3562 (string-to-number (match-string 3)))))
3563 (and (setq nodes (cdr nodes) node (car nodes))))
3564 (Info-goto-node node)))
3565 (if (and line-number where)
3566 (cons (list (nth 0 (car where)) (nth 1 (car where)) line-number)
3570 ;;;###autoload (put 'Info-goto-emacs-command-node 'info-file "emacs")
3572 (defun Info-goto-emacs-command-node (command)
3573 "Go to the Info node in the Emacs manual for command COMMAND.
3574 The command is found by looking up in Emacs manual's indices
3575 or in another manual found via COMMAND's `info-file' property or
3576 the variable `Info-file-list-for-emacs'.
3577 COMMAND must be a symbol or string."
3578 (interactive "CFind documentation for command: ")
3579 ;; If command is given as a string, convert it to a symbol.
3580 (if (stringp command)
3581 (setq command (intern command)))
3582 (or (commandp command)
3583 (signal 'wrong-type-argument (list 'commandp command)))
3584 (let ((where (Info-find-emacs-command-nodes command)))
3586 (let ((num-matches (length where)))
3587 ;; Get Info running, and pop to it in another window.
3588 (save-window-excursion
3590 (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*"))
3591 ;; Bind Info-history to nil, to prevent the last Index node
3592 ;; visited by Info-find-emacs-command-nodes from being
3593 ;; pushed onto the history.
3594 (let ((Info-history nil) (Info-history-list nil)
3595 (line-number (nth 2 (car where))))
3596 (Info-find-node (nth 0 (car where)) (nth 1 (car where)))
3597 (if (and (integerp line-number) (> line-number 0))
3598 (forward-line (1- line-number))))
3599 (if (> num-matches 1)
3601 ;; (car where) will be pushed onto Info-history
3602 ;; when/if they go to another node. Put the other
3603 ;; nodes that were found on the history.
3604 (setq Info-history (nconc (cdr where) Info-history))
3605 (message "Found %d other entr%s. Use %s to see %s."
3607 (if (> num-matches 2) "ies" "y")
3608 (substitute-command-keys "\\[Info-history-back]")
3609 (if (> num-matches 2) "them" "it")))))
3610 (error "Couldn't find documentation for %s" command))))
3612 ;;;###autoload (put 'Info-goto-emacs-key-command-node 'info-file "emacs")
3614 (defun Info-goto-emacs-key-command-node (key)
3615 "Go to the node in the Emacs manual which describes the command bound to KEY.
3617 Interactively, if the binding is `execute-extended-command', a command is read.
3618 The command is found by looking up in Emacs manual's indices
3619 or in another manual found via COMMAND's `info-file' property or
3620 the variable `Info-file-list-for-emacs'."
3621 (interactive "kFind documentation for key: ")
3622 (let ((command (key-binding key)))
3623 (cond ((null command)
3624 (message "%s is undefined" (key-description key)))
3625 ((and (interactive-p)
3626 (eq command 'execute-extended-command))
3627 (Info-goto-emacs-command-node
3628 (read-command "Find documentation for command: ")))
3630 (Info-goto-emacs-command-node command)))))
3632 (defvar Info-next-link-keymap
3633 (let ((keymap (make-sparse-keymap)))
3634 (define-key keymap [header-line mouse-1] 'Info-next)
3635 (define-key keymap [header-line mouse-2] 'Info-next)
3636 (define-key keymap [header-line down-mouse-1] 'ignore)
3637 (define-key keymap [mouse-2] 'Info-next)
3638 (define-key keymap [follow-link] 'mouse-face)
3640 "Keymap to put on the Next link in the text or the header line.")
3642 (defvar Info-prev-link-keymap
3643 (let ((keymap (make-sparse-keymap)))
3644 (define-key keymap [header-line mouse-1] 'Info-prev)
3645 (define-key keymap [header-line mouse-2] 'Info-prev)
3646 (define-key keymap [header-line down-mouse-1] 'ignore)
3647 (define-key keymap [mouse-2] 'Info-prev)
3648 (define-key keymap [follow-link] 'mouse-face)
3650 "Keymap to put on the Prev link in the text or the header line.")
3652 (defvar Info-up-link-keymap
3653 (let ((keymap (make-sparse-keymap)))
3654 (define-key keymap [header-line mouse-1] 'Info-up)
3655 (define-key keymap [header-line mouse-2] 'Info-up)
3656 (define-key keymap [header-line down-mouse-1] 'ignore)
3657 (define-key keymap [mouse-2] 'Info-up)
3658 (define-key keymap [follow-link] 'mouse-face)
3660 "Keymap to put on the Up link in the text or the header line.")
3662 (defun Info-fontify-node ()
3665 (let* ((inhibit-read-only t)
3666 (case-fold-search t)
3668 (not-fontified-p ; the node hasn't already been fontified
3669 (not (let ((where (next-property-change (point-min))))
3670 (and where (not (= where (point-max)))))))
3671 (fontify-visited-p ; visited nodes need to be re-fontified
3672 (and Info-fontify-visited-nodes
3673 ;; Don't take time to refontify visited nodes in huge nodes
3674 (< (- (point-max) (point-min)) Info-fontify-maximum-menu-size)))
3677 ;; Fontify header line
3678 (goto-char (point-min))
3679 (when (and not-fontified-p (looking-at "^\\(File: [^,: \t]+,?[ \t]+\\)?"))
3680 (goto-char (match-end 0))
3681 (while (looking-at "[ \t]*\\([^:, \t\n]+\\):[ \t]+\\([^:,\t\n]+\\),?")
3682 (goto-char (match-end 0))
3683 (let* ((nbeg (match-beginning 2))
3684 (nend (match-end 2))
3685 (tbeg (match-beginning 1))
3686 (tag (match-string 1)))
3687 (if (string-equal (downcase tag) "node")
3688 (put-text-property nbeg nend 'font-lock-face 'info-header-node)
3689 (put-text-property nbeg nend 'font-lock-face 'info-header-xref)
3690 (put-text-property tbeg nend 'mouse-face 'highlight)
3691 (put-text-property tbeg nend
3693 (concat "mouse-2: Go to node "
3694 (buffer-substring nbeg nend)))
3695 ;; Always set up the text property keymap.
3696 ;; It will either be used in the buffer
3697 ;; or copied in the header line.
3701 ((string-equal (downcase tag) "prev") Info-prev-link-keymap)
3702 ((string-equal (downcase tag) "next") Info-next-link-keymap)
3703 ((string-equal (downcase tag) "up" ) Info-up-link-keymap))))))
3704 (when Info-use-header-line
3705 (goto-char (point-min))
3706 (let* ((header-end (line-end-position))
3708 ;; If we find neither Next: nor Prev: link, show the entire
3709 ;; node header. Otherwise, don't show the File: and Node:
3710 ;; parts, to avoid wasting precious space on information that
3711 ;; is available in the mode line.
3712 (if (re-search-forward
3713 "\\(next\\|up\\|prev[ious]*\\): "
3716 (goto-char (match-beginning 1))
3717 (buffer-substring (point) header-end))
3718 (if (re-search-forward "node:[ \t]*[^ \t]+[ \t]*"
3720 (concat "No next, prev or up links -- "
3721 (buffer-substring (point) header-end))
3722 (buffer-substring (point) header-end)))))
3723 (put-text-property (point-min) (1+ (point-min))
3725 (replace-regexp-in-string
3727 ;; Preserve text properties on duplicated `%'.
3728 (lambda (s) (concat s s)) header))
3729 ;; Hide the part of the first line
3730 ;; that is in the header, if it is just part.
3732 ;; Hide the punctuation at the end, too.
3733 (skip-chars-backward " \t,")
3734 (put-text-property (point) header-end 'invisible t)))))
3737 (goto-char (point-min))
3738 (when (and font-lock-mode not-fontified-p)
3739 (while (and (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*\\*+\\|==+\\|--+\\|\\.\\.+\\)$"
3741 ;; Only consider it as an underlined title if the ASCII
3742 ;; underline has the same size as the text. A typical
3743 ;; counter example is when a continuation "..." is alone
3745 (= (string-width (match-string 1))
3746 (string-width (match-string 2))))
3747 (let* ((c (preceding-char))
3749 (cond ((= c ?*) 'info-title-1)
3750 ((= c ?=) 'info-title-2)
3751 ((= c ?-) 'info-title-3)
3752 (t 'info-title-4))))
3753 (put-text-property (match-beginning 1) (match-end 1)
3754 'font-lock-face face))
3755 ;; This is a serious problem for trying to handle multiple
3756 ;; frame types at once. We want this text to be invisible
3757 ;; on frames that can display the font above.
3758 (when (memq (framep (selected-frame)) '(x pc w32 mac))
3759 (add-text-properties (1- (match-beginning 2)) (match-end 2)
3760 '(invisible t front-sticky nil rear-nonsticky t)))))
3762 ;; Fontify cross references
3763 (goto-char (point-min))
3764 (when (or not-fontified-p fontify-visited-p)
3765 (while (re-search-forward "\\(\\*Note[ \n\t]+\\)\\([^:]*\\)\\(:[ \t]*\\([^.,:(]*\\)\\(\\(([^)]*)\\)[^.,:]*\\)?[,:]?\n?\\)" nil t)
3766 (let ((start (match-beginning 0))
3769 (when not-fontified-p
3770 (when Info-hide-note-references
3771 (when (not (eq Info-hide-note-references 'hide))
3772 ;; *Note is often used where *note should have been
3774 (skip-syntax-backward " ")
3775 (when (memq (char-before) '(?\( ?\[ ?\{))
3776 ;; Check whether the paren is preceded by
3777 ;; an end of sentence
3778 (skip-syntax-backward " ("))
3780 (cond ((save-match-data (looking-back "\\<see"))
3782 ((memq (char-before) '(nil ?\. ?! ??))
3786 (search-forward "\n\n" start t)))
3790 (add-text-properties
3792 (or (save-match-data
3793 ;; Don't hide \n after *Note
3794 (let ((start1 (match-beginning 1)))
3795 (if (string-match "\n" (match-string 1))
3796 (+ start1 (match-beginning 0)))))
3799 `(display ,other-tag front-sticky nil rear-nonsticky t)
3800 '(invisible t front-sticky nil rear-nonsticky t))))
3801 (add-text-properties
3802 (match-beginning 2) (match-end 2)
3804 'help-echo (if (or (match-end 5)
3805 (not (equal (match-string 4) "")))
3806 (concat "mouse-2: go to " (or (match-string 5)
3808 "mouse-2: go to this node")
3809 'mouse-face 'highlight)))
3810 (when (or not-fontified-p fontify-visited-p)
3811 (setq rbeg (match-beginning 2)
3816 ;; Display visited nodes in a different face
3817 (if (and Info-fontify-visited-nodes
3819 (let* ((node (replace-regexp-in-string
3821 (replace-regexp-in-string
3823 (or (match-string-no-properties 5)
3824 (and (not (equal (match-string 4) ""))
3825 (match-string-no-properties 4))
3826 (match-string-no-properties 2)))))
3828 (string-match "(\\([^)]+\\))\\([^)]*\\)" node))
3829 (file (if external-link-p
3830 (file-name-nondirectory
3831 (match-string-no-properties 1 node))
3833 (hl Info-history-list)
3836 (setq node (if (equal (match-string 2 node) "")
3838 (match-string-no-properties 2 node))))
3840 (if (and (string-equal node (nth 1 (car hl)))
3842 (if (and external-link-p
3843 (stringp (caar hl)))
3844 (file-name-nondirectory
3847 (setq res (car hl) hl nil)
3848 (setq hl (cdr hl))))
3849 res))) 'info-xref-visited 'info-xref))
3850 ;; For multiline ref, unfontify newline and surrounding whitespace
3854 (while (re-search-forward "\\s-*\n\\s-*" rend t nil)
3855 (remove-text-properties (match-beginning 0)
3857 '(font-lock-face t))))))
3858 (when not-fontified-p
3859 (when (memq Info-hide-note-references '(t hide))
3860 (add-text-properties (match-beginning 3) (match-end 3)
3861 '(invisible t front-sticky nil rear-nonsticky t))
3862 ;; Unhide the file name of the external reference in parens
3863 (if (and (match-string 6) (not (eq Info-hide-note-references 'hide)))
3864 (remove-text-properties (match-beginning 6) (match-end 6)
3865 '(invisible t front-sticky nil rear-nonsticky t)))
3866 ;; Unhide newline because hidden newlines cause too long lines
3868 (let ((beg3 (match-beginning 3))
3869 (end3 (match-end 3)))
3870 (if (and (string-match "\n[ \t]*" (match-string 3))
3871 (not (save-match-data
3873 (goto-char (1+ end3))
3874 (looking-at "[.)]*$")))))
3875 (remove-text-properties (+ beg3 (match-beginning 0))
3876 (+ beg3 (match-end 0))
3877 '(invisible t front-sticky nil rear-nonsticky t))))))
3878 (when (and Info-refill-paragraphs Info-hide-note-references)
3879 (push (set-marker (make-marker) start)
3880 paragraph-markers))))))
3882 ;; Refill paragraphs (experimental feature)
3883 (when (and not-fontified-p
3884 Info-refill-paragraphs
3886 (let ((fill-nobreak-invisible t)
3887 (fill-individual-varying-indent nil)
3888 (paragraph-start "\f\\|[ \t]*[-*]\\|[ \t]*$")
3889 (paragraph-separate ".*\\.[ \t]*\n[ \t]\\|[ \t]*[-*]\\|[ \t\f]*$")
3890 (adaptive-fill-mode nil))
3891 (goto-char (point-max))
3892 (dolist (m paragraph-markers)
3896 (let ((beg (point)))
3897 (when (zerop (forward-paragraph))
3898 (fill-individual-paragraphs beg (point) nil nil)
3900 (set-marker m nil))))
3902 ;; Fontify menu items
3903 (goto-char (point-min))
3904 (when (and (or not-fontified-p fontify-visited-p)
3905 (search-forward "\n* Menu:" nil t)
3906 (not (Info-index-node))
3907 ;; Don't take time to annotate huge menus
3908 (< (- (point-max) (point)) Info-fontify-maximum-menu-size))
3911 (while (re-search-forward
3912 (concat "^\\* Menu:\\|\\(?:^\\* +\\(" Info-menu-entry-name-re "\\)\\(:"
3913 Info-node-spec-re "\\([ \t]*\\)\\)\\)")
3915 (when (match-beginning 1)
3916 (when not-fontified-p
3918 (if (and (<= n 9) (zerop (% n 3))) ; visual aids to help with 1-9 keys
3919 (put-text-property (match-beginning 0)
3920 (1+ (match-beginning 0))
3921 'font-lock-face 'info-menu-star)))
3922 (when not-fontified-p
3923 (add-text-properties
3924 (match-beginning 1) (match-end 1)
3926 'help-echo (if (and (match-end 3)
3927 (not (equal (match-string 3) "")))
3928 (concat "mouse-2: go to " (match-string 3))
3929 "mouse-2: go to this node")
3930 'mouse-face 'highlight)))
3931 (when (or not-fontified-p fontify-visited-p)
3933 (match-beginning 1) (match-end 1)
3935 ;; Display visited menu items in a different face
3936 (if (and Info-fontify-visited-nodes
3938 (let* ((node (if (equal (match-string 3) "")
3939 (match-string-no-properties 1)
3940 (match-string-no-properties 3)))
3942 (string-match "(\\([^)]+\\))\\([^)]*\\)" node))
3943 (file (if external-link-p
3944 (file-name-nondirectory
3945 (match-string-no-properties 1 node))
3947 (hl Info-history-list)
3950 (setq node (if (equal (match-string 2 node) "")
3952 (match-string-no-properties 2 node))))
3954 (if (and (string-equal node (nth 1 (car hl)))
3956 (if (and external-link-p
3957 (stringp (caar hl)))
3958 (file-name-nondirectory
3961 (setq res (car hl) hl nil)
3962 (setq hl (cdr hl))))
3963 res))) 'info-xref-visited 'info-xref)))
3964 (when (and not-fontified-p (memq Info-hide-note-references '(t hide)))
3965 (put-text-property (match-beginning 2) (1- (match-end 6))
3967 ;; Unhide the file name in parens
3968 (if (and (match-end 4) (not (eq (char-after (match-end 4)) ?.)))
3969 (remove-text-properties (match-beginning 4) (match-end 4)
3971 ;; We need a stretchable space like :align-to but with
3973 (put-text-property (1- (match-end 6)) (match-end 6) 'display
3974 (if (>= 22 (- (match-end 1)
3975 (match-beginning 0)))
3976 '(space :align-to 24)
3978 (setq cont (looking-at "."))
3979 (while (and (= (forward-line 1) 0)
3980 (looking-at "\\([ \t]+\\)[^*\n]"))
3981 (put-text-property (match-beginning 1) (1- (match-end 1))
3983 (put-text-property (1- (match-end 1)) (match-end 1)
3986 '(space :align-to 26)
3987 '(space :align-to 24)))
3990 ;; Fontify menu headers
3991 ;; Add the face `info-menu-header' to any header before a menu entry
3992 (goto-char (point-min))
3993 (when (and not-fontified-p (re-search-forward "^\\* Menu:" nil t))
3994 (put-text-property (match-beginning 0) (match-end 0)
3995 'font-lock-face 'info-menu-header)
3996 (while (re-search-forward "\n\n\\([^*\n ].*\\)\n\n?[*]" nil t)
3997 (put-text-property (match-beginning 1) (match-end 1)
3998 'font-lock-face 'info-menu-header)))
4000 ;; Hide index line numbers
4001 (goto-char (point-min))
4002 (when (and not-fontified-p (Info-index-node))
4003 (while (re-search-forward "[ \t\n]*(line +[0-9]+)" nil t)
4004 (put-text-property (match-beginning 0) (match-end 0)
4007 ;; Fontify http and ftp references
4008 (goto-char (point-min))
4009 (when not-fontified-p
4010 (while (re-search-forward "[hf]t?tp://[^ \t\n\"`({<>})']+" nil t)
4011 (add-text-properties (match-beginning 0) (match-end 0)
4012 '(font-lock-face info-xref
4013 mouse-face highlight
4014 help-echo "mouse-2: go to this URL"))))
4016 (set-buffer-modified-p nil))))
4018 ;;; Speedbar support:
4019 ;; These functions permit speedbar to display the "tags" in the
4020 ;; current Info node.
4021 (eval-when-compile (require 'speedbar))
4023 (defvar Info-speedbar-key-map nil
4024 "Keymap used when in the info display mode.")
4026 (defun Info-install-speedbar-variables ()
4027 "Install those variables used by speedbar to enhance Info."
4028 (if Info-speedbar-key-map
4030 (setq Info-speedbar-key-map (speedbar-make-specialized-keymap))
4032 ;; Basic tree features
4033 (define-key Info-speedbar-key-map "e" 'speedbar-edit-line)
4034 (define-key Info-speedbar-key-map "\C-m" 'speedbar-edit-line)
4035 (define-key Info-speedbar-key-map "+" 'speedbar-expand-line)
4036 (define-key Info-speedbar-key-map "-" 'speedbar-contract-line)
4039 (speedbar-add-expansion-list '("Info" Info-speedbar-menu-items
4040 Info-speedbar-key-map
4041 Info-speedbar-hierarchy-buttons)))
4043 (defvar Info-speedbar-menu-items
4044 '(["Browse Node" speedbar-edit-line t]
4045 ["Expand Node" speedbar-expand-line
4046 (save-excursion (beginning-of-line)
4047 (looking-at "[0-9]+: *.\\+. "))]
4048 ["Contract Node" speedbar-contract-line
4049 (save-excursion (beginning-of-line)
4050 (looking-at "[0-9]+: *.-. "))]
4052 "Additional menu-items to add to speedbar frame.")
4054 ;; Make sure our special speedbar major mode is loaded
4055 (if (featurep 'speedbar)
4056 (Info-install-speedbar-variables)
4057 (add-hook 'speedbar-load-hook 'Info-install-speedbar-variables))
4059 ;;; Info hierarchy display method
4061 (defun Info-speedbar-browser ()
4062 "Initialize speedbar to display an Info node browser.
4063 This will add a speedbar major display mode."
4066 ;; Make sure that speedbar is active
4067 (speedbar-frame-mode 1)
4068 ;; Now, throw us into Info mode on speedbar.
4069 (speedbar-change-initial-expansion-list "Info")
4072 (defun Info-speedbar-hierarchy-buttons (directory depth &optional node)
4073 "Display an Info directory hierarchy in speedbar.
4074 DIRECTORY is the current directory in the attached frame.
4075 DEPTH is the current indentation depth.
4076 NODE is an optional argument that is used to represent the
4077 specific node to expand."
4079 (save-excursion (goto-char (point-min))
4080 (let ((case-fold-search t))
4081 (looking-at "Info Nodes:"))))
4082 ;; Update our "current node" maybe?
4084 ;; We cannot use the generic list code, that depends on all leaves
4085 ;; being known at creation time.
4087 (speedbar-with-writable (insert "Info Nodes:\n")))
4088 (let ((completions nil))
4089 (speedbar-select-attached-frame)
4090 (save-window-excursion
4092 (Info-speedbar-fetch-file-nodes (or node '"(dir)top"))))
4093 (select-frame (speedbar-current-frame))
4095 (speedbar-with-writable
4096 (dolist (completion completions)
4097 (speedbar-make-tag-line 'bracket ?+ 'Info-speedbar-expand-node
4100 'Info-speedbar-goto-node
4106 (defun Info-speedbar-goto-node (text node indent)
4107 "When user clicks on TEXT, go to an info NODE.
4108 The INDENT level is ignored."
4109 (speedbar-select-attached-frame)
4110 (let* ((buff (or (get-buffer "*info*")
4111 (progn (info) (get-buffer "*info*"))))
4112 (bwin (get-buffer-window buff 0)))
4115 (select-window bwin)
4116 (raise-frame (window-frame bwin)))
4117 (if speedbar-power-click
4118 (let ((pop-up-frames t)) (select-window (display-buffer buff)))
4119 (speedbar-select-attached-frame)
4120 (switch-to-buffer buff)))
4121 (if (not (string-match "^(\\([^)]+\\))\\([^.]+\\)$" node))
4122 (error "Invalid node %s" node)
4123 (Info-find-node (match-string 1 node) (match-string 2 node))
4124 ;; If we do a find-node, and we were in info mode, restore
4125 ;; the old default method. Once we are in info mode, it makes
4126 ;; sense to return to whatever method the user was using before.
4127 (if (string= speedbar-initial-expansion-list-name "Info")
4128 (speedbar-change-initial-expansion-list
4129 speedbar-previously-used-expansion-list-name)))))
4131 (defun Info-speedbar-expand-node (text token indent)
4132 "Expand the node the user clicked on.
4133 TEXT is the text of the button we clicked on, a + or - item.
4134 TOKEN is data related to this node (NAME . FILE).
4135 INDENT is the current indentation depth."
4136 (cond ((string-match "+" text) ;we have to expand this file
4137 (speedbar-change-expand-button-char ?-)
4138 (if (speedbar-with-writable
4140 (end-of-line) (forward-char 1)
4141 (Info-speedbar-hierarchy-buttons nil (1+ indent) token)))
4142 (speedbar-change-expand-button-char ?-)
4143 (speedbar-change-expand-button-char ??)))
4144 ((string-match "-" text) ;we have to contract this node
4145 (speedbar-change-expand-button-char ?+)
4146 (speedbar-delete-subblock indent))
4147 (t (error "Ooops... not sure what to do")))
4148 (speedbar-center-buffer-smartly))
4150 (defun Info-speedbar-fetch-file-nodes (nodespec)
4151 "Fetch the subnodes from the info NODESPEC.
4152 NODESPEC is a string of the form: (file)node."
4154 ;; Set up a buffer we can use to fake-out Info.
4155 (set-buffer (get-buffer-create " *info-browse-tmp*"))
4156 (if (not (equal major-mode 'Info-mode))
4158 ;; Get the node into this buffer
4159 (if (not (string-match "^(\\([^)]+\\))\\([^.]+\\)$" nodespec))
4160 (error "Invalid node specification %s" nodespec)
4161 (Info-find-node (match-string 1 nodespec) (match-string 2 nodespec)))
4162 ;; Scan the created buffer
4163 (goto-char (point-min))
4164 (let ((completions nil)
4165 (case-fold-search t)
4166 (thisfile (progn (string-match "^(\\([^)]+\\))" nodespec)
4167 (match-string 1 nodespec))))
4168 ;; Always skip the first one...
4169 (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
4170 (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
4171 (let ((name (match-string 1)))
4173 (if (looking-at " *\\(([^)]+)[^.\n]+\\)\\.")
4175 (if (looking-at " *\\(([^)]+)\\)\\.")
4176 (concat (match-string 1) "Top")
4177 (concat "(" thisfile ")"
4178 (if (looking-at " \\([^.]+\\).")
4182 (nreverse completions))))
4184 ;;; Info mode node listing
4185 ;; This is called by `speedbar-add-localized-speedbar-support'
4186 (defun Info-speedbar-buttons (buffer)
4187 "Create a speedbar display to help navigation in an Info file.
4188 BUFFER is the buffer speedbar is requesting buttons for."
4189 (if (save-excursion (goto-char (point-min))
4190 (let ((case-fold-search t))
4191 (not (looking-at "Info Nodes:"))))
4193 (Info-speedbar-hierarchy-buttons nil 0))
4195 (dolist (mess '("^First node in file$"
4196 "^No `.*' in index$"
4197 "^No cross-reference named"
4198 "^No cross.references in this node$"
4199 "^No current Info node$"
4200 "^No menu in this node$"
4201 "^No more items in menu$"
4203 "^No pointer \\(?:forward\\|backward\\) from this node$"
4204 "^No previous `i' command$"
4205 "^No previous items in menu$"
4206 "^No previous nodes$"
4207 "^No such item in menu$"
4208 "^No such node or anchor"
4210 "^Point neither on reference nor in menu item description$"
4211 "^This is the \\(?:first\\|last\\) Info node you looked at$"
4213 (add-to-list 'debug-ignored-errors mess))
4215 ;;;; Desktop support
4217 (defun Info-desktop-buffer-misc-data (desktop-dirname)
4218 "Auxiliary information to be saved in desktop file."
4219 (unless (member Info-current-file '(apropos history toc nil))
4220 (list Info-current-file Info-current-node)))
4222 (defun Info-restore-desktop-buffer (desktop-buffer-file-name
4224 desktop-buffer-misc)
4225 "Restore an Info buffer specified in a desktop file."
4226 (let ((first (nth 0 desktop-buffer-misc))
4227 (second (nth 1 desktop-buffer-misc)))
4228 (when (and first second)
4229 (when desktop-buffer-name
4230 (set-buffer (get-buffer-create desktop-buffer-name))
4232 (Info-find-node first second)
4235 (add-to-list 'desktop-buffer-mode-handlers
4236 '(Info-mode . Info-restore-desktop-buffer))
4240 ;; arch-tag: f2480fe2-2139-40c1-a49b-6314991164ac
4241 ;;; info.el ends here