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