1 ;;; info.el --- info package for Emacs.
3 ;; Copyright (C) 1985, 86, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
28 ;; Note that nowadays we expect info files to be made using makeinfo.
32 (eval-when-compile (require 'jka-compr
))
40 (defvar Info-history nil
41 "List of info nodes user has visited.
42 Each element of list is a list (FILENAME NODENAME BUFFERPOS).")
44 (defcustom Info-enable-edit nil
45 "*Non-nil means the \\<Info-mode-map>\\[Info-edit] command in Info can edit the current node.
46 This is convenient if you want to write info files by hand.
47 However, we recommend that you not do this.
48 It is better to write a Texinfo file and generate the Info file from that,
49 because that gives you a printed manual as well."
53 (defvar Info-enable-active-nodes nil
54 "Non-nil allows Info to execute Lisp code associated with nodes.
55 The Lisp code is executed when the node is selected.")
56 (put 'Info-enable-active-nodes
'risky-local-variable t
)
58 (defcustom Info-fontify t
59 "*Non-nil enables highlighting and fonts in Info nodes."
64 '((((class color
) (background light
)) (:foreground
"brown" :bold t
:italic t
))
65 (((class color
) (background dark
)) (:foreground
"white" :bold t
:italic t
))
66 (t (:bold t
:italic t
)))
67 "Face for Info node names."
71 '((((class color
)) (:foreground
"red1"))
73 "Face for the fifth and nineth `*' in an Info menu."
77 '((((class color
) (background light
)) (:foreground
"magenta4" :bold t
))
78 (((class color
) (background dark
)) (:foreground
"cyan" :bold t
))
80 "Face for Info cross-references."
83 (defcustom Info-fontify-maximum-menu-size
100000
84 "*Maximum size of menu to fontify if `Info-fontify' is non-nil."
88 (defcustom Info-use-header-line t
89 "*Non-nil means to put the beginning-of-node links in an emacs header-line.
90 A header-line does not scroll with the rest of the buffer."
94 (defface info-header-xref
95 '((t (:inherit info-xref
)))
96 "Face for Info cross-references in a node header."
99 (defface info-header-node
100 '((t (:inherit info-node
)))
101 "Face for Info nodes in a node header."
104 (defvar Info-directory-list nil
105 "List of directories to search for Info documentation files.
106 nil means not yet initialized. In this case, Info uses the environment
107 variable INFOPATH to initialize it, or `Info-default-directory-list'
108 if there is no INFOPATH variable in the environment.
110 When `Info-directory-list' is initialized from the value of
111 `Info-default-directory-list', and Emacs is installed in one of the
112 standard directories, the directory of Info files that come with Emacs
113 is put last (so that local Info files override standard ones).
115 When `Info-directory-list' is initialized from the value of
116 `Info-default-directory-list', and Emacs is not installed in one
117 of the standard directories, the first element of the resulting
118 list is the directory where Emacs installs the Info files that
119 come with it. This is so that Emacs's own manual, which suits the
120 version of Emacs you are using, will always be found first. This
121 is useful when you install an experimental version of Emacs without
122 removing the standard installation.
124 If you want to override the order of directories in
125 `Info-default-directory-list', set INFOPATH in the environment.
127 If you run the Emacs executable from the `src' directory in the Emacs
128 source tree, and INFOPATH is not defined, the `info' directory in the
129 source tree is used as the first element of `Info-directory-list', in
130 place of the installation Info directory. This is useful when you run
131 a version of Emacs without installing it.")
133 (defcustom Info-additional-directory-list nil
134 "List of additional directories to search for Info documentation files.
135 These directories are not searched for merging the `dir' file."
136 :type
'(repeat directory
)
139 (defcustom Info-scroll-prefer-subnodes t
140 "*If non-nil, \\<Info-mode-map>\\[Info-scroll-up] in a menu visits subnodes.
141 If this is non-nil, and you scroll far enough in a node that its menu
142 appears on the screen, the next \\<Info-mode-map>\\[Info-scroll-up]
143 moves to a subnode indicated by the following menu item. This means
144 that you visit a subnode before getting to the end of the menu.
146 Setting this option to nil results in behavior similar to the stand-alone
147 Info reader program, which visits the first subnode from the menu only
148 when you hit the end of the current node."
152 (defvar Info-current-file nil
153 "Info file that Info is now looking at, or nil.
154 This is the name that was specified in Info, not the actual file name.
155 It doesn't contain directory names or file name extensions added by Info.
156 Can also be t when using `Info-on-current-buffer'.")
158 (defvar Info-current-subfile nil
159 "Info subfile that is actually in the *info* buffer now.
160 nil if current info file is not split into subfiles.")
162 (defvar Info-current-node nil
163 "Name of node that Info is now looking at, or nil.")
165 (defvar Info-tag-table-marker nil
166 "Marker pointing at beginning of current Info file's tag table.
167 Marker points nowhere if file has no tag table.")
169 (defvar Info-tag-table-buffer nil
170 "Buffer used for indirect tag tables.")
172 (defvar Info-current-file-completions nil
173 "Cached completion list for current Info file.")
175 (defvar Info-index-alternatives nil
176 "List of possible matches for last `Info-index' command.")
178 (defvar Info-standalone nil
179 "Non-nil if Emacs was started solely as an Info browser.")
181 (defvar Info-suffix-list
182 ;; The MS-DOS list should work both when long file names are
183 ;; supported (Windows 9X), and when only 8+3 file names are available.
184 (if (eq system-type
'ms-dos
)
185 '( (".gz" .
"gunzip")
187 (".bz2" .
("bzip2" "-dc"))
190 (".info.Z" .
"gunzip")
191 (".info.gz" .
"gunzip")
192 ("-info.Z" .
"gunzip")
193 ("-info.gz" .
"gunzip")
194 ("/index.gz".
"gunzip")
195 ("/index.z" .
"gunzip")
201 '( (".info.Z".
"uncompress")
202 (".info.Y".
"unyabba")
203 (".info.gz".
"gunzip")
204 (".info.z".
"gunzip")
205 (".info.bz2" .
("bzip2" "-dc"))
207 ("-info.Z".
"uncompress")
208 ("-info.Y".
"unyabba")
209 ("-info.gz".
"gunzip")
210 ("-info.bz2" .
("bzip2" "-dc"))
211 ("-info.z".
"gunzip")
213 ("/index.Z".
"uncompress")
214 ("/index.Y".
"unyabba")
215 ("/index.gz".
"gunzip")
216 ("/index.z".
"gunzip")
217 ("/index.bz2".
("bzip2" "-dc"))
223 (".bz2" .
("bzip2" "-dc"))
225 "List of file name suffixes and associated decoding commands.
226 Each entry should be (SUFFIX . STRING); the file is given to
227 the command as standard input.
229 STRING may be a list of strings. In that case, the first element is
230 the command name, and the rest are arguments to that command.
232 If STRING is nil, no decoding is done.
233 Because the SUFFIXes are tried in order, the empty string should
234 be last in the list.")
236 ;; Concatenate SUFFIX onto FILENAME. SUFFIX should start with a dot.
237 ;; First, on ms-dos, delete some of the extension in FILENAME
239 (defun info-insert-file-contents-1 (filename suffix
)
240 (if (not (eq system-type
'ms-dos
))
241 (concat filename suffix
)
242 (let* ((sans-exts (file-name-sans-extension filename
))
243 ;; How long is the extension in FILENAME (not counting the dot).
244 (ext-len (max 0 (- (length filename
) (length sans-exts
) 1)))
246 ;; SUFFIX starts with a dot. If FILENAME already has one,
247 ;; get rid of the one in SUFFIX (unless suffix is empty).
248 (or (and (<= ext-len
0)
249 (not (eq (aref filename
(1- (length filename
))) ?.
)))
250 (= (length suffix
) 0)
251 (setq suffix
(substring suffix
1)))
252 ;; How many chars of that extension should we keep?
253 (setq ext-left
(min ext-len
(max 0 (- 3 (length suffix
)))))
254 ;; Get rid of the rest of the extension, and add SUFFIX.
255 (concat (substring filename
0 (- (length filename
)
256 (- ext-len ext-left
)))
259 (defun info-file-exists-p (filename)
260 (and (file-exists-p filename
)
261 (not (file-directory-p filename
))))
263 (defun info-insert-file-contents (filename &optional visit
)
264 "Insert the contents of an info file in the current buffer.
265 Do the right thing if the file has been compressed or zipped."
266 (let ((tail Info-suffix-list
)
268 (if (file-exists-p filename
)
269 ;; FILENAME exists--see if that name contains a suffix.
270 ;; If so, set DECODE accordingly.
274 (concat (regexp-quote (car (car tail
))) "$")
276 (setq tail
(cdr tail
)))
277 (setq fullname filename
278 decoder
(cdr (car tail
))))
279 ;; Try adding suffixes to FILENAME and see if we can find something.
281 (not (info-file-exists-p (info-insert-file-contents-1
282 filename
(car (car tail
))))))
283 (setq tail
(cdr tail
)))
284 ;; If we found a file with a suffix, set DECODER according to the suffix
285 ;; and set FULLNAME to the file's actual name.
286 (setq fullname
(info-insert-file-contents-1 filename
(car (car tail
)))
287 decoder
(cdr (car tail
)))
289 (error "Can't find %s or any compressed version of it" filename
)))
290 ;; check for conflict with jka-compr
291 (if (and (featurep 'jka-compr
)
292 (jka-compr-installed-p)
293 (jka-compr-get-compression-info fullname
))
297 (insert-file-contents-literally fullname visit
)
298 (let ((buffer-read-only nil
)
299 (coding-system-for-write 'no-conversion
)
300 (default-directory (or (file-name-directory fullname
)
303 (setq decoder
(list decoder
)))
304 (apply 'call-process-region
(point-min) (point-max)
305 (car decoder
) t t nil
(cdr decoder
))))
306 (insert-file-contents fullname visit
))))
308 (defun info-initialize ()
309 "Initialize `Info-directory-list', if that hasn't been done yet."
310 (unless Info-directory-list
311 (let ((path (getenv "INFOPATH"))
312 (source (expand-file-name "info/" source-directory
))
313 (sibling (if installation-directory
314 (expand-file-name "info/" installation-directory
)
315 (if invocation-directory
316 (let ((infodir (expand-file-name
318 invocation-directory
)))
319 (if (file-exists-p infodir
)
321 (setq infodir
(expand-file-name
323 invocation-directory
))
324 (and (file-exists-p infodir
)
327 (setq Info-directory-list
328 (prune-directory-list
330 (split-string path
(regexp-quote path-separator
))
331 (if (and sibling
(file-exists-p sibling
))
332 ;; Uninstalled, Emacs builddir != srcdir.
333 (setq alternative sibling
)
334 ;; Uninstalled, builddir == srcdir
335 (setq alternative source
))
336 (if (or (member alternative Info-default-directory-list
)
337 ;; On DOS/NT, we use movable executables always,
338 ;; and we must always find the Info dir at run time.
339 (if (memq system-type
'(ms-dos windows-nt
))
341 ;; Use invocation-directory for Info
342 ;; only if we used it for exec-directory also.
343 (not (string= exec-directory
344 (expand-file-name "lib-src/"
345 installation-directory
))))
346 (not (file-exists-p alternative
)))
347 Info-default-directory-list
348 ;; `alternative' contains the Info files that came with this
349 ;; version, so we should look there first. `Info-insert-dir'
350 ;; currently expects to find `alternative' first on the list.
352 (reverse (cdr (reverse Info-default-directory-list
)))))))))))
355 (defun info-other-window (&optional file
)
356 "Like `info' but show the Info buffer in another window."
357 (interactive (if current-prefix-arg
358 (list (read-file-name "Info file name: " nil nil t
))))
359 (let (same-window-buffer-names)
362 ;;;###autoload (add-hook 'same-window-buffer-names "*info*")
365 (defun info (&optional file
)
366 "Enter Info, the documentation browser.
367 Optional argument FILE specifies the file to examine;
368 the default is the top-level directory of Info.
369 Called from a program, FILE may specify an Info node of the form
370 `(FILENAME)NODENAME'.
372 In interactive use, a prefix argument directs this command
373 to read a file name from the minibuffer.
375 The search path for Info files is in the variable `Info-directory-list'.
376 The top-level Info directory is made by combining all the files named `dir'
377 in all the directories in that path."
378 (interactive (if current-prefix-arg
379 (list (read-file-name "Info file name: " nil nil t
))))
382 (pop-to-buffer "*info*")
383 ;; If argument already contains parentheses, don't add another set
384 ;; since the argument will then be parsed improperly. This also
385 ;; has the added benefit of allowing node names to be included
386 ;; following the parenthesized filename.
387 (if (and (stringp file
) (string-match "(.*)" file
))
388 (Info-goto-node file
)
389 (Info-goto-node (concat "(" file
")"))))
390 (if (get-buffer "*info*")
391 (pop-to-buffer "*info*")
395 (defun info-standalone ()
396 "Run Emacs as a standalone Info reader.
397 Usage: emacs -f info-standalone [filename]
398 In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
399 (setq Info-standalone t
)
400 (if (and command-line-args-left
401 (not (string-match "^-" (car command-line-args-left
))))
404 (info (car command-line-args-left
))
405 (setq command-line-args-left
(cdr command-line-args-left
)))
406 (error (send-string-to-terminal
407 (format "%s\n" (if (eq (car-safe err
) 'error
)
409 (save-buffers-kill-emacs)))
412 ;; See if the accessible portion of the buffer begins with a node
413 ;; delimiter, and the node header line which follows matches REGEXP.
414 ;; Typically, this test will be followed by a loop that examines the
415 ;; rest of the buffer with (search-forward "\n\^_"), and it's a pity
416 ;; to have the overhead of this special test inside the loop.
418 ;; This function changes match-data, but supposedly the caller might
419 ;; want to use the results of re-search-backward.
421 ;; The return value is the value of point at the beginning of matching
422 ;; REGEXP, if the function succeeds, nil otherwise.
423 (defun Info-node-at-bob-matching (regexp)
424 (and (bobp) ; are we at beginning of buffer?
425 (looking-at "\^_") ; does it begin with node delimiter?
429 (forward-line 1) ; does the line after delimiter match REGEXP?
430 (re-search-backward regexp beg t
))))
432 (defun Info-find-node (filename nodename
&optional no-going-back
)
433 "Go to an info node specified as separate FILENAME and NODENAME.
434 NO-GOING-BACK is non-nil if recovering from an error in this function;
435 it says do not attempt further (recursive) error recovery."
437 ;; Convert filename to lower case if not found as specified.
439 (if (stringp filename
)
440 (let (temp temp-downcase found
)
441 (setq filename
(substitute-in-file-name filename
))
442 (if (string= (downcase filename
) "dir")
444 (let ((dirs (if (string-match "^\\./" filename
)
445 ;; If specified name starts with `./'
446 ;; then just try current directory.
448 (if (file-name-absolute-p filename
)
449 ;; No point in searching for an
450 ;; absolute file name
452 (if Info-additional-directory-list
453 (append Info-directory-list
454 Info-additional-directory-list
)
455 Info-directory-list
)))))
456 ;; Search the directory list for file FILENAME.
457 (while (and dirs
(not found
))
458 (setq temp
(expand-file-name filename
(car dirs
)))
460 (expand-file-name (downcase filename
) (car dirs
)))
461 ;; Try several variants of specified name.
462 (let ((suffix-list Info-suffix-list
))
463 (while (and suffix-list
(not found
))
464 (cond ((info-file-exists-p
465 (info-insert-file-contents-1
466 temp
(car (car suffix-list
))))
469 (info-insert-file-contents-1
470 temp-downcase
(car (car suffix-list
))))
471 (setq found temp-downcase
)))
472 (setq suffix-list
(cdr suffix-list
))))
473 (setq dirs
(cdr dirs
)))))
475 (setq filename found
)
476 (error "Info file %s does not exist" filename
))))
477 ;; Record the node we are leaving.
478 (if (and Info-current-file
(not no-going-back
))
480 (cons (list Info-current-file Info-current-node
(point))
482 ;; Go into info buffer.
483 (or (eq major-mode
'Info-mode
) (pop-to-buffer "*info*"))
484 (Info-find-node-2 filename nodename no-going-back
))
486 (defun Info-on-current-buffer (&optional nodename
)
487 "Use the `Info-mode' to browse the current info buffer.
488 If a prefix arg is provided, it queries for the NODENAME which
489 else defaults to `Top'."
491 (list (if current-prefix-arg
492 (completing-read "Node name: " (Info-build-node-completions)
497 (set (make-local-variable 'Info-current-file
) t
)
498 (Info-find-node-2 nil nodename
))
500 (defun Info-find-in-tag-table-1 (marker regexp case-fold
)
501 "Find a node in a tag table.
502 MARKER specifies the buffer and position to start searching at.
503 REGEXP is a regular expression matching nodes or references. Its first
504 group should match `Node:' or `Ref:'.
505 CASE-FOLD t means search for a case-insensitive match.
506 If a match was found, value is a list (FOUND-ANCHOR POS MODE), where
507 FOUND-ANCHOR is non-nil if a `Ref:' was matched, POS is the position
508 where the match was found, and MODE is `major-mode' of the buffer in
509 which the match was found."
510 (let ((case-fold-search case-fold
)
511 found-mode guesspos found-anchor
)
513 (set-buffer (marker-buffer marker
))
518 (when (re-search-forward regexp nil t
)
519 (list (string-equal "Ref:" (match-string 1))
520 (1+ (read (current-buffer)))
523 (defun Info-find-in-tag-table (marker regexp
)
524 "Find a node in a tag table.
525 MARKER specifies the buffer and position to start searching at.
526 REGEXP is a regular expression matching nodes or references. Its first
527 group should match `Node:' or `Ref:'.
528 If a match was found, value is a list (FOUND-ANCHOR POS MODE), where
529 FOUND-ANCHOR is non-nil if a `Ref:' was matched, POS is the position
530 where the match was found, and MODE is `major-mode' of the buffer in
531 which the match was found.
532 This function tries to find a case-sensitive match first, then a
533 case-insensitive match is tried."
534 (let ((result (Info-find-in-tag-table-1 marker regexp nil
)))
535 (when (null (car result
))
536 (setq result
(Info-find-in-tag-table-1 marker regexp t
)))
539 (defun Info-find-node-in-buffer-1 (regexp case-fold
)
540 "Find a node or anchor in the current buffer.
541 REGEXP is a regular expression matching nodes or references. Its first
542 group should match `Node:' or `Ref:'.
543 CASE-FOLD t means search for a case-insensitive match.
544 Value is the position at which a match was found, or nil if not found."
545 (let ((case-fold-search case-fold
)
548 (when (Info-node-at-bob-matching regexp
)
549 (setq found
(point)))
550 (while (and (not found
)
551 (search-forward "\n\^_" nil t
))
555 (when (re-search-backward regexp beg t
)
557 (setq found
(point)))))
560 (defun Info-find-node-in-buffer (regexp)
561 "Find a node or anchor in the current buffer.
562 REGEXP is a regular expression matching nodes or references. Its first
563 group should match `Node:' or `Ref:'.
564 Value is the position at which a match was found, or nil if not found.
565 This function looks for a case-sensitive match first. If none is found,
566 a case-insensitive match is tried."
567 (or (Info-find-node-in-buffer-1 regexp nil
)
568 (Info-find-node-in-buffer-1 regexp t
)))
570 (defun Info-find-node-2 (filename nodename
&optional no-going-back
)
571 (buffer-disable-undo (current-buffer))
572 (or (eq major-mode
'Info-mode
)
575 (setq Info-current-node nil
)
577 (let ((case-fold-search t
)
579 ;; Switch files if necessary
581 (equal Info-current-file filename
)
582 (let ((buffer-read-only nil
))
583 (setq Info-current-file nil
584 Info-current-subfile nil
585 Info-current-file-completions nil
586 buffer-file-name nil
)
590 (info-insert-file-contents filename t
)
591 (setq default-directory
(file-name-directory filename
)))
592 (set-buffer-modified-p nil
)
593 ;; See whether file has a tag table. Record the location if yes.
594 (goto-char (point-max))
596 ;; Use string-equal, not equal, to ignore text props.
597 (if (not (or (string-equal nodename
"*")
599 (search-forward "\^_\nEnd tag table\n" nil t
))))
601 ;; We have a tag table. Find its beginning.
602 ;; Is this an indirect file?
603 (search-backward "\nTag table:\n")
607 (looking-at "(Indirect)\n"))
608 ;; It is indirect. Copy it to another buffer
609 ;; and record that the tag table is in that buffer.
610 (let ((buf (current-buffer))
612 (or Info-tag-table-buffer
613 (generate-new-buffer " *info tag table*"))))
614 (setq Info-tag-table-buffer tagbuf
)
617 (buffer-disable-undo (current-buffer))
618 (setq case-fold-search t
)
620 (insert-buffer-substring buf
))
621 (set-marker Info-tag-table-marker
622 (match-end 0) tagbuf
))
623 (set-marker Info-tag-table-marker pos
)))
624 (set-marker Info-tag-table-marker nil
))
625 (setq Info-current-file
626 (if (eq filename t
) "dir" filename
))))
627 ;; Use string-equal, not equal, to ignore text props.
628 (if (string-equal nodename
"*")
629 (progn (setq Info-current-node nodename
)
630 (Info-set-mode-line))
633 ;; 1. Anchor found in tag table
634 ;; 2. Anchor *not* in tag table
636 ;; 3. Node found in tag table
637 ;; 4. Node *not* found in tag table, but found in file
638 ;; 5. Node *not* in tag table, and *not* in file
640 ;; *Or* the same, but in an indirect subfile.
642 ;; Search file for a suitable node.
643 (let ((guesspos (point-min))
644 (regexp (concat "\\(Node:\\|Ref:\\) *\\("
645 (if (stringp nodename
)
646 (regexp-quote nodename
)
653 ;; First, search a tag table, if any
654 (when (marker-position Info-tag-table-marker
)
655 (let* ((m Info-tag-table-marker
)
656 (found (Info-find-in-tag-table m regexp
)))
659 ;; FOUND is (ANCHOR POS MODE).
660 (setq guesspos
(nth 1 found
))
662 ;; If this is an indirect file, determine which
663 ;; file really holds this node and read it in.
664 (unless (eq (nth 2 found
) 'Info-mode
)
665 ;; Note that the current buffer must be the
666 ;; *info* buffer on entry to
667 ;; Info-read-subfile. Thus the hackery above.
668 (setq guesspos
(Info-read-subfile guesspos
)))
672 (goto-char (setq anchorpos guesspos
))
675 ;; Else we may have a node, which we search for:
676 (goto-char (max (point-min)
677 (- (byte-to-position guesspos
) 1000)))
679 ;; Now search from our advised position (or from beg of
680 ;; buffer) to find the actual node. First, check
681 ;; whether the node is right where we are, in case the
682 ;; buffer begins with a node.
683 (let ((pos (Info-find-node-in-buffer regexp
)))
687 (error "No such anchor in tag table or node in tag table or file: %s"
691 (goto-char (or anchorpos
(point-min))))))
692 ;; If we did not finish finding the specified node,
693 ;; go back to the previous one.
694 (or Info-current-node no-going-back
(null Info-history
)
695 (let ((hist (car Info-history
)))
696 (setq Info-history
(cdr Info-history
))
697 (Info-find-node (nth 0 hist
) (nth 1 hist
) t
)
698 (goto-char (nth 2 hist
))))))
700 ;; Cache the contents of the (virtual) dir file, once we have merged
701 ;; it for the first time, so we can save time subsequently.
702 (defvar Info-dir-contents nil
)
704 ;; Cache for the directory we decided to use for the default-directory
705 ;; of the merged dir text.
706 (defvar Info-dir-contents-directory nil
)
708 ;; Record the file attributes of all the files from which we
709 ;; constructed Info-dir-contents.
710 (defvar Info-dir-file-attributes nil
)
712 (defvar Info-dir-file-name nil
)
714 ;; Construct the Info directory node by merging the files named `dir'
715 ;; from various directories. Set the *info* buffer's
716 ;; default-directory to the first directory we actually get any text
718 (defun Info-insert-dir ()
719 (if (and Info-dir-contents Info-dir-file-attributes
720 ;; Verify that none of the files we used has changed
723 (mapcar (lambda (elt)
724 (let ((curr (file-attributes
726 (file-truename (car elt
)))))
728 ;; Don't compare the access time.
729 (if curr
(setcar (nthcdr 4 curr
) 0))
730 (setcar (nthcdr 4 (cdr elt
)) 0)
731 (equal (cdr elt
) curr
)))
732 Info-dir-file-attributes
))))
734 (insert Info-dir-contents
)
735 (goto-char (point-min)))
736 (let ((dirs (if Info-additional-directory-list
737 (append Info-directory-list
738 Info-additional-directory-list
)
739 Info-directory-list
))
740 ;; Bind this in case the user sets it to nil.
742 ;; This is set non-nil if we find a problem in some input files.
744 buffers buffer others nodes dirs-done
)
746 (setq Info-dir-file-attributes nil
)
748 ;; Search the directory list for the directory file.
750 (let ((truename (file-truename (expand-file-name (car dirs
)))))
751 (or (member truename dirs-done
)
752 (member (directory-file-name truename
) dirs-done
)
753 ;; Try several variants of specified name.
754 ;; Try upcasing, appending `.info', or both.
758 (progn (setq file
(expand-file-name "dir" truename
))
759 (file-attributes file
))
760 (progn (setq file
(expand-file-name "DIR" truename
))
761 (file-attributes file
))
762 (progn (setq file
(expand-file-name "dir.info" truename
))
763 (file-attributes file
))
764 (progn (setq file
(expand-file-name "DIR.INFO" truename
))
765 (file-attributes file
)))))
768 (cons (directory-file-name truename
)
773 (message "Composing main Info directory..."))
774 (set-buffer (generate-new-buffer " info dir"))
777 (insert-file-contents file
)
778 (make-local-variable 'Info-dir-file-name
)
779 (setq Info-dir-file-name file
)
780 (setq buffers
(cons (current-buffer) buffers
)
781 Info-dir-file-attributes
782 (cons (cons file attrs
)
783 Info-dir-file-attributes
)))
784 (error (kill-buffer (current-buffer))))))))
785 (or (cdr dirs
) (setq Info-dir-contents-directory
786 (file-name-as-directory (car dirs
))))
787 (setq dirs
(cdr dirs
))))
790 (error "Can't find the Info directory node"))
791 ;; Distinguish the dir file that comes with Emacs from all the
792 ;; others. Yes, that is really what this is supposed to do.
793 ;; The definition of `Info-directory-list' puts it first on that
794 ;; list and so last in `buffers' at this point.
795 (setq buffer
(car (last buffers
))
796 others
(delq buffer buffers
))
798 ;; Insert the entire original dir file as a start; note that we've
799 ;; already saved its default directory to use as the default
800 ;; directory for the whole concatenation.
801 (insert-buffer buffer
)
803 ;; Look at each of the other buffers one by one.
805 (let ((other (car others
))
806 ;; Bind this in case the user sets it to nil.
809 ;; In each, find all the menus.
812 (goto-char (point-min))
813 ;; Find each menu, and add an elt to NODES for it.
814 (while (re-search-forward "^\\* Menu:" nil t
)
815 (let (beg nodename end
)
817 (while (and (eolp) (not (eobp)))
820 (or (search-backward "\n\^_" nil
'move
)
822 (signal 'search-failed
(list "\n\^_")))
823 (search-forward "Node: ")
824 (setq nodename
(Info-following-node-name))
825 (search-forward "\n\^_" nil
'move
)
828 (setq this-buffer-nodes
829 (cons (list nodename other beg end
)
830 this-buffer-nodes
))))
831 (if (assoc-ignore-case "top" this-buffer-nodes
)
832 (setq nodes
(nconc this-buffer-nodes nodes
))
834 (message "No `top' node in %s" Info-dir-file-name
))))
835 (setq others
(cdr others
)))
836 ;; Add to the main menu a menu item for each other node.
837 (let ((case-fold-search t
)
838 (re-search-forward "^\\* Menu:")))
840 (let ((menu-items '("top"))
843 (end (save-excursion (search-forward "\^_" nil t
) (point))))
845 (let ((nodename (car (car nodes
))))
847 (or (member (downcase nodename
) menu-items
)
848 (re-search-forward (concat "^\\* +"
849 (regexp-quote nodename
)
853 (insert "* " nodename
"::" "\n")
854 (setq menu-items
(cons nodename menu-items
))))))
855 (setq nodes
(cdr nodes
))))
856 ;; Now take each node of each of the other buffers
857 ;; and merge it into the main buffer.
859 (let ((case-fold-search t
)
860 (nodename (car (car nodes
))))
861 (goto-char (point-min))
862 ;; Find the like-named node in the main buffer.
863 (if (re-search-forward (concat "^\^_.*\n.*Node: "
864 (regexp-quote nodename
)
868 (search-forward "\n\^_" nil
'move
)
871 ;; If none exists, add one.
872 (goto-char (point-max))
873 (insert "\^_\nFile: dir\tNode: " nodename
"\n\n* Menu:\n\n"))
874 ;; Merge the text from the other buffer's menu
875 ;; into the menu in the like-named node in the main buffer.
876 (apply 'insert-buffer-substring
(cdr (car nodes
))))
877 (setq nodes
(cdr nodes
)))
878 ;; Kill all the buffers we just made.
880 (kill-buffer (car buffers
))
881 (setq buffers
(cdr buffers
)))
882 (if Info-fontify
(Info-fontify-menu-headers))
883 (goto-char (point-min))
885 (message "Composing main Info directory...problems encountered, see `*Messages*'")
886 (message "Composing main Info directory...done")))
887 (setq Info-dir-contents
(buffer-string)))
888 (setq default-directory Info-dir-contents-directory
))
890 ;; Note that on entry to this function the current-buffer must be the
891 ;; *info* buffer; not the info tags buffer.
892 (defun Info-read-subfile (nodepos)
893 ;; NODEPOS is either a position (in the Info file as a whole,
894 ;; not relative to a subfile) or the name of a subfile.
897 (if (numberp nodepos
)
899 (set-buffer (marker-buffer Info-tag-table-marker
))
900 (goto-char (point-min))
901 (or (looking-at "\^_")
902 (search-forward "\n\^_"))
905 (while (not (looking-at "\^_"))
908 thisfilepos thisfilename
)
909 (search-forward ": ")
910 (setq thisfilename
(buffer-substring beg
(- (point) 2)))
911 (setq thisfilepos
(read (current-buffer)))
912 ;; read in version 19 stops at the end of number.
913 ;; Advance to the next line.
915 (if (> thisfilepos nodepos
)
917 (setq lastfilename thisfilename
)
918 (setq lastfilepos thisfilepos
))
920 (setq lastfilename nodepos
)
921 (setq lastfilepos
0))
922 ;; Assume previous buffer is in Info-mode.
923 ;; (set-buffer (get-buffer "*info*"))
924 (or (equal Info-current-subfile lastfilename
)
925 (let ((buffer-read-only nil
))
926 (setq buffer-file-name nil
)
929 (info-insert-file-contents lastfilename
)
930 (set-buffer-modified-p nil
)
931 (setq Info-current-subfile lastfilename
)))
932 (goto-char (point-min))
933 (if (looking-at "\^_")
935 (search-forward "\n\^_"))
936 (if (numberp nodepos
)
937 (+ (- nodepos lastfilepos
) (point)))))
939 (defvar Info-header-line nil
940 "If the info node header is hidden, the text of the header.")
942 (defun Info-select-node ()
943 "Select the info node that point is in.
944 Bind this in case the user sets it to nil."
945 (let ((case-fold-search t
))
947 ;; Find beginning of node.
948 (if (search-backward "\n\^_" nil
'move
)
950 (if (looking-at "\^_")
952 (signal 'search-failed
(list "\n\^_"))))
953 ;; Get nodename spelled as it is in the node.
954 (re-search-forward "Node:[ \t]*")
955 (setq Info-current-node
956 (buffer-substring-no-properties (point)
958 (skip-chars-forward "^,\t\n")
961 ;; Find the end of it, and narrow.
963 (let (active-expression)
964 ;; Narrow to the node contents
965 (narrow-to-region (point)
966 (if (re-search-forward "\n[\^_\f]" nil t
)
969 (if (looking-at "[\n\^_\f]*execute: ")
971 (goto-char (match-end 0))
972 (setq active-expression
973 (read (current-buffer))))))
975 (if Info-enable-active-nodes
(eval active-expression
))
976 (if Info-fontify
(Info-fontify-node))
977 (if Info-use-header-line
978 (Info-setup-header-line)
979 (setq Info-header-line nil
))
980 (run-hooks 'Info-selection-hook
)))))
982 (defun Info-set-mode-line ()
983 (setq mode-line-buffer-identification
984 (nconc (propertized-buffer-identification "%b")
987 (file-name-nondirectory
988 (if (stringp Info-current-file
)
990 (or buffer-file-name
"")))
992 (or Info-current-node
""))))))
994 ;; Skip the node header and make it into a header-line. This function
995 ;; should be called when the node is already narrowed.
996 (defun Info-setup-header-line ()
997 (goto-char (point-min))
998 (let* ((case-fold-search t
)
999 (header-end (save-excursion (forward-line 1) (1- (point))))
1000 ;; If we find neither Next: nor Prev: link, show the entire
1001 ;; node header. Otherwise, don't show the File: and Node:
1002 ;; parts, to avoid wasting precious space on information that
1003 ;; is available in the mode line.
1004 (header-beg (if (re-search-forward
1005 "\\(next\\|prev[ious]*\\): "
1009 (set (make-local-variable 'Info-header-line
)
1010 (buffer-substring header-beg header-end
))
1011 (setq header-line-format
'Info-header-line
)
1012 (narrow-to-region (1+ header-end
) (point-max))))
1014 ;; Go to an info node specified with a filename-and-nodename string
1015 ;; of the sort that is found in pointers in nodes.
1017 (defun Info-goto-node (nodename &optional fork
)
1018 "Go to info node named NAME. Give just NODENAME or (FILENAME)NODENAME.
1019 If FORK is non-nil (interactively with a prefix arg), show the node in
1021 If FORK is a string, it is the name to use for the new buffer."
1022 (interactive (list (Info-read-node-name "Go to node: ") current-prefix-arg
))
1026 (clone-buffer (concat "*info-" (if (stringp fork
) fork nodename
) "*") t
)))
1028 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
1030 (setq filename
(if (= (match-beginning 1) (match-end 1))
1032 (substring nodename
(match-beginning 2) (match-end 2)))
1033 nodename
(substring nodename
(match-beginning 3) (match-end 3)))
1034 (let ((trim (string-match "\\s *\\'" filename
)))
1035 (if trim
(setq filename
(substring filename
0 trim
))))
1036 (let ((trim (string-match "\\s *\\'" nodename
)))
1037 (if trim
(setq nodename
(substring nodename
0 trim
))))
1038 (if transient-mark-mode
(deactivate-mark))
1039 (Info-find-node (if (equal filename
"") nil filename
)
1040 (if (equal nodename
"") "Top" nodename
))))
1042 (defvar Info-read-node-completion-table
)
1044 ;; This function is used as the "completion table" while reading a node name.
1045 ;; It does completion using the alist in Info-read-node-completion-table
1046 ;; unless STRING starts with an open-paren.
1047 (defun Info-read-node-name-1 (string predicate code
)
1048 (let ((no-completion (and (> (length string
) 0) (eq (aref string
0) ?\
())))
1049 (cond ((eq code nil
)
1052 (try-completion string Info-read-node-completion-table predicate
)))
1056 (all-completions string Info-read-node-completion-table predicate
)))
1060 (assoc string Info-read-node-completion-table
))))))
1062 (defun Info-read-node-name (prompt &optional default
)
1063 (let* ((completion-ignore-case t
)
1064 (Info-read-node-completion-table (Info-build-node-completions))
1065 (nodename (completing-read prompt
'Info-read-node-name-1 nil t
)))
1066 (if (equal nodename
"")
1068 (Info-read-node-name prompt
))
1071 (defun Info-build-node-completions ()
1072 (or Info-current-file-completions
1074 ;; Bind this in case the user sets it to nil.
1075 (case-fold-search t
)
1076 (node-regexp "Node: *\\([^,\n]*\\) *[,\n\t]"))
1079 (if (marker-buffer Info-tag-table-marker
)
1080 (let ((marker Info-tag-table-marker
))
1081 (set-buffer (marker-buffer marker
))
1084 (while (re-search-forward "\n\\(Node\\|Ref\\): \\(.*\\)\177" nil t
)
1086 (cons (list (match-string-no-properties 2))
1089 (goto-char (point-min))
1090 ;; If the buffer begins with a node header, process that first.
1091 (if (Info-node-at-bob-matching node-regexp
)
1092 (setq compl
(list (match-string-no-properties 1))))
1093 ;; Now for the rest of the nodes.
1094 (while (search-forward "\n\^_" nil t
)
1096 (let ((beg (point)))
1098 (if (re-search-backward node-regexp beg t
)
1100 (cons (list (match-string-no-properties 1))
1102 (setq compl
(cons '("*") compl
))
1103 (setq Info-current-file-completions compl
))))
1105 (defun Info-restore-point (hl)
1106 "If this node has been visited, restore the point value when we left."
1108 (if (and (equal (nth 0 (car hl
)) Info-current-file
)
1109 ;; Use string-equal, not equal, to ignore text props.
1110 (string-equal (nth 1 (car hl
)) Info-current-node
))
1112 (goto-char (nth 2 (car hl
)))
1113 (setq hl nil
)) ;terminate the while at next iter
1114 (setq hl
(cdr hl
)))))
1116 (defvar Info-search-history nil
1117 "The history list for `Info-search'.")
1119 (defun Info-search (regexp)
1120 "Search for REGEXP, starting from point, and select node it's found in."
1121 (interactive (list (read-string
1122 (if Info-search-history
1123 (format "Regexp search (default `%s'): "
1124 (car Info-search-history
))
1126 nil
'Info-search-history
)))
1127 (when transient-mark-mode
1129 (when (equal regexp
"")
1130 (setq regexp
(car Info-search-history
)))
1132 (let ((found ()) current
1133 (onode Info-current-node
)
1134 (ofile Info-current-file
)
1136 (ostart (window-start))
1137 (osubfile Info-current-subfile
))
1141 (if (null Info-current-subfile
)
1142 (progn (re-search-forward regexp
) (setq found
(point)))
1144 (progn (re-search-forward regexp
) (setq found
(point)))
1145 (search-failed nil
)))))
1146 (if (not found
) ;can only happen in subfile case -- else would have erred
1150 (set-buffer (marker-buffer Info-tag-table-marker
))
1151 (goto-char (point-min))
1152 (search-forward "\n\^_\nIndirect:")
1154 (narrow-to-region (point)
1155 (progn (search-forward "\n\^_")
1157 (goto-char (point-min))
1158 (search-forward (concat "\n" osubfile
": "))
1161 (re-search-forward "\\(^.*\\): [0-9]+$")
1162 (goto-char (+ (match-end 1) 2))
1163 (setq list
(cons (cons (read (current-buffer))
1164 (match-string-no-properties 1))
1166 (goto-char (1+ (match-end 0))))
1167 (setq list
(nreverse list
)
1168 current
(car (car list
))
1171 (message "Searching subfile %s..." (cdr (car list
)))
1172 (Info-read-subfile (car (car list
)))
1173 (setq list
(cdr list
))
1174 ;;; (goto-char (point-min))
1175 (if (re-search-forward regexp nil t
)
1176 (setq found
(point) list
())))
1179 (signal 'search-failed
(list regexp
))))
1181 (progn (Info-read-subfile osubfile
)
1184 (set-window-start (selected-window) ostart
)))))
1188 ;; Use string-equal, not equal, to ignore text props.
1189 (or (and (string-equal onode Info-current-node
)
1190 (equal ofile Info-current-file
))
1191 (setq Info-history
(cons (list ofile onode opoint
)
1194 (defun Info-extract-pointer (name &optional errorname
)
1195 "Extract the value of the node-pointer named NAME.
1196 If there is none, use ERRORNAME in the error message;
1197 if ERRORNAME is nil, just return nil.
1198 Bind this in case the user sets it to nil."
1199 (let ((case-fold-search t
))
1202 (goto-char (point-min))
1203 (when Info-header-line
1204 ;; expose the header line in the buffer
1207 (let ((bound (point)))
1209 (cond ((re-search-backward (concat name
":") bound t
)
1210 (goto-char (match-end 0))
1211 (Info-following-node-name))
1212 ((not (eq errorname t
))
1213 (error "Node has no %s"
1214 (capitalize (or errorname name
))))))))))
1216 (defun Info-following-node-name (&optional allowedchars
)
1217 "Return the node name in the buffer following point.
1218 ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
1219 saying which chars may appear in the node name."
1220 (skip-chars-forward " \t")
1221 (buffer-substring-no-properties
1224 (while (looking-at (concat "[" (or allowedchars
"^,\t\n") "]"))
1225 (skip-chars-forward (concat (or allowedchars
"^,\t\n") "("))
1226 (if (looking-at "(")
1227 (skip-chars-forward "^)")))
1228 (skip-chars-backward " ")
1232 "Go to the next node of this node."
1234 (Info-goto-node (Info-extract-pointer "next")))
1237 "Go to the previous node of this node."
1239 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous")))
1241 (defun Info-up (&optional same-file
)
1242 "Go to the superior node of this node.
1243 If SAME-FILE is non-nil, do not move to a different Info file."
1245 (let ((node (Info-extract-pointer "up")))
1246 (and (or same-file
(not (stringp Info-current-file
)))
1247 (string-match "^(" node
)
1248 (error "Up node is in another Info file"))
1249 (Info-goto-node node
))
1250 (Info-restore-point Info-history
))
1253 "Go back to the last node visited."
1256 (error "This is the first Info node you looked at"))
1257 (let (filename nodename opoint
)
1258 (setq filename
(car (car Info-history
)))
1259 (setq nodename
(car (cdr (car Info-history
))))
1260 (setq opoint
(car (cdr (cdr (car Info-history
)))))
1261 (setq Info-history
(cdr Info-history
))
1262 (Info-find-node filename nodename
)
1263 (setq Info-history
(cdr Info-history
))
1264 (goto-char opoint
)))
1267 (defun Info-directory ()
1268 "Go to the Info directory node."
1270 (Info-find-node "dir" "top"))
1272 (defun Info-follow-reference (footnotename)
1273 "Follow cross reference named FOOTNOTENAME to the node it refers to.
1274 FOOTNOTENAME may be an abbreviation of the reference name."
1276 (let ((completion-ignore-case t
)
1277 (case-fold-search t
)
1278 completions default alt-default
(start-point (point)) str i bol eol
)
1280 ;; Store end and beginning of line.
1286 (goto-char (point-min))
1287 (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t
)
1288 (setq str
(buffer-substring-no-properties
1291 ;; See if this one should be the default.
1293 (<= (match-beginning 0) start-point
)
1294 (<= start-point
(point))
1296 ;; See if this one should be the alternate default.
1297 (and (null alt-default
)
1298 (and (<= bol
(match-beginning 0))
1300 (setq alt-default t
))
1302 (while (setq i
(string-match "[ \n\t]+" str i
))
1303 (setq str
(concat (substring str
0 i
) " "
1304 (substring str
(match-end 0))))
1306 ;; Record as a completion and perhaps as default.
1307 (if (eq default t
) (setq default str
))
1308 (if (eq alt-default t
) (setq alt-default str
))
1309 ;; Don't add this string if it's a duplicate.
1310 ;; We use a loop instead of "(assoc str completions)" because
1311 ;; we want to do a case-insensitive compare.
1312 (let ((tail completions
)
1313 (tem (downcase str
)))
1315 (not (string-equal tem
(downcase (car (car tail
))))))
1316 (setq tail
(cdr tail
)))
1319 (cons (cons str nil
)
1321 ;; If no good default was found, try an alternate.
1323 (setq default alt-default
))
1324 ;; If only one cross-reference found, then make it default.
1325 (if (eq (length completions
) 1)
1326 (setq default
(car (car completions
))))
1328 (let ((input (completing-read (if default
1329 (concat "Follow reference named: ("
1331 "Follow reference named: ")
1332 completions nil t
)))
1333 (list (if (equal input
"")
1335 (error "No cross-references in this node"))))
1337 (unless footnotename
1338 (error "No reference was specified"))
1340 (let (target beg i
(str (concat "\\*note " (regexp-quote footnotename
)))
1341 (case-fold-search t
))
1342 (while (setq i
(string-match " " str i
))
1343 (setq str
(concat (substring str
0 i
) "[ \t\n]+" (substring str
(1+ i
))))
1346 (goto-char (point-min))
1347 (or (re-search-forward str nil t
)
1348 (error "No cross-reference named %s" footnotename
))
1349 (goto-char (+ (match-beginning 0) 5))
1351 (Info-extract-menu-node-name "Bad format cross reference" t
)))
1352 (while (setq i
(string-match "[ \t\n]+" target i
))
1353 (setq target
(concat (substring target
0 i
) " "
1354 (substring target
(match-end 0))))
1356 (Info-goto-node target
)))
1358 (defun Info-extract-menu-node-name (&optional errmessage multi-line
)
1359 (skip-chars-forward " \t\n")
1362 (skip-chars-forward "^:")
1365 (if (looking-at ":")
1366 (buffer-substring-no-properties beg
(1- (point)))
1367 (skip-chars-forward " \t\n")
1368 (Info-following-node-name (if multi-line
"^.,\t" "^.,\t\n"))))
1369 (while (setq i
(string-match "\n" str i
))
1371 ;; Collapse multiple spaces.
1372 (while (string-match " +" str
)
1373 (setq str
(replace-match " " t t str
)))
1376 ;; No one calls this.
1377 ;;(defun Info-menu-item-sequence (list)
1379 ;; (Info-menu (car list))
1380 ;; (setq list (cdr list))))
1382 (defvar Info-complete-menu-buffer
)
1384 (defun Info-complete-menu-item (string predicate action
)
1385 (let ((completion-ignore-case t
)
1386 (case-fold-search t
))
1387 (cond ((eq action nil
)
1389 (pattern (concat "\n\\* +\\("
1390 (regexp-quote string
)
1393 (set-buffer Info-complete-menu-buffer
)
1394 (goto-char (point-min))
1395 (search-forward "\n* Menu:")
1396 (while (re-search-forward pattern nil t
)
1398 (cons (cons (match-string-no-properties 1)
1399 (match-beginning 1))
1401 (try-completion string completions predicate
)))
1404 (pattern (concat "\n\\* +\\("
1405 (regexp-quote string
)
1408 (set-buffer Info-complete-menu-buffer
)
1409 (goto-char (point-min))
1410 (search-forward "\n* Menu:")
1411 (while (re-search-forward pattern nil t
)
1412 (setq completions
(cons (cons
1413 (match-string-no-properties 1)
1414 (match-beginning 1))
1416 (all-completions string completions predicate
)))
1419 (set-buffer Info-complete-menu-buffer
)
1420 (goto-char (point-min))
1421 (search-forward "\n* Menu:")
1422 (re-search-forward (concat "\n\\* +"
1423 (regexp-quote string
)
1428 (defun Info-menu (menu-item &optional fork
)
1429 "Go to node for menu item named (or abbreviated) NAME.
1430 Completion is allowed, and the menu item point is on is the default.
1431 If FORK is non-nil (interactively with a prefix arg), show the node in
1432 a new info buffer. If FORK is a string, it is the name to use for the
1435 (let ((completions '())
1436 ;; If point is within a menu item, use that item as the default
1441 (case-fold-search t
))
1443 (goto-char (point-min))
1444 (if (not (search-forward "\n* menu:" nil t
))
1445 (error "No menu in this node"))
1451 (if (re-search-backward "\n\\* +\\([^:\t\n]*\\):" beg t
)
1452 (setq default
(match-string-no-properties 1))))))
1455 (setq item
(let ((completion-ignore-case t
)
1456 (Info-complete-menu-buffer (current-buffer)))
1457 (completing-read (if default
1458 (format "Menu item (default %s): "
1461 'Info-complete-menu-item nil t
)))
1462 ;; we rely on the fact that completing-read accepts an input
1463 ;; of "" even when the require-match argument is true and ""
1464 ;; is not a valid possibility
1465 (if (string= item
"")
1470 (list item current-prefix-arg
))))
1471 ;; there is a problem here in that if several menu items have the same
1472 ;; name you can only go to the node of the first with this command.
1473 (Info-goto-node (Info-extract-menu-item menu-item
) (if fork menu-item
)))
1475 (defun Info-extract-menu-item (menu-item)
1476 (setq menu-item
(regexp-quote menu-item
))
1477 (let ((case-fold-search t
))
1479 (let ((case-fold-search t
))
1480 (goto-char (point-min))
1481 (or (search-forward "\n* menu:" nil t
)
1482 (error "No menu in this node"))
1483 (or (re-search-forward (concat "\n\\* +" menu-item
":") nil t
)
1484 (re-search-forward (concat "\n\\* +" menu-item
) nil t
)
1485 (error "No such item in menu"))
1488 (Info-extract-menu-node-name)))))
1490 ;; If COUNT is nil, use the last item in the menu.
1491 (defun Info-extract-menu-counting (count)
1492 (let ((case-fold-search t
))
1494 (let ((case-fold-search t
))
1495 (goto-char (point-min))
1496 (or (search-forward "\n* menu:" nil t
)
1497 (error "No menu in this node"))
1499 (or (search-forward "\n* " nil t count
)
1500 (error "Too few items in menu"))
1501 (while (search-forward "\n* " nil t
)
1503 (Info-extract-menu-node-name)))))
1505 (defun Info-nth-menu-item ()
1506 "Go to the node of the Nth menu item.
1507 N is the digit argument used to invoke this command."
1510 (Info-extract-menu-counting
1511 (- (aref (this-command-keys) (1- (length (this-command-keys)))) ?
0))))
1513 (defun Info-top-node ()
1514 "Go to the Top node of this file."
1516 (Info-goto-node "Top"))
1518 (defun Info-final-node ()
1519 "Go to the final node in this file."
1521 (Info-goto-node "Top")
1522 (let ((Info-history nil
)
1523 (case-fold-search t
))
1524 ;; Go to the last node in the menu of Top.
1525 (Info-goto-node (Info-extract-menu-counting nil
))
1526 ;; If the last node in the menu is not last in pointer structure,
1527 ;; move forward until we can't go any farther.
1528 (while (Info-forward-node t t
) nil
)
1529 ;; Then keep moving down to last subnode, unless we reach an index.
1530 (while (and (not (string-match "\\<index\\>" Info-current-node
))
1531 (save-excursion (search-forward "\n* Menu:" nil t
)))
1532 (Info-goto-node (Info-extract-menu-counting nil
)))))
1534 (defun Info-forward-node (&optional not-down no-error
)
1535 "Go forward one node, considering all nodes as forming one sequence."
1537 (goto-char (point-min))
1539 (let ((case-fold-search t
))
1540 ;; three possibilities, in order of priority:
1541 ;; 1. next node is in a menu in this node (but not in an index)
1542 ;; 2. next node is next at same level
1543 ;; 3. next node is up and next
1544 (cond ((and (not not-down
)
1545 (save-excursion (search-forward "\n* menu:" nil t
))
1546 (not (string-match "\\<index\\>" Info-current-node
)))
1547 (Info-goto-node (Info-extract-menu-counting 1))
1552 (when Info-header-line
1553 (goto-char (point-min))
1556 (setq limit
(point))
1558 (search-backward "next:" limit t
))))
1561 ((and (save-excursion
1564 (when Info-header-line
1565 (goto-char (point-min))
1568 (setq limit
(point))
1570 (search-backward "up:" limit t
))))
1571 ;; Use string-equal, not equal, to ignore text props.
1572 (not (string-equal (downcase (Info-extract-pointer "up"))
1574 (let ((old-node Info-current-node
))
1576 (let (Info-history success
)
1578 (setq success
(Info-forward-node t no-error
))
1579 (or success
(Info-goto-node old-node
))))))
1581 (t (error "No pointer forward from this node")))))
1583 (defun Info-backward-node ()
1584 "Go backward one node, considering all nodes as forming one sequence."
1586 (let ((prevnode (Info-extract-pointer "prev[ious]*" t
))
1587 (upnode (Info-extract-pointer "up" t
))
1588 (case-fold-search t
))
1589 (cond ((and upnode
(string-match "(" upnode
))
1590 (error "First node in file"))
1591 ((and upnode
(or (null prevnode
)
1592 ;; Use string-equal, not equal,
1593 ;; to ignore text properties.
1594 (string-equal (downcase prevnode
)
1595 (downcase upnode
))))
1598 ;; If we move back at the same level,
1599 ;; go down to find the last subnode*.
1602 (while (and (not (string-match "\\<index\\>" Info-current-node
))
1603 (save-excursion (search-forward "\n* Menu:" nil t
)))
1604 (Info-goto-node (Info-extract-menu-counting nil
)))))
1606 (error "No pointer backward from this node")))))
1609 "Exit Info by selecting some other buffer."
1612 (save-buffers-kill-emacs)
1615 (defun Info-next-menu-item ()
1617 ;; Bind this in case the user sets it to nil.
1618 (let* ((case-fold-search t
)
1622 (search-forward "\n* menu:" nil t
)
1623 (and (search-forward "\n* " nil t
)
1624 (Info-extract-menu-node-name)))))
1625 (if node
(Info-goto-node node
)
1626 (error "No more items in menu"))))
1628 (defun Info-last-menu-item ()
1632 ;; Bind this in case the user sets it to nil.
1633 (let* ((case-fold-search t
)
1634 (beg (save-excursion
1635 (and (search-backward "\n* menu:" nil t
)
1637 (or (and beg
(search-backward "\n* " beg t
))
1638 (error "No previous items in menu")))
1639 (Info-goto-node (save-excursion
1640 (goto-char (match-end 0))
1641 (Info-extract-menu-node-name)))))
1643 (defmacro Info-no-error
(&rest body
)
1644 (list 'condition-case nil
(cons 'progn
(append body
'(t))) '(error nil
)))
1646 (defun Info-next-preorder ()
1647 "Go to the next subnode or the next node, or go up a level."
1649 (cond ((Info-no-error (Info-next-menu-item)))
1650 ((Info-no-error (Info-next)))
1651 ((Info-no-error (Info-up t
))
1652 ;; Since we have already gone thru all the items in this menu,
1653 ;; go up to the end of this node.
1654 (goto-char (point-max))
1655 ;; Since logically we are done with the node with that menu,
1657 (Info-next-preorder))
1659 (error "No more nodes"))))
1661 (defun Info-last-preorder ()
1662 "Go to the last node, popping up a level if there is none."
1664 (cond ((Info-no-error
1665 (Info-last-menu-item)
1666 ;; If we go down a menu item, go to the end of the node
1667 ;; so we can scroll back through it.
1668 (goto-char (point-max)))
1669 ;; Keep going down, as long as there are nested menu nodes.
1670 (while (Info-no-error
1671 (Info-last-menu-item)
1672 ;; If we go down a menu item, go to the end of the node
1673 ;; so we can scroll back through it.
1674 (goto-char (point-max))))
1676 ((and (Info-no-error (Info-extract-pointer "prev"))
1677 (not (equal (Info-extract-pointer "up")
1678 (Info-extract-pointer "prev"))))
1679 (Info-no-error (Info-prev))
1680 (goto-char (point-max))
1681 (while (Info-no-error
1682 (Info-last-menu-item)
1683 ;; If we go down a menu item, go to the end of the node
1684 ;; so we can scroll back through it.
1685 (goto-char (point-max))))
1687 ((Info-no-error (Info-up t
))
1688 (goto-char (point-min))
1689 (let ((case-fold-search t
))
1690 (or (search-forward "\n* Menu:" nil t
)
1691 (goto-char (point-max)))))
1692 (t (error "No previous nodes"))))
1694 (defun Info-scroll-up ()
1695 "Scroll one screenful forward in Info, considering all nodes as one sequence.
1696 Once you scroll far enough in a node that its menu appears on the screen
1697 but after point, the next scroll moves into its first subnode, unless
1698 `Info-scroll-prefer-subnodes' is nil.
1700 When you scroll past the end of a node, that goes to the next node if
1701 `Info-scroll-prefer-subnodes' is non-nil and to the first subnode otherwise;
1702 if this node has no successor, it moves to the parent node's successor,
1703 and so on. If `Info-scroll-prefer-subnodes' is non-nil and point is inside
1704 the menu of a node, it moves to subnode indicated by the following menu
1705 item. (That case won't normally result from this command, but can happen
1709 (if (or (< (window-start) (point-min))
1710 (> (window-start) (point-max)))
1711 (set-window-start (selected-window) (point)))
1712 (let* ((case-fold-search t
)
1713 (virtual-end (save-excursion
1714 (goto-char (point-min))
1715 (if (and Info-scroll-prefer-subnodes
1716 (search-forward "\n* Menu:" nil t
))
1719 (if (or (< virtual-end
(window-start))
1720 (pos-visible-in-window-p virtual-end
))
1722 (Info-scroll-prefer-subnodes (Info-next-preorder))
1723 ((Info-no-error (Info-goto-node (Info-extract-menu-counting 1))))
1724 (t (Info-next-preorder)))
1727 (defun Info-scroll-down ()
1728 "Scroll one screenful back in Info, considering all nodes as one sequence.
1729 If point is within the menu of a node, and `Info-scroll-prefer-subnodes'
1730 is non-nil, this goes to its last subnode. When you scroll past the
1731 beginning of a node, that goes to the previous node or back up to the
1734 (if (or (< (window-start) (point-min))
1735 (> (window-start) (point-max)))
1736 (set-window-start (selected-window) (point)))
1737 (let* ((case-fold-search t
)
1738 (current-point (point))
1740 (and Info-scroll-prefer-subnodes
1743 (setq current-point
(point))
1744 (goto-char (point-min))
1745 (search-forward "\n* Menu:"
1748 (if (or virtual-end
(pos-visible-in-window-p (point-min)))
1749 (Info-last-preorder)
1752 (defun Info-next-reference (&optional recur
)
1753 "Move cursor to the next cross-reference or menu item in the node."
1755 (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:")
1757 (case-fold-search t
))
1758 (or (eobp) (forward-char 1))
1759 (or (re-search-forward pat nil t
)
1761 (goto-char (point-min))
1762 (or (re-search-forward pat nil t
)
1765 (error "No cross references in this node")))))
1766 (goto-char (match-beginning 0))
1767 (if (looking-at "\\* Menu:")
1769 (error "No cross references in this node")
1770 (Info-next-reference t
)))))
1772 (defun Info-prev-reference (&optional recur
)
1773 "Move cursor to the previous cross-reference or menu item in the node."
1775 (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:")
1777 (case-fold-search t
))
1778 (or (re-search-backward pat nil t
)
1780 (goto-char (point-max))
1781 (or (re-search-backward pat nil t
)
1784 (error "No cross references in this node")))))
1785 (goto-char (match-beginning 0))
1786 (if (looking-at "\\* Menu:")
1788 (error "No cross references in this node")
1789 (Info-prev-reference t
)))))
1791 (defun Info-index (topic)
1792 "Look up a string TOPIC in the index for this file.
1793 The index is defined as the first node in the top-level menu whose
1794 name contains the word \"Index\", plus any immediately following
1795 nodes whose names also contain the word \"Index\".
1796 If there are no exact matches to the specified topic, this chooses
1797 the first match which is a case-insensitive substring of a topic.
1798 Use the `,' command to see the other matches.
1799 Give a blank topic name to go to the Index node itself."
1800 (interactive "sIndex topic: ")
1801 (let ((orignode Info-current-node
)
1803 (pattern (format "\n\\* +\\([^\n:]*%s[^\n:]*\\):[ \t]*\\([^.\n]*\\)\\.[ \t]*\\([0-9]*\\)"
1804 (regexp-quote topic
)))
1806 (case-fold-search t
))
1807 (Info-goto-node "Top")
1808 (or (search-forward "\n* menu:" nil t
)
1810 (or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t
)
1812 (goto-char (match-beginning 1))
1813 ;; Here, and subsequently in this function,
1814 ;; we bind Info-history to nil for internal node-switches
1815 ;; so that we don't put junk in the history.
1816 ;; In the first Info-goto-node call, above, we do update the history
1817 ;; because that is what the user's previous node choice into it.
1818 (let ((Info-history nil
))
1819 (Info-goto-node (Info-extract-menu-node-name)))
1820 (or (equal topic
"")
1827 (goto-char (point-min))
1828 (while (re-search-forward pattern nil t
)
1829 (push (list (match-string-no-properties 1)
1830 (match-string-no-properties 2)
1832 (string-to-int (concat "0"
1835 (and (setq node
(Info-extract-pointer "next" t
))
1836 (string-match "\\<Index\\>" node
)))
1837 (Info-goto-node node
))
1840 (Info-goto-node orignode
)
1841 (error "No `%s' in index" topic
)))
1842 ;; Here it is a feature that assoc is case-sensitive.
1843 (while (setq found
(assoc topic matches
))
1844 (setq exact
(cons found exact
)
1845 matches
(delq found matches
)))
1846 (setq Info-index-alternatives
(nconc exact
(nreverse matches
)))
1847 (Info-index-next 0)))))
1849 (defun Info-index-next (num)
1850 "Go to the next matching index item from the last `i' command."
1852 (or Info-index-alternatives
1853 (error "No previous `i' command"))
1855 (setq num
(+ num
(length Info-index-alternatives
))))
1857 (setq Info-index-alternatives
1858 (nconc (cdr Info-index-alternatives
)
1859 (list (car Info-index-alternatives
)))
1861 (Info-goto-node (nth 1 (car Info-index-alternatives
)))
1862 (if (> (nth 3 (car Info-index-alternatives
)) 0)
1863 (forward-line (nth 3 (car Info-index-alternatives
)))
1864 (forward-line 3) ; don't search in headers
1865 (let ((name (car (car Info-index-alternatives
))))
1866 (Info-find-index-name name
)))
1867 (message "Found `%s' in %s. %s"
1868 (car (car Info-index-alternatives
))
1869 (nth 2 (car Info-index-alternatives
))
1870 (if (cdr Info-index-alternatives
)
1871 "(Press `,' for more)"
1874 (defun Info-find-index-name (name)
1875 "Move point to the place within the current node where NAME is defined."
1876 (let ((case-fold-search t
))
1877 (if (or (re-search-forward (format
1878 "[a-zA-Z]+: %s\\( \\|$\\)"
1879 (regexp-quote name
)) nil t
)
1880 (search-forward (format "`%s'" name
) nil t
)
1881 (and (string-match "\\`.*\\( (.*)\\)\\'" name
)
1883 (format "`%s'" (substring name
0 (match-beginning 1)))
1885 (search-forward name nil t
))
1887 (goto-char (point-min)))))
1889 (defun Info-undefined ()
1890 "Make command be undefined in Info."
1895 "Enter the Info tutorial."
1897 (delete-other-windows)
1898 (Info-find-node "info"
1899 (if (< (window-height) 23)
1903 (defun Info-summary ()
1904 "Display a brief summary of all Info commands."
1906 (save-window-excursion
1907 (switch-to-buffer "*Help*")
1908 (setq buffer-read-only nil
)
1910 (insert (documentation 'Info-mode
))
1912 (goto-char (point-min))
1914 (while (progn (setq flag
(not (pos-visible-in-window-p (point-max))))
1915 (message (if flag
"Type Space to see more"
1916 "Type Space to return to Info"))
1917 (if (not (eq ?\
(setq ch
(read-event))))
1918 (progn (setq unread-command-events
(list ch
)) nil
)
1921 (bury-buffer "*Help*")))
1923 (defun Info-get-token (pos start all
&optional errorstring
)
1924 "Return the token around POS.
1925 POS must be somewhere inside the token
1926 START is a regular expression which will match the
1927 beginning of the tokens delimited string
1928 ALL is a regular expression with a single
1929 parenthesized subpattern which is the token to be
1930 returned. E.g. '{\(.*\)}' would return any string
1931 enclosed in braces around POS.
1932 ERRORSTRING optional fourth argument, controls action on no match
1935 a string: signal an error, using that string."
1936 (let ((case-fold-search t
))
1939 ;; First look for a match for START that goes across POS.
1940 (while (and (not (bobp)) (> (point) (- pos
(length start
)))
1941 (not (looking-at start
)))
1943 ;; If we did not find one, search back for START
1944 ;; (this finds only matches that end at or before POS).
1945 (or (looking-at start
)
1948 (re-search-backward start
(max (point-min) (- pos
200)) 'yes
)))
1950 (while (and (re-search-forward all
(min (point-max) (+ pos
200)) 'yes
)
1951 (not (setq found
(and (<= (match-beginning 0) pos
)
1952 (> (match-end 0) pos
))))))
1953 (if (and found
(<= (match-beginning 0) pos
)
1954 (> (match-end 0) pos
))
1955 (match-string-no-properties 1)
1956 (cond ((null errorstring
)
1962 (error "No %s around position %d" errorstring pos
))))))))
1964 (defun Info-mouse-follow-nearest-node (click)
1965 "\\<Info-mode-map>Follow a node reference near point.
1966 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click.
1967 At end of the node's text, moves to the next node, or up if none."
1969 (mouse-set-point click
)
1970 (and (not (Info-try-follow-nearest-node))
1971 (save-excursion (forward-line 1) (eobp))
1972 (Info-next-preorder)))
1974 (defun Info-follow-nearest-node ()
1975 "\\<Info-mode-map>Follow a node reference near point.
1976 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where point is.
1977 If no reference to follow, moves to the next node, or up if none."
1979 (or (Info-try-follow-nearest-node)
1980 (Info-next-preorder)))
1982 ;; Common subroutine.
1983 (defun Info-try-follow-nearest-node ()
1984 "Follow a node reference near point. Return non-nil if successful."
1987 ((setq node
(Info-get-token (point) "\\*note[ \n]"
1988 "\\*note[ \n]\\([^:]*\\):"))
1989 (Info-follow-reference node
))
1990 ((setq node
(Info-get-token (point) "\\* +" "\\* +\\([^:]*\\)::"))
1991 (Info-goto-node node
))
1992 ((Info-get-token (point) "\\* +" "\\* +\\([^:]*\\):")
1995 (setq node
(Info-extract-menu-node-name))
1996 (Info-goto-node node
))
1997 ((setq node
(Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)"))
1998 (Info-goto-node node
))
1999 ((setq node
(Info-get-token (point) "Next: " "Next: \\([^,\n\t]*\\)"))
2000 (Info-goto-node node
))
2001 ((setq node
(Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)"))
2002 (Info-goto-node "Top"))
2003 ((setq node
(Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)"))
2004 (Info-goto-node node
)))
2007 (defvar Info-mode-map nil
2008 "Keymap containing Info commands.")
2011 (setq Info-mode-map
(make-keymap))
2012 (suppress-keymap Info-mode-map
)
2013 (define-key Info-mode-map
"." 'beginning-of-buffer
)
2014 (define-key Info-mode-map
" " 'Info-scroll-up
)
2015 (define-key Info-mode-map
"\C-m" 'Info-follow-nearest-node
)
2016 (define-key Info-mode-map
"\t" 'Info-next-reference
)
2017 (define-key Info-mode-map
"\e\t" 'Info-prev-reference
)
2018 (define-key Info-mode-map
"1" 'Info-nth-menu-item
)
2019 (define-key Info-mode-map
"2" 'Info-nth-menu-item
)
2020 (define-key Info-mode-map
"3" 'Info-nth-menu-item
)
2021 (define-key Info-mode-map
"4" 'Info-nth-menu-item
)
2022 (define-key Info-mode-map
"5" 'Info-nth-menu-item
)
2023 (define-key Info-mode-map
"6" 'Info-nth-menu-item
)
2024 (define-key Info-mode-map
"7" 'Info-nth-menu-item
)
2025 (define-key Info-mode-map
"8" 'Info-nth-menu-item
)
2026 (define-key Info-mode-map
"9" 'Info-nth-menu-item
)
2027 (define-key Info-mode-map
"0" 'undefined
)
2028 (define-key Info-mode-map
"?" 'Info-summary
)
2029 (define-key Info-mode-map
"]" 'Info-forward-node
)
2030 (define-key Info-mode-map
"[" 'Info-backward-node
)
2031 (define-key Info-mode-map
"<" 'Info-top-node
)
2032 (define-key Info-mode-map
">" 'Info-final-node
)
2033 (define-key Info-mode-map
"b" 'beginning-of-buffer
)
2034 (define-key Info-mode-map
"d" 'Info-directory
)
2035 (define-key Info-mode-map
"e" 'Info-edit
)
2036 (define-key Info-mode-map
"f" 'Info-follow-reference
)
2037 (define-key Info-mode-map
"g" 'Info-goto-node
)
2038 (define-key Info-mode-map
"h" 'Info-help
)
2039 (define-key Info-mode-map
"i" 'Info-index
)
2040 (define-key Info-mode-map
"l" 'Info-last
)
2041 (define-key Info-mode-map
"m" 'Info-menu
)
2042 (define-key Info-mode-map
"n" 'Info-next
)
2043 (define-key Info-mode-map
"p" 'Info-prev
)
2044 (define-key Info-mode-map
"q" 'Info-exit
)
2045 (define-key Info-mode-map
"s" 'Info-search
)
2046 ;; For consistency with Rmail.
2047 (define-key Info-mode-map
"\M-s" 'Info-search
)
2048 (define-key Info-mode-map
"\M-n" 'clone-buffer
)
2049 (define-key Info-mode-map
"t" 'Info-top-node
)
2050 (define-key Info-mode-map
"u" 'Info-up
)
2051 (define-key Info-mode-map
"," 'Info-index-next
)
2052 (define-key Info-mode-map
"\177" 'Info-scroll-down
)
2053 (define-key Info-mode-map
[mouse-2
] 'Info-mouse-follow-nearest-node
)
2056 (defun Info-check-pointer (item)
2057 "Non-nil if ITEM is present in this node."
2059 (Info-extract-pointer item
)
2063 Info-mode-menu Info-mode-map
2064 "Menu for info files."
2066 ["Up" Info-up
:active
(Info-check-pointer "up")
2067 :help
"Go up in the Info tree"]
2068 ["Next" Info-next
:active
(Info-check-pointer "next")
2069 :help
"Go to the next node"]
2070 ["Previous" Info-prev
:active
(Info-check-pointer "prev[ious]*")
2071 :help
"Go to the previous node"]
2072 ["Backward" Info-backward-node
2073 :help
"Go backward one node, considering all as a sequence"]
2074 ["Forward" Info-forward-node
2075 :help
"Go forward one node, considering all as a sequence"]
2076 ["Beginning" beginning-of-buffer
2077 :help
"Go to beginning of this node"]
2078 ["Top" Info-top-node
2079 :help
"Go to top node of file"]
2080 ["Final Node" Info-final-node
2081 :help
"Go to final node in this file"]
2082 ("Menu Item" ["You should never see this" report-emacs-bug t
])
2083 ("Reference" ["You should never see this" report-emacs-bug t
])
2084 ["Search..." Info-search
2085 :help
"Search for regular expression in this Info file"]
2086 ["Go to Node..." Info-goto-node
2087 :help
"Go to a named node"]
2088 ["Last" Info-last
:active Info-history
2089 :help
"Go to the last node you were at"]
2091 ["Lookup a String" Info-index
2092 :help
"Look for a string in the index items"]
2093 ["Next Matching Item" Info-index-next
2094 :help
"Look for another occurrence of previous item"])
2095 ["Edit" Info-edit
:help
"Edit contents of this node"
2096 :active Info-enable-edit
]
2097 ["Exit" Info-exit
:help
"Stop reading Info"]))
2100 (defvar info-tool-bar-map
2101 (if (display-graphic-p)
2102 (let ((tool-bar-map (make-sparse-keymap)))
2103 (tool-bar-add-item-from-menu 'Info-exit
"close" Info-mode-map
)
2104 (tool-bar-add-item-from-menu 'Info-prev
"left_arrow" Info-mode-map
)
2105 (tool-bar-add-item-from-menu 'Info-next
"right_arrow" Info-mode-map
)
2106 (tool-bar-add-item-from-menu 'Info-up
"up_arrow" Info-mode-map
)
2107 (tool-bar-add-item-from-menu 'Info-last
"undo" Info-mode-map
)
2108 (tool-bar-add-item-from-menu 'Info-top-node
"home" Info-mode-map
)
2109 (tool-bar-add-item-from-menu 'Info-index
"index" Info-mode-map
)
2110 (tool-bar-add-item-from-menu 'Info-goto-node
"jump_to" Info-mode-map
)
2111 (tool-bar-add-item-from-menu 'Info-search
"search" Info-mode-map
)
2114 (defvar Info-menu-last-node nil
)
2115 ;; Last node the menu was created for.
2116 ;; Value is a list, (FILE-NAME NODE-NAME).
2118 (defun Info-menu-update ()
2119 "Update the Info menu for the current node."
2121 (if (or (not (eq major-mode
'Info-mode
))
2122 (equal (list Info-current-file Info-current-node
)
2123 Info-menu-last-node
))
2125 ;; Update menu menu.
2126 (let* ((Info-complete-menu-buffer (current-buffer))
2127 (items (nreverse (condition-case nil
2128 (Info-complete-menu-item
2129 "" (lambda (e) t
) t
)
2133 (while (and items
(< number
9))
2134 (setq current
(car items
)
2137 (setq entries
(cons `[,current
2138 (Info-menu ,current
)
2139 :keys
,(format "%d" number
)]
2142 (setq entries
(cons ["Other..." Info-menu t
] entries
)))
2144 (setq entries
(list ["No menu" nil nil
])))
2145 (easy-menu-change '("Info") "Menu Item" (nreverse entries
)))
2146 ;; Update reference menu. Code stolen from `Info-follow-reference'.
2148 str i entries current
2150 (case-fold-search t
))
2152 (goto-char (point-min))
2153 (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t
)
2154 (setq str
(buffer-substring
2158 (while (setq i
(string-match "[ \n\t]+" str i
))
2159 (setq str
(concat (substring str
0 i
) " "
2160 (substring str
(match-end 0))))
2164 (while (and items
(< number
9))
2165 (setq current
(car items
)
2168 (setq entries
(cons `[,current
2169 (Info-follow-reference ,current
)
2173 (setq entries
(cons ["Other..." Info-follow-reference t
]
2176 (setq entries
(list ["No references" nil nil
])))
2177 (easy-menu-change '("Info") "Reference" (nreverse entries
)))
2178 ;; Update last seen node.
2179 (setq Info-menu-last-node
(list Info-current-file Info-current-node
)))
2180 ;; Try to avoid entering infinite beep mode in case of errors.
2184 ;; Info mode is suitable only for specially formatted data.
2185 (put 'Info-mode
'mode-class
'special
)
2188 "Info mode provides commands for browsing through the Info documentation tree.
2189 Documentation in Info is divided into \"nodes\", each of which discusses
2190 one topic and contains references to other nodes which discuss related
2191 topics. Info has commands to follow the references and show you other nodes.
2194 \\[Info-help] Invoke the Info tutorial.
2195 \\[Info-exit] Quit Info: reselect previously selected buffer.
2197 Selecting other nodes:
2198 \\[Info-mouse-follow-nearest-node]
2199 Follow a node reference you click on.
2200 This works with menu items, cross references, and
2201 the \"next\", \"previous\" and \"up\", depending on where you click.
2202 \\[Info-follow-nearest-node] Follow a node reference near point, like \\[Info-mouse-follow-nearest-node].
2203 \\[Info-next] Move to the \"next\" node of this node.
2204 \\[Info-prev] Move to the \"previous\" node of this node.
2205 \\[Info-up] Move \"up\" from this node.
2206 \\[Info-menu] Pick menu item specified by name (or abbreviation).
2207 Picking a menu item causes another node to be selected.
2208 \\[Info-directory] Go to the Info directory node.
2209 \\[Info-follow-reference] Follow a cross reference. Reads name of reference.
2210 \\[Info-last] Move to the last node you were at.
2211 \\[Info-index] Look up a topic in this file's Index and move to that node.
2212 \\[Info-index-next] (comma) Move to the next match from a previous `i' command.
2213 \\[Info-top-node] Go to the Top node of this file.
2214 \\[Info-final-node] Go to the final node in this file.
2215 \\[Info-backward-node] Go backward one node, considering all nodes as forming one sequence.
2216 \\[Info-forward-node] Go forward one node, considering all nodes as forming one sequence.
2218 Moving within a node:
2219 \\[Info-scroll-up] Normally, scroll forward a full screen.
2220 Once you scroll far enough in a node that its menu appears on the screen
2221 but after point, the next scroll moves into its first subnode.
2222 When after all menu items (or if their is no menu), move up to
2224 \\[Info-scroll-down] Normally, scroll backward. If the beginning of the buffer is
2225 already visible, try to go to the previous menu entry, or up if there is none.
2226 \\[beginning-of-buffer] Go to beginning of node.
2229 \\[Info-exit] Quit Info: reselect previously selected buffer.
2230 \\[Info-edit] Edit contents of selected node.
2231 1 Pick first item in node's menu.
2232 2, 3, 4, 5 Pick second ... fifth item in node's menu.
2233 \\[Info-goto-node] Move to node specified by name.
2234 You may include a filename as well, as (FILENAME)NODENAME.
2235 \\[universal-argument] \\[info] Move to new Info file with completion.
2236 \\[Info-search] Search through this Info file for specified regexp,
2237 and select the node in which the next occurrence is found.
2238 \\[Info-next-reference] Move cursor to next cross-reference or menu item.
2239 \\[Info-prev-reference] Move cursor to previous cross-reference or menu item."
2240 (kill-all-local-variables)
2241 (setq major-mode
'Info-mode
)
2242 (setq mode-name
"Info")
2244 (use-local-map Info-mode-map
)
2245 (add-hook 'activate-menubar-hook
'Info-menu-update nil t
)
2246 (set-syntax-table text-mode-syntax-table
)
2247 (setq local-abbrev-table text-mode-abbrev-table
)
2248 (setq case-fold-search t
)
2249 (setq buffer-read-only t
)
2250 (make-local-variable 'Info-current-file
)
2251 (make-local-variable 'Info-current-subfile
)
2252 (make-local-variable 'Info-current-node
)
2253 (make-local-variable 'Info-tag-table-marker
)
2254 (setq Info-tag-table-marker
(make-marker))
2255 (make-local-variable 'Info-tag-table-buffer
)
2256 (setq Info-tag-table-buffer nil
)
2257 (make-local-variable 'Info-history
)
2258 (make-local-variable 'Info-index-alternatives
)
2259 (set (make-local-variable 'tool-bar-map
) info-tool-bar-map
)
2260 ;; This is for the sake of the invisible text we use handling titles.
2261 (make-local-variable 'line-move-ignore-invisible
)
2262 (setq line-move-ignore-invisible t
)
2263 (add-hook 'clone-buffer-hook
'Info-clone-buffer-hook nil t
)
2264 (Info-set-mode-line)
2265 (run-hooks 'Info-mode-hook
))
2267 (defun Info-clone-buffer-hook ()
2268 (when (bufferp Info-tag-table-buffer
)
2269 (setq Info-tag-table-buffer
2270 (with-current-buffer Info-tag-table-buffer
(clone-buffer)))
2271 (let ((m Info-tag-table-marker
))
2272 (when (and (markerp m
) (marker-position m
))
2273 (setq Info-tag-table-marker
2274 (with-current-buffer Info-tag-table-buffer
2275 (copy-marker (marker-position m
))))))))
2277 (defvar Info-edit-map
(let ((map (make-sparse-keymap)))
2278 (set-keymap-parent map text-mode-map
)
2279 (define-key map
"\C-c\C-c" 'Info-cease-edit
)
2281 "Local keymap used within `e' command of Info.")
2283 ;; Info-edit mode is suitable only for specially formatted data.
2284 (put 'Info-edit-mode
'mode-class
'special
)
2286 (defun Info-edit-mode ()
2287 "Major mode for editing the contents of an Info node.
2288 Like text mode with the addition of `Info-cease-edit'
2289 which returns to Info mode for browsing.
2291 (use-local-map Info-edit-map
)
2292 (setq major-mode
'Info-edit-mode
)
2293 (setq mode-name
"Info Edit")
2294 (kill-local-variable 'mode-line-buffer-identification
)
2295 (setq buffer-read-only nil
)
2296 (force-mode-line-update)
2297 (buffer-enable-undo (current-buffer))
2298 (run-hooks 'Info-edit-mode-hook
))
2301 "Edit the contents of this Info node.
2302 Allowed only if variable `Info-enable-edit' is non-nil."
2304 (or Info-enable-edit
2305 (error "Editing info nodes is not enabled"))
2307 (message "%s" (substitute-command-keys
2308 "Editing: Type \\<Info-edit-map>\\[Info-cease-edit] to return to info")))
2310 (defun Info-cease-edit ()
2311 "Finish editing Info node; switch back to Info proper."
2313 ;; Do this first, so nothing has changed if user C-g's at query.
2314 (and (buffer-modified-p)
2315 (y-or-n-p "Save the file? ")
2317 (use-local-map Info-mode-map
)
2318 (setq major-mode
'Info-mode
)
2319 (setq mode-name
"Info")
2320 (Info-set-mode-line)
2321 (setq buffer-read-only t
)
2322 (force-mode-line-update)
2323 (and (marker-position Info-tag-table-marker
)
2325 (message "Tags may have changed. Use Info-tagify if necessary")))
2327 (defvar Info-file-list-for-emacs
2328 '("ediff" "forms" "gnus" ("mh" .
"mh-e") "sc" "message"
2329 ("dired" .
"dired-x") ("c" .
"ccmode") "viper" "vip"
2330 ("skeleton" .
"autotype") ("auto-insert" .
"autotype")
2331 ("copyright" .
"autotype") ("executable" .
"autotype")
2332 ("time-stamp" .
"autotype") ("quickurl" .
"autotype")
2333 ("tempo" .
"autotype") ("hippie-expand" .
"autotype")
2335 "ebrowse" "eshell" "cl" "idlwave" "reftex" "speedbar" "widget" "woman")
2336 "List of Info files that describe Emacs commands.
2337 An element can be a file name, or a list of the form (PREFIX . FILE)
2338 where PREFIX is a name prefix and FILE is the file to look in.
2339 If the element is just a file name, the file name also serves as the prefix.")
2341 (defun Info-find-emacs-command-nodes (command)
2342 "Return a list of locations documenting COMMAND.
2343 The `info-file' property of COMMAND says which Info manual to search.
2344 If COMMAND has no property, the variable `Info-file-list-for-emacs'
2345 defines heuristics for which Info manual to try.
2346 The locations are of the format used in `Info-history', i.e.
2347 \(FILENAME NODENAME BUFFERPOS\)."
2349 (cmd-desc (concat "^\\* +" (regexp-quote (symbol-name command
))
2350 "\\( <[0-9]+>\\)?:\\s *\\(.*\\)\\.$"))
2351 (info-file "emacs")) ;default
2352 ;; Determine which info file this command is documented in.
2353 (if (get command
'info-file
)
2354 (setq info-file
(get command
'info-file
))
2355 ;; If it doesn't say explicitly, test its name against
2356 ;; various prefixes that we know.
2357 (let ((file-list Info-file-list-for-emacs
))
2359 (let* ((elt (car file-list
))
2360 (name (if (consp elt
)
2363 (file (if (consp elt
) (cdr elt
) elt
))
2364 (regexp (concat "\\`" (regexp-quote name
)
2366 (if (string-match regexp
(symbol-name command
))
2367 (setq info-file file file-list nil
))
2368 (setq file-list
(cdr file-list
))))))
2369 (Info-find-node info-file
"Top")
2370 (or (and (search-forward "\n* menu:" nil t
)
2371 (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t
))
2372 (error "Info file `%s' appears to lack an index" info-file
))
2373 (goto-char (match-beginning 1))
2374 ;; Bind Info-history to nil, to prevent the index nodes from
2375 ;; getting into the node history.
2376 (let ((Info-history nil
)
2379 (Info-goto-node (Info-extract-menu-node-name))
2382 (goto-char (point-min))
2383 (while (re-search-forward cmd-desc nil t
)
2385 (cons (list Info-current-file
2386 (match-string-no-properties 2)
2389 (and (setq node
(Info-extract-pointer "next" t
))
2390 (string-match "\\<Index\\>" node
)))
2391 (Info-goto-node node
)))
2395 (defun Info-goto-emacs-command-node (command)
2396 "Go to the Info node in the Emacs manual for command COMMAND.
2397 The command is found by looking up in Emacs manual's indices
2398 or in another manual found via COMMAND's `info-file' property or
2399 the variable `Info-file-list-for-emacs'."
2400 (interactive "CFind documentation for command: ")
2401 (or (commandp command
)
2402 (signal 'wrong-type-argument
(list 'commandp command
)))
2403 (let ((where (Info-find-emacs-command-nodes command
)))
2405 (let ((num-matches (length where
)))
2406 ;; Get Info running, and pop to it in another window.
2407 (save-window-excursion
2409 ;; FIXME It would be cool if this could use a buffer other
2411 (pop-to-buffer "*info*")
2412 ;; Bind Info-history to nil, to prevent the last Index node
2413 ;; visited by Info-find-emacs-command-nodes from being
2414 ;; pushed onto the history.
2415 (let ((Info-history nil
))
2416 (Info-find-node (car (car where
))
2417 (car (cdr (car where
)))))
2418 (if (> num-matches
1)
2420 ;; (car where) will be pushed onto Info-history
2421 ;; when/if they go to another node. Put the other
2422 ;; nodes that were found on the history.
2423 (setq Info-history
(nconc (cdr where
) Info-history
))
2424 (message "Found %d other entr%s. Use %s to see %s."
2426 (if (> num-matches
2) "ies" "y")
2427 (substitute-command-keys "\\[Info-last]")
2428 (if (> num-matches
2) "them" "it")))))
2429 (error "Couldn't find documentation for %s" command
))))
2432 (defun Info-goto-emacs-key-command-node (key)
2433 "Go to the node in the Emacs manual which describes the command bound to KEY.
2435 Interactively, if the binding is `execute-extended-command', a command is read.
2436 The command is found by looking up in Emacs manual's indices
2437 or in another manual found via COMMAND's `info-file' property or
2438 the variable `Info-file-list-for-emacs'."
2439 (interactive "kFind documentation for key: ")
2440 (let ((command (key-binding key
)))
2441 (cond ((null command
)
2442 (message "%s is undefined" (key-description key
)))
2443 ((and (interactive-p)
2444 (eq command
'execute-extended-command
))
2445 (Info-goto-emacs-command-node
2446 (read-command "Find documentation for command: ")))
2448 (Info-goto-emacs-command-node command
)))))
2450 (defface Info-title-1-face
2451 '((((type tty pc
) (class color
)) (:foreground
"yellow" :weight bold
))
2452 (t (:height
1.2 :inherit Info-title-2-face
)))
2453 "Face for Info titles at level 1."
2456 (defface Info-title-2-face
2457 '((((type tty pc
) (class color
)) (:foreground
"lightblue" :weight bold
))
2458 (t (:height
1.2 :inherit Info-title-3-face
)))
2459 "Face for Info titles at level 2."
2462 (defface Info-title-3-face
2463 '((((type tty pc
) (class color
)) (:weight bold
))
2464 (t (:height
1.2 :inherit Info-title-4-face
)))
2465 "Face for Info titles at level 3."
2468 (defface Info-title-4-face
2469 '((((type tty pc
) (class color
)) (:weight bold
))
2470 (t (:weight bold
:inherit variable-pitch
)))
2471 "Face for Info titles at level 4."
2474 (defface info-menu-header
2479 :inherit variable-pitch
2481 "Face for headers in Info menus."
2484 (defun Info-fontify-menu-headers ()
2485 "Add the face `info-menu-header' to any header before a menu entry."
2487 (goto-char (point-min))
2488 (when (re-search-forward "\\* Menu:" nil t
)
2489 (put-text-property (match-beginning 0) (match-end 0)
2490 'face
'info-menu-header
)
2491 (while (re-search-forward "\n\n\\([^*\n ].*\\)\n\n?[*]" nil t
)
2492 (put-text-property (match-beginning 1) (match-end 1)
2493 'face
'info-menu-header
)))))
2495 (defun Info-fontify-node ()
2497 (let ((buffer-read-only nil
)
2498 (case-fold-search t
))
2499 (goto-char (point-min))
2500 (when (looking-at "^File: [^,: \t]+,?[ \t]+")
2501 (goto-char (match-end 0))
2502 (while (looking-at "[ \t]*\\([^:, \t\n]+\\):[ \t]+\\([^:,\t\n]+\\),?")
2503 (goto-char (match-end 0))
2504 (let* ((nbeg (match-beginning 2))
2505 (nend (match-end 2))
2506 (tbeg (match-beginning 1))
2507 (tag (buffer-substring tbeg
(match-end 1))))
2508 (if (string-equal tag
"Node")
2509 (put-text-property nbeg nend
'face
'info-header-node
)
2510 (put-text-property nbeg nend
'face
'info-header-xref
)
2511 (put-text-property nbeg nend
'mouse-face
'highlight
)
2512 (put-text-property tbeg nend
2514 (concat "Go to node "
2515 (buffer-substring nbeg nend
)))
2516 (let ((fun (cdr (assoc tag
'(("Prev" . Info-prev
)
2517 ("Next" . Info-next
)
2518 ("Up" . Info-up
))))))
2520 (let ((keymap (make-sparse-keymap)))
2521 (define-key keymap
[header-line mouse-1
] fun
)
2522 (define-key keymap
[header-line mouse-2
] fun
)
2523 (put-text-property tbeg nend
'local-map keymap
))))
2525 (goto-char (point-min))
2526 (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*+\\|=+\\|-+\\|\\.+\\)$"
2528 (let ((c (preceding-char))
2530 (cond ((= c ?
*) (setq face
'Info-title-1-face
))
2531 ((= c ?
=) (setq face
'Info-title-2-face
))
2532 ((= c ?-
) (setq face
'Info-title-3-face
))
2533 (t (setq face
'Info-title-4-face
)))
2534 (put-text-property (match-beginning 1) (match-end 1)
2536 ;; This is a serious problem for trying to handle multiple
2537 ;; frame types at once. We want this text to be invisible
2538 ;; on frames that can display the font above.
2539 (when (memq (framep (selected-frame)) '(x pc w32 mac
))
2540 (add-text-properties (match-end 1) (match-end 2)
2541 '(invisible t intangible t
))
2542 (add-text-properties (1- (match-end 1)) (match-end 2)
2544 (goto-char (point-min))
2545 (while (re-search-forward "\\*Note[ \n\t]+\\([^:]*\\):" nil t
)
2546 (if (= (char-after (1- (match-beginning 0))) ?
\") ; hack
2548 (add-text-properties (match-beginning 1) (match-end 1)
2550 mouse-face highlight
2551 help-echo
"mouse-2: go to this node"))))
2552 (goto-char (point-min))
2553 (if (and (search-forward "\n* Menu:" nil t
)
2554 (not (string-match "\\<Index\\>" Info-current-node
))
2555 ;; Don't take time to annotate huge menus
2556 (< (- (point-max) (point)) Info-fontify-maximum-menu-size
))
2558 (while (re-search-forward "^\\* +\\([^:\t\n]*\\):" nil t
)
2560 (if (memq n
'(5 9)) ; visual aids to help with 1-9 keys
2561 (put-text-property (match-beginning 0)
2562 (1+ (match-beginning 0))
2563 'face
'info-menu-5
))
2564 (add-text-properties (match-beginning 1) (match-end 1)
2566 mouse-face highlight
2567 help-echo
"mouse-2: go to this node")))))
2568 (Info-fontify-menu-headers)
2569 (set-buffer-modified-p nil
))))
2572 ;; When an Info buffer is killed, make sure the associated tags buffer
2574 (defun Info-kill-buffer ()
2575 (and (eq major-mode
'Info-mode
)
2576 Info-tag-table-buffer
2577 (kill-buffer Info-tag-table-buffer
)))
2579 (add-hook 'kill-buffer-hook
'Info-kill-buffer
)
2581 ;;; Speedbar support:
2582 ;; These functions permit speedbar to display the "tags" in the
2583 ;; current info node.
2584 (eval-when-compile (require 'speedbar
))
2586 (defvar Info-speedbar-key-map nil
2587 "Keymap used when in the info display mode.")
2589 (defun Info-install-speedbar-variables ()
2590 "Install those variables used by speedbar to enhance Info."
2591 (if Info-speedbar-key-map
2593 (setq Info-speedbar-key-map
(speedbar-make-specialized-keymap))
2595 ;; Basic tree features
2596 (define-key Info-speedbar-key-map
"e" 'speedbar-edit-line
)
2597 (define-key Info-speedbar-key-map
"\C-m" 'speedbar-edit-line
)
2598 (define-key Info-speedbar-key-map
"+" 'speedbar-expand-line
)
2599 (define-key Info-speedbar-key-map
"-" 'speedbar-contract-line
)
2602 (speedbar-add-expansion-list '("Info" Info-speedbar-menu-items
2603 Info-speedbar-key-map
2604 Info-speedbar-hierarchy-buttons
)))
2606 (defvar Info-speedbar-menu-items
2607 '(["Browse Node" speedbar-edit-line t
]
2608 ["Expand Node" speedbar-expand-line
2609 (save-excursion (beginning-of-line)
2610 (looking-at "[0-9]+: *.\\+. "))]
2611 ["Contract Node" speedbar-contract-line
2612 (save-excursion (beginning-of-line)
2613 (looking-at "[0-9]+: *.-. "))]
2615 "Additional menu-items to add to speedbar frame.")
2617 ;; Make sure our special speedbar major mode is loaded
2618 (if (featurep 'speedbar
)
2619 (Info-install-speedbar-variables)
2620 (add-hook 'speedbar-load-hook
'Info-install-speedbar-variables
))
2622 ;;; Info hierarchy display method
2624 (defun Info-speedbar-browser ()
2625 "Initialize speedbar to display an info node browser.
2626 This will add a speedbar major display mode."
2629 ;; Make sure that speedbar is active
2630 (speedbar-frame-mode 1)
2631 ;; Now, throw us into Info mode on speedbar.
2632 (speedbar-change-initial-expansion-list "Info")
2635 (eval-when-compile (defvar speedbar-attached-frame
))
2637 (defun Info-speedbar-hierarchy-buttons (directory depth
&optional node
)
2638 "Display an Info directory hierarchy in speedbar.
2639 DIRECTORY is the current directory in the attached frame.
2640 DEPTH is the current indentation depth.
2641 NODE is an optional argument that is used to represent the
2642 specific node to expand."
2644 (save-excursion (goto-char (point-min))
2645 (let ((case-fold-search t
))
2646 (looking-at "Info Nodes:"))))
2647 ;; Update our "current node" maybe?
2649 ;; We cannot use the generic list code, that depends on all leaves
2650 ;; being known at creation time.
2652 (speedbar-with-writable (insert "Info Nodes:\n")))
2653 (let ((completions nil
)
2654 (cf (selected-frame)))
2655 (select-frame speedbar-attached-frame
)
2656 (save-window-excursion
2658 (Info-speedbar-fetch-file-nodes (or node
'"(dir)top"))))
2661 (speedbar-with-writable
2663 (speedbar-make-tag-line 'bracket ?
+ 'Info-speedbar-expand-node
2664 (cdr (car completions
))
2665 (car (car completions
))
2666 'Info-speedbar-goto-node
2667 (cdr (car completions
))
2669 (setq completions
(cdr completions
)))
2673 (defun Info-speedbar-goto-node (text node indent
)
2674 "When user clicks on TEXT, go to an info NODE.
2675 The INDENT level is ignored."
2676 (select-frame speedbar-attached-frame
)
2677 (let* ((buff (or (get-buffer "*info*")
2678 (progn (info) (get-buffer "*info*"))))
2679 (bwin (get-buffer-window buff
0)))
2682 (select-window bwin
)
2683 (raise-frame (window-frame bwin
)))
2684 (if speedbar-power-click
2685 (let ((pop-up-frames t
)) (select-window (display-buffer buff
)))
2686 (select-frame speedbar-attached-frame
)
2687 (switch-to-buffer buff
)))
2688 (let ((junk (string-match "^(\\([^)]+\\))\\([^.]+\\)$" node
))
2689 (file (match-string 1 node
))
2690 (node (match-string 2 node
)))
2691 (Info-find-node file node
)
2692 ;; If we do a find-node, and we were in info mode, restore
2693 ;; the old default method. Once we are in info mode, it makes
2694 ;; sense to return to whatever method the user was using before.
2695 (if (string= speedbar-initial-expansion-list-name
"Info")
2696 (speedbar-change-initial-expansion-list
2697 speedbar-previously-used-expansion-list-name
)))))
2699 (defun Info-speedbar-expand-node (text token indent
)
2700 "Expand the node the user clicked on.
2701 TEXT is the text of the button we clicked on, a + or - item.
2702 TOKEN is data related to this node (NAME . FILE).
2703 INDENT is the current indentation depth."
2704 (cond ((string-match "+" text
) ;we have to expand this file
2705 (speedbar-change-expand-button-char ?-
)
2706 (if (speedbar-with-writable
2708 (end-of-line) (forward-char 1)
2709 (Info-speedbar-hierarchy-buttons nil
(1+ indent
) token
)))
2710 (speedbar-change-expand-button-char ?-
)
2711 (speedbar-change-expand-button-char ??
)))
2712 ((string-match "-" text
) ;we have to contract this node
2713 (speedbar-change-expand-button-char ?
+)
2714 (speedbar-delete-subblock indent
))
2715 (t (error "Ooops... not sure what to do")))
2716 (speedbar-center-buffer-smartly))
2718 (defun Info-speedbar-fetch-file-nodes (nodespec)
2719 "Fetch the subnodes from the info NODESPEC.
2720 NODESPEC is a string of the form: (file)node.
2721 Optional THISFILE represends the filename of"
2723 ;; Set up a buffer we can use to fake-out Info.
2724 (set-buffer (get-buffer-create "*info-browse-tmp*"))
2725 (if (not (equal major-mode
'Info-mode
))
2727 ;; Get the node into this buffer
2728 (let ((junk (string-match "^(\\([^)]+\\))\\([^.]+\\)$" nodespec
))
2729 (file (match-string 1 nodespec
))
2730 (node (match-string 2 nodespec
)))
2731 (Info-find-node file node
))
2732 ;; Scan the created buffer
2733 (goto-char (point-min))
2734 (let ((completions nil
)
2735 (case-fold-search t
)
2736 (thisfile (progn (string-match "^(\\([^)]+\\))" nodespec
)
2737 (match-string 1 nodespec
))))
2738 ;; Always skip the first one...
2739 (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t
)
2740 (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t
)
2741 (let ((name (match-string 1)))
2742 (if (looking-at " *\\(([^)]+)[^.\n]+\\)\\.")
2743 (setq name
(cons name
(match-string 1)))
2744 (if (looking-at " *\\(([^)]+)\\)\\.")
2745 (setq name
(cons name
(concat (match-string 1) "Top")))
2746 (if (looking-at " \\([^.]+\\).")
2748 (cons name
(concat "(" thisfile
")" (match-string 1))))
2749 (setq name
(cons name
(concat "(" thisfile
")" name
))))))
2750 (setq completions
(cons name completions
))))
2751 (nreverse completions
))))
2753 ;;; Info mode node listing
2754 (defun Info-speedbar-buttons (buffer)
2755 "Create a speedbar display to help navigation in an Info file.
2756 BUFFER is the buffer speedbar is requesting buttons for."
2757 (if (save-excursion (goto-char (point-min))
2758 (let ((case-fold-search t
))
2759 (not (looking-at "Info Nodes:"))))
2761 (Info-speedbar-hierarchy-buttons nil
0)
2764 (dolist (mess '("^Node has no Previous$"
2765 "^No menu in this node$"
2766 "^Node has no Next$"
2767 "^No cross-references in this node^"
2769 "^No \".*\" in index$"))
2770 (add-to-list 'debug-ignored-errors mess
))
2774 ;;; info.el ends here