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, 2007, 2008, 2009
5 ;; Free Software Foundation, Inc.
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 ;; Note that nowadays we expect Info files to be made using makeinfo.
28 ;; In particular we make these assumptions:
29 ;; - a menu item MAY contain colons but not colon-space ": "
30 ;; - a menu item ending with ": " (but not ":: ") is an index entry
31 ;; - a node name MAY NOT contain a colon
32 ;; This distinction is to support indexing of computer programming
33 ;; language terms that may contain ":" but not ": ".
37 (eval-when-compile (require 'jka-compr
) (require 'cl
))
45 (defvar Info-history nil
46 "Stack of Info nodes user has visited.
47 Each element of the stack is a list (FILENAME NODENAME BUFFERPOS).")
49 (defvar Info-history-forward nil
50 "Stack of Info nodes user has visited with `Info-history-back' command.
51 Each element of the stack is a list (FILENAME NODENAME BUFFERPOS).")
53 (defvar Info-history-list nil
54 "List of all Info nodes user has visited.
55 Each element of the list is a list (FILENAME NODENAME).")
57 (defcustom Info-enable-edit nil
58 "Non-nil means the \\<Info-mode-map>\\[Info-edit] command in Info can edit the current node.
59 This is convenient if you want to write Info files by hand.
60 However, we recommend that you not do this.
61 It is better to write a Texinfo file and generate the Info file from that,
62 because that gives you a printed manual as well."
66 (defvar Info-enable-active-nodes nil
67 "Non-nil allows Info to execute Lisp code associated with nodes.
68 The Lisp code is executed when the node is selected.")
69 (put 'Info-enable-active-nodes
'risky-local-variable t
)
72 '((((class color
) (background light
)) :foreground
"brown" :weight bold
:slant italic
)
73 (((class color
) (background dark
)) :foreground
"white" :weight bold
:slant italic
)
74 (t :weight bold
:slant italic
))
75 "Face for Info node names."
79 '((((type tty pc
) (class color
) (background light
))
80 :foreground
"green" :weight bold
)
81 (((type tty pc
) (class color
) (background dark
))
82 :foreground
"yellow" :weight bold
)
83 (t :height
1.2 :inherit info-title-2
))
84 "Face for info titles at level 1."
86 ;; backward-compatibility alias
87 (put 'Info-title-1-face
'face-alias
'info-title-1
)
90 '((((type tty pc
) (class color
)) :foreground
"lightblue" :weight bold
)
91 (t :height
1.2 :inherit info-title-3
))
92 "Face for info titles at level 2."
94 ;; backward-compatibility alias
95 (put 'Info-title-2-face
'face-alias
'info-title-2
)
98 '((((type tty pc
) (class color
)) :weight bold
)
99 (t :height
1.2 :inherit info-title-4
))
100 "Face for info titles at level 3."
102 ;; backward-compatibility alias
103 (put 'Info-title-3-face
'face-alias
'info-title-3
)
105 (defface info-title-4
106 '((((type tty pc
) (class color
)) :weight bold
)
107 (t :weight bold
:inherit variable-pitch
))
108 "Face for info titles at level 4."
110 ;; backward-compatibility alias
111 (put 'Info-title-4-face
'face-alias
'info-title-4
)
113 (defface info-menu-header
118 :inherit variable-pitch
120 "Face for headers in Info menus."
123 (defface info-menu-star
124 '((((class color
)) :foreground
"red1")
126 "Face for every third `*' in an Info menu."
128 (put 'info-menu-5
'face-alias
'info-menu-star
)
132 "Face for unvisited Info cross-references."
135 (defface info-xref-visited
136 '((t :inherit
(link-visited info-xref
)))
137 "Face for visited Info cross-references."
141 (defcustom Info-fontify-visited-nodes t
142 "Non-nil to fontify references to visited nodes in `info-xref-visited' face."
147 (defcustom Info-fontify-maximum-menu-size
100000
148 "Maximum size of menu to fontify if `font-lock-mode' is non-nil.
149 Set to nil to disable node fontification."
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. If this is non-nil, you might
225 want to set `Info-refill-paragraphs'."
227 :type
'(choice (const :tag
"No hiding" nil
)
228 (const :tag
"Replace tag and hide reference" t
)
229 (const :tag
"Hide tag and reference" hide
)
230 (other :tag
"Only replace tag" tag
))
233 (defcustom Info-refill-paragraphs nil
234 "If non-nil, attempt to refill paragraphs with hidden references.
235 This refilling may accidentally remove explicit line breaks in the Info
236 file, so be prepared for a few surprises if you enable this feature.
237 This only has an effect if `Info-hide-note-references' is non-nil."
242 (defcustom Info-breadcrumbs-depth
4
243 "Depth of breadcrumbs to display.
244 0 means do not display breadcrumbs."
247 (defcustom Info-search-whitespace-regexp
"\\s-+"
248 "If non-nil, regular expression to match a sequence of whitespace chars.
249 This applies to Info search for regular expressions.
250 You might want to use something like \"[ \\t\\r\\n]+\" instead.
251 In the Customization buffer, that is `[' followed by a space,
252 a tab, a carriage return (control-M), a newline, and `]+'."
256 (defcustom Info-isearch-search t
257 "If non-nil, isearch in Info searches through multiple nodes.
258 Before leaving the initial Info node, where isearch was started,
259 it fails once with the error message [initial node], and with
260 subsequent C-s/C-r continues through other nodes without failing
261 with this error message in other nodes. When isearch fails for
262 the rest of the manual, it wraps aroung the whole manual and
263 restarts the search from the top/final node depending on
266 Setting this option to nil restores the default isearch behavior
267 with wrapping around the current Info node."
272 (defvar Info-isearch-initial-node nil
)
274 (defcustom Info-mode-hook
275 ;; Try to obey obsolete Info-fontify settings.
276 (unless (and (boundp 'Info-fontify
) (null Info-fontify
))
277 '(turn-on-font-lock))
278 "Hooks run when `Info-mode' is called."
282 (defcustom Info-selection-hook nil
283 "Hooks run when `Info-select-node' is called."
287 (defvar Info-edit-mode-hook nil
288 "Hooks run when `Info-edit-mode' is called.")
290 (defvar Info-current-file nil
291 "Info file that Info is now looking at, or nil.
292 This is the name that was specified in Info, not the actual file name.
293 It doesn't contain directory names or file name extensions added by Info.")
295 (defvar Info-current-subfile nil
296 "Info subfile that is actually in the *info* buffer now.
297 It is nil if current Info file is not split into subfiles.")
299 (defvar Info-current-node nil
300 "Name of node that Info is now looking at, or nil.")
302 (defvar Info-tag-table-marker nil
303 "Marker pointing at beginning of current Info file's tag table.
304 Marker points nowhere if file has no tag table.")
306 (defvar Info-tag-table-buffer nil
307 "Buffer used for indirect tag tables.")
309 (defvar Info-current-file-completions nil
310 "Cached completion list for current Info file.")
312 (defvar Info-file-supports-index-cookies nil
313 "Non-nil if current Info file supports index cookies.")
315 (defvar Info-file-supports-index-cookies-list nil
316 "List of Info files with information about index cookies support.
317 Each element of the list is a list (FILENAME SUPPORTS-INDEX-COOKIES)
318 where SUPPORTS-INDEX-COOKIES can be either t or nil.")
320 (defvar Info-index-alternatives nil
321 "List of possible matches for last `Info-index' command.")
323 (defvar Info-point-loc nil
324 "Point location within a selected node.
325 If string, the point is moved to the proper occurrence of the
326 name of the followed cross reference within a selected node.
327 If number, the point is moved to the corresponding line.")
329 (defvar Info-standalone nil
330 "Non-nil if Emacs was started solely as an Info browser.")
332 (defvar Info-suffix-list
333 ;; The MS-DOS list should work both when long file names are
334 ;; supported (Windows 9X), and when only 8+3 file names are available.
335 (if (eq system-type
'ms-dos
)
336 '( (".gz" .
"gunzip")
338 (".bz2" .
("bzip2" "-dc"))
341 (".info.Z" .
"gunzip")
342 (".info.gz" .
"gunzip")
343 ("-info.Z" .
"gunzip")
344 ("-info.gz" .
"gunzip")
345 ("/index.gz".
"gunzip")
346 ("/index.z" .
"gunzip")
352 '( (".info.Z".
"uncompress")
353 (".info.Y".
"unyabba")
354 (".info.gz".
"gunzip")
355 (".info.z".
"gunzip")
356 (".info.bz2" .
("bzip2" "-dc"))
358 ("-info.Z".
"uncompress")
359 ("-info.Y".
"unyabba")
360 ("-info.gz".
"gunzip")
361 ("-info.bz2" .
("bzip2" "-dc"))
362 ("-info.z".
"gunzip")
364 ("/index.Z".
"uncompress")
365 ("/index.Y".
"unyabba")
366 ("/index.gz".
"gunzip")
367 ("/index.z".
"gunzip")
368 ("/index.bz2".
("bzip2" "-dc"))
374 (".bz2" .
("bzip2" "-dc"))
376 "List of file name suffixes and associated decoding commands.
377 Each entry should be (SUFFIX . STRING); the file is given to
378 the command as standard input.
380 STRING may be a list of strings. In that case, the first element is
381 the command name, and the rest are arguments to that command.
383 If STRING is nil, no decoding is done.
384 Because the SUFFIXes are tried in order, the empty string should
385 be last in the list.")
387 ;; Concatenate SUFFIX onto FILENAME. SUFFIX should start with a dot.
388 ;; First, on MS-DOS with no long file names support, delete some of
389 ;; the extension in FILENAME to make room.
390 (defun info-insert-file-contents-1 (filename suffix lfn
)
391 (if lfn
; long file names are supported
392 (concat filename suffix
)
393 (let* ((sans-exts (file-name-sans-extension filename
))
394 ;; How long is the extension in FILENAME (not counting the dot).
395 (ext-len (max 0 (- (length filename
) (length sans-exts
) 1)))
397 ;; SUFFIX starts with a dot. If FILENAME already has one,
398 ;; get rid of the one in SUFFIX (unless suffix is empty).
399 (or (and (<= ext-len
0)
400 (not (eq (aref filename
(1- (length filename
))) ?.
)))
401 (= (length suffix
) 0)
402 (setq suffix
(substring suffix
1)))
403 ;; How many chars of that extension should we keep?
404 (setq ext-left
(min ext-len
(max 0 (- 3 (length suffix
)))))
405 ;; Get rid of the rest of the extension, and add SUFFIX.
406 (concat (substring filename
0 (- (length filename
)
407 (- ext-len ext-left
)))
410 (defun info-file-exists-p (filename)
411 (and (file-exists-p filename
)
412 (not (file-directory-p filename
))))
414 (defun info-insert-file-contents (filename &optional visit
)
415 "Insert the contents of an Info file in the current buffer.
416 Do the right thing if the file has been compressed or zipped."
417 (let* ((tail Info-suffix-list
)
418 (lfn (if (fboundp 'msdos-long-file-names
)
419 (msdos-long-file-names)
421 (check-short (and (fboundp 'msdos-long-file-names
)
423 fullname decoder done
)
424 (if (info-file-exists-p filename
)
425 ;; FILENAME exists--see if that name contains a suffix.
426 ;; If so, set DECODE accordingly.
430 (concat (regexp-quote (car (car tail
))) "$")
432 (setq tail
(cdr tail
)))
433 (setq fullname filename
434 decoder
(cdr (car tail
))))
435 ;; Try adding suffixes to FILENAME and see if we can find something.
436 (while (and tail
(not done
))
437 (setq fullname
(info-insert-file-contents-1 filename
438 (car (car tail
)) lfn
))
439 (if (info-file-exists-p fullname
)
441 ;; If we found a file with a suffix, set DECODER
442 ;; according to the suffix.
443 decoder
(cdr (car tail
)))
444 ;; When the MS-DOS port runs on Windows, we need to check
445 ;; the short variant of a long file name as well.
447 (setq fullname
(info-insert-file-contents-1 filename
448 (car (car tail
)) nil
))
449 (if (info-file-exists-p fullname
)
451 decoder
(cdr (car tail
))))))
452 (setq tail
(cdr tail
)))
454 (error "Can't find %s or any compressed version of it" filename
)))
455 ;; check for conflict with jka-compr
456 (if (and (jka-compr-installed-p)
457 (jka-compr-get-compression-info fullname
))
461 (insert-file-contents-literally fullname visit
)
462 (let ((inhibit-read-only t
)
463 (coding-system-for-write 'no-conversion
)
464 (inhibit-null-byte-detection t
) ; Index nodes include null bytes
465 (default-directory (or (file-name-directory fullname
)
468 (setq decoder
(list decoder
)))
469 (apply 'call-process-region
(point-min) (point-max)
470 (car decoder
) t t nil
(cdr decoder
))))
471 (let ((inhibit-null-byte-detection t
)) ; Index nodes include null bytes
472 (insert-file-contents fullname visit
)))))
474 (defun Info-file-supports-index-cookies (&optional file
)
475 "Return non-nil value if FILE supports Info index cookies.
476 Info index cookies were first introduced in 4.7, and all later
477 makeinfo versions output them in index nodes, so we can rely
478 solely on the makeinfo version. This function caches the information
479 in `Info-file-supports-index-cookies-list'."
480 (or file
(setq file Info-current-file
))
481 (or (assoc file Info-file-supports-index-cookies-list
)
482 ;; Skip virtual Info files
483 (and (or (not (stringp file
))
484 (member file
'("dir" apropos history toc
)))
485 (setq Info-file-supports-index-cookies-list
486 (cons (cons file nil
) Info-file-supports-index-cookies-list
)))
489 (goto-char (point-min))
491 (if (and (re-search-forward
492 "makeinfo[ \n]version[ \n]\\([0-9]+.[0-9]+\\)"
493 (line-beginning-position 3) t
)
494 (not (version< (match-string 1) "4.7")))
497 (setq Info-file-supports-index-cookies-list
498 (cons (cons file found
) Info-file-supports-index-cookies-list
)))))
499 (cdr (assoc file Info-file-supports-index-cookies-list
)))
502 (defun Info-default-dirs ()
503 (let ((source (expand-file-name "info/" source-directory
))
504 (sibling (if installation-directory
505 (expand-file-name "info/" installation-directory
)
506 (if invocation-directory
507 (let ((infodir (expand-file-name
509 invocation-directory
)))
510 (if (file-exists-p infodir
)
512 (setq infodir
(expand-file-name
513 "../../../share/info/"
514 invocation-directory
))
515 (and (file-exists-p infodir
)
519 (if (and sibling
(file-exists-p sibling
))
520 ;; Uninstalled, Emacs builddir != srcdir.
522 ;; Uninstalled, builddir == srcdir
524 (if (or (member alternative Info-default-directory-list
)
525 ;; On DOS/NT, we use movable executables always,
526 ;; and we must always find the Info dir at run time.
527 (if (memq system-type
'(ms-dos windows-nt
))
529 ;; Use invocation-directory for Info
530 ;; only if we used it for exec-directory also.
531 (not (string= exec-directory
532 (expand-file-name "lib-src/"
533 installation-directory
))))
534 (not (file-exists-p alternative
)))
535 Info-default-directory-list
536 ;; `alternative' contains the Info files that came with this
537 ;; version, so we should look there first. `Info-insert-dir'
538 ;; currently expects to find `alternative' first on the list.
540 ;; Don't drop the last part, it might contain non-Emacs stuff.
541 ;; (reverse (cdr (reverse
542 Info-default-directory-list
)))) ;; )))
544 (defun info-initialize ()
545 "Initialize `Info-directory-list', if that hasn't been done yet."
546 (unless Info-directory-list
547 (let ((path (getenv "INFOPATH")))
548 (setq Info-directory-list
549 (prune-directory-list
551 (if (string-match ":\\'" path
)
552 (append (split-string (substring path
0 -
1)
553 (regexp-quote path-separator
))
555 (split-string path
(regexp-quote path-separator
)))
556 (Info-default-dirs)))))))
559 (defun info-other-window (&optional file-or-node
)
560 "Like `info' but show the Info buffer in another window."
561 (interactive (if current-prefix-arg
562 (list (read-file-name "Info file name: " nil nil t
))))
563 (let (same-window-buffer-names same-window-regexps
)
564 (info file-or-node
)))
566 ;;;###autoload (add-hook 'same-window-regexps "\\*info\\*\\(\\|<[0-9]+>\\)")
568 ;;;###autoload (put 'info 'info-file "emacs")
570 (defun info (&optional file-or-node buffer
)
571 "Enter Info, the documentation browser.
572 Optional argument FILE-OR-NODE specifies the file to examine;
573 the default is the top-level directory of Info.
574 Called from a program, FILE-OR-NODE may specify an Info node of the form
575 `(FILENAME)NODENAME'.
576 Optional argument BUFFER specifies the Info buffer name;
577 the default buffer name is *info*. If BUFFER exists,
578 just switch to BUFFER. Otherwise, create a new buffer
579 with the top-level Info directory.
581 In interactive use, a non-numeric prefix argument directs
582 this command to read a file name from the minibuffer.
583 A numeric prefix argument selects an Info buffer with the prefix number
584 appended to the Info buffer name.
586 The search path for Info files is in the variable `Info-directory-list'.
587 The top-level Info directory is made by combining all the files named `dir'
588 in all the directories in that path.
590 See a list of available Info commands in `Info-mode'."
592 (if (and current-prefix-arg
(not (numberp current-prefix-arg
)))
593 (read-file-name "Info file name: " nil nil t
))
594 (if (numberp current-prefix-arg
)
595 (format "*info*<%s>" current-prefix-arg
))))
596 (pop-to-buffer (or buffer
"*info*"))
597 (if (and buffer
(not (eq major-mode
'Info-mode
)))
600 ;; If argument already contains parentheses, don't add another set
601 ;; since the argument will then be parsed improperly. This also
602 ;; has the added benefit of allowing node names to be included
603 ;; following the parenthesized filename.
605 (if (and (stringp file-or-node
) (string-match "(.*)" file-or-node
))
607 (concat "(" file-or-node
")")))
608 (if (and (zerop (buffer-size))
610 ;; If we just created the Info buffer, go to the directory.
614 (defun info-emacs-manual ()
615 "Display the Emacs manual in Info mode."
620 (defun info-standalone ()
621 "Run Emacs as a standalone Info reader.
622 Usage: emacs -f info-standalone [filename]
623 In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
624 (setq Info-standalone t
)
625 (if (and command-line-args-left
626 (not (string-match "^-" (car command-line-args-left
))))
629 (info (car command-line-args-left
))
630 (setq command-line-args-left
(cdr command-line-args-left
)))
631 (error (send-string-to-terminal
632 (format "%s\n" (if (eq (car-safe err
) 'error
)
634 (save-buffers-kill-emacs)))
637 ;; See if the accessible portion of the buffer begins with a node
638 ;; delimiter, and the node header line which follows matches REGEXP.
639 ;; Typically, this test will be followed by a loop that examines the
640 ;; rest of the buffer with (search-forward "\n\^_"), and it's a pity
641 ;; to have the overhead of this special test inside the loop.
643 ;; This function changes match-data, but supposedly the caller might
644 ;; want to use the results of re-search-backward.
646 ;; The return value is the value of point at the beginning of matching
647 ;; REGEXP, if the function succeeds, nil otherwise.
648 (defun Info-node-at-bob-matching (regexp)
649 (and (bobp) ; are we at beginning of buffer?
650 (looking-at "\^_") ; does it begin with node delimiter?
654 (forward-line 1) ; does the line after delimiter match REGEXP?
655 (re-search-backward regexp beg t
))))
657 (defun Info-find-file (filename &optional noerror
)
658 "Return expanded FILENAME, or t, if FILENAME is \"dir\".
659 Optional second argument NOERROR, if t, means if file is not found
660 just return nil (no error)."
661 ;; Convert filename to lower case if not found as specified.
663 (if (stringp filename
)
664 (let (temp temp-downcase found
)
665 (setq filename
(substitute-in-file-name filename
))
667 ((string= (downcase filename
) "dir")
670 (let ((dirs (if (string-match "^\\./" filename
)
671 ;; If specified name starts with `./'
672 ;; then just try current directory.
674 (if (file-name-absolute-p filename
)
675 ;; No point in searching for an
676 ;; absolute file name
678 (if Info-additional-directory-list
679 (append Info-directory-list
680 Info-additional-directory-list
)
681 Info-directory-list
)))))
682 ;; Search the directory list for file FILENAME.
683 (while (and dirs
(not found
))
684 (setq temp
(expand-file-name filename
(car dirs
)))
686 (expand-file-name (downcase filename
) (car dirs
)))
687 ;; Try several variants of specified name.
688 (let ((suffix-list Info-suffix-list
)
689 (lfn (if (fboundp 'msdos-long-file-names
)
690 (msdos-long-file-names)
692 (while (and suffix-list
(not found
))
693 (cond ((info-file-exists-p
694 (info-insert-file-contents-1
695 temp
(car (car suffix-list
)) lfn
))
698 (info-insert-file-contents-1
699 temp-downcase
(car (car suffix-list
)) lfn
))
700 (setq found temp-downcase
))
701 ((and (fboundp 'msdos-long-file-names
)
704 (info-insert-file-contents-1
705 temp
(car (car suffix-list
)) nil
)))
707 (setq suffix-list
(cdr suffix-list
))))
708 (setq dirs
(cdr dirs
))))))
710 (setq filename found
)
713 (error "Info file %s does not exist" filename
)))
715 (and (member filename
'(apropos history toc
)) filename
)))
717 (defun Info-find-node (filename nodename
&optional no-going-back
)
718 "Go to an Info node specified as separate FILENAME and NODENAME.
719 NO-GOING-BACK is non-nil if recovering from an error in this function;
720 it says do not attempt further (recursive) error recovery."
722 (setq filename
(Info-find-file filename
))
723 ;; Go into Info buffer.
724 (or (eq major-mode
'Info-mode
) (pop-to-buffer "*info*"))
725 ;; Record the node we are leaving, if we were in one.
726 (and (not no-going-back
)
728 (push (list Info-current-file Info-current-node
(point))
730 (Info-find-node-2 filename nodename no-going-back
))
733 (defun Info-on-current-buffer (&optional nodename
)
734 "Use Info mode to browse the current Info buffer.
735 With a prefix arg, this queries for the node name to visit first;
736 otherwise, that defaults to `Top'."
738 (list (if current-prefix-arg
739 (completing-read "Node name: " (Info-build-node-completions)
741 (unless nodename
(setq nodename
"Top"))
744 (set (make-local-variable 'Info-current-file
)
746 ;; If called on a non-file buffer, make a fake file name.
747 (concat default-directory
(buffer-name))))
748 (Info-find-node-2 nil nodename
))
750 ;; It's perhaps a bit nasty to kill the *info* buffer to force a re-read,
751 ;; but at least it keeps this routine (which is for makeinfo-buffer and
752 ;; Info-revert-buffer-function) out of the way of normal operations.
754 (defun Info-revert-find-node (filename nodename
)
755 "Go to an Info node FILENAME and NODENAME, re-reading disk contents.
756 When *info* is already displaying FILENAME and NODENAME, the window position
757 is preserved, if possible."
758 (pop-to-buffer "*info*")
759 (let ((old-filename Info-current-file
)
760 (old-nodename Info-current-node
)
761 (pcolumn (current-column))
762 (pline (count-lines (point-min) (line-beginning-position)))
763 (wline (count-lines (point-min) (window-start)))
764 (old-history Info-history
)
765 (new-history (and Info-current-file
766 (list Info-current-file Info-current-node
(point)))))
767 (kill-buffer (current-buffer))
768 (Info-find-node filename nodename
)
769 (setq Info-history old-history
)
770 (if (and (equal old-filename Info-current-file
)
771 (equal old-nodename Info-current-node
))
773 ;; note goto-line is no good, we want to measure from point-min
774 (goto-char (point-min))
776 (set-window-start (selected-window) (point))
777 (goto-char (point-min))
779 (move-to-column pcolumn
))
780 ;; only add to the history when coming from a different file+node
782 (setq Info-history
(cons new-history Info-history
))))))
784 (defun Info-revert-buffer-function (ignore-auto noconfirm
)
785 (when (or noconfirm
(y-or-n-p "Revert info buffer? "))
786 (Info-revert-find-node Info-current-file Info-current-node
)
787 (message "Reverted %s" Info-current-file
)))
789 (defun Info-find-in-tag-table-1 (marker regexp case-fold
)
790 "Find a node in a tag table.
791 MARKER specifies the buffer and position to start searching at.
792 REGEXP is a regular expression matching nodes or references. Its first
793 group should match `Node:' or `Ref:'.
794 CASE-FOLD t means search for a case-insensitive match.
795 If a match was found, value is a list (FOUND-ANCHOR POS MODE), where
796 FOUND-ANCHOR is non-nil if a `Ref:' was matched, POS is the position
797 where the match was found, and MODE is `major-mode' of the buffer in
798 which the match was found."
799 (let ((case-fold-search case-fold
))
800 (with-current-buffer (marker-buffer marker
)
805 (when (re-search-forward regexp nil t
)
806 (list (string-equal "Ref:" (match-string 1))
807 (+ (point-min) (read (current-buffer)))
810 (defun Info-find-in-tag-table (marker regexp
)
811 "Find a node in a tag table.
812 MARKER specifies the buffer and position to start searching at.
813 REGEXP is a regular expression matching nodes or references. Its first
814 group should match `Node:' or `Ref:'.
815 If a match was found, value is a list (FOUND-ANCHOR POS MODE), where
816 FOUND-ANCHOR is non-nil if a `Ref:' was matched, POS is the position
817 where the match was found, and MODE is `major-mode' of the buffer in
818 which the match was found.
819 This function tries to find a case-sensitive match first, then a
820 case-insensitive match is tried."
821 (let ((result (Info-find-in-tag-table-1 marker regexp nil
)))
822 (when (null (car result
))
823 (setq result
(Info-find-in-tag-table-1 marker regexp t
)))
826 (defun Info-find-node-in-buffer-1 (regexp case-fold
)
827 "Find a node or anchor in the current buffer.
828 REGEXP is a regular expression matching nodes or references. Its first
829 group should match `Node:' or `Ref:'.
830 CASE-FOLD t means search for a case-insensitive match.
831 Value is the position at which a match was found, or nil if not found."
832 (let ((case-fold-search case-fold
)
835 (when (Info-node-at-bob-matching regexp
)
836 (setq found
(point)))
837 (while (and (not found
)
838 (search-forward "\n\^_" nil t
))
842 (when (re-search-backward regexp beg t
)
844 (setq found
(point)))))
847 (defun Info-find-node-in-buffer (regexp)
848 "Find a node or anchor in the current buffer.
849 REGEXP is a regular expression matching nodes or references. Its first
850 group should match `Node:' or `Ref:'.
851 Value is the position at which a match was found, or nil if not found.
852 This function looks for a case-sensitive match first. If none is found,
853 a case-insensitive match is tried."
854 (or (Info-find-node-in-buffer-1 regexp nil
)
855 (Info-find-node-in-buffer-1 regexp t
)))
857 (defun Info-find-node-2 (filename nodename
&optional no-going-back
)
858 (buffer-disable-undo (current-buffer))
859 (or (eq major-mode
'Info-mode
)
862 (setq Info-current-node nil
)
864 (let ((case-fold-search t
)
866 ;; Switch files if necessary
868 (equal Info-current-file filename
)
869 (let ((inhibit-read-only t
))
870 (setq Info-current-file nil
871 Info-current-subfile nil
872 Info-current-file-completions nil
873 buffer-file-name nil
)
878 ((eq filename
'apropos
)
879 (insert-buffer-substring " *info-apropos*"))
880 ((eq filename
'history
)
881 (insert-buffer-substring " *info-history*"))
883 (insert-buffer-substring " *info-toc*"))
885 (info-insert-file-contents filename nil
)
886 (setq default-directory
(file-name-directory filename
))))
887 (set-buffer-modified-p nil
)
888 (set (make-local-variable 'Info-file-supports-index-cookies
)
889 (Info-file-supports-index-cookies filename
))
891 ;; See whether file has a tag table. Record the location if yes.
892 (goto-char (point-max))
894 ;; Use string-equal, not equal, to ignore text props.
895 (if (not (or (string-equal nodename
"*")
897 (search-forward "\^_\nEnd tag table\n" nil t
))))
899 ;; We have a tag table. Find its beginning.
900 ;; Is this an indirect file?
901 (search-backward "\nTag table:\n")
905 (looking-at "(Indirect)\n"))
906 ;; It is indirect. Copy it to another buffer
907 ;; and record that the tag table is in that buffer.
908 (let ((buf (current-buffer))
910 (or Info-tag-table-buffer
911 (generate-new-buffer " *info tag table*"))))
912 (setq Info-tag-table-buffer tagbuf
)
913 (with-current-buffer tagbuf
914 (buffer-disable-undo (current-buffer))
915 (setq case-fold-search t
)
917 (insert-buffer-substring buf
))
918 (set-marker Info-tag-table-marker
919 (match-end 0) tagbuf
))
920 (set-marker Info-tag-table-marker pos
)))
921 (set-marker Info-tag-table-marker nil
))
922 (setq Info-current-file
924 ((eq filename t
) "dir")
927 ;; Use string-equal, not equal, to ignore text props.
928 (if (string-equal nodename
"*")
929 (progn (setq Info-current-node nodename
)
930 (Info-set-mode-line))
933 ;; 1. Anchor found in tag table
934 ;; 2. Anchor *not* in tag table
936 ;; 3. Node found in tag table
937 ;; 4. Node *not* found in tag table, but found in file
938 ;; 5. Node *not* in tag table, and *not* in file
940 ;; *Or* the same, but in an indirect subfile.
942 ;; Search file for a suitable node.
943 (let ((guesspos (point-min))
944 (regexp (concat "\\(Node:\\|Ref:\\) *\\("
945 (if (stringp nodename
)
946 (regexp-quote nodename
)
948 "\\) *[,\t\n\177]")))
952 ;; First, search a tag table, if any
953 (when (marker-position Info-tag-table-marker
)
954 (let* ((m Info-tag-table-marker
)
955 (found (Info-find-in-tag-table m regexp
)))
958 ;; FOUND is (ANCHOR POS MODE).
959 (setq guesspos
(nth 1 found
))
961 ;; If this is an indirect file, determine which
962 ;; file really holds this node and read it in.
963 (unless (eq (nth 2 found
) 'Info-mode
)
964 ;; Note that the current buffer must be the
965 ;; *info* buffer on entry to
966 ;; Info-read-subfile. Thus the hackery above.
967 (setq guesspos
(Info-read-subfile guesspos
)))
971 (goto-char (setq anchorpos guesspos
))
974 ;; Else we may have a node, which we search for:
975 (goto-char (max (point-min)
976 (- (byte-to-position guesspos
) 1000)))
978 ;; Now search from our advised position (or from beg of
979 ;; buffer) to find the actual node. First, check
980 ;; whether the node is right where we are, in case the
981 ;; buffer begins with a node.
982 (let ((pos (Info-find-node-in-buffer regexp
)))
987 (when (string-match "\\([^.]+\\)\\." nodename
)
988 (let (Info-point-loc)
990 filename
(match-string 1 nodename
) no-going-back
))
994 ;; No such anchor in tag table or node in tag table or file
995 (error "No such node or anchor: %s" nodename
))
998 (goto-char (point-min))
999 (forward-line 1) ; skip header line
1000 (when (> Info-breadcrumbs-depth
0) ; skip breadcrumbs line
1004 (let ((new-history (list Info-current-file
1005 (substring-no-properties nodename
))))
1006 ;; Add anchors to the history too
1007 (setq Info-history-list
1009 (delete new-history Info-history-list
))))
1010 (goto-char anchorpos
))
1011 ((numberp Info-point-loc
)
1012 (forward-line (- Info-point-loc
2))
1013 (setq Info-point-loc nil
))
1014 ((stringp Info-point-loc
)
1015 (Info-find-index-name Info-point-loc
)
1016 (setq Info-point-loc nil
))))))
1017 ;; If we did not finish finding the specified node,
1018 ;; go back to the previous one.
1019 (or Info-current-node no-going-back
(null Info-history
)
1020 (let ((hist (car Info-history
)))
1021 (setq Info-history
(cdr Info-history
))
1022 (Info-find-node (nth 0 hist
) (nth 1 hist
) t
)
1023 (goto-char (nth 2 hist
))))))
1025 ;; Cache the contents of the (virtual) dir file, once we have merged
1026 ;; it for the first time, so we can save time subsequently.
1027 (defvar Info-dir-contents nil
)
1029 ;; Cache for the directory we decided to use for the default-directory
1030 ;; of the merged dir text.
1031 (defvar Info-dir-contents-directory nil
)
1033 ;; Record the file attributes of all the files from which we
1034 ;; constructed Info-dir-contents.
1035 (defvar Info-dir-file-attributes nil
)
1037 (defvar Info-dir-file-name nil
)
1039 ;; Construct the Info directory node by merging the files named `dir'
1040 ;; from various directories. Set the *info* buffer's
1041 ;; default-directory to the first directory we actually get any text
1043 (defun Info-insert-dir ()
1044 (if (and Info-dir-contents Info-dir-file-attributes
1045 ;; Verify that none of the files we used has changed
1046 ;; since we used it.
1048 (mapcar (lambda (elt)
1049 (let ((curr (file-attributes
1051 (file-truename (car elt
)))))
1053 ;; Don't compare the access time.
1054 (if curr
(setcar (nthcdr 4 curr
) 0))
1055 (setcar (nthcdr 4 (cdr elt
)) 0)
1056 (equal (cdr elt
) curr
)))
1057 Info-dir-file-attributes
))))
1059 (insert Info-dir-contents
)
1060 (goto-char (point-min)))
1061 (let ((dirs (if Info-additional-directory-list
1062 (append Info-directory-list
1063 Info-additional-directory-list
)
1064 Info-directory-list
))
1065 (dir-file-attrs nil
)
1066 ;; Bind this in case the user sets it to nil.
1067 (case-fold-search t
)
1068 ;; This is set non-nil if we find a problem in some input files.
1070 buffers buffer others nodes dirs-done
)
1072 ;; Search the directory list for the directory file.
1074 (let ((truename (file-truename (expand-file-name (car dirs
)))))
1075 (or (member truename dirs-done
)
1076 (member (directory-file-name truename
) dirs-done
)
1077 ;; Try several variants of specified name.
1078 ;; Try upcasing, appending `.info', or both.
1082 (progn (setq file
(expand-file-name "dir" truename
))
1083 (file-attributes file
))
1084 (progn (setq file
(expand-file-name "DIR" truename
))
1085 (file-attributes file
))
1086 (progn (setq file
(expand-file-name "dir.info" truename
))
1087 (file-attributes file
))
1088 (progn (setq file
(expand-file-name "DIR.INFO" truename
))
1089 (file-attributes file
)))))
1092 (cons (directory-file-name truename
)
1095 (with-current-buffer (generate-new-buffer " info dir")
1097 (message "Composing main Info directory..."))
1099 ;; Index nodes include null bytes. DIR
1100 ;; files should not have indices, but who
1102 (let ((inhibit-null-byte-detection t
))
1103 (insert-file-contents file
)
1104 (set (make-local-variable 'Info-dir-file-name
)
1106 (push (current-buffer) buffers
)
1107 (push (cons file attrs
) dir-file-attrs
))
1108 (error (kill-buffer (current-buffer))))))))
1110 (set (make-local-variable 'Info-dir-contents-directory
)
1111 (file-name-as-directory (car dirs
))))
1112 (setq dirs
(cdr dirs
))))
1115 (error "Can't find the Info directory node"))
1117 ;; Distinguish the dir file that comes with Emacs from all the
1118 ;; others. Yes, that is really what this is supposed to do.
1119 ;; The definition of `Info-directory-list' puts it first on that
1120 ;; list and so last in `buffers' at this point.
1121 (setq buffer
(car (last buffers
))
1122 others
(delq buffer buffers
))
1124 ;; Insert the entire original dir file as a start; note that we've
1125 ;; already saved its default directory to use as the default
1126 ;; directory for the whole concatenation.
1127 (save-excursion (insert-buffer-substring buffer
))
1129 ;; Look at each of the other buffers one by one.
1130 (dolist (other others
)
1131 (let (this-buffer-nodes)
1132 ;; In each, find all the menus.
1133 (with-current-buffer other
1134 (goto-char (point-min))
1135 ;; Find each menu, and add an elt to NODES for it.
1136 (while (re-search-forward "^\\* Menu:" nil t
)
1137 (while (and (zerop (forward-line 1)) (eolp)))
1140 (re-search-backward "^\^_")
1141 (search-forward "Node: ")
1142 (setq nodename
(Info-following-node-name))
1143 (search-forward "\n\^_" nil
'move
)
1146 (push (list nodename other beg end
) this-buffer-nodes
)))
1147 (if (assoc-string "top" this-buffer-nodes t
)
1148 (setq nodes
(nconc this-buffer-nodes nodes
))
1150 (message "No `top' node in %s" Info-dir-file-name
)))))
1151 ;; Add to the main menu a menu item for each other node.
1152 (re-search-forward "^\\* Menu:")
1154 (let ((menu-items '("top"))
1155 (end (save-excursion (search-forward "\^_" nil t
) (point))))
1156 (dolist (node nodes
)
1157 (let ((nodename (car node
)))
1159 (or (member (downcase nodename
) menu-items
)
1160 (re-search-forward (concat "^\\* +"
1161 (regexp-quote nodename
)
1165 (insert "* " nodename
"::" "\n")
1166 (push nodename menu-items
)))))))
1167 ;; Now take each node of each of the other buffers
1168 ;; and merge it into the main buffer.
1169 (dolist (node nodes
)
1170 (let ((case-fold-search t
)
1171 (nodename (car node
)))
1172 (goto-char (point-min))
1173 ;; Find the like-named node in the main buffer.
1174 (if (re-search-forward (concat "^\^_.*\n.*Node: "
1175 (regexp-quote nodename
)
1179 (search-forward "\n\^_" nil
'move
)
1182 ;; If none exists, add one.
1183 (goto-char (point-max))
1184 (insert "\^_\nFile: dir\tNode: " nodename
"\n\n* Menu:\n\n"))
1185 ;; Merge the text from the other buffer's menu
1186 ;; into the menu in the like-named node in the main buffer.
1187 (apply 'insert-buffer-substring
(cdr node
))))
1188 (Info-dir-remove-duplicates)
1189 ;; Kill all the buffers we just made, including the special one excised.
1190 (mapc 'kill-buffer
(cons buffer buffers
))
1191 (goto-char (point-min))
1193 (message "Composing main Info directory...problems encountered, see `*Messages*'")
1194 (message "Composing main Info directory...done"))
1195 (set (make-local-variable 'Info-dir-contents
) (buffer-string))
1196 (set (make-local-variable 'Info-dir-file-attributes
) dir-file-attrs
)))
1197 (setq default-directory Info-dir-contents-directory
))
1199 (defvar Info-streamline-headings
1200 '(("Emacs" .
"Emacs")
1201 ("Programming" .
"Programming")
1202 ("Libraries" .
"Libraries")
1203 ("World Wide Web\\|Net Utilities" .
"Net Utilities"))
1204 "List of elements (RE . NAME) to merge headings matching RE to NAME.")
1206 (defun Info-dir-remove-duplicates ()
1208 (goto-char (point-min))
1209 ;; Remove duplicate headings in the same menu.
1210 (while (search-forward "\n* Menu:" nil t
)
1211 (setq limit
(save-excursion (search-forward "\n\^_" nil t
)))
1212 ;; Look for the next heading to unify.
1213 (while (re-search-forward "^\\(\\w.*\\)\n\\*" limit t
)
1214 (let ((name (match-string 1))
1215 (start (match-beginning 0))
1217 ;; Check whether this heading should be streamlined.
1219 (dolist (x Info-streamline-headings
)
1220 (when (string-match (car x
) name
)
1222 (setq re
(car x
)))))
1223 (if re
(replace-match name t t nil
1))
1224 (goto-char (if (re-search-forward "^[^* \n\t]" limit t
)
1226 (or limit
(point-max))))
1227 ;; Look for other headings of the same category and merge them.
1229 (while (re-search-forward "^\\(\\w.*\\)\n\\*" limit t
)
1230 (when (if re
(save-match-data (string-match re
(match-string 1)))
1231 (equal name
(match-string 1)))
1233 ;; Delete redundant heading.
1234 (delete-region (match-beginning 0) (point))
1235 ;; Push the entries onto `text'.
1237 (delete-and-extract-region
1239 (if (re-search-forward "^[^* \n\t]" nil t
)
1241 (or limit
(point-max))))
1244 ;; Insert the entries just found.
1245 (while (= (line-beginning-position 0) (1- (point)))
1247 (dolist (entry (nreverse entries
))
1249 (while (= (line-beginning-position 0) (1- (point)))
1250 (delete-region (1- (point)) (point))))
1252 ;; Now remove duplicate entries under the same heading.
1255 (narrow-to-region start
(point))
1256 (goto-char (point-min))
1257 (while (re-search-forward "^* \\([^:\n]+:\\(:\\|[^.\n]+\\).\\)" nil
'move
)
1258 ;; Fold case straight away; `member-ignore-case' here wasteful.
1259 (let ((x (downcase (match-string 1))))
1263 (if (re-search-forward "^[^ \t]" nil
'move
)
1264 (goto-char (match-beginning 0))
1266 (push x seen
)))))))))))
1268 ;; Note that on entry to this function the current-buffer must be the
1269 ;; *info* buffer; not the info tags buffer.
1270 (defun Info-read-subfile (nodepos)
1271 ;; NODEPOS is either a position (in the Info file as a whole,
1272 ;; not relative to a subfile) or the name of a subfile.
1275 (if (numberp nodepos
)
1276 (with-current-buffer (marker-buffer Info-tag-table-marker
)
1277 (goto-char (point-min))
1278 (or (looking-at "\^_")
1279 (search-forward "\n\^_"))
1282 (while (not (looking-at "\^_"))
1285 thisfilepos thisfilename
)
1286 (search-forward ": ")
1287 (setq thisfilename
(buffer-substring beg
(- (point) 2)))
1288 (setq thisfilepos
(+ (point-min) (read (current-buffer))))
1289 ;; read in version 19 stops at the end of number.
1290 ;; Advance to the next line.
1292 (if (> thisfilepos nodepos
)
1294 (setq lastfilename thisfilename
)
1295 (setq lastfilepos thisfilepos
))
1296 (forward-line 1)))))
1297 (setq lastfilename nodepos
)
1298 (setq lastfilepos
0))
1299 ;; Assume previous buffer is in Info-mode.
1300 ;; (set-buffer (get-buffer "*info*"))
1301 (or (equal Info-current-subfile lastfilename
)
1302 (let ((inhibit-read-only t
))
1303 (setq buffer-file-name nil
)
1306 (info-insert-file-contents lastfilename
)
1307 (set-buffer-modified-p nil
)
1308 (setq Info-current-subfile lastfilename
)))
1309 ;; Widen in case we are in the same subfile as before.
1311 (goto-char (point-min))
1312 (if (looking-at "\^_")
1314 (search-forward "\n\^_"))
1315 (if (numberp nodepos
)
1316 (+ (- nodepos lastfilepos
) (point)))))
1318 (defun Info-unescape-quotes (value)
1319 "Unescape double quotes and backslashes in VALUE."
1322 (while (string-match "[^\\\"]*\\(\\\\\\)[\\\\\"]" unquote start
)
1323 (setq unquote
(replace-match "" t t unquote
1))
1324 (setq start
(- (match-end 0) 1)))
1327 ;; As of Texinfo 4.6, makeinfo writes constructs like
1328 ;; \0\h[image param=value ...\h\0]
1329 ;; into the Info file for handling images.
1330 (defun Info-split-parameter-string (parameter-string)
1331 "Return alist of (\"KEY\" . \"VALUE\") from PARAMETER-STRING; a
1332 whitespace separated list of KEY=VALUE pairs. If VALUE contains
1333 whitespace or double quotes, it must be quoted in double quotes and
1334 any double quotes or backslashes must be escaped (\\\",\\\\)."
1337 (while (string-match
1338 "\\s *\\([^=]+\\)=\\(?:\\([^\\s \"]+\\)\\|\\(?:\"\\(\\(?:[^\\\"]\\|\\\\[\\\\\"]\\)*\\)\"\\)\\)"
1339 parameter-string start
)
1340 (setq start
(match-end 0))
1341 (push (cons (match-string 1 parameter-string
)
1342 (or (match-string 2 parameter-string
)
1343 (Info-unescape-quotes
1344 (match-string 3 parameter-string
))))
1348 (defun Info-display-images-node ()
1349 "Display images in current node."
1351 (let ((inhibit-read-only t
)
1352 (case-fold-search t
))
1353 (goto-char (point-min))
1354 (while (re-search-forward
1355 "\\(\0\b[[]image\\(\\(?:[^\b]\\|[^\0]+\b\\)*\\)\0\b[]]\\)"
1357 (let* ((start (match-beginning 1))
1358 (parameter-alist (Info-split-parameter-string (match-string 2)))
1359 (src (cdr (assoc-string "src" parameter-alist
))))
1360 (if (display-images-p)
1361 (let* ((image-file (if src
(if (file-name-absolute-p src
) src
1362 (concat default-directory src
))
1364 (image (if (file-exists-p image-file
)
1365 (create-image image-file
)
1367 (if (not (get-text-property start
'display
))
1368 (add-text-properties
1369 start
(point) `(display ,image rear-nonsticky
(display)))))
1370 ;; text-only display, show alternative text if provided, or
1371 ;; otherwise a clue that there's meant to be a picture
1372 (delete-region start
(point))
1373 (insert (or (cdr (assoc-string "text" parameter-alist
))
1374 (cdr (assoc-string "alt" parameter-alist
))
1376 (concat "[image:" src
"]"))
1378 (set-buffer-modified-p nil
)))
1380 ;; Texinfo 4.7 adds cookies of the form ^@^H[NAME CONTENTS ^@^H].
1381 ;; Hide any construct of the general form ^@[^@-^_][ ... ^@[^@-^_]],
1382 ;; including one optional trailing newline.
1383 (defun Info-hide-cookies-node ()
1384 "Hide unrecognized cookies in current node."
1386 (let ((inhibit-read-only t
)
1387 (case-fold-search t
))
1388 (goto-char (point-min))
1389 (while (re-search-forward
1390 "\\(\0[\0-\37][[][^\0]*\0[\0-\37][]]\n?\\)"
1392 (let* ((start (match-beginning 1)))
1393 (if (not (get-text-property start
'invisible
))
1394 (put-text-property start
(point) 'invisible t
)))))
1395 (set-buffer-modified-p nil
)))
1397 (defun Info-select-node ()
1398 "Select the Info node that point is in."
1399 ;; Bind this in case the user sets it to nil.
1400 (let ((case-fold-search t
))
1402 ;; Find beginning of node.
1403 (if (search-backward "\n\^_" nil
'move
)
1405 (if (looking-at "\^_")
1407 (signal 'search-failed
(list "\n\^_"))))
1408 ;; Get nodename spelled as it is in the node.
1409 (re-search-forward "Node:[ \t]*")
1410 (setq Info-current-node
1411 (buffer-substring-no-properties (point)
1413 (skip-chars-forward "^,\t\n")
1415 (Info-set-mode-line)
1416 ;; Find the end of it, and narrow.
1418 (let (active-expression)
1419 ;; Narrow to the node contents
1420 (narrow-to-region (point)
1421 (if (re-search-forward "\n[\^_\f]" nil t
)
1424 (if (looking-at "[\n\^_\f]*execute: ")
1426 (goto-char (match-end 0))
1427 (setq active-expression
1428 (read (current-buffer))))))
1430 (if Info-enable-active-nodes
(eval active-expression
))
1431 ;; Add a new unique history item to full history list
1432 (let ((new-history (list Info-current-file Info-current-node
)))
1433 (setq Info-history-list
1434 (cons new-history
(delete new-history Info-history-list
)))
1435 (setq Info-history-forward nil
))
1436 (if (not (eq Info-fontify-maximum-menu-size nil
))
1437 (Info-fontify-node))
1438 (Info-display-images-node)
1439 (Info-hide-cookies-node)
1440 (run-hooks 'Info-selection-hook
)))))
1442 (defvar Info-mode-line-node-keymap
1443 (let ((map (make-sparse-keymap)))
1444 (define-key map
[mode-line mouse-1
] 'Info-mouse-scroll-up
)
1445 (define-key map
[mode-line mouse-3
] 'Info-mouse-scroll-down
)
1447 "Keymap to put on the Info node name in the mode line.")
1449 (defun Info-set-mode-line ()
1450 (setq mode-line-buffer-identification
1451 (nconc (propertized-buffer-identification "%b")
1455 (if (stringp Info-current-file
)
1456 (replace-regexp-in-string
1457 "%" "%%" (file-name-nondirectory Info-current-file
))
1458 (format "*%S*" Info-current-file
))
1460 (if Info-current-node
1461 (propertize (replace-regexp-in-string
1462 "%" "%%" Info-current-node
)
1463 'face
'mode-line-buffer-id
1465 "mouse-1: scroll forward, mouse-3: scroll back"
1466 'mouse-face
'mode-line-highlight
1467 'local-map Info-mode-line-node-keymap
)
1470 ;; Go to an Info node specified with a filename-and-nodename string
1471 ;; of the sort that is found in pointers in nodes.
1473 ;; Don't autoload this function: the correct entry point for other packages
1474 ;; to use is `info'. --Stef
1476 (defun Info-goto-node (nodename &optional fork
)
1477 "Go to Info node named NODENAME. Give just NODENAME or (FILENAME)NODENAME.
1478 If NODENAME is of the form (FILENAME)NODENAME, the node is in the Info file
1479 FILENAME; otherwise, NODENAME should be in the current Info file (or one of
1481 Completion is available, but only for node names in the current Info file.
1482 If FORK is non-nil (interactively with a prefix arg), show the node in
1484 If FORK is a string, it is the name to use for the new buffer."
1485 (interactive (list (Info-read-node-name "Go to node: ") current-prefix-arg
))
1489 (clone-buffer (concat "*info-" (if (stringp fork
) fork nodename
) "*") t
)))
1491 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
1493 (setq filename
(if (= (match-beginning 1) (match-end 1))
1495 (match-string 2 nodename
))
1496 nodename
(match-string 3 nodename
))
1497 (let ((trim (string-match "\\s +\\'" filename
)))
1498 (if trim
(setq filename
(substring filename
0 trim
))))
1499 (let ((trim (string-match "\\s +\\'" nodename
)))
1500 (if trim
(setq nodename
(substring nodename
0 trim
))))
1501 (if transient-mark-mode
(deactivate-mark))
1502 (Info-find-node (if (equal filename
"") nil filename
)
1503 (if (equal nodename
"") "Top" nodename
))))
1505 (defvar Info-read-node-completion-table
)
1507 (defun Info-read-node-name-2 (dirs suffixes string pred action
)
1508 "Virtual completion table for file names input in Info node names.
1509 PATH-AND-SUFFIXES is a pair of lists, (DIRECTORIES . SUFFIXES)."
1510 (setq suffixes
(remove "" suffixes
))
1511 (when (file-name-absolute-p string
)
1512 (setq dirs
(list (file-name-directory string
))))
1514 (suffix (concat (regexp-opt suffixes t
) "\\'"))
1515 (string-dir (file-name-directory string
)))
1518 (setq dir default-directory
))
1519 (if string-dir
(setq dir
(expand-file-name string-dir dir
)))
1520 (when (file-directory-p dir
)
1521 (dolist (file (file-name-all-completions
1522 (file-name-nondirectory string
) dir
))
1523 ;; If the file name has no suffix or a standard suffix,
1525 (and (or (null (file-name-extension file
))
1526 (string-match suffix file
))
1527 ;; But exclude subfiles of split Info files.
1528 (not (string-match "-[0-9]+\\'" file
))
1529 ;; And exclude backup files.
1530 (not (string-match "~\\'" file
))
1531 (push (if string-dir
(concat string-dir file
) file
) names
))
1532 ;; If the file name ends in a standard suffix,
1533 ;; add the unsuffixed name as a completion option.
1534 (when (string-match suffix file
)
1535 (setq file
(substring file
0 (match-beginning 0)))
1536 (push (if string-dir
(concat string-dir file
) file
) names
)))))
1537 (complete-with-action action names string pred
)))
1539 ;; This function is used as the "completion table" while reading a node name.
1540 ;; It does completion using the alist in Info-read-node-completion-table
1541 ;; unless STRING starts with an open-paren.
1542 (defun Info-read-node-name-1 (string predicate code
)
1544 ;; First complete embedded file names.
1545 ((string-match "\\`([^)]*\\'" string
)
1546 (completion-table-with-context
1548 (apply-partially 'completion-table-with-terminator
")"
1549 (apply-partially 'Info-read-node-name-2
1551 (mapcar 'car Info-suffix-list
)))
1552 (substring string
1)
1556 ;; If a file name was given, then any node is fair game.
1557 ((string-match "\\`(" string
)
1559 ((eq code nil
) string
)
1562 ;; Otherwise use Info-read-node-completion-table.
1563 (t (complete-with-action
1564 code Info-read-node-completion-table string predicate
))))
1566 ;; Arrange to highlight the proper letters in the completion list buffer.
1569 (defun Info-read-node-name (prompt)
1570 (let* ((completion-ignore-case t
)
1571 (Info-read-node-completion-table (Info-build-node-completions))
1572 (nodename (completing-read prompt
'Info-read-node-name-1 nil t
)))
1573 (if (equal nodename
"")
1574 (Info-read-node-name prompt
)
1577 (defun Info-build-node-completions ()
1578 (or Info-current-file-completions
1580 ;; Bind this in case the user sets it to nil.
1581 (case-fold-search t
)
1582 (node-regexp "Node: *\\([^,\n]*\\) *[,\n\t]"))
1585 (or Info-tag-table-marker
1586 (error "No Info tags found"))
1587 (if (marker-buffer Info-tag-table-marker
)
1588 (let ((marker Info-tag-table-marker
))
1589 (set-buffer (marker-buffer marker
))
1592 (while (re-search-forward "\n\\(Node\\|Ref\\): \\(.*\\)\177" nil t
)
1594 (cons (list (match-string-no-properties 2))
1597 (goto-char (point-min))
1598 ;; If the buffer begins with a node header, process that first.
1599 (if (Info-node-at-bob-matching node-regexp
)
1600 (setq compl
(list (match-string-no-properties 1))))
1601 ;; Now for the rest of the nodes.
1602 (while (search-forward "\n\^_" nil t
)
1604 (let ((beg (point)))
1606 (if (re-search-backward node-regexp beg t
)
1608 (cons (list (match-string-no-properties 1))
1610 (setq compl
(cons '("*") compl
))
1611 (set (make-local-variable 'Info-current-file-completions
) compl
))))
1613 (defun Info-restore-point (hl)
1614 "If this node has been visited, restore the point value when we left."
1616 (if (and (equal (nth 0 (car hl
)) Info-current-file
)
1617 ;; Use string-equal, not equal, to ignore text props.
1618 (string-equal (nth 1 (car hl
)) Info-current-node
))
1620 (goto-char (nth 2 (car hl
)))
1621 (setq hl nil
)) ;terminate the while at next iter
1622 (setq hl
(cdr hl
)))))
1624 (defvar Info-search-history nil
1625 "The history list for `Info-search'.")
1627 (defvar Info-search-case-fold nil
1628 "The value of `case-fold-search' from previous `Info-search' command.")
1630 (defun Info-search (regexp &optional bound noerror count direction
)
1631 "Search for REGEXP, starting from point, and select node it's found in.
1632 If DIRECTION is `backward', search in the reverse direction."
1633 (interactive (list (read-string
1634 (if Info-search-history
1635 (format "Regexp search%s (default %s): "
1636 (if case-fold-search
"" " case-sensitively")
1637 (car Info-search-history
))
1638 (format "Regexp search%s: "
1639 (if case-fold-search
"" " case-sensitively")))
1640 nil
'Info-search-history
)))
1641 (when transient-mark-mode
1643 (when (equal regexp
"")
1644 (setq regexp
(car Info-search-history
)))
1646 (let (found beg-found give-up
1647 (backward (eq direction
'backward
))
1648 (onode Info-current-node
)
1649 (ofile Info-current-file
)
1651 (opoint-min (point-min))
1652 (opoint-max (point-max))
1653 (ostart (window-start))
1654 (osubfile Info-current-subfile
))
1655 (setq Info-search-case-fold case-fold-search
)
1660 ;; Hide Info file header for backward search
1661 (narrow-to-region (save-excursion
1662 (goto-char (point-min))
1663 (search-forward "\n\^_")
1666 (while (and (not give-up
)
1668 (not (funcall isearch-filter-predicate beg-found found
))))
1669 (let ((search-spaces-regexp
1670 (if (or (not isearch-mode
) isearch-regexp
)
1671 Info-search-whitespace-regexp
)))
1673 (re-search-backward regexp bound t
)
1674 (re-search-forward regexp bound t
))
1675 (setq found
(point) beg-found
(if backward
(match-end 0)
1676 (match-beginning 0)))
1677 (setq give-up t
))))))
1679 (when (and isearch-mode Info-isearch-search
1680 (not Info-isearch-initial-node
)
1682 (or give-up
(and found
(not (and (> found opoint-min
)
1683 (< found opoint-max
))))))
1684 (signal 'search-failed
(list regexp
"initial node")))
1686 ;; If no subfiles, give error now.
1688 (if (null Info-current-subfile
)
1689 (let ((search-spaces-regexp
1690 (if (or (not isearch-mode
) isearch-regexp
)
1691 Info-search-whitespace-regexp
)))
1693 (re-search-backward regexp
)
1694 (re-search-forward regexp
)))
1697 (if (and bound
(not found
))
1698 (signal 'search-failed
(list regexp
)))
1700 (unless (or found bound
)
1702 ;; Try other subfiles.
1704 (with-current-buffer (marker-buffer Info-tag-table-marker
)
1705 (goto-char (point-min))
1706 (search-forward "\n\^_\nIndirect:")
1708 (narrow-to-region (point)
1709 (progn (search-forward "\n\^_")
1711 (goto-char (point-min))
1712 ;; Find the subfile we just searched.
1713 (search-forward (concat "\n" osubfile
": "))
1715 (forward-line (if backward
0 1))
1716 (if backward
(forward-char -
1))
1717 ;; Make a list of all following subfiles.
1718 ;; Each elt has the form (VIRT-POSITION . SUBFILENAME).
1719 (while (not (if backward
(bobp) (eobp)))
1721 (re-search-backward "\\(^.*\\): [0-9]+$")
1722 (re-search-forward "\\(^.*\\): [0-9]+$"))
1723 (goto-char (+ (match-end 1) 2))
1724 (setq list
(cons (cons (+ (point-min)
1725 (read (current-buffer)))
1726 (match-string-no-properties 1))
1728 (goto-char (if backward
1729 (1- (match-beginning 0))
1730 (1+ (match-end 0)))))
1731 ;; Put in forward order
1732 (setq list
(nreverse list
))))
1734 (message "Searching subfile %s..." (cdr (car list
)))
1735 (Info-read-subfile (car (car list
)))
1737 ;; Hide Info file header for backward search
1738 (narrow-to-region (save-excursion
1739 (goto-char (point-min))
1740 (search-forward "\n\^_")
1743 (goto-char (point-max)))
1744 (setq list
(cdr list
))
1745 (setq give-up nil found nil
)
1746 (while (and (not give-up
)
1748 (not (funcall isearch-filter-predicate beg-found found
))))
1749 (let ((search-spaces-regexp
1750 (if (or (not isearch-mode
) isearch-regexp
)
1751 Info-search-whitespace-regexp
)))
1753 (re-search-backward regexp nil t
)
1754 (re-search-forward regexp nil t
))
1755 (setq found
(point) beg-found
(if backward
(match-end 0)
1756 (match-beginning 0)))
1764 (signal 'search-failed
(list regexp
))))
1766 (progn (Info-read-subfile osubfile
)
1769 (set-window-start (selected-window) ostart
)))))
1771 (if (and (string= osubfile Info-current-subfile
)
1772 (> found opoint-min
)
1773 (< found opoint-max
))
1774 ;; Search landed in the same node
1778 (save-match-data (Info-select-node)))
1780 ;; Use string-equal, not equal, to ignore text props.
1781 (or (and (string-equal onode Info-current-node
)
1782 (equal ofile Info-current-file
))
1783 (and isearch-mode isearch-wrapped
1784 (eq opoint
(if isearch-forward opoint-min opoint-max
)))
1785 (setq Info-history
(cons (list ofile onode opoint
)
1788 (defun Info-search-case-sensitively ()
1789 "Search for a regexp case-sensitively."
1791 (let ((case-fold-search nil
))
1792 (call-interactively 'Info-search
)))
1794 (defun Info-search-next ()
1795 "Search for next regexp from a previous `Info-search' command."
1797 (let ((case-fold-search Info-search-case-fold
))
1798 (if Info-search-history
1799 (Info-search (car Info-search-history
))
1800 (call-interactively 'Info-search
))))
1802 (defun Info-search-backward (regexp &optional bound noerror count
)
1803 "Search for REGEXP in the reverse direction."
1804 (interactive (list (read-string
1805 (if Info-search-history
1806 (format "Regexp search%s backward (default %s): "
1807 (if case-fold-search
"" " case-sensitively")
1808 (car Info-search-history
))
1809 (format "Regexp search%s backward: "
1810 (if case-fold-search
"" " case-sensitively")))
1811 nil
'Info-search-history
)))
1812 (Info-search regexp bound noerror count
'backward
))
1814 (defun Info-isearch-search ()
1815 (if Info-isearch-search
1816 (lambda (string &optional bound noerror count
)
1818 (Info-search (concat "\\b" (replace-regexp-in-string
1820 (replace-regexp-in-string
1821 "^\\W+\\|\\W+$" "" string
)
1823 ;; Lax version of word search
1824 (if (or isearch-nonincremental
1826 (length (isearch-string-state
1827 (car isearch-cmds
)))))
1830 (unless isearch-forward
'backward
))
1831 (Info-search (if isearch-regexp string
(regexp-quote string
))
1833 (unless isearch-forward
'backward
)))
1835 (let ((isearch-search-fun-function nil
))
1836 (isearch-search-fun))))
1838 (defun Info-isearch-wrap ()
1839 (if Info-isearch-search
1840 (if Info-isearch-initial-node
1842 (if isearch-forward
(Info-top-node) (Info-final-node))
1843 (goto-char (if isearch-forward
(point-min) (point-max))))
1844 (setq Info-isearch-initial-node Info-current-node
)
1845 (setq isearch-wrapped nil
))
1846 (goto-char (if isearch-forward
(point-min) (point-max)))))
1848 (defun Info-isearch-push-state ()
1850 (Info-isearch-pop-state cmd
',Info-current-file
',Info-current-node
)))
1852 (defun Info-isearch-pop-state (cmd file node
)
1853 (or (and (equal Info-current-file file
)
1854 (equal Info-current-node node
))
1855 (progn (Info-find-node file node
) (sit-for 0))))
1857 (defun Info-isearch-start ()
1858 (setq Info-isearch-initial-node
1859 ;; Don't stop at initial node for nonincremental search.
1860 ;; Otherwise this variable is set after first search failure.
1861 (and isearch-nonincremental Info-current-node
)))
1863 (defun Info-isearch-filter (beg-found found
)
1864 "Test whether the current search hit is a visible useful text.
1865 Return non-nil if the text from BEG-FOUND to FOUND is visible
1866 and is not in the header line or a tag table."
1868 (let ((backward (< found beg-found
)))
1871 (and (not (eq search-invisible t
))
1873 (or (text-property-not-all found beg-found
'invisible nil
)
1874 (text-property-not-all found beg-found
'display nil
))
1875 (or (text-property-not-all beg-found found
'invisible nil
)
1876 (text-property-not-all beg-found found
'display nil
))))
1877 ;; Skip node header line
1878 (and (save-excursion (forward-line -
1)
1880 (forward-line (if backward -
1 1)))
1881 ;; Skip Tag Table node
1883 (and (search-backward "\^_" nil t
)
1885 "\^_\n\\(Tag Table\\|Local Variables\\)"))))))))
1888 (defun Info-extract-pointer (name &optional errorname
)
1889 "Extract the value of the node-pointer named NAME.
1890 If there is none, use ERRORNAME in the error message;
1891 if ERRORNAME is nil, just return nil."
1892 ;; Bind this in case the user sets it to nil.
1893 (let ((case-fold-search t
))
1895 (goto-char (point-min))
1896 (let ((bound (point)))
1898 (cond ((re-search-backward
1899 (concat name
":" (Info-following-node-name-re)) bound t
)
1900 (match-string-no-properties 1))
1901 ((not (eq errorname t
))
1902 (error "Node has no %s"
1903 (capitalize (or errorname name
)))))))))
1905 (defun Info-following-node-name-re (&optional allowedchars
)
1906 "Return a regexp matching a node name.
1907 ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
1908 saying which chars may appear in the node name.
1909 Submatch 1 is the complete node name.
1910 Submatch 2 if non-nil is the parenthesized file name part of the node name.
1911 Submatch 3 is the local part of the node name.
1912 End of submatch 0, 1, and 3 are the same, so you can safely concat."
1913 (concat "[ \t]*" ;Skip leading space.
1914 "\\(\\(([^)]+)\\)?" ;Node name can start with a file name.
1915 "\\([" (or allowedchars
"^,\t\n") "]*" ;Any number of allowed chars.
1916 "[" (or allowedchars
"^,\t\n") " ]" ;The last char can't be a space.
1917 "\\|\\)\\)")) ;Allow empty node names.
1919 ;;; For compatibility; other files have used this name.
1920 (defun Info-following-node-name ()
1921 (and (looking-at (Info-following-node-name-re))
1922 (match-string-no-properties 1)))
1925 "Go to the next node of this node."
1927 ;; In case another window is currently selected
1928 (save-window-excursion
1929 (or (eq major-mode
'Info-mode
) (pop-to-buffer "*info*"))
1930 (Info-goto-node (Info-extract-pointer "next"))))
1933 "Go to the previous node of this node."
1935 ;; In case another window is currently selected
1936 (save-window-excursion
1937 (or (eq major-mode
'Info-mode
) (pop-to-buffer "*info*"))
1938 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous"))))
1940 (defun Info-up (&optional same-file
)
1941 "Go to the superior node of this node.
1942 If SAME-FILE is non-nil, do not move to a different Info file."
1944 ;; In case another window is currently selected
1945 (save-window-excursion
1946 (or (eq major-mode
'Info-mode
) (pop-to-buffer "*info*"))
1947 (let ((old-node Info-current-node
)
1948 (old-file Info-current-file
)
1949 (node (Info-extract-pointer "up")) p
)
1951 (string-match "^(" node
)
1952 (error "Up node is in another Info file"))
1953 (Info-goto-node node
)
1955 (goto-char (point-min))
1956 (if (and (stringp old-file
)
1957 (search-forward "\n* Menu:" nil t
)
1959 (if (string-equal old-node
"Top")
1960 (concat "\n\\*[^:]+: +(" (file-name-nondirectory old-file
) ")")
1961 (concat "\n\\* +\\(" (regexp-quote old-node
)
1962 ":\\|[^:]+: +" (regexp-quote old-node
) "\\)"))
1964 (progn (beginning-of-line) (if (looking-at "^\\* ") (forward-char 2)))
1966 (Info-restore-point Info-history
)))))
1968 (defun Info-history-back ()
1969 "Go back in the history to the last node visited."
1972 (error "This is the first Info node you looked at"))
1973 (let ((history-forward
1974 (cons (list Info-current-file Info-current-node
(point))
1975 Info-history-forward
))
1976 filename nodename opoint
)
1977 (setq filename
(car (car Info-history
)))
1978 (setq nodename
(car (cdr (car Info-history
))))
1979 (setq opoint
(car (cdr (cdr (car Info-history
)))))
1980 (setq Info-history
(cdr Info-history
))
1981 (Info-find-node filename nodename
)
1982 (setq Info-history
(cdr Info-history
))
1983 (setq Info-history-forward history-forward
)
1984 (goto-char opoint
)))
1986 (defalias 'Info-last
'Info-history-back
)
1988 (defun Info-history-forward ()
1989 "Go forward in the history of visited nodes."
1991 (or Info-history-forward
1992 (error "This is the last Info node you looked at"))
1993 (let ((history-forward (cdr Info-history-forward
))
1994 filename nodename opoint
)
1995 (setq filename
(car (car Info-history-forward
)))
1996 (setq nodename
(car (cdr (car Info-history-forward
))))
1997 (setq opoint
(car (cdr (cdr (car Info-history-forward
)))))
1998 (Info-find-node filename nodename
)
1999 (setq Info-history-forward history-forward
)
2000 (goto-char opoint
)))
2003 (defun Info-directory ()
2004 "Go to the Info directory node."
2006 (Info-find-node "dir" "top"))
2008 (defun Info-history ()
2009 "Go to a node with a menu of visited nodes."
2011 (let ((curr-file Info-current-file
)
2012 (curr-node Info-current-node
)
2014 (with-current-buffer (get-buffer-create " *info-history*")
2015 (let ((inhibit-read-only t
))
2017 (goto-char (point-min))
2018 (insert "\n\^_\nFile: history, Node: Top, Up: (dir)\n\n")
2019 (insert "Recently Visited Nodes\n**********************\n\n")
2020 (insert "* Menu:\n\n")
2021 (let ((hl (delete '("history" "Top") Info-history-list
)))
2023 (let ((file (nth 0 (car hl
)))
2024 (node (nth 1 (car hl
))))
2025 (if (and (equal file curr-file
)
2026 (equal node curr-node
))
2029 (insert "* " node
": ("
2030 (propertize (or (file-name-directory file
) "") 'invisible t
)
2031 (file-name-nondirectory file
)
2033 (setq hl
(cdr hl
))))))
2034 (Info-find-node 'history
"Top")
2035 (goto-char (or p
(point-min)))))
2038 "Go to a node with table of contents of the current Info file.
2039 Table of contents is created from the tree structure of menus."
2041 (if (stringp Info-current-file
)
2042 (let ((curr-file (substring-no-properties Info-current-file
))
2043 (curr-node (substring-no-properties Info-current-node
))
2045 (with-current-buffer (get-buffer-create " *info-toc*")
2046 (let ((inhibit-read-only t
)
2047 (node-list (Info-toc-nodes curr-file
)))
2049 (goto-char (point-min))
2050 (insert "\n\^_\nFile: toc, Node: Top, Up: (dir)\n\n")
2051 (insert "Table of Contents\n*****************\n\n")
2052 (insert "*Note Top: (" curr-file
")Top.\n")
2054 (nth 3 (assoc "Top" node-list
)) ; get Top nodes
2055 node-list
0 curr-file
))
2057 (let ((Info-hide-note-references 'hide
)
2058 (Info-fontify-visited-nodes nil
))
2060 (setq Info-current-file
'toc Info-current-node
"Top")
2061 (goto-char (point-min))
2062 (narrow-to-region (or (re-search-forward "\n[\^_\f]\n" nil t
)
2067 (goto-char (point-min))
2068 (if (setq p
(search-forward (concat "*Note " curr-node
":") nil t
))
2069 (setq p
(- p
(length curr-node
) 2))))
2070 (Info-find-node 'toc
"Top")
2071 (goto-char (or p
(point-min))))))
2073 (defun Info-insert-toc (nodes node-list level curr-file
)
2074 "Insert table of contents with references to nodes."
2075 (let ((section "Top"))
2077 (let ((node (assoc (car nodes
) node-list
)))
2078 (unless (member (nth 2 node
) (list nil section
))
2079 (insert (setq section
(nth 2 node
)) "\n"))
2080 (insert (make-string level ?
\t))
2081 (insert "*Note " (car nodes
) ": (" curr-file
")" (car nodes
) ".\n")
2082 (Info-insert-toc (nth 3 node
) node-list
(1+ level
) curr-file
)
2083 (setq nodes
(cdr nodes
))))))
2085 (defun Info-build-toc (file)
2086 "Build table of contents from menus of Info FILE and its subfiles."
2088 (let* ((file (and (stringp file
) (Info-find-file file
)))
2089 (default-directory (or (and (stringp file
)
2090 (file-name-directory file
))
2092 (main-file (and (stringp file
) file
))
2093 (sections '(("Top" "Top")))
2095 (while (or main-file subfiles
)
2096 ;; (or main-file (message "Searching subfile %s..." (car subfiles)))
2098 (info-insert-file-contents (or main-file
(car subfiles
)))
2099 (goto-char (point-min))
2100 (while (and (search-forward "\n\^_\nFile:" nil
'move
)
2101 (search-forward "Node: " nil
'move
))
2102 (let* ((nodename (substring-no-properties (Info-following-node-name)))
2103 (bound (- (or (save-excursion (search-forward "\n\^_" nil t
))
2105 (upnode (and (re-search-forward
2106 (concat "Up:" (Info-following-node-name-re))
2108 (match-string-no-properties 1)))
2111 (when (string-match "(" upnode
) (setq upnode nil
))
2112 (when (and (not (Info-index-node nodename file
))
2113 (re-search-forward "^\\* Menu:" bound t
))
2116 (setq bound
(or (and (equal nodename
"Top")
2119 "^[ \t-]*The Detailed Node Listing" nil t
)))
2121 (while (< (point) bound
)
2124 ((looking-at "^\\* +[^:]+:")
2127 (let ((menu-node-name (substring-no-properties
2128 (Info-extract-menu-node-name))))
2129 (setq menu-items
(cons menu-node-name menu-items
))
2130 (if (equal nodename
"Top")
2132 (cons (list menu-node-name section
) sections
)))))
2133 ;; Other non-empty strings in the Top node are section names
2134 ((and (equal nodename
"Top")
2135 (looking-at "^\\([^ \t\n*=.-][^:\n]*\\)"))
2136 (setq section
(match-string-no-properties 1))))
2138 (beginning-of-line)))
2139 (setq nodes
(cons (list nodename upnode
2140 (cadr (assoc nodename sections
))
2141 (nreverse menu-items
))
2146 (goto-char (point-min))
2147 (if (search-forward "\n\^_\nIndirect:" nil t
)
2148 (let ((bound (save-excursion (search-forward "\n\^_" nil t
))))
2149 (while (re-search-forward "^\\(.*\\): [0-9]+$" bound t
)
2150 (setq subfiles
(cons (match-string-no-properties 1)
2152 (setq subfiles
(nreverse subfiles
)
2154 (setq subfiles
(cdr subfiles
))))
2158 (defvar Info-toc-nodes nil
2159 "Alist of cached parent-children node information in visited Info files.
2160 Each element is (FILE (NODE-NAME PARENT SECTION CHILDREN) ...)
2161 where PARENT is the parent node extracted from the Up pointer,
2162 SECTION is the section name in the Top node where this node is placed,
2163 CHILDREN is a list of child nodes extracted from the node menu.")
2165 (defun Info-toc-nodes (file)
2166 "Return a node list of Info FILE with parent-children information.
2167 This information is cached in the variable `Info-toc-nodes' with the help
2168 of the function `Info-build-toc'."
2169 (or file
(setq file Info-current-file
))
2170 (or (assoc file Info-toc-nodes
)
2171 ;; Skip virtual Info files
2172 (and (or (not (stringp file
))
2173 (member file
'("dir" apropos history toc
)))
2174 (push (cons file nil
) Info-toc-nodes
))
2175 ;; Scan the entire manual and cache the result in Info-toc-nodes
2176 (let ((nodes (Info-build-toc file
)))
2177 (push (cons file nodes
) Info-toc-nodes
)
2179 ;; If there is an error, still add nil to the cache
2180 (push (cons file nil
) Info-toc-nodes
))
2181 (cdr (assoc file Info-toc-nodes
)))
2184 (defun Info-follow-reference (footnotename &optional fork
)
2185 "Follow cross reference named FOOTNOTENAME to the node it refers to.
2186 FOOTNOTENAME may be an abbreviation of the reference name.
2187 If FORK is non-nil (interactively with a prefix arg), show the node in
2188 a new Info buffer. If FORK is a string, it is the name to use for the
2191 (let ((completion-ignore-case t
)
2192 (case-fold-search t
)
2193 completions default alt-default
(start-point (point)) str i bol eol
)
2195 ;; Store end and beginning of line.
2201 (goto-char (point-min))
2202 (while (re-search-forward "\\*note[ \n\t]+\\([^:]*\\):" nil t
)
2203 (setq str
(match-string-no-properties 1))
2204 ;; See if this one should be the default.
2206 (<= (match-beginning 0) start-point
)
2207 (<= start-point
(point))
2209 ;; See if this one should be the alternate default.
2210 (and (null alt-default
)
2211 (and (<= bol
(match-beginning 0))
2213 (setq alt-default t
))
2215 (while (setq i
(string-match "[ \n\t]+" str i
))
2216 (setq str
(concat (substring str
0 i
) " "
2217 (substring str
(match-end 0))))
2219 ;; Record as a completion and perhaps as default.
2220 (if (eq default t
) (setq default str
))
2221 (if (eq alt-default t
) (setq alt-default str
))
2222 ;; Don't add this string if it's a duplicate.
2223 (or (assoc-string str completions t
)
2224 (push str completions
))))
2225 ;; If no good default was found, try an alternate.
2227 (setq default alt-default
))
2228 ;; If only one cross-reference found, then make it default.
2229 (if (eq (length completions
) 1)
2230 (setq default
(car completions
)))
2232 (let ((input (completing-read (if default
2234 "Follow reference named (default "
2236 "Follow reference named: ")
2237 completions nil t
)))
2238 (list (if (equal input
"")
2239 default input
) current-prefix-arg
))
2240 (error "No cross-references in this node"))))
2242 (unless footnotename
2243 (error "No reference was specified"))
2245 (let (target i
(str (concat "\\*note " (regexp-quote footnotename
)))
2246 (case-fold-search t
))
2247 (while (setq i
(string-match " " str i
))
2248 (setq str
(concat (substring str
0 i
) "[ \t\n]+" (substring str
(1+ i
))))
2251 ;; Move point to the beginning of reference if point is on reference
2252 (or (looking-at "\\*note[ \n\t]+")
2253 (and (looking-back "\\*note[ \n\t]+")
2254 (goto-char (match-beginning 0)))
2255 (if (and (save-excursion
2256 (goto-char (+ (point) 5)) ; skip a possible *note
2257 (re-search-backward "\\*note[ \n\t]+" nil t
)
2259 (<= (point) (match-end 0)))
2260 (goto-char (match-beginning 0))))
2261 ;; Go to the reference closest to point
2262 (let ((next-ref (save-excursion (and (re-search-forward str nil t
)
2263 (+ (match-beginning 0) 5))))
2264 (prev-ref (save-excursion (and (re-search-backward str nil t
)
2265 (+ (match-beginning 0) 5)))))
2266 (goto-char (cond ((and next-ref prev-ref
)
2267 (if (< (abs (- next-ref
(point)))
2268 (abs (- prev-ref
(point))))
2270 ((or next-ref prev-ref
))
2271 ((error "No cross-reference named %s" footnotename
))))
2272 (setq target
(Info-extract-menu-node-name t
))))
2273 (while (setq i
(string-match "[ \t\n]+" target i
))
2274 (setq target
(concat (substring target
0 i
) " "
2275 (substring target
(match-end 0))))
2277 (Info-goto-node target fork
)))
2279 (defconst Info-menu-entry-name-re
"\\(?:[^:]\\|:[^:,.;() \t\n]\\)*"
2280 ;; We allow newline because this is also used in Info-follow-reference,
2281 ;; where the xref name might be wrapped over two lines.
2282 "Regexp that matches a menu entry name upto but not including the colon.
2283 Because of ambiguities, this should be concatenated with something like
2284 `:' and `Info-following-node-name-re'.")
2286 (defun Info-extract-menu-node-name (&optional multi-line index-node
)
2287 (skip-chars-forward " \t\n")
2288 (when (looking-at (concat Info-menu-entry-name-re
":\\(:\\|"
2289 (Info-following-node-name-re
2291 (index-node "^,\t\n")
2292 (multi-line "^.,\t")
2296 "\\.\\(?:[ \t\n]+(line +\\([0-9]+\\))\\)?"
2299 (setq Info-point-loc
2300 (if (match-beginning 5)
2301 (string-to-number (match-string 5))
2302 (buffer-substring-no-properties
2303 (match-beginning 0) (1- (match-beginning 1)))))
2304 ;;; Uncomment next line to use names of cross-references in non-index nodes:
2305 ;;; (setq Info-point-loc
2306 ;;; (buffer-substring (match-beginning 0) (1- (match-beginning 1))))
2308 (replace-regexp-in-string
2310 (or (match-string-no-properties 2)
2311 ;; If the node name is the menu entry name (using `entry::').
2312 (buffer-substring-no-properties
2313 (match-beginning 0) (1- (match-beginning 1)))))))
2315 ;; No one calls this.
2316 ;;(defun Info-menu-item-sequence (list)
2318 ;; (Info-menu (car list))
2319 ;; (setq list (cdr list))))
2321 (defvar Info-complete-menu-buffer
)
2322 (defvar Info-complete-next-re nil
)
2323 (defvar Info-complete-nodes nil
)
2324 (defvar Info-complete-cache nil
)
2326 (defconst Info-node-spec-re
2327 (concat (Info-following-node-name-re "^.,:") "[,:.]")
2328 "Regexp to match the text after a : until the terminating `.'.")
2330 (defun Info-complete-menu-item (string predicate action
)
2331 ;; This uses two dynamically bound variables:
2332 ;; - `Info-complete-menu-buffer' which contains the buffer in which
2333 ;; is the menu of items we're trying to complete.
2334 ;; - `Info-complete-next-re' which, if non-nil, indicates that we should
2335 ;; also look for menu items in subsequent nodes as long as those
2336 ;; nodes' names match `Info-complete-next-re'. This feature is currently
2338 ;; - `Info-complete-nodes' which, if non-nil, indicates that we should
2339 ;; also look for menu items in these nodes. This feature is currently
2340 ;; only used for completion in Info-index.
2342 ;; Note that `Info-complete-menu-buffer' could be current already,
2343 ;; so we want to save point.
2344 (with-current-buffer Info-complete-menu-buffer
2346 (let ((completion-ignore-case t
)
2347 (case-fold-search t
)
2348 (orignode Info-current-node
)
2350 (goto-char (point-min))
2351 (search-forward "\n* Menu:")
2352 (if (not (memq action
'(nil t
)))
2354 (concat "\n\\* +" (regexp-quote string
) ":") nil t
)
2355 (let ((pattern (concat "\n\\* +\\("
2356 (regexp-quote string
)
2357 Info-menu-entry-name-re
"\\):" Info-node-spec-re
))
2359 (complete-nodes Info-complete-nodes
))
2361 (if (and (equal (nth 0 Info-complete-cache
) Info-current-file
)
2362 (equal (nth 1 Info-complete-cache
) Info-current-node
)
2363 (equal (nth 2 Info-complete-cache
) Info-complete-next-re
)
2364 (equal (nth 5 Info-complete-cache
) Info-complete-nodes
)
2365 (let ((prev (nth 3 Info-complete-cache
)))
2366 (eq t
(compare-strings string
0 (length prev
)
2368 ;; We can reuse the previous list.
2369 (setq completions
(nth 4 Info-complete-cache
))
2370 ;; The cache can't be used.
2373 (while (re-search-forward pattern nil t
)
2374 (push (match-string-no-properties 1)
2376 ;; Check subsequent nodes if applicable.
2377 (or (and Info-complete-next-re
2378 (setq nextnode
(Info-extract-pointer "next" t
))
2379 (string-match Info-complete-next-re nextnode
))
2381 (setq complete-nodes
(cdr complete-nodes
)
2382 nextnode
(car complete-nodes
)))))
2383 (Info-goto-node nextnode
))
2384 ;; Go back to the start node (for the next completion).
2385 (unless (equal Info-current-node orignode
)
2386 (Info-goto-node orignode
))
2387 ;; Update the cache.
2388 (set (make-local-variable 'Info-complete-cache
)
2389 (list Info-current-file Info-current-node
2390 Info-complete-next-re string completions
2391 Info-complete-nodes
)))
2393 (all-completions string completions predicate
)
2394 (try-completion string completions predicate
))))))))
2397 (defun Info-menu (menu-item &optional fork
)
2398 "Go to the node pointed to by the menu item named (or abbreviated) MENU-ITEM.
2399 The menu item should one of those listed in the current node's menu.
2400 Completion is allowed, and the default menu item is the one point is on.
2401 If FORK is non-nil (interactively with a prefix arg), show the node in
2402 a new Info buffer. If FORK is a string, it is the name to use for the
2405 (let ((completions '())
2406 ;; If point is within a menu item, use that item as the default
2411 (case-fold-search t
))
2413 (goto-char (point-min))
2414 (if (not (search-forward "\n* menu:" nil t
))
2415 (error "No menu in this node"))
2421 (if (re-search-backward (concat "\n\\* +\\("
2422 Info-menu-entry-name-re
2424 (setq default
(match-string-no-properties 1))))))
2427 (setq item
(let ((completion-ignore-case t
)
2428 (Info-complete-menu-buffer (current-buffer)))
2429 (completing-read (if default
2430 (format "Menu item (default %s): "
2433 'Info-complete-menu-item nil t
)))
2434 ;; we rely on the fact that completing-read accepts an input
2435 ;; of "" even when the require-match argument is true and ""
2436 ;; is not a valid possibility
2437 (if (string= item
"")
2442 (list item current-prefix-arg
))))
2443 ;; there is a problem here in that if several menu items have the same
2444 ;; name you can only go to the node of the first with this command.
2445 (Info-goto-node (Info-extract-menu-item menu-item
) (if fork menu-item
)))
2447 (defun Info-extract-menu-item (menu-item)
2448 (setq menu-item
(regexp-quote menu-item
))
2449 (let ((case-fold-search t
))
2451 (let ((case-fold-search t
))
2452 (goto-char (point-min))
2453 (or (search-forward "\n* menu:" nil t
)
2454 (error "No menu in this node"))
2455 (or (re-search-forward (concat "\n\\* +" menu-item
":") nil t
)
2456 (re-search-forward (concat "\n\\* +" menu-item
) nil t
)
2457 (error "No such item in menu"))
2460 (Info-extract-menu-node-name nil
(Info-index-node))))))
2462 ;; If COUNT is nil, use the last item in the menu.
2463 (defun Info-extract-menu-counting (count &optional no-detail
)
2464 (let ((case-fold-search t
))
2466 (let ((case-fold-search t
)
2467 (bound (when (and no-detail
2469 "^[ \t-]*The Detailed Node Listing" nil t
))
2470 (match-beginning 0))))
2471 (goto-char (point-min))
2472 (or (search-forward "\n* menu:" bound t
)
2473 (error "No menu in this node"))
2475 (or (search-forward "\n* " bound t count
)
2476 (error "Too few items in menu"))
2477 (while (search-forward "\n* " bound t
)
2479 (Info-extract-menu-node-name nil
(Info-index-node))))))
2481 (defun Info-nth-menu-item ()
2482 "Go to the node of the Nth menu item.
2483 N is the digit argument used to invoke this command."
2486 (Info-extract-menu-counting
2487 (- (aref (this-command-keys) (1- (length (this-command-keys)))) ?
0))))
2489 (defun Info-top-node ()
2490 "Go to the Top node of this file."
2492 (Info-goto-node "Top"))
2494 (defun Info-final-node ()
2495 "Go to the final node in this file."
2497 (Info-goto-node "Top")
2498 (let ((Info-history nil
)
2499 (case-fold-search t
))
2500 ;; Go to the last node in the menu of Top. But don't delve into
2501 ;; detailed node listings.
2502 (Info-goto-node (Info-extract-menu-counting nil t
))
2503 ;; If the last node in the menu is not last in pointer structure,
2504 ;; move forward (but not down- or upward - see bug#1116) until we
2505 ;; can't go any farther.
2506 (while (Info-forward-node t t t
) nil
)
2507 ;; Then keep moving down to last subnode, unless we reach an index.
2508 (while (and (not (Info-index-node))
2509 (save-excursion (search-forward "\n* Menu:" nil t
)))
2510 (Info-goto-node (Info-extract-menu-counting nil
)))))
2512 (defun Info-forward-node (&optional not-down not-up no-error
)
2513 "Go forward one node, considering all nodes as forming one sequence."
2515 (goto-char (point-min))
2517 (let ((case-fold-search t
))
2518 ;; three possibilities, in order of priority:
2519 ;; 1. next node is in a menu in this node (but not in an index)
2520 ;; 2. next node is next at same level
2521 ;; 3. next node is up and next
2522 (cond ((and (not not-down
)
2523 (save-excursion (search-forward "\n* menu:" nil t
))
2524 (not (Info-index-node)))
2525 (Info-goto-node (Info-extract-menu-counting 1))
2527 ((save-excursion (search-backward "next:" nil t
))
2531 (save-excursion (search-backward "up:" nil t
))
2532 ;; Use string-equal, not equal, to ignore text props.
2533 (not (string-equal (downcase (Info-extract-pointer "up"))
2535 (let ((old-node Info-current-node
))
2537 (let (Info-history success
)
2539 (setq success
(Info-forward-node t nil no-error
))
2540 (or success
(Info-goto-node old-node
))))))
2542 (t (error "No pointer forward from this node")))))
2544 (defun Info-backward-node ()
2545 "Go backward one node, considering all nodes as forming one sequence."
2547 (let ((prevnode (Info-extract-pointer "prev[ious]*" t
))
2548 (upnode (Info-extract-pointer "up" t
))
2549 (case-fold-search t
))
2550 (cond ((and upnode
(string-match "(" upnode
))
2551 (error "First node in file"))
2552 ((and upnode
(or (null prevnode
)
2553 ;; Use string-equal, not equal,
2554 ;; to ignore text properties.
2555 (string-equal (downcase prevnode
)
2556 (downcase upnode
))))
2559 ;; If we move back at the same level,
2560 ;; go down to find the last subnode*.
2563 (while (and (not (Info-index-node))
2564 (save-excursion (search-forward "\n* Menu:" nil t
)))
2565 (Info-goto-node (Info-extract-menu-counting nil
)))))
2567 (error "No pointer backward from this node")))))
2570 "Exit Info by selecting some other buffer."
2573 (save-buffers-kill-emacs)
2576 (defun Info-next-menu-item ()
2577 "Go to the node of the next menu item."
2579 ;; Bind this in case the user sets it to nil.
2580 (let* ((case-fold-search t
)
2584 (search-forward "\n* menu:" nil t
)
2585 (and (search-forward "\n* " nil t
)
2586 (Info-extract-menu-node-name)))))
2587 (if node
(Info-goto-node node
)
2588 (error "No more items in menu"))))
2590 (defun Info-last-menu-item ()
2591 "Go to the node of the previous menu item."
2595 ;; Bind this in case the user sets it to nil.
2596 (let* ((case-fold-search t
)
2597 (beg (save-excursion
2598 (and (search-backward "\n* menu:" nil t
)
2600 (or (and beg
(search-backward "\n* " beg t
))
2601 (error "No previous items in menu")))
2602 (Info-goto-node (save-excursion
2603 (goto-char (match-end 0))
2604 (Info-extract-menu-node-name)))))
2606 (defmacro Info-no-error
(&rest body
)
2607 (list 'condition-case nil
(cons 'progn
(append body
'(t))) '(error nil
)))
2609 (defun Info-next-preorder ()
2610 "Go to the next subnode or the next node, or go up a level."
2612 (cond ((Info-no-error (Info-next-menu-item)))
2613 ((Info-no-error (Info-next)))
2614 ((Info-no-error (Info-up t
))
2615 ;; Since we have already gone thru all the items in this menu,
2616 ;; go up to the end of this node.
2617 (goto-char (point-max))
2618 ;; Since logically we are done with the node with that menu,
2619 ;; move on from it. But don't add intermediate nodes
2620 ;; to the history on recursive calls.
2622 (Info-next-preorder)))
2624 (error "No more nodes"))))
2626 (defun Info-last-preorder ()
2627 "Go to the last node, popping up a level if there is none."
2629 (cond ((Info-no-error
2630 (Info-last-menu-item)
2631 ;; If we go down a menu item, go to the end of the node
2632 ;; so we can scroll back through it.
2633 (goto-char (point-max)))
2634 ;; Keep going down, as long as there are nested menu nodes.
2635 (while (Info-no-error
2636 (Info-last-menu-item)
2637 ;; If we go down a menu item, go to the end of the node
2638 ;; so we can scroll back through it.
2639 (goto-char (point-max))))
2641 ((and (Info-no-error (Info-extract-pointer "prev"))
2642 (not (equal (Info-extract-pointer "up")
2643 (Info-extract-pointer "prev"))))
2644 (Info-no-error (Info-prev))
2645 (goto-char (point-max))
2646 (while (Info-no-error
2647 (Info-last-menu-item)
2648 ;; If we go down a menu item, go to the end of the node
2649 ;; so we can scroll back through it.
2650 (goto-char (point-max))))
2652 ((Info-no-error (Info-up t
))
2653 (goto-char (point-min))
2654 (let ((case-fold-search t
))
2655 (or (search-forward "\n* Menu:" nil t
)
2656 (goto-char (point-max)))))
2657 (t (error "No previous nodes"))))
2659 (defun Info-scroll-up ()
2660 "Scroll one screenful forward in Info, considering all nodes as one sequence.
2661 Once you scroll far enough in a node that its menu appears on the screen
2662 but after point, the next scroll moves into its first subnode, unless
2663 `Info-scroll-prefer-subnodes' is nil.
2665 When you scroll past the end of a node, that goes to the next node if
2666 `Info-scroll-prefer-subnodes' is non-nil and to the first subnode otherwise;
2667 if this node has no successor, it moves to the parent node's successor,
2668 and so on. If `Info-scroll-prefer-subnodes' is non-nil and point is inside
2669 the menu of a node, it moves to subnode indicated by the following menu
2670 item. (That case won't normally result from this command, but can happen
2674 (if (or (< (window-start) (point-min))
2675 (> (window-start) (point-max)))
2676 (set-window-start (selected-window) (point)))
2677 (let* ((case-fold-search t
)
2678 (virtual-end (save-excursion
2679 (goto-char (point-min))
2680 (if (and Info-scroll-prefer-subnodes
2681 (search-forward "\n* Menu:" nil t
))
2684 (if (or (< virtual-end
(window-start))
2685 (pos-visible-in-window-p virtual-end
))
2687 (Info-scroll-prefer-subnodes (Info-next-preorder))
2688 ((Info-no-error (Info-goto-node (Info-extract-menu-counting 1))))
2689 (t (Info-next-preorder)))
2692 (defun Info-mouse-scroll-up (e)
2693 "Scroll one screenful forward in Info, using the mouse.
2694 See `Info-scroll-up'."
2696 (save-selected-window
2698 (select-window (posn-window (event-start e
))))
2701 (defun Info-scroll-down ()
2702 "Scroll one screenful back in Info, considering all nodes as one sequence.
2703 If point is within the menu of a node, and `Info-scroll-prefer-subnodes'
2704 is non-nil, this goes to its last subnode. When you scroll past the
2705 beginning of a node, that goes to the previous node or back up to the
2708 (if (or (< (window-start) (point-min))
2709 (> (window-start) (point-max)))
2710 (set-window-start (selected-window) (point)))
2711 (let* ((case-fold-search t
)
2712 (current-point (point))
2714 (and Info-scroll-prefer-subnodes
2717 (setq current-point
(point))
2718 (goto-char (point-min))
2719 (search-forward "\n* Menu:"
2723 (pos-visible-in-window-p (point-min) nil t
))
2724 (Info-last-preorder)
2727 (defun Info-mouse-scroll-down (e)
2728 "Scroll one screenful backward in Info, using the mouse.
2729 See `Info-scroll-down'."
2731 (save-selected-window
2733 (select-window (posn-window (event-start e
))))
2734 (Info-scroll-down)))
2736 (defun Info-next-reference (&optional recur
)
2737 "Move cursor to the next cross-reference or menu item in the node."
2739 (let ((pat "\\*note[ \n\t]+\\([^:]+\\):\\|^\\* .*:\\|[hf]t?tps?://")
2741 (case-fold-search t
))
2742 (or (eobp) (forward-char 1))
2743 (or (re-search-forward pat nil t
)
2745 (goto-char (point-min))
2746 (or (re-search-forward pat nil t
)
2749 (error "No cross references in this node")))))
2750 (goto-char (or (match-beginning 1) (match-beginning 0)))
2751 (if (looking-at "\\* Menu:")
2753 (error "No cross references in this node")
2754 (Info-next-reference t
))
2755 (if (looking-at "^\\* ")
2756 (forward-char 2)))))
2758 (defun Info-prev-reference (&optional recur
)
2759 "Move cursor to the previous cross-reference or menu item in the node."
2761 (let ((pat "\\*note[ \n\t]+\\([^:]+\\):\\|^\\* .*:\\|[hf]t?tps?://")
2763 (case-fold-search t
))
2764 (or (re-search-backward pat nil t
)
2766 (goto-char (point-max))
2767 (or (re-search-backward pat nil t
)
2770 (error "No cross references in this node")))))
2771 (goto-char (or (match-beginning 1) (match-beginning 0)))
2772 (if (looking-at "\\* Menu:")
2774 (error "No cross references in this node")
2775 (Info-prev-reference t
))
2776 (if (looking-at "^\\* ")
2777 (forward-char 2)))))
2779 (defvar Info-index-nodes nil
2780 "Alist of cached index node names of visited Info files.
2781 Each element has the form (INFO-FILE INDEX-NODE-NAMES-LIST).")
2783 (defun Info-index-nodes (&optional file
)
2784 "Return a list of names of all index nodes in Info FILE.
2785 If FILE is omitted, it defaults to the current Info file.
2786 First look in a list of cached index node names. Then scan Info
2787 file and its subfiles for nodes with the index cookie. Then try
2788 to find index nodes starting from the first node in the top level
2789 menu whose name contains the word \"Index\", plus any immediately
2790 following nodes whose names also contain the word \"Index\"."
2791 (or file
(setq file Info-current-file
))
2792 (or (assoc file Info-index-nodes
)
2793 ;; Skip virtual Info files
2794 (and (or (not (stringp file
))
2795 (member file
'("dir" apropos history toc
)))
2796 (setq Info-index-nodes
(cons (cons file nil
) Info-index-nodes
)))
2797 (if (Info-file-supports-index-cookies file
)
2798 ;; Find nodes with index cookie
2799 (let* ((default-directory (or (and (stringp file
)
2800 (file-name-directory
2801 (setq file
(Info-find-file file
))))
2803 Info-history Info-history-list Info-fontify-maximum-menu-size
2804 (main-file file
) subfiles nodes node
)
2807 (while (or main-file subfiles
)
2809 (info-insert-file-contents (or main-file
(car subfiles
)))
2810 (goto-char (point-min))
2811 (while (search-forward "\0\b[index\0\b]" nil
'move
)
2813 (re-search-backward "^\^_")
2814 (search-forward "Node: ")
2815 (setq nodes
(cons (Info-following-node-name) nodes
))))
2818 (goto-char (point-min))
2819 (if (search-forward "\n\^_\nIndirect:" nil t
)
2820 (let ((bound (save-excursion (search-forward "\n\^_" nil t
))))
2821 (while (re-search-forward "^\\(.*\\): [0-9]+$" bound t
)
2822 (setq subfiles
(cons (match-string-no-properties 1)
2824 (setq subfiles
(nreverse subfiles
)
2826 (setq subfiles
(cdr subfiles
)))))
2829 (setq nodes
(nreverse nodes
)
2830 Info-index-nodes
(cons (cons file nodes
) Info-index-nodes
)))
2832 ;; Else find nodes with the word "Index" in the node name
2833 (let ((case-fold-search t
)
2834 Info-history Info-history-list Info-fontify-maximum-menu-size Info-point-loc
2839 (Info-find-node file
"Top")
2840 (when (and (search-forward "\n* menu:" nil t
)
2841 (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t
))
2842 (goto-char (match-beginning 1))
2843 (setq nodes
(list (Info-extract-menu-node-name)))
2844 (Info-goto-node (car nodes
))
2845 (while (and (setq node
(Info-extract-pointer "next" t
))
2846 (string-match "\\<Index\\>" node
))
2847 (setq nodes
(cons node nodes
))
2848 (Info-goto-node node
))))
2851 (setq nodes
(nreverse nodes
)
2852 Info-index-nodes
(cons (cons file nodes
) Info-index-nodes
)))
2854 ;; If file has no index nodes, still add it to the cache
2855 (setq Info-index-nodes
(cons (cons file nil
) Info-index-nodes
)))
2856 (cdr (assoc file Info-index-nodes
)))
2858 (defun Info-index-node (&optional node file
)
2859 "Return non-nil value if NODE is an index node.
2860 If NODE is nil, check the current Info node.
2861 If FILE is nil, check the current Info file."
2862 (or file
(setq file Info-current-file
))
2863 (if (or (and node
(not (equal node Info-current-node
)))
2864 (assoc file Info-index-nodes
))
2865 (member (or node Info-current-node
) (Info-index-nodes file
))
2866 ;; Don't search all index nodes if request is only for the current node
2867 ;; and file is not in the cache of index nodes
2868 (if (Info-file-supports-index-cookies file
)
2870 (goto-char (+ (or (save-excursion
2871 (search-backward "\n\^_" nil t
))
2873 (search-forward "\0\b[index\0\b]"
2875 (search-forward "\n\^_" nil t
))
2878 (string-match "\\<Index\\>" (or node Info-current-node
""))))))
2880 (defun Info-goto-index ()
2881 "Go to the first index node."
2882 (let ((node (car (Info-index-nodes))))
2883 (or node
(error "No index"))
2884 (Info-goto-node node
)))
2887 (defun Info-index (topic)
2888 "Look up a string TOPIC in the index for this manual and go to that entry.
2889 If there are no exact matches to the specified topic, this chooses
2890 the first match which is a case-insensitive substring of a topic.
2891 Use the \\<Info-mode-map>\\[Info-index-next] command to see the other matches.
2892 Give an empty topic name to go to the Index node itself."
2895 (let ((completion-ignore-case t
)
2896 (Info-complete-menu-buffer (clone-buffer))
2897 (Info-complete-nodes (Info-index-nodes))
2898 (Info-history-list nil
))
2899 (if (equal Info-current-file
"dir")
2900 (error "The Info directory node has no index; use m to select a manual"))
2902 (with-current-buffer Info-complete-menu-buffer
2904 (completing-read "Index topic: " 'Info-complete-menu-item
))
2905 (kill-buffer Info-complete-menu-buffer
)))))
2906 (if (equal Info-current-file
"dir")
2907 (error "The Info directory node has no index; use m to select a manual"))
2908 ;; Strip leading colon in topic; index format does not allow them.
2909 (if (and (stringp topic
)
2910 (> (length topic
) 0)
2911 (= (aref topic
0) ?
:))
2912 (setq topic
(substring topic
1)))
2913 (let ((orignode Info-current-node
)
2914 (pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^\n]*\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?"
2915 (regexp-quote topic
)))
2916 node
(nodes (Info-index-nodes))
2917 (ohist-list Info-history-list
)
2918 (case-fold-search t
))
2920 (or (equal topic
"")
2923 ;; We bind Info-history to nil for internal node-switches so
2924 ;; that we don't put junk in the history. In the first
2925 ;; Info-goto-index call, above, we do update the history
2926 ;; because that is what the user's previous node choice into it.
2931 (goto-char (point-min))
2932 (while (re-search-forward pattern nil t
)
2933 (push (list (match-string-no-properties 1)
2934 (match-string-no-properties 2)
2936 (string-to-number (concat "0"
2939 (setq nodes
(cdr nodes
) node
(car nodes
)))
2940 (Info-goto-node node
))
2943 (Info-goto-node orignode
)
2944 (error "No `%s' in index" topic
)))
2945 ;; Here it is a feature that assoc is case-sensitive.
2946 (while (setq found
(assoc topic matches
))
2947 (setq exact
(cons found exact
)
2948 matches
(delq found matches
)))
2949 (setq Info-history-list ohist-list
)
2950 (setq Info-index-alternatives
(nconc exact
(nreverse matches
)))
2951 (Info-index-next 0)))))
2953 (defun Info-index-next (num)
2954 "Go to the next matching index item from the last \\<Info-mode-map>\\[Info-index] command."
2956 (or Info-index-alternatives
2957 (error "No previous `i' command"))
2959 (setq num
(+ num
(length Info-index-alternatives
))))
2961 (setq Info-index-alternatives
2962 (nconc (cdr Info-index-alternatives
)
2963 (list (car Info-index-alternatives
)))
2965 (Info-goto-node (nth 1 (car Info-index-alternatives
)))
2966 (if (> (nth 3 (car Info-index-alternatives
)) 0)
2967 (forward-line (1- (nth 3 (car Info-index-alternatives
))))
2968 (forward-line 3) ; don't search in headers
2969 (let ((name (car (car Info-index-alternatives
))))
2970 (Info-find-index-name name
)))
2971 (message "Found `%s' in %s. %s"
2972 (car (car Info-index-alternatives
))
2973 (nth 2 (car Info-index-alternatives
))
2974 (if (cdr Info-index-alternatives
)
2975 (format "(%s total; use `%s' for next)"
2976 (length Info-index-alternatives
)
2977 (key-description (where-is-internal
2978 'Info-index-next overriding-local-map
2982 (defun Info-find-index-name (name)
2983 "Move point to the place within the current node where NAME is defined."
2984 (let ((case-fold-search t
))
2985 (if (or (re-search-forward (format
2986 "[a-zA-Z]+: %s\\( \\|$\\)"
2987 (regexp-quote name
)) nil t
)
2988 ;; Find a function definition with a return type.
2989 (re-search-forward (format
2990 "[a-zA-Z]+: [a-zA-Z0-9_ *&]+ %s\\( \\|$\\)"
2991 (regexp-quote name
)) nil t
)
2992 (search-forward (format "`%s'" name
) nil t
)
2993 (and (string-match "\\`.*\\( (.*)\\)\\'" name
)
2995 (format "`%s'" (substring name
0 (match-beginning 1)))
2997 (search-forward name nil t
)
2998 ;; Try again without the " <1>" makeinfo can append
2999 (and (string-match "\\`\\(.*\\) <[0-9]+>\\'" name
)
3000 (Info-find-index-name (match-string 1 name
))))
3001 (progn (beginning-of-line) t
) ;; non-nil for recursive call
3002 (goto-char (point-min)))))
3005 (defun info-apropos (string)
3006 "Grovel indices of all known Info files on your system for STRING.
3007 Build a menu of the possible matches."
3008 (interactive "sIndex apropos: ")
3009 (unless (string= string
"")
3010 (let ((pattern (format "\n\\* +\\([^\n]*%s[^\n]*\\):[ \t]+\\([^\n]+\\)\\.\\(?:[ \t\n]*(line +\\([0-9]+\\))\\)?"
3011 (regexp-quote string
)))
3012 (ohist Info-history
)
3013 (ohist-list Info-history-list
)
3014 (current-node Info-current-node
)
3015 (current-file Info-current-file
)
3016 manuals matches node nodes
)
3017 (let ((Info-fontify-maximum-menu-size nil
))
3019 ;; current-node and current-file are nil when they invoke info-apropos
3020 ;; as the first Info command, i.e. info-apropos loads info.el. In that
3021 ;; case, we use (DIR)Top instead, to avoid signalling an error after
3022 ;; the search is complete.
3023 (when (null current-node
)
3024 (setq current-file Info-current-file
)
3025 (setq current-node Info-current-node
))
3026 (message "Searching indices...")
3027 (goto-char (point-min))
3028 (re-search-forward "\\* Menu: *\n" nil t
)
3029 (while (re-search-forward "\\*.*: *(\\([^)]+\\))" nil t
)
3030 ;; add-to-list makes sure we don't have duplicates in `manuals',
3031 ;; so that the following dolist loop runs faster.
3032 (add-to-list 'manuals
(match-string 1)))
3033 (dolist (manual (nreverse manuals
))
3034 (message "Searching %s" manual
)
3036 (if (setq nodes
(Info-index-nodes (Info-find-file manual
)))
3038 (Info-find-node manual
(car nodes
))
3041 (goto-char (point-min))
3042 (while (re-search-forward pattern nil t
)
3045 (match-string-no-properties 1)
3046 (match-string-no-properties 2)
3047 (match-string-no-properties 3))
3049 (setq nodes
(cdr nodes
) node
(car nodes
)))
3050 (Info-goto-node node
))))
3052 (message "%s" (if (eq (car-safe err
) 'error
)
3055 (Info-find-node current-file current-node
)
3056 (setq Info-history ohist
3057 Info-history-list ohist-list
)
3058 (message "Searching indices...done")
3060 (message "No matches found")
3061 (with-current-buffer (get-buffer-create " *info-apropos*")
3063 (insert "\n\^_\nFile: apropos, Node: Index, Up: (dir)\n")
3064 (insert "* Menu: \nNodes whose indices contain `" string
"':\n\n")
3065 (dolist (entry (nreverse matches
))
3067 (format "* %-38s (%s)%s.%s\n"
3068 (concat (nth 1 entry
) " [" (nth 0 entry
) "]:")
3072 (concat " (line " (nth 3 entry
) ")")
3074 (Info-find-node 'apropos
"Index")
3075 (setq Info-complete-cache nil
)))))
3077 (defun Info-undefined ()
3078 "Make command be undefined in Info."
3083 "Enter the Info tutorial."
3085 (delete-other-windows)
3086 (Info-find-node "info"
3087 (if (< (window-height) 23)
3091 (defun Info-summary ()
3092 "Display a brief summary of all Info commands."
3094 (save-window-excursion
3095 (switch-to-buffer "*Help*")
3096 (setq buffer-read-only nil
)
3098 (insert (documentation 'Info-mode
))
3100 (goto-char (point-min))
3102 (while (progn (setq flag
(not (pos-visible-in-window-p (point-max))))
3103 (message (if flag
"Type Space to see more"
3104 "Type Space to return to Info"))
3105 (if (not (eq ?\s
(setq ch
(read-event))))
3106 (progn (setq unread-command-events
(list ch
)) nil
)
3109 (bury-buffer "*Help*")))
3111 (defun Info-get-token (pos start all
&optional errorstring
)
3112 "Return the token around POS.
3113 POS must be somewhere inside the token
3114 START is a regular expression which will match the
3115 beginning of the tokens delimited string
3116 ALL is a regular expression with a single
3117 parenthesized subpattern which is the token to be
3118 returned. E.g. '{\(.*\)}' would return any string
3119 enclosed in braces around POS.
3120 ERRORSTRING optional fourth argument, controls action on no match
3123 a string: signal an error, using that string."
3124 (let ((case-fold-search t
))
3127 ;; First look for a match for START that goes across POS.
3128 (while (and (not (bobp)) (> (point) (- pos
(length start
)))
3129 (not (looking-at start
)))
3131 ;; If we did not find one, search back for START
3132 ;; (this finds only matches that end at or before POS).
3133 (or (looking-at start
)
3136 (re-search-backward start
(max (point-min) (- pos
200)) 'yes
)))
3138 (while (and (re-search-forward all
(min (point-max) (+ pos
200)) 'yes
)
3139 (not (setq found
(and (<= (match-beginning 0) pos
)
3140 (> (match-end 0) pos
))))))
3141 (if (and found
(<= (match-beginning 0) pos
)
3142 (> (match-end 0) pos
))
3143 (match-string-no-properties 1)
3144 (cond ((null errorstring
)
3150 (error "No %s around position %d" errorstring pos
))))))))
3152 (defun Info-mouse-follow-nearest-node (click)
3153 "\\<Info-mode-map>Follow a node reference near point.
3154 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click.
3155 At end of the node's text, moves to the next node, or up if none."
3157 (mouse-set-point click
)
3158 (and (not (Info-follow-nearest-node))
3159 (save-excursion (forward-line 1) (eobp))
3160 (Info-next-preorder)))
3162 (defun Info-follow-nearest-node (&optional fork
)
3163 "Follow a node reference near point.
3164 If point is on a reference, follow that reference. Otherwise,
3165 if point is in a menu item description, follow that menu item.
3167 If FORK is non-nil (interactively with a prefix arg), show the node in
3169 If FORK is a string, it is the name to use for the new buffer."
3171 (or (Info-try-follow-nearest-node fork
)
3172 (when (save-excursion
3173 (search-backward "\n* menu:" nil t
))
3176 (while (not (or (bobp) (looking-at "[^ \t]\\|[ \t]*$")))
3177 (beginning-of-line 0))
3178 (when (looking-at "\\* +\\([^\t\n]*\\):")
3180 (Info-extract-menu-item (match-string-no-properties 1)) fork
)
3182 (and (eq this-command
'Info-mouse-follow-nearest-node
)
3183 ;; Don't raise an error when mouse-1 is bound to this - it's
3184 ;; often used to simply select the window or frame.
3185 (eq 'mouse-1
(event-basic-type last-input-event
)))
3186 (error "Point neither on reference nor in menu item description")))
3188 ;; Common subroutine.
3189 (defun Info-try-follow-nearest-node (&optional fork
)
3190 "Follow a node reference near point. Return non-nil if successful.
3191 If FORK is non-nil, it is passed to `Info-goto-node'."
3194 ((Info-get-token (point) "[hf]t?tps?://" "[hf]t?tps?://\\([^ \t\n\"`({<>})']+\\)")
3196 (browse-url (browse-url-url-at-point)))
3197 ((setq node
(Info-get-token (point) "\\*note[ \n\t]+"
3198 "\\*note[ \n\t]+\\([^:]*\\):\\(:\\|[ \n\t]*(\\)?"))
3199 (Info-follow-reference node fork
))
3200 ;; menu item: node name
3201 ((setq node
(Info-get-token (point) "\\* +" "\\* +\\([^:]*\\)::"))
3202 (Info-goto-node node fork
))
3203 ;; menu item: node name or index entry
3204 ((Info-get-token (point) "\\* +" "\\* +\\(.*\\): ")
3207 (setq node
(Info-extract-menu-node-name nil
(Info-index-node)))
3208 (Info-goto-node node fork
))
3209 ((setq node
(Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)"))
3210 (Info-goto-node node fork
))
3211 ((setq node
(Info-get-token (point) "Next: " "Next: \\([^,\n\t]*\\)"))
3212 (Info-goto-node node fork
))
3213 ((setq node
(Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)"))
3214 (Info-goto-node "Top" fork
))
3215 ((setq node
(Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)"))
3216 (Info-goto-node node fork
)))
3219 (defvar Info-mode-map
3220 (let ((map (make-keymap)))
3221 (suppress-keymap map
)
3222 (define-key map
"." 'beginning-of-buffer
)
3223 (define-key map
" " 'Info-scroll-up
)
3224 (define-key map
"\C-m" 'Info-follow-nearest-node
)
3225 (define-key map
"\t" 'Info-next-reference
)
3226 (define-key map
"\e\t" 'Info-prev-reference
)
3227 (define-key map
[(shift tab
)] 'Info-prev-reference
)
3228 (define-key map
[backtab] 'Info-prev-reference)
3229 (define-key map "1" 'Info-nth-menu-item)
3230 (define-key map "2" 'Info-nth-menu-item)
3231 (define-key map "3" 'Info-nth-menu-item)
3232 (define-key map "4" 'Info-nth-menu-item)
3233 (define-key map "5" 'Info-nth-menu-item)
3234 (define-key map "6" 'Info-nth-menu-item)
3235 (define-key map "7" 'Info-nth-menu-item)
3236 (define-key map "8" 'Info-nth-menu-item)
3237 (define-key map "9" 'Info-nth-menu-item)
3238 (define-key map "0" 'undefined)
3239 (define-key map "?" 'Info-summary)
3240 (define-key map "]" 'Info-forward-node)
3241 (define-key map "[" 'Info-backward-node)
3242 (define-key map "<" 'Info-top-node)
3243 (define-key map ">" 'Info-final-node)
3244 (define-key map "b" 'beginning-of-buffer)
3245 (define-key map "d" 'Info-directory)
3246 (define-key map "e" 'Info-edit)
3247 (define-key map "f" 'Info-follow-reference)
3248 (define-key map "g" 'Info-goto-node)
3249 (define-key map "h" 'Info-help)
3250 (define-key map "i" 'Info-index)
3251 (define-key map "l" 'Info-history-back)
3252 (define-key map "L" 'Info-history)
3253 (define-key map "m" 'Info-menu)
3254 (define-key map "n" 'Info-next)
3255 (define-key map "p" 'Info-prev)
3256 (define-key map "q" 'Info-exit)
3257 (define-key map "r" 'Info-history-forward)
3258 (define-key map "s" 'Info-search)
3259 (define-key map "S" 'Info-search-case-sensitively)
3260 (define-key map "\M-n" 'clone-buffer)
3261 (define-key map "t" 'Info-top-node)
3262 (define-key map "T" 'Info-toc)
3263 (define-key map "u" 'Info-up)
3264 ;; `w' for consistency with `dired-copy-filename-as-kill'.
3265 (define-key map "w" 'Info-copy-current-node-name)
3266 (define-key map "c" 'Info-copy-current-node-name)
3267 ;; `^' for consistency with `dired-up-directory'.
3268 (define-key map "^" 'Info-up)
3269 (define-key map "," 'Info-index-next)
3270 (define-key map "\177" 'Info-scroll-down)
3271 (define-key map [mouse-2] 'Info-mouse-follow-nearest-node)
3272 (define-key map [follow-link] 'mouse-face)
3274 "Keymap containing Info commands.")
3277 (defun Info-check-pointer (item)
3278 "Non-nil if ITEM is present in this node."
3280 (Info-extract-pointer item)
3284 Info-mode-menu Info-mode-map
3285 "Menu for Info files."
3287 ["Up" Info-up :active (Info-check-pointer "up")
3288 :help "Go up in the Info tree"]
3289 ["Next" Info-next :active (Info-check-pointer "next")
3290 :help "Go to the next node"]
3291 ["Previous" Info-prev :active (Info-check-pointer "prev[ious]*")
3292 :help "Go to the previous node"]
3293 ["Backward" Info-backward-node
3294 :help "Go backward one node, considering all as a sequence"]
3295 ["Forward" Info-forward-node
3296 :help "Go forward one node, considering all as a sequence"]
3297 ["Beginning" beginning-of-buffer
3298 :help "Go to beginning of this node"]
3299 ["Top" Info-top-node
3300 :help "Go to top node of file"]
3301 ["Final Node" Info-final-node
3302 :help "Go to final node in this file"]
3303 ("Menu Item" ["You should never see this" report-emacs-bug t])
3304 ("Reference" ["You should never see this" report-emacs-bug t])
3305 ["Search..." Info-search
3306 :help "Search for regular expression in this Info file"]
3307 ["Search Next" Info-search-next
3308 :help "Search for another occurrence of regular expression"]
3309 ["Go to Node..." Info-goto-node
3310 :help "Go to a named node"]
3311 ["Back in history" Info-history-back :active Info-history
3312 :help "Go back in history to the last node you were at"]
3313 ["Forward in history" Info-history-forward :active Info-history-forward
3314 :help "Go forward in history"]
3315 ["History" Info-history :active Info-history-list
3316 :help "Go to menu of visited nodes"]
3317 ["Table of Contents" Info-toc
3318 :help "Go to table of contents"]
3320 ["Lookup a String..." Info-index
3321 :help "Look for a string in the index items"]
3322 ["Next Matching Item" Info-index-next :active Info-index-alternatives
3323 :help "Look for another occurrence of previous item"]
3324 ["Lookup a string in all indices..." info-apropos
3325 :help "Look for a string in the indices of all manuals"])
3326 ["Copy Node Name" Info-copy-current-node-name
3327 :help "Copy the name of the current node into the kill ring"]
3328 ["Clone Info buffer" clone-buffer
3329 :help "Create a twin copy of the current Info buffer."]
3330 ["Exit" Info-exit :help "Stop reading Info"]))
3333 (defvar info-tool-bar-map
3334 (let ((map (make-sparse-keymap)))
3335 (tool-bar-local-item-from-menu 'Info-history-back "left-arrow" map Info-mode-map
3337 (tool-bar-local-item-from-menu 'Info-history-forward "right-arrow" map Info-mode-map
3339 (tool-bar-local-item-from-menu 'Info-prev "prev-node" map Info-mode-map
3341 (tool-bar-local-item-from-menu 'Info-next "next-node" map Info-mode-map
3343 (tool-bar-local-item-from-menu 'Info-up "up-node" map Info-mode-map)
3344 (tool-bar-local-item-from-menu 'Info-top-node "home" map Info-mode-map)
3345 (tool-bar-local-item-from-menu 'Info-goto-node "jump-to" map Info-mode-map)
3346 (tool-bar-local-item-from-menu 'Info-index "index" map Info-mode-map)
3347 (tool-bar-local-item-from-menu 'Info-search "search" map Info-mode-map)
3348 (tool-bar-local-item-from-menu 'Info-exit "exit" map Info-mode-map)
3351 (defvar Info-menu-last-node nil)
3352 ;; Last node the menu was created for.
3353 ;; Value is a list, (FILE-NAME NODE-NAME).
3355 (defun Info-menu-update ()
3356 "Update the Info menu for the current node."
3358 (if (or (not (eq major-mode 'Info-mode))
3359 (equal (list Info-current-file Info-current-node)
3360 Info-menu-last-node))
3362 ;; Update menu menu.
3363 (let* ((Info-complete-menu-buffer (current-buffer))
3364 (items (nreverse (condition-case nil
3365 (Info-complete-menu-item "" nil t)
3369 (while (and items (< number 9))
3370 (setq current (car items)
3373 (setq entries (cons `[,current
3374 (Info-menu ,current)
3375 :keys ,(format "%d" number)]
3378 (setq entries (cons ["Other..." Info-menu t] entries)))
3380 (setq entries (list ["No menu" nil nil] nil :active)))
3381 (easy-menu-change '("Info") "Menu Item" (nreverse entries)))
3382 ;; Update reference menu. Code stolen from `Info-follow-reference'.
3384 str i entries current
3386 (case-fold-search t))
3388 (goto-char (point-min))
3389 (while (re-search-forward "\\*note[ \n\t]+\\([^:]*\\):" nil t)
3390 (setq str (match-string 1))
3392 (while (setq i (string-match "[ \n\t]+" str i))
3393 (setq str (concat (substring str 0 i) " "
3394 (substring str (match-end 0))))
3398 (while (and items (< number 9))
3399 (setq current (car items)
3402 (setq entries (cons `[,current
3403 (Info-follow-reference ,current)
3407 (setq entries (cons ["Other..." Info-follow-reference t]
3410 (setq entries (list ["No references" nil nil] nil :active)))
3411 (easy-menu-change '("Info") "Reference" (nreverse entries)))
3412 ;; Update last seen node.
3413 (setq Info-menu-last-node (list Info-current-file Info-current-node)))
3414 ;; Try to avoid entering infinite beep mode in case of errors.
3418 (defun Info-copy-current-node-name (&optional arg)
3419 "Put the name of the current Info node into the kill ring.
3420 The name of the Info file is prepended to the node name in parentheses.
3421 With a zero prefix arg, put the name inside a function call to `info'."
3423 (unless Info-current-node
3424 (error "No current Info node"))
3425 (let ((node (if (stringp Info-current-file)
3426 (concat "(" (file-name-nondirectory Info-current-file) ") "
3427 Info-current-node))))
3428 (if (zerop (prefix-numeric-value arg))
3429 (setq node (concat "(info \"" node "\")")))
3430 (unless (stringp Info-current-file)
3431 (setq node (format "(Info-find-node '%S '%S)"
3432 Info-current-file Info-current-node)))
3434 (message "%s" node)))
3437 ;; Info mode is suitable only for specially formatted data.
3438 (put 'Info-mode 'mode-class 'special)
3439 (put 'Info-mode 'no-clone-indirect t)
3441 (defvar tool-bar-map)
3442 (defvar bookmark-make-record-function)
3444 ;; Autoload cookie needed by desktop.el
3447 "Info mode provides commands for browsing through the Info documentation tree.
3448 Documentation in Info is divided into \"nodes\", each of which discusses
3449 one topic and contains references to other nodes which discuss related
3450 topics. Info has commands to follow the references and show you other nodes.
3453 \\[Info-help] Invoke the Info tutorial.
3454 \\[Info-exit] Quit Info: reselect previously selected buffer.
3456 Selecting other nodes:
3457 \\[Info-mouse-follow-nearest-node]
3458 Follow a node reference you click on.
3459 This works with menu items, cross references, and
3460 the \"next\", \"previous\" and \"up\", depending on where you click.
3461 \\[Info-follow-nearest-node] Follow a node reference near point, like \\[Info-mouse-follow-nearest-node].
3462 \\[Info-next] Move to the \"next\" node of this node.
3463 \\[Info-prev] Move to the \"previous\" node of this node.
3464 \\[Info-up] Move \"up\" from this node.
3465 \\[Info-menu] Pick menu item specified by name (or abbreviation).
3466 Picking a menu item causes another node to be selected.
3467 \\[Info-directory] Go to the Info directory node.
3468 \\[Info-top-node] Go to the Top node of this file.
3469 \\[Info-final-node] Go to the final node in this file.
3470 \\[Info-backward-node] Go backward one node, considering all nodes as forming one sequence.
3471 \\[Info-forward-node] Go forward one node, considering all nodes as forming one sequence.
3472 \\[Info-next-reference] Move cursor to next cross-reference or menu item.
3473 \\[Info-prev-reference] Move cursor to previous cross-reference or menu item.
3474 \\[Info-follow-reference] Follow a cross reference. Reads name of reference.
3475 \\[Info-history-back] Move back in history to the last node you were at.
3476 \\[Info-history-forward] Move forward in history to the node you returned from after using \\[Info-history-back].
3477 \\[Info-history] Go to menu of visited nodes.
3478 \\[Info-toc] Go to table of contents of the current Info file.
3480 Moving within a node:
3481 \\[Info-scroll-up] Normally, scroll forward a full screen.
3482 Once you scroll far enough in a node that its menu appears on the
3483 screen but after point, the next scroll moves into its first
3484 subnode. When after all menu items (or if there is no menu),
3485 move up to the parent node.
3486 \\[Info-scroll-down] Normally, scroll backward. If the beginning of the buffer is
3487 already visible, try to go to the previous menu entry, or up
3489 \\[beginning-of-buffer] Go to beginning of node.
3492 \\[Info-search] Search through this Info file for specified regexp,
3493 and select the node in which the next occurrence is found.
3494 \\[Info-search-case-sensitively] Search through this Info file for specified regexp case-sensitively.
3495 \\[Info-search-next] Search for another occurrence of regexp
3496 from a previous \\<Info-mode-map>\\[Info-search] command.
3497 \\[isearch-forward], \\[isearch-forward-regexp] Use Isearch to search through multiple Info nodes.
3498 \\[Info-index] Search for a topic in this manual's Index and go to index entry.
3499 \\[Info-index-next] (comma) Move to the next match from a previous \\<Info-mode-map>\\[Info-index] command.
3500 \\[info-apropos] Look for a string in the indices of all manuals.
3501 \\[Info-goto-node] Move to node specified by name.
3502 You may include a filename as well, as (FILENAME)NODENAME.
3503 1 .. 9 Pick first ... ninth item in node's menu.
3504 Every third `*' is highlighted to help pick the right number.
3505 \\[Info-copy-current-node-name] Put name of current Info node in the kill ring.
3506 \\[clone-buffer] Select a new cloned Info buffer in another window.
3507 \\[universal-argument] \\[info] Move to new Info file with completion.
3508 \\[universal-argument] N \\[info] Select Info buffer with prefix number in the name *info*<N>."
3509 (kill-all-local-variables)
3510 (setq major-mode 'Info-mode)
3511 (setq mode-name "Info")
3513 (use-local-map Info-mode-map)
3514 (add-hook 'activate-menubar-hook 'Info-menu-update nil t)
3515 (set-syntax-table text-mode-syntax-table)
3516 (setq local-abbrev-table text-mode-abbrev-table)
3517 (setq case-fold-search t)
3518 (setq buffer-read-only t)
3519 (make-local-variable 'Info-current-file)
3520 (make-local-variable 'Info-current-subfile)
3521 (make-local-variable 'Info-current-node)
3522 (make-local-variable 'Info-tag-table-marker)
3523 (setq Info-tag-table-marker (make-marker))
3524 (make-local-variable 'Info-tag-table-buffer)
3525 (setq Info-tag-table-buffer nil)
3526 (make-local-variable 'Info-history)
3527 (make-local-variable 'Info-history-forward)
3528 (make-local-variable 'Info-index-alternatives)
3529 (if Info-use-header-line ; do not override global header lines
3530 (setq header-line-format
3531 '(:eval (get-text-property (point-min) 'header-line))))
3532 (set (make-local-variable 'tool-bar-map) info-tool-bar-map)
3533 ;; This is for the sake of the invisible text we use handling titles.
3534 (make-local-variable 'line-move-ignore-invisible)
3535 (setq line-move-ignore-invisible t)
3536 (make-local-variable 'desktop-save-buffer)
3537 (make-local-variable 'widen-automatically)
3538 (setq widen-automatically nil)
3539 (setq desktop-save-buffer 'Info-desktop-buffer-misc-data)
3540 (add-hook 'kill-buffer-hook 'Info-kill-buffer nil t)
3541 (add-hook 'clone-buffer-hook 'Info-clone-buffer nil t)
3542 (add-hook 'change-major-mode-hook 'font-lock-defontify nil t)
3543 (add-hook 'isearch-mode-hook 'Info-isearch-start nil t)
3544 (set (make-local-variable 'isearch-search-fun-function)
3545 'Info-isearch-search)
3546 (set (make-local-variable 'isearch-wrap-function)
3548 (set (make-local-variable 'isearch-push-state-function)
3549 'Info-isearch-push-state)
3550 (set (make-local-variable 'isearch-filter-predicate)
3551 'Info-isearch-filter)
3552 (set (make-local-variable 'search-whitespace-regexp)
3553 Info-search-whitespace-regexp)
3554 (set (make-local-variable 'revert-buffer-function)
3555 'Info-revert-buffer-function)
3556 (Info-set-mode-line)
3557 (set (make-local-variable 'bookmark-make-record-function)
3558 'Info-bookmark-make-record)
3559 (run-mode-hooks 'Info-mode-hook))
3561 ;; When an Info buffer is killed, make sure the associated tags buffer
3563 (defun Info-kill-buffer ()
3564 (and (eq major-mode 'Info-mode)
3565 Info-tag-table-buffer
3566 (kill-buffer Info-tag-table-buffer)))
3568 ;; Placed on `clone-buffer-hook'.
3569 (defun Info-clone-buffer ()
3570 (when (bufferp Info-tag-table-buffer)
3571 (setq Info-tag-table-buffer
3572 (with-current-buffer Info-tag-table-buffer (clone-buffer))))
3573 (let ((m Info-tag-table-marker))
3575 (setq Info-tag-table-marker
3576 (if (and (marker-position m) (bufferp Info-tag-table-buffer))
3577 (with-current-buffer Info-tag-table-buffer
3578 (copy-marker (marker-position m)))
3581 (defvar Info-edit-map (let ((map (make-sparse-keymap)))
3582 (set-keymap-parent map text-mode-map)
3583 (define-key map "\C-c\C-c" 'Info-cease-edit)
3585 "Local keymap used within `e' command of Info.")
3587 ;; Info-edit mode is suitable only for specially formatted data.
3588 (put 'Info-edit-mode 'mode-class 'special)
3590 (defun Info-edit-mode ()
3591 "Major mode for editing the contents of an Info node.
3592 Like text mode with the addition of `Info-cease-edit'
3593 which returns to Info mode for browsing.
3595 (use-local-map Info-edit-map)
3596 (setq major-mode 'Info-edit-mode)
3597 (setq mode-name "Info Edit")
3598 (kill-local-variable 'mode-line-buffer-identification)
3599 (setq buffer-read-only nil)
3600 (force-mode-line-update)
3601 (buffer-enable-undo (current-buffer))
3602 (run-mode-hooks 'Info-edit-mode-hook))
3605 "Edit the contents of this Info node.
3606 Allowed only if variable `Info-enable-edit' is non-nil."
3608 (or Info-enable-edit
3609 (error "Editing Info nodes is not enabled"))
3611 (message "%s" (substitute-command-keys
3612 "Editing: Type \\<Info-edit-map>\\[Info-cease-edit] to return to info")))
3614 (defun Info-cease-edit ()
3615 "Finish editing Info node; switch back to Info proper."
3617 ;; Do this first, so nothing has changed if user C-g's at query.
3618 (and (buffer-modified-p)
3619 (y-or-n-p "Save the file? ")
3621 (use-local-map Info-mode-map)
3622 (setq major-mode 'Info-mode)
3623 (setq mode-name "Info")
3624 (Info-set-mode-line)
3625 (setq buffer-read-only t)
3626 (force-mode-line-update)
3627 (and (marker-position Info-tag-table-marker)
3629 (message "Tags may have changed. Use Info-tagify if necessary")))
3631 (defvar Info-file-list-for-emacs
3632 '("ediff" "eudc" "forms" "gnus" "info" ("Info" . "info") ("mh" . "mh-e")
3633 "sc" "message" ("dired" . "dired-x") "viper" "vip" "idlwave"
3634 ("c" . "ccmode") ("c++" . "ccmode") ("objc" . "ccmode")
3635 ("java" . "ccmode") ("idl" . "ccmode") ("pike" . "ccmode")
3636 ("skeleton" . "autotype") ("auto-insert" . "autotype")
3637 ("copyright" . "autotype") ("executable" . "autotype")
3638 ("time-stamp" . "autotype") ("quickurl" . "autotype")
3639 ("tempo" . "autotype") ("hippie-expand" . "autotype")
3640 ("cvs" . "pcl-cvs") ("ada" . "ada-mode") "calc"
3641 ("calcAlg" . "calc") ("calcDigit" . "calc") ("calcVar" . "calc")
3642 "ebrowse" "eshell" "cl" "reftex" "speedbar" "widget" "woman"
3643 ("mail-header" . "emacs-mime") ("mail-content" . "emacs-mime")
3644 ("mail-encode" . "emacs-mime") ("mail-decode" . "emacs-mime")
3645 ("rfc2045" . "emacs-mime")
3646 ("rfc2231" . "emacs-mime") ("rfc2047" . "emacs-mime")
3647 ("rfc2045" . "emacs-mime") ("rfc1843" . "emacs-mime")
3648 ("ietf-drums" . "emacs-mime") ("quoted-printable" . "emacs-mime")
3649 ("binhex" . "emacs-mime") ("uudecode" . "emacs-mime")
3650 ("mailcap" . "emacs-mime") ("mm" . "emacs-mime")
3651 ("mml" . "emacs-mime"))
3652 "List of Info files that describe Emacs commands.
3653 An element can be a file name, or a list of the form (PREFIX . FILE)
3654 where PREFIX is a name prefix and FILE is the file to look in.
3655 If the element is just a file name, the file name also serves as the prefix.")
3657 (defun Info-find-emacs-command-nodes (command)
3658 "Return a list of locations documenting COMMAND.
3659 The `info-file' property of COMMAND says which Info manual to search.
3660 If COMMAND has no property, the variable `Info-file-list-for-emacs'
3661 defines heuristics for which Info manual to try.
3662 The locations are of the format used in `Info-history', i.e.
3663 \(FILENAME NODENAME BUFFERPOS\), where BUFFERPOS is the line number
3664 in the first element of the returned list (which is treated specially in
3665 `Info-goto-emacs-command-node'), and 0 for the rest elements of a list."
3666 (let ((where '()) line-number
3667 (cmd-desc (concat "^\\* +" (regexp-quote (symbol-name command))
3668 "\\( <[0-9]+>\\)?:\\s *\\(.*\\)\\."
3669 "\\(?:[ \t\n]+(line +\\([0-9]+\\))\\)?"))
3670 (info-file "emacs")) ;default
3671 ;; Determine which Info file this command is documented in.
3672 (if (get command 'info-file)
3673 (setq info-file (get command 'info-file))
3674 ;; If it doesn't say explicitly, test its name against
3675 ;; various prefixes that we know.
3676 (let ((file-list Info-file-list-for-emacs))
3678 (let* ((elt (car file-list))
3679 (name (if (consp elt)
3682 (file (if (consp elt) (cdr elt) elt))
3683 (case-fold-search nil)
3684 (regexp (concat "\\`" (regexp-quote name)
3686 (if (string-match regexp (symbol-name command))
3687 (setq info-file file file-list nil))
3688 (setq file-list (cdr file-list))))))
3689 (Info-find-node info-file "Top")
3690 ;; Bind Info-history to nil, to prevent the index nodes from
3691 ;; getting into the node history.
3692 (let ((Info-history nil)
3693 (Info-history-list nil)
3694 node (nodes (Info-index-nodes)))
3695 (Info-goto-node (car nodes))
3698 (goto-char (point-min))
3699 (while (re-search-forward cmd-desc nil t)
3701 (cons (list Info-current-file
3702 (match-string-no-properties 2)
3705 (setq line-number (and (match-beginning 3)
3706 (string-to-number (match-string 3)))))
3707 (and (setq nodes (cdr nodes) node (car nodes))))
3708 (Info-goto-node node)))
3709 (if (and line-number where)
3710 (cons (list (nth 0 (car where)) (nth 1 (car where)) line-number)
3714 ;;;###autoload (put 'Info-goto-emacs-command-node 'info-file "emacs")
3716 (defun Info-goto-emacs-command-node (command)
3717 "Go to the Info node in the Emacs manual for command COMMAND.
3718 The command is found by looking up in Emacs manual's indices
3719 or in another manual found via COMMAND's `info-file' property or
3720 the variable `Info-file-list-for-emacs'.
3721 COMMAND must be a symbol or string."
3722 (interactive "CFind documentation for command: ")
3723 ;; If command is given as a string, convert it to a symbol.
3724 (if (stringp command)
3725 (setq command (intern command)))
3726 (or (commandp command)
3727 (signal 'wrong-type-argument (list 'commandp command)))
3728 (let ((where (Info-find-emacs-command-nodes command)))
3730 (let ((num-matches (length where)))
3731 ;; Get Info running, and pop to it in another window.
3732 (save-window-excursion
3734 (or (eq major-mode 'Info-mode) (pop-to-buffer "*info*"))
3735 ;; Bind Info-history to nil, to prevent the last Index node
3736 ;; visited by Info-find-emacs-command-nodes from being
3737 ;; pushed onto the history.
3738 (let ((Info-history nil) (Info-history-list nil)
3739 (line-number (nth 2 (car where))))
3740 (Info-find-node (nth 0 (car where)) (nth 1 (car where)))
3741 (if (and (integerp line-number) (> line-number 0))
3742 (forward-line (1- line-number))))
3743 (if (> num-matches 1)
3745 ;; (car where) will be pushed onto Info-history
3746 ;; when/if they go to another node. Put the other
3747 ;; nodes that were found on the history.
3748 (setq Info-history (nconc (cdr where) Info-history))
3749 (message "Found %d other entr%s. Use %s to see %s."
3751 (if (> num-matches 2) "ies" "y")
3752 (substitute-command-keys "\\[Info-history-back]")
3753 (if (> num-matches 2) "them" "it")))))
3754 (error "Couldn't find documentation for %s" command))))
3756 ;;;###autoload (put 'Info-goto-emacs-key-command-node 'info-file "emacs")
3758 (defun Info-goto-emacs-key-command-node (key)
3759 "Go to the node in the Emacs manual which describes the command bound to KEY.
3761 Interactively, if the binding is `execute-extended-command', a command is read.
3762 The command is found by looking up in Emacs manual's indices
3763 or in another manual found via COMMAND's `info-file' property or
3764 the variable `Info-file-list-for-emacs'."
3765 (interactive "kFind documentation for key: ")
3766 (let ((command (key-binding key)))
3767 (cond ((null command)
3768 (message "%s is undefined" (key-description key)))
3769 ((and (interactive-p)
3770 (eq command 'execute-extended-command))
3771 (Info-goto-emacs-command-node
3772 (read-command "Find documentation for command: ")))
3774 (Info-goto-emacs-command-node command)))))
3776 (defvar Info-next-link-keymap
3777 (let ((keymap (make-sparse-keymap)))
3778 (define-key keymap [header-line mouse-1] 'Info-next)
3779 (define-key keymap [header-line mouse-2] 'Info-next)
3780 (define-key keymap [header-line down-mouse-1] 'ignore)
3781 (define-key keymap [mouse-2] 'Info-next)
3782 (define-key keymap [follow-link] 'mouse-face)
3784 "Keymap to put on the Next link in the text or the header line.")
3786 (defvar Info-prev-link-keymap
3787 (let ((keymap (make-sparse-keymap)))
3788 (define-key keymap [header-line mouse-1] 'Info-prev)
3789 (define-key keymap [header-line mouse-2] 'Info-prev)
3790 (define-key keymap [header-line down-mouse-1] 'ignore)
3791 (define-key keymap [mouse-2] 'Info-prev)
3792 (define-key keymap [follow-link] 'mouse-face)
3794 "Keymap to put on the Prev link in the text or the header line.")
3796 (defvar Info-up-link-keymap
3797 (let ((keymap (make-sparse-keymap)))
3798 (define-key keymap [header-line mouse-1] 'Info-up)
3799 (define-key keymap [header-line mouse-2] 'Info-up)
3800 (define-key keymap [header-line down-mouse-1] 'ignore)
3801 (define-key keymap [mouse-2] 'Info-up)
3802 (define-key keymap [follow-link] 'mouse-face)
3804 "Keymap to put on the Up link in the text or the header line.")
3806 (defun Info-insert-breadcrumbs ()
3807 (let ((nodes (Info-toc-nodes Info-current-file))
3808 (node Info-current-node)
3810 (depth Info-breadcrumbs-depth))
3812 ;; Get ancestors from the cached parent-children node info
3813 (while (and (not (equal "Top" node)) (> depth 0))
3814 (setq node (nth 1 (assoc node nodes)))
3815 (if node (push node crumbs))
3816 (setq depth (1- depth)))
3819 (when Info-use-header-line
3820 ;; Let it disappear if crumbs is nil.
3821 (nconc crumbs (list Info-current-node)))
3822 (when (or Info-use-header-line crumbs)
3823 ;; Add top node (and continuation if needed).
3825 (cons "Top" (if (member (pop crumbs) '(nil "Top"))
3826 crumbs (cons nil crumbs))))
3827 ;; Eliminate duplicate.
3829 (dolist (node crumbs)
3831 (if (not (equal node "Top")) node
3833 (if (stringp Info-current-file)
3834 (file-name-nondirectory Info-current-file)
3835 ;; Can be `toc', `apropos', or even `history'.
3836 Info-current-file)))))
3837 (insert (if (bolp) "" " > ")
3840 ((equal node Info-current-node)
3841 ;; No point linking to ourselves.
3842 (propertize text 'font-lock-face 'info-header-node))
3844 (concat "*Note " text "::"))))))
3847 (defun Info-fontify-node ()
3850 (let* ((inhibit-read-only t)
3851 (case-fold-search t)
3853 (not-fontified-p ; the node hasn't already been fontified
3854 (not (let ((where (next-single-property-change (point-min)
3856 (and where (not (= where (point-max)))))))
3857 (fontify-visited-p ; visited nodes need to be re-fontified
3858 (and Info-fontify-visited-nodes
3859 ;; Don't take time to refontify visited nodes in huge nodes
3860 Info-fontify-maximum-menu-size
3861 (< (- (point-max) (point-min)) Info-fontify-maximum-menu-size)))
3864 ;; Fontify header line
3865 (goto-char (point-min))
3866 (when (and not-fontified-p (looking-at "^\\(File: [^,: \t]+,?[ \t]+\\)?"))
3867 (goto-char (match-end 0))
3868 (while (looking-at "[ \t]*\\([^:, \t\n]+\\):[ \t]+\\([^:,\t\n]+\\),?")
3869 (goto-char (match-end 0))
3870 (let* ((nbeg (match-beginning 2))
3871 (nend (match-end 2))
3872 (tbeg (match-beginning 1))
3873 (tag (match-string 1)))
3874 (if (string-equal (downcase tag) "node")
3875 (put-text-property nbeg nend 'font-lock-face 'info-header-node)
3876 (put-text-property nbeg nend 'font-lock-face 'info-header-xref)
3877 (put-text-property tbeg nend 'mouse-face 'highlight)
3878 (put-text-property tbeg nend
3880 (concat "mouse-2: Go to node "
3881 (buffer-substring nbeg nend)))
3882 ;; Always set up the text property keymap.
3883 ;; It will either be used in the buffer
3884 ;; or copied in the header line.
3888 ((string-equal (downcase tag) "prev") Info-prev-link-keymap)
3889 ((string-equal (downcase tag) "next") Info-next-link-keymap)
3890 ((string-equal (downcase tag) "up" ) Info-up-link-keymap))))))
3892 (when (> Info-breadcrumbs-depth 0)
3893 (Info-insert-breadcrumbs))
3895 ;; Treat header line.
3896 (when Info-use-header-line
3897 (goto-char (point-min))
3898 (let* ((header-end (line-end-position))
3900 ;; If we find neither Next: nor Prev: link, show the entire
3901 ;; node header. Otherwise, don't show the File: and Node:
3902 ;; parts, to avoid wasting precious space on information that
3903 ;; is available in the mode line.
3904 (if (re-search-forward
3905 "\\(next\\|up\\|prev[ious]*\\): "
3908 (goto-char (match-beginning 1))
3909 (buffer-substring (point) header-end))
3910 (if (re-search-forward "node:[ \t]*[^ \t]+[ \t]*"
3912 (concat "No next, prev or up links -- "
3913 (buffer-substring (point) header-end))
3914 (buffer-substring (point) header-end)))))
3915 (put-text-property (point-min) (1+ (point-min))
3917 (replace-regexp-in-string
3919 ;; Preserve text properties on duplicated `%'.
3920 (lambda (s) (concat s s)) header))
3921 ;; Hide the part of the first line
3922 ;; that is in the header, if it is just part.
3924 ((> Info-breadcrumbs-depth 0)
3925 (put-text-property (point-min) (1+ header-end) 'invisible t))
3927 ;; Hide the punctuation at the end, too.
3928 (skip-chars-backward " \t,")
3929 (put-text-property (point) header-end 'invisible t))))))
3932 (goto-char (point-min))
3933 (when (and font-lock-mode not-fontified-p)
3934 (while (and (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*\\*+\\|==+\\|--+\\|\\.\\.+\\)$"
3936 ;; Only consider it as an underlined title if the ASCII
3937 ;; underline has the same size as the text. A typical
3938 ;; counter example is when a continuation "..." is alone
3940 (= (string-width (match-string 1))
3941 (string-width (match-string 2))))
3942 (let* ((c (preceding-char))
3944 (cond ((= c ?*) 'info-title-1)
3945 ((= c ?=) 'info-title-2)
3946 ((= c ?-) 'info-title-3)
3947 (t 'info-title-4))))
3948 (put-text-property (match-beginning 1) (match-end 1)
3949 'font-lock-face face))
3950 ;; This is a serious problem for trying to handle multiple
3951 ;; frame types at once. We want this text to be invisible
3952 ;; on frames that can display the font above.
3953 (when (memq (framep (selected-frame)) '(x pc w32 ns))
3954 (add-text-properties (1- (match-beginning 2)) (match-end 2)
3955 '(invisible t front-sticky nil rear-nonsticky t)))))
3957 ;; Fontify cross references
3958 (goto-char (point-min))
3959 (when (or not-fontified-p fontify-visited-p)
3960 (while (re-search-forward "\\(\\*Note[ \n\t]+\\)\\([^:]*\\)\\(:[ \t]*\\([^.,:(]*\\)\\(\\(([^)]*)\\)[^.,:]*\\)?[,:]?\n?\\)" nil t)
3961 (let ((start (match-beginning 0))
3964 (when not-fontified-p
3965 (when Info-hide-note-references
3966 (when (and (not (eq Info-hide-note-references 'hide))
3967 (> (line-number-at-pos) 4)) ; Skip breadcrumbs
3968 ;; *Note is often used where *note should have been
3970 (skip-syntax-backward " ")
3971 (when (memq (char-before) '(?\( ?\[ ?\{))
3972 ;; Check whether the paren is preceded by
3973 ;; an end of sentence
3974 (skip-syntax-backward " ("))
3976 (cond ((save-match-data (looking-back "\\<see"))
3978 ((save-match-data (looking-back "\\<in"))
3980 ((memq (char-before) '(nil ?\. ?! ??))
3984 (search-forward "\n\n" start t)))
3988 (add-text-properties
3990 (or (save-match-data
3991 ;; Don't hide \n after *Note
3992 (let ((start1 (match-beginning 1)))
3993 (if (string-match "\n" (match-string 1))
3994 (+ start1 (match-beginning 0)))))
3997 `(display ,other-tag front-sticky nil rear-nonsticky t)
3998 '(invisible t front-sticky nil rear-nonsticky t))))
3999 (add-text-properties
4000 (match-beginning 2) (match-end 2)
4002 'help-echo (if (or (match-end 5)
4003 (not (equal (match-string 4) "")))
4004 (concat "mouse-2: go to " (or (match-string 5)
4006 "mouse-2: go to this node")
4007 'mouse-face 'highlight)))
4008 (when (or not-fontified-p fontify-visited-p)
4009 (setq rbeg (match-beginning 2)
4014 ;; Display visited nodes in a different face
4015 (if (and Info-fontify-visited-nodes
4017 (let* ((node (replace-regexp-in-string
4019 (replace-regexp-in-string
4021 (or (match-string-no-properties 5)
4022 (and (not (equal (match-string 4) ""))
4023 (match-string-no-properties 4))
4024 (match-string-no-properties 2)))))
4026 (string-match "(\\([^)]+\\))\\([^)]*\\)" node))
4027 (file (if external-link-p
4028 (file-name-nondirectory
4029 (match-string-no-properties 1 node))
4031 (hl Info-history-list)
4034 (setq node (if (equal (match-string 2 node) "")
4036 (match-string-no-properties 2 node))))
4038 (if (and (string-equal node (nth 1 (car hl)))
4040 (if (and external-link-p
4041 (stringp (caar hl)))
4042 (file-name-nondirectory
4045 (setq res (car hl) hl nil)
4046 (setq hl (cdr hl))))
4047 res))) 'info-xref-visited 'info-xref))
4048 ;; For multiline ref, unfontify newline and surrounding whitespace
4052 (while (re-search-forward "\\s-*\n\\s-*" rend t nil)
4053 (remove-text-properties (match-beginning 0)
4055 '(font-lock-face t))))))
4056 (when not-fontified-p
4057 (when (memq Info-hide-note-references '(t hide))
4058 (add-text-properties (match-beginning 3) (match-end 3)
4059 '(invisible t front-sticky nil rear-nonsticky t))
4060 ;; Unhide the file name of the external reference in parens
4061 (if (and (match-string 6) (not (eq Info-hide-note-references 'hide)))
4062 (remove-text-properties (match-beginning 6) (match-end 6)
4063 '(invisible t front-sticky nil rear-nonsticky t)))
4064 ;; Unhide newline because hidden newlines cause too long lines
4066 (let ((beg3 (match-beginning 3))
4067 (end3 (match-end 3)))
4068 (if (and (string-match "\n[ \t]*" (match-string 3))
4069 (not (save-match-data
4071 (goto-char (1+ end3))
4072 (looking-at "[.)]*$")))))
4073 (remove-text-properties (+ beg3 (match-beginning 0))
4074 (+ beg3 (match-end 0))
4075 '(invisible t front-sticky nil rear-nonsticky t))))))
4076 (when (and Info-refill-paragraphs Info-hide-note-references)
4077 (push (set-marker (make-marker) start)
4078 paragraph-markers))))))
4080 ;; Refill paragraphs (experimental feature)
4081 (when (and not-fontified-p
4082 Info-refill-paragraphs
4084 (let ((fill-nobreak-invisible t)
4085 (fill-individual-varying-indent nil)
4086 (paragraph-start "\f\\|[ \t]*[-*]\\|[ \t]*$")
4087 (paragraph-separate ".*\\.[ \t]*\n[ \t]\\|[ \t]*[-*]\\|[ \t\f]*$")
4088 (adaptive-fill-mode nil))
4089 (goto-char (point-max))
4090 (dolist (m paragraph-markers)
4094 (let ((beg (point)))
4095 (when (zerop (forward-paragraph))
4096 (fill-individual-paragraphs beg (point) nil nil)
4098 (set-marker m nil))))
4100 ;; Fontify menu items
4101 (goto-char (point-min))
4102 (when (and (or not-fontified-p fontify-visited-p)
4103 (search-forward "\n* Menu:" nil t)
4104 ;; Don't take time to annotate huge menus
4105 Info-fontify-maximum-menu-size
4106 (< (- (point-max) (point)) Info-fontify-maximum-menu-size))
4109 (while (re-search-forward
4110 (concat "^\\* Menu:\\|\\(?:^\\* +\\(" Info-menu-entry-name-re "\\)\\(:"
4111 Info-node-spec-re "\\([ \t]*\\)\\)\\)")
4113 (when (match-beginning 1)
4114 (when not-fontified-p
4116 (if (and (<= n 9) (zerop (% n 3))) ; visual aids to help with 1-9 keys
4117 (put-text-property (match-beginning 0)
4118 (1+ (match-beginning 0))
4119 'font-lock-face 'info-menu-star)))
4120 (when not-fontified-p
4121 (add-text-properties
4122 (match-beginning 1) (match-end 1)
4124 'help-echo (if (and (match-end 3)
4125 (not (equal (match-string 3) "")))
4126 (concat "mouse-2: go to " (match-string 3))
4127 "mouse-2: go to this node")
4128 'mouse-face 'highlight)))
4129 (when (or not-fontified-p fontify-visited-p)
4131 (match-beginning 1) (match-end 1)
4133 ;; Display visited menu items in a different face
4134 (if (and Info-fontify-visited-nodes
4136 (let* ((node (if (equal (match-string 3) "")
4137 (match-string-no-properties 1)
4138 (match-string-no-properties 3)))
4140 (string-match "(\\([^)]+\\))\\([^)]*\\)" node))
4141 (file (if external-link-p
4142 (file-name-nondirectory
4143 (match-string-no-properties 1 node))
4145 (hl Info-history-list)
4148 (setq node (if (equal (match-string 2 node) "")
4150 (match-string-no-properties 2 node))))
4152 (if (and (string-equal node (nth 1 (car hl)))
4154 (if (and external-link-p
4155 (stringp (caar hl)))
4156 (file-name-nondirectory
4159 (setq res (car hl) hl nil)
4160 (setq hl (cdr hl))))
4161 res))) 'info-xref-visited 'info-xref)))
4162 (when (and not-fontified-p
4163 (memq Info-hide-note-references '(t hide))
4164 (not (Info-index-node)))
4165 (put-text-property (match-beginning 2) (1- (match-end 6))
4167 ;; Unhide the file name in parens
4168 (if (and (match-end 4) (not (eq (char-after (match-end 4)) ?.)))
4169 (remove-text-properties (match-beginning 4) (match-end 4)
4171 ;; We need a stretchable space like :align-to but with
4173 (put-text-property (1- (match-end 6)) (match-end 6) 'display
4174 (if (>= 22 (- (match-end 1)
4175 (match-beginning 0)))
4176 '(space :align-to 24)
4178 (setq cont (looking-at "."))
4179 (while (and (= (forward-line 1) 0)
4180 (looking-at "\\([ \t]+\\)[^*\n]"))
4181 (put-text-property (match-beginning 1) (1- (match-end 1))
4183 (put-text-property (1- (match-end 1)) (match-end 1)
4186 '(space :align-to 26)
4187 '(space :align-to 24)))
4190 ;; Fontify menu headers
4191 ;; Add the face `info-menu-header' to any header before a menu entry
4192 (goto-char (point-min))
4193 (when (and not-fontified-p (re-search-forward "^\\* Menu:" nil t))
4194 (put-text-property (match-beginning 0) (match-end 0)
4195 'font-lock-face 'info-menu-header)
4196 (while (re-search-forward "\n\n\\([^*\n ].*\\)\n\n?[*]" nil t)
4197 (put-text-property (match-beginning 1) (match-end 1)
4198 'font-lock-face 'info-menu-header)))
4200 ;; Hide index line numbers
4201 (goto-char (point-min))
4202 (when (and not-fontified-p (Info-index-node))
4203 (while (re-search-forward "[ \t\n]*(line +[0-9]+)" nil t)
4204 (put-text-property (match-beginning 0) (match-end 0)
4207 ;; Fontify http and ftp references
4208 (goto-char (point-min))
4209 (when not-fontified-p
4210 (while (re-search-forward "\\(https?\\|ftp\\)://[^ \t\n\"`({<>})']+"
4212 (add-text-properties (match-beginning 0) (match-end 0)
4213 '(font-lock-face info-xref
4214 mouse-face highlight
4215 help-echo "mouse-2: go to this URL"))))
4217 (set-buffer-modified-p nil))))
4219 ;;; Speedbar support:
4220 ;; These functions permit speedbar to display the "tags" in the
4221 ;; current Info node.
4222 (eval-when-compile (require 'speedbar))
4224 (defvar Info-speedbar-key-map nil
4225 "Keymap used when in the info display mode.")
4227 (defun Info-install-speedbar-variables ()
4228 "Install those variables used by speedbar to enhance Info."
4229 (if Info-speedbar-key-map
4231 (setq Info-speedbar-key-map (speedbar-make-specialized-keymap))
4233 ;; Basic tree features
4234 (define-key Info-speedbar-key-map "e" 'speedbar-edit-line)
4235 (define-key Info-speedbar-key-map "\C-m" 'speedbar-edit-line)
4236 (define-key Info-speedbar-key-map "+" 'speedbar-expand-line)
4237 (define-key Info-speedbar-key-map "-" 'speedbar-contract-line)
4240 (speedbar-add-expansion-list '("Info" Info-speedbar-menu-items
4241 Info-speedbar-key-map
4242 Info-speedbar-hierarchy-buttons)))
4244 (defvar Info-speedbar-menu-items
4245 '(["Browse Node" speedbar-edit-line t]
4246 ["Expand Node" speedbar-expand-line
4247 (save-excursion (beginning-of-line)
4248 (looking-at "[0-9]+: *.\\+. "))]
4249 ["Contract Node" speedbar-contract-line
4250 (save-excursion (beginning-of-line)
4251 (looking-at "[0-9]+: *.-. "))]
4253 "Additional menu-items to add to speedbar frame.")
4255 ;; Make sure our special speedbar major mode is loaded
4256 (if (featurep 'speedbar)
4257 (Info-install-speedbar-variables)
4258 (add-hook 'speedbar-load-hook 'Info-install-speedbar-variables))
4260 ;;; Info hierarchy display method
4262 (defun Info-speedbar-browser ()
4263 "Initialize speedbar to display an Info node browser.
4264 This will add a speedbar major display mode."
4267 ;; Make sure that speedbar is active
4268 (speedbar-frame-mode 1)
4269 ;; Now, throw us into Info mode on speedbar.
4270 (speedbar-change-initial-expansion-list "Info")
4273 (defun Info-speedbar-hierarchy-buttons (directory depth &optional node)
4274 "Display an Info directory hierarchy in speedbar.
4275 DIRECTORY is the current directory in the attached frame.
4276 DEPTH is the current indentation depth.
4277 NODE is an optional argument that is used to represent the
4278 specific node to expand."
4280 (save-excursion (goto-char (point-min))
4281 (let ((case-fold-search t))
4282 (looking-at "Info Nodes:"))))
4283 ;; Update our "current node" maybe?
4285 ;; We cannot use the generic list code, that depends on all leaves
4286 ;; being known at creation time.
4288 (speedbar-with-writable (insert "Info Nodes:\n")))
4289 (let ((completions nil))
4290 (speedbar-select-attached-frame)
4291 (save-window-excursion
4293 (Info-speedbar-fetch-file-nodes (or node '"(dir)top"))))
4294 (select-frame (speedbar-current-frame))
4296 (speedbar-with-writable
4297 (dolist (completion completions)
4298 (speedbar-make-tag-line 'bracket ?+ 'Info-speedbar-expand-node
4301 'Info-speedbar-goto-node
4307 (defun Info-speedbar-goto-node (text node indent)
4308 "When user clicks on TEXT, go to an info NODE.
4309 The INDENT level is ignored."
4310 (speedbar-select-attached-frame)
4311 (let* ((buff (or (get-buffer "*info*")
4312 (progn (info) (get-buffer "*info*"))))
4313 (bwin (get-buffer-window buff 0)))
4316 (select-window bwin)
4317 (raise-frame (window-frame bwin)))
4318 (if speedbar-power-click
4319 (let ((pop-up-frames t)) (select-window (display-buffer buff)))
4320 (speedbar-select-attached-frame)
4321 (switch-to-buffer buff)))
4322 (if (not (string-match "^(\\([^)]+\\))\\([^.]+\\)$" node))
4323 (error "Invalid node %s" node)
4324 (Info-find-node (match-string 1 node) (match-string 2 node))
4325 ;; If we do a find-node, and we were in info mode, restore
4326 ;; the old default method. Once we are in info mode, it makes
4327 ;; sense to return to whatever method the user was using before.
4328 (if (string= speedbar-initial-expansion-list-name "Info")
4329 (speedbar-change-initial-expansion-list
4330 speedbar-previously-used-expansion-list-name)))))
4332 (defun Info-speedbar-expand-node (text token indent)
4333 "Expand the node the user clicked on.
4334 TEXT is the text of the button we clicked on, a + or - item.
4335 TOKEN is data related to this node (NAME . FILE).
4336 INDENT is the current indentation depth."
4337 (cond ((string-match "+" text) ;we have to expand this file
4338 (speedbar-change-expand-button-char ?-)
4339 (if (speedbar-with-writable
4341 (end-of-line) (forward-char 1)
4342 (Info-speedbar-hierarchy-buttons nil (1+ indent) token)))
4343 (speedbar-change-expand-button-char ?-)
4344 (speedbar-change-expand-button-char ??)))
4345 ((string-match "-" text) ;we have to contract this node
4346 (speedbar-change-expand-button-char ?+)
4347 (speedbar-delete-subblock indent))
4348 (t (error "Ooops... not sure what to do")))
4349 (speedbar-center-buffer-smartly))
4351 (defun Info-speedbar-fetch-file-nodes (nodespec)
4352 "Fetch the subnodes from the info NODESPEC.
4353 NODESPEC is a string of the form: (file)node."
4354 ;; Set up a buffer we can use to fake-out Info.
4355 (with-current-buffer (get-buffer-create " *info-browse-tmp*")
4356 (if (not (equal major-mode 'Info-mode))
4358 ;; Get the node into this buffer
4359 (if (not (string-match "^(\\([^)]+\\))\\([^.]+\\)$" nodespec))
4360 (error "Invalid node specification %s" nodespec)
4361 (Info-find-node (match-string 1 nodespec) (match-string 2 nodespec)))
4362 ;; Scan the created buffer
4363 (goto-char (point-min))
4364 (let ((completions nil)
4365 (case-fold-search t)
4366 (thisfile (progn (string-match "^(\\([^)]+\\))" nodespec)
4367 (match-string 1 nodespec))))
4368 ;; Always skip the first one...
4369 (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
4370 (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
4371 (let ((name (match-string 1)))
4373 (if (looking-at " *\\(([^)]+)[^.\n]+\\)\\.")
4375 (if (looking-at " *\\(([^)]+)\\)\\.")
4376 (concat (match-string 1) "Top")
4377 (concat "(" thisfile ")"
4378 (if (looking-at " \\([^.]+\\).")
4382 (nreverse completions))))
4384 ;;; Info mode node listing
4385 ;; This is called by `speedbar-add-localized-speedbar-support'
4386 (defun Info-speedbar-buttons (buffer)
4387 "Create a speedbar display to help navigation in an Info file.
4388 BUFFER is the buffer speedbar is requesting buttons for."
4389 (if (save-excursion (goto-char (point-min))
4390 (let ((case-fold-search t))
4391 (not (looking-at "Info Nodes:"))))
4393 (Info-speedbar-hierarchy-buttons nil 0))
4395 (dolist (mess '("^First node in file$"
4396 "^No `.*' in index$"
4397 "^No cross-reference named"
4398 "^No cross.references in this node$"
4399 "^No current Info node$"
4400 "^No menu in this node$"
4401 "^No more items in menu$"
4403 "^No pointer \\(?:forward\\|backward\\) from this node$"
4404 "^No previous `i' command$"
4405 "^No previous items in menu$"
4406 "^No previous nodes$"
4407 "^No such item in menu$"
4408 "^No such node or anchor"
4410 "^Point neither on reference nor in menu item description$"
4411 "^This is the \\(?:first\\|last\\) Info node you looked at$"
4413 (add-to-list 'debug-ignored-errors mess))
4415 ;;;; Desktop support
4417 (defun Info-desktop-buffer-misc-data (desktop-dirname)
4418 "Auxiliary information to be saved in desktop file."
4419 (unless (member Info-current-file '(apropos history toc nil))
4420 (list Info-current-file Info-current-node)))
4422 (defun Info-restore-desktop-buffer (desktop-buffer-file-name
4424 desktop-buffer-misc)
4425 "Restore an Info buffer specified in a desktop file."
4426 (let ((first (nth 0 desktop-buffer-misc))
4427 (second (nth 1 desktop-buffer-misc)))
4428 (when (and first second)
4429 (when desktop-buffer-name
4430 (set-buffer (get-buffer-create desktop-buffer-name))
4432 (Info-find-node first second)
4435 (add-to-list 'desktop-buffer-mode-handlers
4436 '(Info-mode . Info-restore-desktop-buffer))
4438 ;;;; Bookmark support
4439 (declare-function bookmark-make-record-default "bookmark" (&optional pos-only))
4440 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
4441 (declare-function bookmark-default-handler "bookmark" (bmk))
4442 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
4444 (defun Info-bookmark-make-record ()
4445 `(,Info-current-node
4446 ,@(bookmark-make-record-default 'point-only)
4447 (filename . ,Info-current-file)
4448 (info-node . ,Info-current-node)
4449 (handler . Info-bookmark-jump)))
4452 (defun Info-bookmark-jump (bmk)
4453 ;; This implements the `handler' function interface for record type returned
4454 ;; by `Info-bookmark-make-record', which see.
4455 (let* ((file (bookmark-prop-get bmk 'filename))
4456 (info-node (bookmark-prop-get bmk 'info-node))
4457 (buf (save-window-excursion ;FIXME: doesn't work with frames!
4458 (Info-find-node file info-node) (current-buffer))))
4459 ;; Use bookmark-default-handler to move to the appropriate location
4461 (bookmark-default-handler
4462 (list* "" `(buffer . ,buf) (bookmark-get-bookmark-record bmk)))))
4466 ;; arch-tag: f2480fe2-2139-40c1-a49b-6314991164ac
4467 ;;; info.el ends here