entered into RCS
[emacs.git] / lisp / info.el
blob28755da156e71e6d5b09938b3ea5e8c56077d384
1 ;;; info.el --- info package for Emacs.
3 ;; Copyright (C) 1985, 1986, 1992, 1993, 1994 Free Software Foundation, Inc.
5 ;; Maintainer: FSF
6 ;; Keywords: help
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
25 ;;; Commentary:
27 ;; Note that nowadays we expect info files to be made using makeinfo.
29 ;;; Code:
31 (defvar Info-history nil
32 "List of info nodes user has visited.
33 Each element of list is a list (FILENAME NODENAME BUFFERPOS).")
35 (defvar Info-enable-edit nil
36 "*Non-nil means the \\<Info-mode-map>\\[Info-edit] command in Info can edit the current node.
37 This is convenient if you want to write info files by hand.
38 However, we recommend that you not do this.
39 It is better to write a Texinfo file and generate the Info file from that,
40 because that gives you a printed manual as well.")
42 (defvar Info-enable-active-nodes nil
43 "Non-nil allows Info to execute Lisp code associated with nodes.
44 The Lisp code is executed when the node is selected.")
45 (put 'Info-enable-active-nodes 'risky-local-variable t)
47 (defvar Info-fontify t
48 "*Non-nil enables highlighting and fonts in Info nodes.")
50 (defvar Info-fontify-maximum-menu-size 30000
51 "*Maximum size of menu to fontify if `Info-fontify' is non-nil.")
53 (defvar Info-directory-list
54 (let ((path (getenv "INFOPATH"))
55 ;; This is for older Emacs versions
56 ;; which might get this info.el from the Texinfo distribution.
57 (path-separator (if (boundp 'path-separator) path-separator
58 (if (eq system-type 'ms-dos) ";" ":")))
59 (source (expand-file-name "info/" source-directory))
60 (sibling (if installation-directory
61 (expand-file-name "info/" installation-directory)))
62 alternative)
63 (if path
64 (let ((list nil)
65 idx)
66 (while (> (length path) 0)
67 (setq idx (or (string-match path-separator path) (length path))
68 list (cons (substring path 0 idx) list)
69 path (substring path (min (1+ idx)
70 (length path)))))
71 (nreverse list))
72 (if (and sibling (file-exists-p sibling))
73 (setq alternative sibling)
74 (setq alternative source))
75 (if (or (member alternative Info-default-directory-list)
76 (not (file-exists-p alternative))
77 ;; On DOS/NT, we use movable executables always,
78 ;; and we must always find the Info dir at run time.
79 (if (or (eq system-type 'ms-dos) (eq system-type 'windows-nt))
80 nil
81 ;; Use invocation-directory for Info only if we used it for
82 ;; exec-directory also.
83 (not (string= exec-directory
84 (expand-file-name "lib-src/"
85 installation-directory)))))
86 Info-default-directory-list
87 (reverse (cons alternative
88 (cdr (reverse Info-default-directory-list)))))))
89 "List of directories to search for Info documentation files.
90 nil means not yet initialized. In this case, Info uses the environment
91 variable INFOPATH to initialize it, or `Info-default-directory-list'
92 if there is no INFOPATH variable in the environment.
93 The last element of `Info-default-directory-list' is the directory
94 where Emacs installs the Info files that come with it.
96 If you run the Emacs executable from the `src' directory in the Emacs
97 source tree, the `info' directory in the source tree is used as the last
98 element, in place of the installation Info directory. This is useful
99 when you run a version of Emacs without installing it.")
101 (defvar Info-additional-directory-list nil
102 "List of additional directories to search for Info documentation files.
103 These directories are not searched for merging the `dir' file.")
105 (defvar Info-current-file nil
106 "Info file that Info is now looking at, or nil.
107 This is the name that was specified in Info, not the actual file name.
108 It doesn't contain directory names or file name extensions added by Info.")
110 (defvar Info-current-subfile nil
111 "Info subfile that is actually in the *info* buffer now,
112 or nil if current info file is not split into subfiles.")
114 (defvar Info-current-node nil
115 "Name of node that Info is now looking at, or nil.")
117 (defvar Info-tag-table-marker (make-marker)
118 "Marker pointing at beginning of current Info file's tag table.
119 Marker points nowhere if file has no tag table.")
121 (defvar Info-current-file-completions nil
122 "Cached completion list for current Info file.")
124 (defvar Info-index-alternatives nil
125 "List of possible matches for last Info-index command.")
127 (defvar Info-standalone nil
128 "Non-nil if Emacs was started solely as an Info browser.")
130 (defvar Info-suffix-list
131 (if (eq system-type 'ms-dos)
132 '( (".gz" . "gunzip")
133 (".z" . "gunzip")
134 (".inf" . nil)
135 ("" . nil))
136 '( (".info.Z" . "uncompress")
137 (".info.Y" . "unyabba")
138 (".info.gz" . "gunzip")
139 (".info.z" . "gunzip")
140 (".info" . nil)
141 (".Z" . "uncompress")
142 (".Y" . "unyabba")
143 (".gz" . "gunzip")
144 (".z" . "gunzip")
145 ("" . nil)))
146 "List of file name suffixes and associated decoding commands.
147 Each entry should be (SUFFIX . STRING); the file is given to
148 the command as standard input. If STRING is nil, no decoding is done.
149 Because the SUFFIXes are tried in order, the empty string should
150 be last in the list.")
152 ;; Concatenate SUFFIX onto FILENAME. SUFFIX should start with a dot.
153 ;; First, on ms-dos, delete some of the extension in FILENAME
154 ;; to make room.
155 (defun info-insert-file-contents-1 (filename suffix)
156 (if (not (eq system-type 'ms-dos))
157 (concat filename suffix)
158 (let* ((sans-exts (file-name-sans-extension filename))
159 ;; How long is the extension in FILENAME (not counting the dot).
160 (ext-len (max 0 (- (length filename) (length sans-exts) 1)))
161 ext-left)
162 ;; SUFFIX starts with a dot. If FILENAME already has one,
163 ;; get rid of the one in SUFFIX (unless suffix is empty).
164 (or (and (<= ext-len 0)
165 (not (eq (aref filename (1- (length filename))) ?.)))
166 (= (length suffix) 0)
167 (setq suffix (substring suffix 1)))
168 ;; How many chars of that extension should we keep?
169 (setq ext-left (min ext-len (max 0 (- 3 (length suffix)))))
170 ;; Get rid of the rest of the extension, and add SUFFIX.
171 (concat (substring filename 0 (- (length filename)
172 (- ext-len ext-left)))
173 suffix))))
175 (defun info-insert-file-contents (filename &optional visit)
176 "Insert the contents of an info file in the current buffer.
177 Do the right thing if the file has been compressed or zipped."
178 (let ((tail Info-suffix-list)
179 fullname decoder)
180 (if (file-exists-p filename)
181 ;; FILENAME exists--see if that name contains a suffix.
182 ;; If so, set DECODE accordingly.
183 (progn
184 (while (and tail
185 (not (string-match
186 (concat (regexp-quote (car (car tail))) "$")
187 filename)))
188 (setq tail (cdr tail)))
189 (setq fullname filename
190 decoder (cdr (car tail))))
191 ;; Try adding suffixes to FILENAME and see if we can find something.
192 (while (and tail
193 (not (file-exists-p (info-insert-file-contents-1
194 filename (car (car tail))))))
195 (setq tail (cdr tail)))
196 ;; If we found a file with a suffix, set DECODER according to the suffix
197 ;; and set FULLNAME to the file's actual name.
198 (setq fullname (info-insert-file-contents-1 filename (car (car tail)))
199 decoder (cdr (car tail)))
200 (or tail
201 (error "Can't find %s or any compressed version of it" filename)))
202 ;; check for conflict with jka-compr
203 (if (and (featurep 'jka-compr)
204 (jka-compr-installed-p)
205 (jka-compr-get-compression-info fullname))
206 (setq decoder nil))
207 (insert-file-contents fullname visit)
208 (if decoder
209 (let ((buffer-read-only nil)
210 (default-directory (or (file-name-directory fullname)
211 default-directory)))
212 (call-process-region (point-min) (point-max) decoder t t)))))
214 ;;;###autoload (add-hook 'same-window-buffer-names "*info*")
216 ;;;###autoload
217 (defun info (&optional file)
218 "Enter Info, the documentation browser.
219 Optional argument FILE specifies the file to examine;
220 the default is the top-level directory of Info.
222 In interactive use, a prefix argument directs this command
223 to read a file name from the minibuffer.
225 The search path for Info files is in the variable `Info-directory-list'.
226 The top-level Info directory is made by combining all the files named `dir'
227 in all the directories in that path."
228 (interactive (if current-prefix-arg
229 (list (read-file-name "Info file name: " nil nil t))))
230 (if file
231 (Info-goto-node (concat "(" file ")"))
232 (if (get-buffer "*info*")
233 (pop-to-buffer "*info*")
234 (Info-directory))))
236 ;;;###autoload
237 (defun info-standalone ()
238 "Run Emacs as a standalone Info reader.
239 Usage: emacs -f info-standalone [filename]
240 In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
241 (setq Info-standalone t)
242 (if (and command-line-args-left
243 (not (string-match "^-" (car command-line-args-left))))
244 (condition-case err
245 (progn
246 (info (car command-line-args-left))
247 (setq command-line-args-left (cdr command-line-args-left)))
248 (error (send-string-to-terminal
249 (format "%s\n" (if (eq (car-safe err) 'error)
250 (nth 1 err) err)))
251 (save-buffers-kill-emacs)))
252 (info)))
254 ;; Go to an info node specified as separate filename and nodename.
255 ;; no-going-back is non-nil if recovering from an error in this function;
256 ;; it says do not attempt further (recursive) error recovery.
257 (defun Info-find-node (filename nodename &optional no-going-back)
258 ;; Convert filename to lower case if not found as specified.
259 ;; Expand it.
260 (if filename
261 (let (temp temp-downcase found)
262 (setq filename (substitute-in-file-name filename))
263 (if (string= (downcase filename) "dir")
264 (setq found t)
265 (let ((dirs (if (string-match "^\\./" filename)
266 ;; If specified name starts with `./'
267 ;; then just try current directory.
268 '("./")
269 (if (file-name-absolute-p filename)
270 ;; No point in searching for an
271 ;; absolute file name
272 '(nil)
273 (if Info-additional-directory-list
274 (append Info-directory-list
275 Info-additional-directory-list)
276 Info-directory-list)))))
277 ;; Search the directory list for file FILENAME.
278 (while (and dirs (not found))
279 (setq temp (expand-file-name filename (car dirs)))
280 (setq temp-downcase
281 (expand-file-name (downcase filename) (car dirs)))
282 ;; Try several variants of specified name.
283 (let ((suffix-list Info-suffix-list))
284 (while (and suffix-list (not found))
285 (cond ((file-exists-p
286 (info-insert-file-contents-1
287 temp (car (car suffix-list))))
288 (setq found temp))
289 ((file-exists-p
290 (info-insert-file-contents-1
291 temp-downcase (car (car suffix-list))))
292 (setq found temp-downcase)))
293 (setq suffix-list (cdr suffix-list))))
294 (setq dirs (cdr dirs)))))
295 (if found
296 (setq filename found)
297 (error "Info file %s does not exist" filename))))
298 ;; Record the node we are leaving.
299 (if (and Info-current-file (not no-going-back))
300 (setq Info-history
301 (cons (list Info-current-file Info-current-node (point))
302 Info-history)))
303 ;; Go into info buffer.
304 (pop-to-buffer "*info*")
305 (buffer-disable-undo (current-buffer))
306 (or (eq major-mode 'Info-mode)
307 (Info-mode))
308 (widen)
309 (setq Info-current-node nil)
310 (unwind-protect
311 (progn
312 ;; Switch files if necessary
313 (or (null filename)
314 (equal Info-current-file filename)
315 (let ((buffer-read-only nil))
316 (setq Info-current-file nil
317 Info-current-subfile nil
318 Info-current-file-completions nil
319 Info-index-alternatives nil
320 buffer-file-name nil)
321 (erase-buffer)
322 (if (eq filename t)
323 (Info-insert-dir)
324 (info-insert-file-contents filename t)
325 (setq default-directory (file-name-directory filename)))
326 (set-buffer-modified-p nil)
327 ;; See whether file has a tag table. Record the location if yes.
328 (set-marker Info-tag-table-marker nil)
329 (goto-char (point-max))
330 (forward-line -8)
331 ;; Use string-equal, not equal, to ignore text props.
332 (or (string-equal nodename "*")
333 (not (search-forward "\^_\nEnd tag table\n" nil t))
334 (let (pos)
335 ;; We have a tag table. Find its beginning.
336 ;; Is this an indirect file?
337 (search-backward "\nTag table:\n")
338 (setq pos (point))
339 (if (save-excursion
340 (forward-line 2)
341 (looking-at "(Indirect)\n"))
342 ;; It is indirect. Copy it to another buffer
343 ;; and record that the tag table is in that buffer.
344 (save-excursion
345 (let ((buf (current-buffer)))
346 (set-buffer (get-buffer-create " *info tag table*"))
347 (buffer-disable-undo (current-buffer))
348 (setq case-fold-search t)
349 (erase-buffer)
350 (insert-buffer-substring buf)
351 (set-marker Info-tag-table-marker
352 (match-end 0))))
353 (set-marker Info-tag-table-marker pos))))
354 (setq Info-current-file
355 (if (eq filename t) "dir" filename))))
356 ;; Use string-equal, not equal, to ignore text props.
357 (if (string-equal nodename "*")
358 (progn (setq Info-current-node nodename)
359 (Info-set-mode-line))
360 ;; Search file for a suitable node.
361 (let ((guesspos (point-min))
362 (regexp (concat "Node: *" (regexp-quote nodename) " *[,\t\n\177]")))
363 ;; First get advice from tag table if file has one.
364 ;; Also, if this is an indirect info file,
365 ;; read the proper subfile into this buffer.
366 (if (marker-position Info-tag-table-marker)
367 (save-excursion
368 (set-buffer (marker-buffer Info-tag-table-marker))
369 (goto-char Info-tag-table-marker)
370 (if (re-search-forward regexp nil t)
371 (progn
372 (setq guesspos (read (current-buffer)))
373 ;; If this is an indirect file,
374 ;; determine which file really holds this node
375 ;; and read it in.
376 (if (not (eq (current-buffer) (get-buffer "*info*")))
377 (setq guesspos
378 (Info-read-subfile guesspos))))
379 (error "No such node: %s" nodename))))
380 (goto-char (max (point-min) (- guesspos 1000)))
381 ;; Now search from our advised position (or from beg of buffer)
382 ;; to find the actual node.
383 (catch 'foo
384 (while (search-forward "\n\^_" nil t)
385 (forward-line 1)
386 (let ((beg (point)))
387 (forward-line 1)
388 (if (re-search-backward regexp beg t)
389 (throw 'foo t))))
390 (error "No such node: %s" nodename)))
391 (Info-select-node)))
392 ;; If we did not finish finding the specified node,
393 ;; go back to the previous one.
394 (or Info-current-node no-going-back (null Info-history)
395 (let ((hist (car Info-history)))
396 (setq Info-history (cdr Info-history))
397 (Info-find-node (nth 0 hist) (nth 1 hist) t)
398 (goto-char (nth 2 hist)))))
399 (goto-char (point-min)))
401 ;; Cache the contents of the (virtual) dir file, once we have merged
402 ;; it for the first time, so we can save time subsequently.
403 (defvar Info-dir-contents nil)
405 ;; Cache for the directory we decided to use for the default-directory
406 ;; of the merged dir text.
407 (defvar Info-dir-contents-directory nil)
409 ;; Record the file attributes of all the files from which we
410 ;; constructed Info-dir-contents.
411 (defvar Info-dir-file-attributes nil)
413 ;; Construct the Info directory node by merging the files named `dir'
414 ;; from various directories. Set the *info* buffer's
415 ;; default-directory to the first directory we actually get any text
416 ;; from.
417 (defun Info-insert-dir ()
418 (if (and Info-dir-contents Info-dir-file-attributes
419 ;; Verify that none of the files we used has changed
420 ;; since we used it.
421 (eval (cons 'and
422 (mapcar '(lambda (elt)
423 (let ((curr (file-attributes (car elt))))
424 ;; Don't compare the access time.
425 (if curr (setcar (nthcdr 4 curr) 0))
426 (setcar (nthcdr 4 (cdr elt)) 0)
427 (equal (cdr elt) curr)))
428 Info-dir-file-attributes))))
429 (insert Info-dir-contents)
430 (let ((dirs Info-directory-list)
431 buffers buffer others nodes dirs-done)
433 (setq Info-dir-file-attributes nil)
435 ;; Search the directory list for the directory file.
436 (while dirs
437 (let ((truename (file-truename (expand-file-name (car dirs)))))
438 (or (member truename dirs-done)
439 (member (directory-file-name truename) dirs-done)
440 ;; Try several variants of specified name.
441 ;; Try upcasing, appending `.info', or both.
442 (let* (file
443 (attrs
445 (progn (setq file (expand-file-name "dir" truename))
446 (file-attributes file))
447 (progn (setq file (expand-file-name "DIR" truename))
448 (file-attributes file))
449 (progn (setq file (expand-file-name "dir.info" truename))
450 (file-attributes file))
451 (progn (setq file (expand-file-name "DIR.INFO" truename))
452 (file-attributes file)))))
453 (setq dirs-done
454 (cons truename
455 (cons (directory-file-name truename)
456 dirs-done)))
457 (if attrs
458 (save-excursion
459 (or buffers
460 (message "Composing main Info directory..."))
461 (set-buffer (generate-new-buffer "info dir"))
462 (insert-file-contents file)
463 (setq buffers (cons (current-buffer) buffers)
464 Info-dir-file-attributes
465 (cons (cons file attrs)
466 Info-dir-file-attributes))))))
467 (or (cdr dirs) (setq Info-dir-contents-directory (car dirs)))
468 (setq dirs (cdr dirs))))
470 (or buffers
471 (error "Can't find the Info directory node"))
472 ;; Distinguish the dir file that comes with Emacs from all the
473 ;; others. Yes, that is really what this is supposed to do.
474 ;; If it doesn't work, fix it.
475 (setq buffer (car buffers)
476 others (cdr buffers))
478 ;; Insert the entire original dir file as a start; note that we've
479 ;; already saved its default directory to use as the default
480 ;; directory for the whole concatenation.
481 (insert-buffer buffer)
483 ;; Look at each of the other buffers one by one.
484 (while others
485 (let ((other (car others)))
486 ;; In each, find all the menus.
487 (save-excursion
488 (set-buffer other)
489 (goto-char (point-min))
490 ;; Find each menu, and add an elt to NODES for it.
491 (while (re-search-forward "^\\* Menu:" nil t)
492 (let (beg nodename end)
493 (forward-line 1)
494 (setq beg (point))
495 (search-backward "\n\^_")
496 (search-forward "Node: ")
497 (setq nodename (Info-following-node-name))
498 (search-forward "\n\^_" nil 'move)
499 (beginning-of-line)
500 (setq end (point))
501 (setq nodes (cons (list nodename other beg end) nodes))))))
502 (setq others (cdr others)))
503 ;; Add to the main menu a menu item for each other node.
504 (re-search-forward "^\\* Menu:")
505 (forward-line 1)
506 (let ((menu-items '("top"))
507 (nodes nodes)
508 (case-fold-search t)
509 (end (save-excursion (search-forward "\^_" nil t) (point))))
510 (while nodes
511 (let ((nodename (car (car nodes))))
512 (save-excursion
513 (or (member (downcase nodename) menu-items)
514 (re-search-forward (concat "^\\* "
515 (regexp-quote nodename)
516 "::")
517 end t)
518 (progn
519 (insert "* " nodename "::" "\n")
520 (setq menu-items (cons nodename menu-items))))))
521 (setq nodes (cdr nodes))))
522 ;; Now take each node of each of the other buffers
523 ;; and merge it into the main buffer.
524 (while nodes
525 (let ((nodename (car (car nodes))))
526 (goto-char (point-min))
527 ;; Find the like-named node in the main buffer.
528 (if (re-search-forward (concat "\n\^_.*\n.*Node: "
529 (regexp-quote nodename)
530 "[,\n\t]")
531 nil t)
532 (progn
533 (search-forward "\n\^_" nil 'move)
534 (beginning-of-line)
535 (insert "\n"))
536 ;; If none exists, add one.
537 (goto-char (point-max))
538 (insert "\^_\nFile: dir\tNode: " nodename "\n\n* Menu:\n\n"))
539 ;; Merge the text from the other buffer's menu
540 ;; into the menu in the like-named node in the main buffer.
541 (apply 'insert-buffer-substring (cdr (car nodes))))
542 (setq nodes (cdr nodes)))
543 ;; Kill all the buffers we just made.
544 (while buffers
545 (kill-buffer (car buffers))
546 (setq buffers (cdr buffers)))
547 (message "Composing main Info directory...done"))
548 (setq Info-dir-contents (buffer-string)))
549 (setq default-directory Info-dir-contents-directory))
551 (defun Info-read-subfile (nodepos)
552 (set-buffer (marker-buffer Info-tag-table-marker))
553 (goto-char (point-min))
554 (search-forward "\n\^_")
555 (let (lastfilepos
556 lastfilename)
557 (forward-line 2)
558 (catch 'foo
559 (while (not (looking-at "\^_"))
560 (if (not (eolp))
561 (let ((beg (point))
562 thisfilepos thisfilename)
563 (search-forward ": ")
564 (setq thisfilename (buffer-substring beg (- (point) 2)))
565 (setq thisfilepos (read (current-buffer)))
566 ;; read in version 19 stops at the end of number.
567 ;; Advance to the next line.
568 (forward-line 1)
569 (if (> thisfilepos nodepos)
570 (throw 'foo t))
571 (setq lastfilename thisfilename)
572 (setq lastfilepos thisfilepos))
573 (forward-line 1))))
574 (set-buffer (get-buffer "*info*"))
575 (or (equal Info-current-subfile lastfilename)
576 (let ((buffer-read-only nil))
577 (setq buffer-file-name nil)
578 (widen)
579 (erase-buffer)
580 (info-insert-file-contents lastfilename)
581 (set-buffer-modified-p nil)
582 (setq Info-current-subfile lastfilename)))
583 (goto-char (point-min))
584 (search-forward "\n\^_")
585 (+ (- nodepos lastfilepos) (point))))
587 ;; Select the info node that point is in.
588 (defun Info-select-node ()
589 (save-excursion
590 ;; Find beginning of node.
591 (search-backward "\n\^_")
592 (forward-line 2)
593 ;; Get nodename spelled as it is in the node.
594 (re-search-forward "Node:[ \t]*")
595 (setq Info-current-node
596 (buffer-substring-no-properties (point)
597 (progn
598 (skip-chars-forward "^,\t\n")
599 (point))))
600 (Info-set-mode-line)
601 ;; Find the end of it, and narrow.
602 (beginning-of-line)
603 (let (active-expression)
604 (narrow-to-region (point)
605 (if (re-search-forward "\n[\^_\f]" nil t)
606 (prog1
607 (1- (point))
608 (if (looking-at "[\n\^_\f]*execute: ")
609 (progn
610 (goto-char (match-end 0))
611 (setq active-expression
612 (read (current-buffer))))))
613 (point-max)))
614 (if Info-enable-active-nodes (eval active-expression))
615 (if Info-fontify (Info-fontify-node))
616 (run-hooks 'Info-selection-hook))))
618 (defun Info-set-mode-line ()
619 (setq mode-line-buffer-identification
620 (concat
621 "Info: ("
622 (if Info-current-file
623 (file-name-nondirectory Info-current-file)
626 (or Info-current-node ""))))
628 ;; Go to an info node specified with a filename-and-nodename string
629 ;; of the sort that is found in pointers in nodes.
631 (defun Info-goto-node (nodename)
632 "Go to info node named NAME. Give just NODENAME or (FILENAME)NODENAME."
633 (interactive (list (Info-read-node-name "Goto node: ")))
634 (let (filename)
635 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
636 nodename)
637 (setq filename (if (= (match-beginning 1) (match-end 1))
639 (substring nodename (match-beginning 2) (match-end 2)))
640 nodename (substring nodename (match-beginning 3) (match-end 3)))
641 (let ((trim (string-match "\\s *\\'" filename)))
642 (if trim (setq filename (substring filename 0 trim))))
643 (let ((trim (string-match "\\s *\\'" nodename)))
644 (if trim (setq nodename (substring nodename 0 trim))))
645 (if transient-mark-mode (deactivate-mark))
646 (Info-find-node (if (equal filename "") nil filename)
647 (if (equal nodename "") "Top" nodename))))
649 ;; This function is used as the "completion table" while reading a node name.
650 ;; It does completion using the alist in completion-table
651 ;; unless STRING starts with an open-paren.
652 (defun Info-read-node-name-1 (string predicate code)
653 (let ((no-completion (and (> (length string) 0) (eq (aref string 0) ?\())))
654 (cond ((eq code nil)
655 (if no-completion
656 string
657 (try-completion string completion-table predicate)))
658 ((eq code t)
659 (if no-completion
661 (all-completions string completion-table predicate)))
662 ((eq code 'lambda)
663 (if no-completion
665 (assoc string completion-table))))))
667 (defun Info-read-node-name (prompt &optional default)
668 (let* ((completion-ignore-case t)
669 (completion-table (Info-build-node-completions))
670 (nodename (completing-read prompt 'Info-read-node-name-1)))
671 (if (equal nodename "")
672 (or default
673 (Info-read-node-name prompt))
674 nodename)))
676 (defun Info-build-node-completions ()
677 (or Info-current-file-completions
678 (let ((compl nil))
679 (save-excursion
680 (save-restriction
681 (if (marker-buffer Info-tag-table-marker)
682 (progn
683 (set-buffer (marker-buffer Info-tag-table-marker))
684 (widen)
685 (goto-char Info-tag-table-marker)
686 (while (re-search-forward "\nNode: \\(.*\\)\177" nil t)
687 (setq compl
688 (cons (list (buffer-substring (match-beginning 1)
689 (match-end 1)))
690 compl))))
691 (widen)
692 (goto-char (point-min))
693 (while (search-forward "\n\^_" nil t)
694 (forward-line 1)
695 (let ((beg (point)))
696 (forward-line 1)
697 (if (re-search-backward "Node: *\\([^,\n]*\\) *[,\n\t]"
698 beg t)
699 (setq compl
700 (cons (list (buffer-substring (match-beginning 1)
701 (match-end 1)))
702 compl))))))))
703 (setq Info-current-file-completions compl))))
705 (defun Info-restore-point (hl)
706 "If this node has been visited, restore the point value when we left."
707 (while hl
708 (if (and (equal (nth 0 (car hl)) Info-current-file)
709 ;; Use string-equal, not equal, to ignore text props.
710 (string-equal (nth 1 (car hl)) Info-current-node))
711 (progn
712 (goto-char (nth 2 (car hl)))
713 (setq hl nil)) ;terminate the while at next iter
714 (setq hl (cdr hl)))))
716 (defvar Info-last-search nil
717 "Default regexp for \\<Info-mode-map>\\[Info-search] command to search for.")
719 (defun Info-search (regexp)
720 "Search for REGEXP, starting from point, and select node it's found in."
721 (interactive "sSearch (regexp): ")
722 (if transient-mark-mode (deactivate-mark))
723 (if (equal regexp "")
724 (setq regexp Info-last-search)
725 (setq Info-last-search regexp))
726 (let ((found ()) current
727 (onode Info-current-node)
728 (ofile Info-current-file)
729 (opoint (point))
730 (osubfile Info-current-subfile))
731 (save-excursion
732 (save-restriction
733 (widen)
734 (if (null Info-current-subfile)
735 (progn (re-search-forward regexp) (setq found (point)))
736 (condition-case err
737 (progn (re-search-forward regexp) (setq found (point)))
738 (search-failed nil)))))
739 (if (not found) ;can only happen in subfile case -- else would have erred
740 (unwind-protect
741 (let ((list ()))
742 (set-buffer (marker-buffer Info-tag-table-marker))
743 (goto-char (point-min))
744 (search-forward "\n\^_\nIndirect:")
745 (save-restriction
746 (narrow-to-region (point)
747 (progn (search-forward "\n\^_")
748 (1- (point))))
749 (goto-char (point-min))
750 (search-forward (concat "\n" osubfile ": "))
751 (beginning-of-line)
752 (while (not (eobp))
753 (re-search-forward "\\(^.*\\): [0-9]+$")
754 (goto-char (+ (match-end 1) 2))
755 (setq list (cons (cons (read (current-buffer))
756 (buffer-substring (match-beginning 1)
757 (match-end 1)))
758 list))
759 (goto-char (1+ (match-end 0))))
760 (setq list (nreverse list)
761 current (car (car list))
762 list (cdr list)))
763 (while list
764 (message "Searching subfile %s..." (cdr (car list)))
765 (Info-read-subfile (car (car list)))
766 (setq list (cdr list))
767 ;; (goto-char (point-min))
768 (if (re-search-forward regexp nil t)
769 (setq found (point) list ())))
770 (if found
771 (message "")
772 (signal 'search-failed (list regexp))))
773 (if (not found)
774 (progn (Info-read-subfile opoint)
775 (goto-char opoint)
776 (Info-select-node)))))
777 (widen)
778 (goto-char found)
779 (Info-select-node)
780 ;; Use string-equal, not equal, to ignore text props.
781 (or (and (string-equal onode Info-current-node)
782 (equal ofile Info-current-file))
783 (setq Info-history (cons (list ofile onode opoint)
784 Info-history)))))
786 ;; Extract the value of the node-pointer named NAME.
787 ;; If there is none, use ERRORNAME in the error message;
788 ;; if ERRORNAME is nil, just return nil.
789 (defun Info-extract-pointer (name &optional errorname)
790 (save-excursion
791 (goto-char (point-min))
792 (forward-line 1)
793 (if (re-search-backward (concat name ":") nil t)
794 (progn
795 (goto-char (match-end 0))
796 (Info-following-node-name))
797 (if (eq errorname t)
799 (error "Node has no %s" (capitalize (or errorname name)))))))
801 ;; Return the node name in the buffer following point.
802 ;; ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
803 ;; saying which chas may appear in the node name.
804 (defun Info-following-node-name (&optional allowedchars)
805 (skip-chars-forward " \t")
806 (buffer-substring-no-properties
807 (point)
808 (progn
809 (while (looking-at (concat "[" (or allowedchars "^,\t\n") "]"))
810 (skip-chars-forward (concat (or allowedchars "^,\t\n") "("))
811 (if (looking-at "(")
812 (skip-chars-forward "^)")))
813 (skip-chars-backward " ")
814 (point))))
816 (defun Info-next ()
817 "Go to the next node of this node."
818 (interactive)
819 (Info-goto-node (Info-extract-pointer "next")))
821 (defun Info-prev ()
822 "Go to the previous node of this node."
823 (interactive)
824 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous")))
826 (defun Info-up ()
827 "Go to the superior node of this node."
828 (interactive)
829 (Info-goto-node (Info-extract-pointer "up"))
830 (Info-restore-point Info-history))
832 (defun Info-last ()
833 "Go back to the last node visited."
834 (interactive)
835 (or Info-history
836 (error "This is the first Info node you looked at"))
837 (let (filename nodename opoint)
838 (setq filename (car (car Info-history)))
839 (setq nodename (car (cdr (car Info-history))))
840 (setq opoint (car (cdr (cdr (car Info-history)))))
841 (setq Info-history (cdr Info-history))
842 (Info-find-node filename nodename)
843 (setq Info-history (cdr Info-history))
844 (goto-char opoint)))
846 (defun Info-directory ()
847 "Go to the Info directory node."
848 (interactive)
849 (Info-find-node "dir" "top"))
851 (defun Info-follow-reference (footnotename)
852 "Follow cross reference named NAME to the node it refers to.
853 NAME may be an abbreviation of the reference name."
854 (interactive
855 (let ((completion-ignore-case t)
856 completions default alt-default (start-point (point)) str i bol eol)
857 (save-excursion
858 ;; Store end and beginning of line.
859 (end-of-line)
860 (setq eol (point))
861 (beginning-of-line)
862 (setq bol (point))
864 (goto-char (point-min))
865 (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t)
866 (setq str (buffer-substring
867 (match-beginning 1)
868 (1- (point))))
869 ;; See if this one should be the default.
870 (and (null default)
871 (<= (match-beginning 0) start-point)
872 (<= start-point (point))
873 (setq default t))
874 ;; See if this one should be the alternate default.
875 (and (null alt-default)
876 (and (<= bol (match-beginning 0))
877 (<= (point) eol))
878 (setq alt-default t))
879 (setq i 0)
880 (while (setq i (string-match "[ \n\t]+" str i))
881 (setq str (concat (substring str 0 i) " "
882 (substring str (match-end 0))))
883 (setq i (1+ i)))
884 ;; Record as a completion and perhaps as default.
885 (if (eq default t) (setq default str))
886 (if (eq alt-default t) (setq alt-default str))
887 (setq completions
888 (cons (cons str nil)
889 completions))))
890 ;; If no good default was found, try an alternate.
891 (or default
892 (setq default alt-default))
893 ;; If only one cross-reference found, then make it default.
894 (if (eq (length completions) 1)
895 (setq default (car (car completions))))
896 (if completions
897 (let ((input (completing-read (if default
898 (concat "Follow reference named: ("
899 default ") ")
900 "Follow reference named: ")
901 completions nil t)))
902 (list (if (equal input "")
903 default input)))
904 (error "No cross-references in this node"))))
905 (let (target beg i (str (concat "\\*note " (regexp-quote footnotename))))
906 (while (setq i (string-match " " str i))
907 (setq str (concat (substring str 0 i) "[ \t\n]+" (substring str (1+ i))))
908 (setq i (+ i 6)))
909 (save-excursion
910 (goto-char (point-min))
911 (or (re-search-forward str nil t)
912 (error "No cross-reference named %s" footnotename))
913 (goto-char (+ (match-beginning 0) 5))
914 (setq target
915 (Info-extract-menu-node-name "Bad format cross reference" t)))
916 (while (setq i (string-match "[ \t\n]+" target i))
917 (setq target (concat (substring target 0 i) " "
918 (substring target (match-end 0))))
919 (setq i (+ i 1)))
920 (Info-goto-node target)))
922 (defun Info-extract-menu-node-name (&optional errmessage multi-line)
923 (skip-chars-forward " \t\n")
924 (let ((beg (point))
925 str i)
926 (skip-chars-forward "^:")
927 (forward-char 1)
928 (setq str
929 (if (looking-at ":")
930 (buffer-substring-no-properties beg (1- (point)))
931 (skip-chars-forward " \t\n")
932 (Info-following-node-name (if multi-line "^.,\t" "^.,\t\n"))))
933 (while (setq i (string-match "\n" str i))
934 (aset str i ?\ ))
935 ;; Collapse multiple spaces.
936 (while (string-match " +" str)
937 (setq str (replace-match " " t t str)))
938 str))
940 ;; No one calls this.
941 ;;(defun Info-menu-item-sequence (list)
942 ;; (while list
943 ;; (Info-menu (car list))
944 ;; (setq list (cdr list))))
946 (defun Info-complete-menu-item (string predicate action)
947 (let ((case-fold-search t))
948 (cond ((eq action nil)
949 (let (completions
950 (pattern (concat "\n\\* \\("
951 (regexp-quote string)
952 "[^:\t\n]*\\):")))
953 (save-excursion
954 (set-buffer Info-complete-menu-buffer)
955 (goto-char (point-min))
956 (search-forward "\n* Menu:")
957 (while (re-search-forward pattern nil t)
958 (setq completions (cons (cons (format "%s"
959 (buffer-substring
960 (match-beginning 1)
961 (match-end 1)))
962 (match-beginning 1))
963 completions))))
964 (try-completion string completions predicate)))
965 ((eq action t)
966 (let (completions
967 (pattern (concat "\n\\* \\("
968 (regexp-quote string)
969 "[^:\t\n]*\\):")))
970 (save-excursion
971 (set-buffer Info-complete-menu-buffer)
972 (goto-char (point-min))
973 (search-forward "\n* Menu:")
974 (while (re-search-forward pattern nil t)
975 (setq completions (cons (cons (format "%s"
976 (buffer-substring
977 (match-beginning 1)
978 (match-end 1)))
979 (match-beginning 1))
980 completions))))
981 (all-completions string completions predicate)))
983 (save-excursion
984 (set-buffer Info-complete-menu-buffer)
985 (goto-char (point-min))
986 (search-forward "\n* Menu:")
987 (re-search-forward (concat "\n\\* "
988 (regexp-quote string)
989 ":")
990 nil t))))))
993 (defun Info-menu (menu-item)
994 "Go to node for menu item named (or abbreviated) NAME.
995 Completion is allowed, and the menu item point is on is the default."
996 (interactive
997 (let ((completions '())
998 ;; If point is within a menu item, use that item as the default
999 (default nil)
1000 (p (point))
1002 (last nil))
1003 (save-excursion
1004 (goto-char (point-min))
1005 (if (not (search-forward "\n* menu:" nil t))
1006 (error "No menu in this node"))
1007 (setq beg (point))
1008 (and (< (point) p)
1009 (save-excursion
1010 (goto-char p)
1011 (end-of-line)
1012 (re-search-backward "\n\\* \\([^:\t\n]*\\):" beg t)
1013 (setq default (format "%s" (buffer-substring
1014 (match-beginning 1)
1015 (match-end 1)))))))
1016 (let ((item nil))
1017 (while (null item)
1018 (setq item (let ((completion-ignore-case t)
1019 (Info-complete-menu-buffer (current-buffer)))
1020 (completing-read (if default
1021 (format "Menu item (default %s): "
1022 default)
1023 "Menu item: ")
1024 'Info-complete-menu-item nil t)))
1025 ;; we rely on the fact that completing-read accepts an input
1026 ;; of "" even when the require-match argument is true and ""
1027 ;; is not a valid possibility
1028 (if (string= item "")
1029 (if default
1030 (setq item default)
1031 ;; ask again
1032 (setq item nil))))
1033 (list item))))
1034 ;; there is a problem here in that if several menu items have the same
1035 ;; name you can only go to the node of the first with this command.
1036 (Info-goto-node (Info-extract-menu-item menu-item)))
1038 (defun Info-extract-menu-item (menu-item)
1039 (setq menu-item (regexp-quote menu-item))
1040 (save-excursion
1041 (goto-char (point-min))
1042 (or (search-forward "\n* menu:" nil t)
1043 (error "No menu in this node"))
1044 (or (re-search-forward (concat "\n\\* " menu-item ":") nil t)
1045 (re-search-forward (concat "\n\\* " menu-item) nil t)
1046 (error "No such item in menu"))
1047 (beginning-of-line)
1048 (forward-char 2)
1049 (Info-extract-menu-node-name)))
1051 ;; If COUNT is nil, use the last item in the menu.
1052 (defun Info-extract-menu-counting (count)
1053 (save-excursion
1054 (goto-char (point-min))
1055 (or (search-forward "\n* menu:" nil t)
1056 (error "No menu in this node"))
1057 (if count
1058 (or (search-forward "\n* " nil t count)
1059 (error "Too few items in menu"))
1060 (while (search-forward "\n* " nil t)
1061 nil))
1062 (Info-extract-menu-node-name)))
1064 (defun Info-nth-menu-item ()
1065 "Go to the node of the Nth menu item.
1066 N is the digit argument used to invoke this command."
1067 (interactive)
1068 (Info-goto-node
1069 (Info-extract-menu-counting
1070 (- (aref (this-command-keys) (1- (length (this-command-keys)))) ?0))))
1072 (defun Info-top-node ()
1073 "Go to the Top node of this file."
1074 (interactive)
1075 (Info-goto-node "Top"))
1077 (defun Info-final-node ()
1078 "Go to the final node in this file."
1079 (interactive)
1080 (Info-goto-node "Top")
1081 (let (Info-history)
1082 ;; Go to the last node in the menu of Top.
1083 (Info-goto-node (Info-extract-menu-counting nil))
1084 ;; If the last node in the menu is not last in pointer structure,
1085 ;; move forward until we can't go any farther.
1086 (while (Info-forward-node t t) nil)
1087 ;; Then keep moving down to last subnode, unless we reach an index.
1088 (while (and (not (string-match "\\<index\\>" Info-current-node))
1089 (save-excursion (search-forward "\n* Menu:" nil t)))
1090 (Info-goto-node (Info-extract-menu-counting nil)))))
1092 (defun Info-forward-node (&optional not-down no-error)
1093 "Go forward one node, considering all nodes as forming one sequence."
1094 (interactive)
1095 (goto-char (point-min))
1096 (forward-line 1)
1097 ;; three possibilities, in order of priority:
1098 ;; 1. next node is in a menu in this node (but not in an index)
1099 ;; 2. next node is next at same level
1100 ;; 3. next node is up and next
1101 (cond ((and (not not-down)
1102 (save-excursion (search-forward "\n* menu:" nil t))
1103 (not (string-match "\\<index\\>" Info-current-node)))
1104 (Info-goto-node (Info-extract-menu-counting 1))
1106 ((save-excursion (search-backward "next:" nil t))
1107 (Info-next)
1109 ((and (save-excursion (search-backward "up:" nil t))
1110 ;; Use string-equal, not equal, to ignore text props.
1111 (not (string-equal (downcase (Info-extract-pointer "up"))
1112 "top")))
1113 (let ((old-node Info-current-node))
1114 (Info-up)
1115 (let (Info-history success)
1116 (unwind-protect
1117 (setq success (Info-forward-node t no-error))
1118 (or success (Info-goto-node old-node))))))
1119 (no-error nil)
1120 (t (error "No pointer forward from this node"))))
1122 (defun Info-backward-node ()
1123 "Go backward one node, considering all nodes as forming one sequence."
1124 (interactive)
1125 (let ((prevnode (Info-extract-pointer "prev[ious]*" t))
1126 (upnode (Info-extract-pointer "up" t)))
1127 (cond ((and upnode (string-match "(" upnode))
1128 (error "First node in file"))
1129 ((and upnode (or (null prevnode)
1130 ;; Use string-equal, not equal,
1131 ;; to ignore text properties.
1132 (string-equal (downcase prevnode)
1133 (downcase upnode))))
1134 (Info-up))
1135 (prevnode
1136 ;; If we move back at the same level,
1137 ;; go down to find the last subnode*.
1138 (Info-prev)
1139 (let (Info-history)
1140 (while (and (not (string-match "\\<index\\>" Info-current-node))
1141 (save-excursion (search-forward "\n* Menu:" nil t)))
1142 (Info-goto-node (Info-extract-menu-counting nil)))))
1144 (error "No pointer backward from this node")))))
1146 (defun Info-exit ()
1147 "Exit Info by selecting some other buffer."
1148 (interactive)
1149 (if Info-standalone
1150 (save-buffers-kill-emacs)
1151 (switch-to-buffer (prog1 (other-buffer (current-buffer))
1152 (bury-buffer (current-buffer))))))
1154 (defun Info-next-menu-item ()
1155 (interactive)
1156 (save-excursion
1157 (forward-line -1)
1158 (search-forward "\n* menu:" nil t)
1159 (or (search-forward "\n* " nil t)
1160 (error "No more items in menu"))
1161 (Info-goto-node (Info-extract-menu-node-name))))
1163 (defun Info-last-menu-item ()
1164 (interactive)
1165 (save-excursion
1166 (forward-line 1)
1167 (let ((beg (save-excursion
1168 (and (search-backward "\n* menu:" nil t)
1169 (point)))))
1170 (or (and beg (search-backward "\n* " beg t))
1171 (error "No previous items in menu")))
1172 (Info-goto-node (save-excursion
1173 (goto-char (match-end 0))
1174 (Info-extract-menu-node-name)))))
1176 (defmacro Info-no-error (&rest body)
1177 (list 'condition-case nil (cons 'progn (append body '(t))) '(error nil)))
1179 (defun Info-next-preorder ()
1180 "Go to the next subnode or the next node, or go up a level."
1181 (interactive)
1182 (cond ((Info-no-error (Info-next-menu-item)))
1183 ((Info-no-error (Info-next)))
1184 ((Info-no-error (Info-up))
1185 ;; Since we have already gone thru all the items in this menu,
1186 ;; go up to the end of this node.
1187 (goto-char (point-max))
1188 ;; Since logically we are done with the node with that menu,
1189 ;; move on from it.
1190 (Info-next-preorder))
1192 (error "No more nodes"))))
1194 (defun Info-last-preorder ()
1195 "Go to the last node, popping up a level if there is none."
1196 (interactive)
1197 (cond ((Info-no-error
1198 (Info-last-menu-item)
1199 ;; If we go down a menu item, go to the end of the node
1200 ;; so we can scroll back through it.
1201 (goto-char (point-max)))
1202 ;; Keep going down, as long as there are nested menu nodes.
1203 (while (Info-no-error
1204 (Info-last-menu-item)
1205 ;; If we go down a menu item, go to the end of the node
1206 ;; so we can scroll back through it.
1207 (goto-char (point-max))))
1208 (recenter -1))
1209 ((Info-no-error (Info-prev))
1210 (goto-char (point-max))
1211 (while (Info-no-error
1212 (Info-last-menu-item)
1213 ;; If we go down a menu item, go to the end of the node
1214 ;; so we can scroll back through it.
1215 (goto-char (point-max))))
1216 (recenter -1))
1217 ((Info-no-error (Info-up))
1218 (goto-char (point-min))
1219 (or (search-forward "\n* Menu:" nil t)
1220 (goto-char (point-max))))
1221 (t (error "No previous nodes"))))
1223 (defun Info-scroll-up ()
1224 "Scroll one screenful forward in Info, considering all nodes as one sequence.
1225 Once you scroll far enough in a node that its menu appears on the screen,
1226 the next scroll moves into its first subnode. When you scroll past
1227 the end of a node, that goes to the next node or back up to the parent node."
1228 (interactive)
1229 (if (or (< (window-start) (point-min))
1230 (> (window-start) (point-max)))
1231 (set-window-start (selected-window) (point)))
1232 (let ((virtual-end (save-excursion
1233 (goto-char (point-min))
1234 (if (search-forward "\n* Menu:" nil t)
1235 (point)
1236 (point-max)))))
1237 (if (or (< virtual-end (window-start))
1238 (pos-visible-in-window-p virtual-end))
1239 (Info-next-preorder)
1240 (scroll-up))))
1242 (defun Info-scroll-down ()
1243 "Scroll one screenful back in Info, considering all nodes as one sequence.
1244 Within the menu of a node, this goes to its last subnode.
1245 When you scroll past the beginning of a node, that goes to the
1246 previous node or back up to the parent node."
1247 (interactive)
1248 (if (or (< (window-start) (point-min))
1249 (> (window-start) (point-max)))
1250 (set-window-start (selected-window) (point)))
1251 (let* ((current-point (point))
1252 (virtual-end (save-excursion
1253 (beginning-of-line)
1254 (setq current-point (point))
1255 (goto-char (point-min))
1256 (search-forward "\n* Menu:"
1257 current-point
1258 t))))
1259 (if (or virtual-end (pos-visible-in-window-p (point-min)))
1260 (Info-last-preorder)
1261 (scroll-down))))
1263 (defun Info-next-reference (&optional recur)
1264 "Move cursor to the next cross-reference or menu item in the node."
1265 (interactive)
1266 (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:")
1267 (old-pt (point)))
1268 (or (eobp) (forward-char 1))
1269 (or (re-search-forward pat nil t)
1270 (progn
1271 (goto-char (point-min))
1272 (or (re-search-forward pat nil t)
1273 (progn
1274 (goto-char old-pt)
1275 (error "No cross references in this node")))))
1276 (goto-char (match-beginning 0))
1277 (if (looking-at "\\* Menu:")
1278 (if recur
1279 (error "No cross references in this node")
1280 (Info-next-reference t)))))
1282 (defun Info-prev-reference (&optional recur)
1283 "Move cursor to the previous cross-reference or menu item in the node."
1284 (interactive)
1285 (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:")
1286 (old-pt (point)))
1287 (or (re-search-backward pat nil t)
1288 (progn
1289 (goto-char (point-max))
1290 (or (re-search-backward pat nil t)
1291 (progn
1292 (goto-char old-pt)
1293 (error "No cross references in this node")))))
1294 (goto-char (match-beginning 0))
1295 (if (looking-at "\\* Menu:")
1296 (if recur
1297 (error "No cross references in this node")
1298 (Info-prev-reference t)))))
1300 (defun Info-index (topic)
1301 "Look up a string in the index for this file.
1302 The index is defined as the first node in the top-level menu whose
1303 name contains the word \"Index\", plus any immediately following
1304 nodes whose names also contain the word \"Index\".
1305 If there are no exact matches to the specified topic, this chooses
1306 the first match which is a case-insensitive substring of a topic.
1307 Use the `,' command to see the other matches.
1308 Give a blank topic name to go to the Index node itself."
1309 (interactive "sIndex topic: ")
1310 (let ((orignode Info-current-node)
1311 (rnode nil)
1312 (pattern (format "\n\\* \\([^\n:]*%s[^\n:]*\\):[ \t]*\\([^.\n]*\\)\\.[ \t]*\\([0-9]*\\)"
1313 (regexp-quote topic)))
1314 node)
1315 (Info-goto-node "Top")
1316 (or (search-forward "\n* menu:" nil t)
1317 (error "No index"))
1318 (or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t)
1319 (error "No index"))
1320 (goto-char (match-beginning 1))
1321 ;; Here, and subsequently in this function,
1322 ;; we bind Info-history to nil for internal node-switches
1323 ;; so that we don't put junk in the history.
1324 ;; In the first Info-goto-node call, above, we do update the history
1325 ;; because that is what the user's previous node choice into it.
1326 (let ((Info-history nil))
1327 (Info-goto-node (Info-extract-menu-node-name)))
1328 (or (equal topic "")
1329 (let ((matches nil)
1330 (exact nil)
1331 (Info-history nil)
1332 found)
1333 (while
1334 (progn
1335 (goto-char (point-min))
1336 (while (re-search-forward pattern nil t)
1337 (setq matches
1338 (cons (list (buffer-substring (match-beginning 1)
1339 (match-end 1))
1340 (buffer-substring (match-beginning 2)
1341 (match-end 2))
1342 Info-current-node
1343 (string-to-int (concat "0"
1344 (buffer-substring
1345 (match-beginning 3)
1346 (match-end 3)))))
1347 matches)))
1348 (and (setq node (Info-extract-pointer "next" t))
1349 (string-match "\\<Index\\>" node)))
1350 (Info-goto-node node))
1351 (or matches
1352 (progn
1353 (Info-goto-node orignode)
1354 (error "No `%s' in index" topic)))
1355 ;; Here it is a feature that assoc is case-sensitive.
1356 (while (setq found (assoc topic matches))
1357 (setq exact (cons found exact)
1358 matches (delq found matches)))
1359 (setq Info-index-alternatives (nconc exact (nreverse matches)))
1360 (Info-index-next 0)))))
1362 (defun Info-index-next (num)
1363 "Go to the next matching index item from the last `i' command."
1364 (interactive "p")
1365 (or Info-index-alternatives
1366 (error "No previous `i' command in this file"))
1367 (while (< num 0)
1368 (setq num (+ num (length Info-index-alternatives))))
1369 (while (> num 0)
1370 (setq Info-index-alternatives
1371 (nconc (cdr Info-index-alternatives)
1372 (list (car Info-index-alternatives)))
1373 num (1- num)))
1374 (Info-goto-node (nth 1 (car Info-index-alternatives)))
1375 (if (> (nth 3 (car Info-index-alternatives)) 0)
1376 (forward-line (nth 3 (car Info-index-alternatives)))
1377 (forward-line 3) ; don't search in headers
1378 (let ((name (car (car Info-index-alternatives))))
1379 (Info-find-index-name name)))
1380 (message "Found `%s' in %s. %s"
1381 (car (car Info-index-alternatives))
1382 (nth 2 (car Info-index-alternatives))
1383 (if (cdr Info-index-alternatives)
1384 "(Press `,' for more)"
1385 "(Only match)")))
1387 (defun Info-find-index-name (name)
1388 "Move point to the place within the current node where NAME is defined."
1389 (if (or (re-search-forward (format
1390 "[a-zA-Z]+: %s\\( \\|$\\)"
1391 (regexp-quote name)) nil t)
1392 (search-forward (format "`%s'" name) nil t)
1393 (and (string-match "\\`.*\\( (.*)\\)\\'" name)
1394 (search-forward
1395 (format "`%s'" (substring name 0 (match-beginning 1)))
1396 nil t))
1397 (search-forward name nil t))
1398 (beginning-of-line)
1399 (goto-char (point-min))))
1401 (defun Info-undefined ()
1402 "Make command be undefined in Info."
1403 (interactive)
1404 (ding))
1406 (defun Info-help ()
1407 "Enter the Info tutorial."
1408 (interactive)
1409 (delete-other-windows)
1410 (Info-find-node "info"
1411 (if (< (window-height) 23)
1412 "Help-Small-Screen"
1413 "Help")))
1415 (defun Info-summary ()
1416 "Display a brief summary of all Info commands."
1417 (interactive)
1418 (save-window-excursion
1419 (switch-to-buffer "*Help*")
1420 (erase-buffer)
1421 (insert (documentation 'Info-mode))
1422 (help-mode)
1423 (goto-char (point-min))
1424 (let (ch flag)
1425 (while (progn (setq flag (not (pos-visible-in-window-p (point-max))))
1426 (message (if flag "Type Space to see more"
1427 "Type Space to return to Info"))
1428 (if (not (eq ?\ (setq ch (read-event))))
1429 (progn (setq unread-command-events (list ch)) nil)
1430 flag))
1431 (scroll-up)))
1432 (bury-buffer "*Help*")))
1434 (defun Info-get-token (pos start all &optional errorstring)
1435 "Return the token around POS,
1436 POS must be somewhere inside the token
1437 START is a regular expression which will match the
1438 beginning of the tokens delimited string
1439 ALL is a regular expression with a single
1440 parenthesized subpattern which is the token to be
1441 returned. E.g. '{\(.*\)}' would return any string
1442 enclosed in braces around POS.
1443 SIG optional fourth argument, controls action on no match
1444 nil: return nil
1445 t: beep
1446 a string: signal an error, using that string."
1447 (save-excursion
1448 (goto-char pos)
1449 (re-search-backward start (max (point-min) (- pos 200)) 'yes)
1450 (let (found)
1451 (while (and (re-search-forward all (min (point-max) (+ pos 200)) 'yes)
1452 (not (setq found (and (<= (match-beginning 0) pos)
1453 (> (match-end 0) pos))))))
1454 (if (and found (<= (match-beginning 0) pos)
1455 (> (match-end 0) pos))
1456 (buffer-substring (match-beginning 1) (match-end 1))
1457 (cond ((null errorstring)
1458 nil)
1459 ((eq errorstring t)
1460 (beep)
1461 nil)
1463 (error "No %s around position %d" errorstring pos)))))))
1465 (defun Info-mouse-follow-nearest-node (click)
1466 "\\<Info-mode-map>Follow a node reference near point.
1467 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click.
1468 At end of the node's text, moves to the next node, or up if none."
1469 (interactive "e")
1470 (let* ((start (event-start click))
1471 (window (car start))
1472 (pos (car (cdr start))))
1473 (select-window window)
1474 (goto-char pos))
1475 (and (not (Info-try-follow-nearest-node))
1476 (save-excursion (forward-line 1) (eobp))
1477 (Info-next-preorder)))
1479 (defun Info-follow-nearest-node ()
1480 "\\<Info-mode-map>Follow a node reference near point.
1481 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where point is.
1482 If no reference to follow, moves to the next node, or up if none."
1483 (interactive)
1484 (or (Info-try-follow-nearest-node)
1485 (Info-next-preorder)))
1487 ;; Common subroutine.
1488 (defun Info-try-follow-nearest-node ()
1489 "Follow a node reference near point. Return non-nil if successful."
1490 (let (node)
1491 (cond
1492 ((setq node (Info-get-token (point) "\\*note[ \n]"
1493 "\\*note[ \n]\\([^:]*\\):"))
1494 (Info-follow-reference node))
1495 ((setq node (Info-get-token (point) "\\* " "\\* \\([^:]*\\)::"))
1496 (Info-goto-node node))
1497 ((setq node (Info-get-token (point) "\\* " "\\* \\([^:]*\\):"))
1498 (Info-menu node))
1499 ((setq node (Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)"))
1500 (Info-goto-node node))
1501 ((setq node (Info-get-token (point) "Next: " "Next: \\([^,\n\t]*\\)"))
1502 (Info-goto-node node))
1503 ((setq node (Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)"))
1504 (Info-goto-node "Top"))
1505 ((setq node (Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)"))
1506 (Info-goto-node node)))
1507 node))
1509 (defvar Info-mode-map nil
1510 "Keymap containing Info commands.")
1511 (if Info-mode-map
1513 (setq Info-mode-map (make-keymap))
1514 (suppress-keymap Info-mode-map)
1515 (define-key Info-mode-map "." 'beginning-of-buffer)
1516 (define-key Info-mode-map " " 'Info-scroll-up)
1517 (define-key Info-mode-map "\C-m" 'Info-follow-nearest-node)
1518 (define-key Info-mode-map "\t" 'Info-next-reference)
1519 (define-key Info-mode-map "\e\t" 'Info-prev-reference)
1520 (define-key Info-mode-map "1" 'Info-nth-menu-item)
1521 (define-key Info-mode-map "2" 'Info-nth-menu-item)
1522 (define-key Info-mode-map "3" 'Info-nth-menu-item)
1523 (define-key Info-mode-map "4" 'Info-nth-menu-item)
1524 (define-key Info-mode-map "5" 'Info-nth-menu-item)
1525 (define-key Info-mode-map "6" 'Info-nth-menu-item)
1526 (define-key Info-mode-map "7" 'Info-nth-menu-item)
1527 (define-key Info-mode-map "8" 'Info-nth-menu-item)
1528 (define-key Info-mode-map "9" 'Info-nth-menu-item)
1529 (define-key Info-mode-map "0" 'undefined)
1530 (define-key Info-mode-map "?" 'Info-summary)
1531 (define-key Info-mode-map "]" 'Info-forward-node)
1532 (define-key Info-mode-map "[" 'Info-backward-node)
1533 (define-key Info-mode-map "<" 'Info-top-node)
1534 (define-key Info-mode-map ">" 'Info-final-node)
1535 (define-key Info-mode-map "b" 'beginning-of-buffer)
1536 (define-key Info-mode-map "d" 'Info-directory)
1537 (define-key Info-mode-map "e" 'Info-edit)
1538 (define-key Info-mode-map "f" 'Info-follow-reference)
1539 (define-key Info-mode-map "g" 'Info-goto-node)
1540 (define-key Info-mode-map "h" 'Info-help)
1541 (define-key Info-mode-map "i" 'Info-index)
1542 (define-key Info-mode-map "l" 'Info-last)
1543 (define-key Info-mode-map "m" 'Info-menu)
1544 (define-key Info-mode-map "n" 'Info-next)
1545 (define-key Info-mode-map "p" 'Info-prev)
1546 (define-key Info-mode-map "q" 'Info-exit)
1547 (define-key Info-mode-map "s" 'Info-search)
1548 ;; For consistency with Rmail.
1549 (define-key Info-mode-map "\M-s" 'Info-search)
1550 (define-key Info-mode-map "t" 'Info-top-node)
1551 (define-key Info-mode-map "u" 'Info-up)
1552 (define-key Info-mode-map "," 'Info-index-next)
1553 (define-key Info-mode-map "\177" 'Info-scroll-down)
1554 (define-key Info-mode-map [mouse-2] 'Info-mouse-follow-nearest-node)
1557 ;; Info mode is suitable only for specially formatted data.
1558 (put 'info-mode 'mode-class 'special)
1560 (defun Info-mode ()
1561 "\\<Info-mode-map>
1562 Info mode provides commands for browsing through the Info documentation tree.
1563 Documentation in Info is divided into \"nodes\", each of which discusses
1564 one topic and contains references to other nodes which discuss related
1565 topics. Info has commands to follow the references and show you other nodes.
1567 \\[Info-help] Invoke the Info tutorial.
1569 Selecting other nodes:
1570 \\[Info-mouse-follow-nearest-node]
1571 Follow a node reference you click on.
1572 This works with menu items, cross references, and
1573 the \"next\", \"previous\" and \"up\", depending on where you click.
1574 \\[Info-next] Move to the \"next\" node of this node.
1575 \\[Info-prev] Move to the \"previous\" node of this node.
1576 \\[Info-up] Move \"up\" from this node.
1577 \\[Info-menu] Pick menu item specified by name (or abbreviation).
1578 Picking a menu item causes another node to be selected.
1579 \\[Info-directory] Go to the Info directory node.
1580 \\[Info-follow-reference] Follow a cross reference. Reads name of reference.
1581 \\[Info-last] Move to the last node you were at.
1582 \\[Info-index] Look up a topic in this file's Index and move to that node.
1583 \\[Info-index-next] (comma) Move to the next match from a previous `i' command.
1585 Moving within a node:
1586 \\[Info-scroll-up] Normally, scroll forward a full screen. If the end of the buffer is
1587 already visible, try to go to the next menu entry, or up if there is none.
1588 \\[Info-scroll-down] Normally, scroll backward. If the beginning of the buffer is
1589 already visible, try to go to the previous menu entry, or up if there is none.
1590 \\[beginning-of-buffer] Go to beginning of node.
1592 Advanced commands:
1593 \\[Info-exit] Quit Info: reselect previously selected buffer.
1594 \\[Info-edit] Edit contents of selected node.
1595 1 Pick first item in node's menu.
1596 2, 3, 4, 5 Pick second ... fifth item in node's menu.
1597 \\[Info-goto-node] Move to node specified by name.
1598 You may include a filename as well, as (FILENAME)NODENAME.
1599 \\[universal-argument] \\[info] Move to new Info file with completion.
1600 \\[Info-search] Search through this Info file for specified regexp,
1601 and select the node in which the next occurrence is found.
1602 \\[Info-next-reference] Move cursor to next cross-reference or menu item.
1603 \\[Info-prev-reference] Move cursor to previous cross-reference or menu item."
1604 (kill-all-local-variables)
1605 (setq major-mode 'Info-mode)
1606 (setq mode-name "Info")
1607 (use-local-map Info-mode-map)
1608 (set-syntax-table text-mode-syntax-table)
1609 (setq local-abbrev-table text-mode-abbrev-table)
1610 (setq case-fold-search t)
1611 (setq buffer-read-only t)
1612 (make-local-variable 'Info-current-file)
1613 (make-local-variable 'Info-current-subfile)
1614 (make-local-variable 'Info-current-node)
1615 (make-local-variable 'Info-tag-table-marker)
1616 (make-local-variable 'Info-history)
1617 (make-local-variable 'Info-index-alternatives)
1618 (if (memq (framep (selected-frame)) '(x pc))
1619 (progn
1620 (make-face 'info-node)
1621 (make-face 'info-menu-5)
1622 (make-face 'info-xref)
1623 (or (face-differs-from-default-p 'info-node)
1624 (if (face-differs-from-default-p 'bold-italic)
1625 (copy-face 'bold-italic 'info-node)
1626 (copy-face 'bold 'info-node)))
1627 (or (face-differs-from-default-p 'info-menu-5)
1628 (set-face-underline-p 'info-menu-5 t))
1629 (or (face-differs-from-default-p 'info-xref)
1630 (copy-face 'bold 'info-xref)))
1631 (setq Info-fontify nil))
1632 (Info-set-mode-line)
1633 (run-hooks 'Info-mode-hook))
1635 (defvar Info-edit-map nil
1636 "Local keymap used within `e' command of Info.")
1637 (if Info-edit-map
1639 (setq Info-edit-map (nconc (make-sparse-keymap) text-mode-map))
1640 (define-key Info-edit-map "\C-c\C-c" 'Info-cease-edit))
1642 ;; Info-edit mode is suitable only for specially formatted data.
1643 (put 'info-edit-mode 'mode-class 'special)
1645 (defun Info-edit-mode ()
1646 "Major mode for editing the contents of an Info node.
1647 Like text mode with the addition of `Info-cease-edit'
1648 which returns to Info mode for browsing.
1649 \\{Info-edit-map}"
1650 (use-local-map Info-edit-map)
1651 (setq major-mode 'Info-edit-mode)
1652 (setq mode-name "Info Edit")
1653 (kill-local-variable 'mode-line-buffer-identification)
1654 (setq buffer-read-only nil)
1655 (force-mode-line-update)
1656 (buffer-enable-undo (current-buffer))
1657 (run-hooks 'Info-edit-mode-hook))
1659 (defun Info-edit ()
1660 "Edit the contents of this Info node.
1661 Allowed only if variable `Info-enable-edit' is non-nil."
1662 (interactive)
1663 (or Info-enable-edit
1664 (error "Editing info nodes is not enabled"))
1665 (Info-edit-mode)
1666 (message "%s" (substitute-command-keys
1667 "Editing: Type \\<Info-edit-map>\\[Info-cease-edit] to return to info")))
1669 (defun Info-cease-edit ()
1670 "Finish editing Info node; switch back to Info proper."
1671 (interactive)
1672 ;; Do this first, so nothing has changed if user C-g's at query.
1673 (and (buffer-modified-p)
1674 (y-or-n-p "Save the file? ")
1675 (save-buffer))
1676 (use-local-map Info-mode-map)
1677 (setq major-mode 'Info-mode)
1678 (setq mode-name "Info")
1679 (Info-set-mode-line)
1680 (setq buffer-read-only t)
1681 (force-mode-line-update)
1682 (and (marker-position Info-tag-table-marker)
1683 (buffer-modified-p)
1684 (message "Tags may have changed. Use Info-tagify if necessary")))
1686 (defvar Info-file-list-for-emacs
1687 '("ediff" "forms" "gnus" "info" ("mh" . "mh-e") "sc")
1688 "List of Info files that describe Emacs commands.
1689 An element can be a file name, or a list of the form (PREFIX . FILE)
1690 where PREFIX is a name prefix and FILE is the file to look in.
1691 If the element is just a file name, the file name also serves as the prefix.")
1693 (defun Info-find-emacs-command-nodes (command)
1694 "Return a list of locations documenting COMMAND.
1695 The `info-file' property of COMMAND says which Info manual to search.
1696 If COMMAND has no property, the variable `Info-file-list-for-emacs'
1697 defines heuristics for which Info manual to try.
1698 The locations are of the format used in Info-history, i.e.
1699 \(FILENAME NODENAME BUFFERPOS\)."
1700 (let ((where '())
1701 (cmd-desc (concat "^\\* " (regexp-quote (symbol-name command))
1702 ":\\s *\\(.*\\)\\.$"))
1703 (info-file "emacs")) ;default
1704 ;; Determine which info file this command is documented in.
1705 (if (get command 'info-file)
1706 (setq info-file (get command 'info-file))
1707 ;; If it doesn't say explicitly, test its name against
1708 ;; various prefixes that we know.
1709 (let ((file-list Info-file-list-for-emacs))
1710 (while file-list
1711 (let* ((elt (car file-list))
1712 (name (if (consp elt)
1713 (car elt)
1714 elt))
1715 (file (if (consp elt) (cdr elt) elt))
1716 (regexp (concat "\\`" (regexp-quote name)
1717 "\\(\\'\\|-\\)")))
1718 (if (string-match regexp (symbol-name command))
1719 (setq info-file file file-list nil))
1720 (setq file-list (cdr file-list))))))
1721 (save-excursion
1722 (condition-case nil
1723 (Info-find-node info-file "Command Index")
1724 ;; Some manuals may not have a separate Command Index node,
1725 ;; so try just Index instead.
1726 (error
1727 (Info-find-node info-file "Index")))
1728 ;; Take the index node off the Info history.
1729 (setq Info-history (cdr Info-history))
1730 (goto-char (point-max))
1731 (while (re-search-backward cmd-desc nil t)
1732 (setq where (cons (list Info-current-file
1733 (buffer-substring
1734 (match-beginning 1)
1735 (match-end 1))
1737 where)))
1738 where)))
1740 ;;;###autoload
1741 (defun Info-goto-emacs-command-node (command)
1742 "Go to the Info node in the Emacs manual for command COMMAND.
1743 The command is found by looking up in Emacs manual's Command Index
1744 or in another manual found via COMMAND's `info-file' property or
1745 the variable `Info-file-list-for-emacs'."
1746 (interactive "CFind documentation for command: ")
1747 (or (commandp command)
1748 (signal 'wrong-type-argument (list 'commandp command)))
1749 (let ((where (Info-find-emacs-command-nodes command)))
1750 (if where
1751 (let ((num-matches (length where)))
1752 ;; Get Info running, and pop to it in another window.
1753 (save-window-excursion
1754 (info))
1755 (pop-to-buffer "*info*")
1756 (Info-find-node (car (car where))
1757 (car (cdr (car where))))
1758 (if (> num-matches 1)
1759 (progn
1760 ;; Info-find-node already pushed (car where) onto
1761 ;; Info-history. Put the other nodes that were found on
1762 ;; the history.
1763 (setq Info-history (nconc (cdr where) Info-history))
1764 (message "Found %d other entr%s. Use %s to see %s."
1765 (1- num-matches)
1766 (if (> num-matches 2) "ies" "y")
1767 (substitute-command-keys "\\[Info-last]")
1768 (if (> num-matches 2) "them" "it")))))
1769 (error "Couldn't find documentation for %s" command))))
1771 ;;;###autoload
1772 (defun Info-goto-emacs-key-command-node (key)
1773 "Go to the Info node in the Emacs manual the command bound to KEY, a string.
1774 Interactively, if the binding is execute-extended-command, a command is read.
1775 The command is found by looking up in Emacs manual's Command Index
1776 or in another manual found via COMMAND's `info-file' property or
1777 the variable `Info-file-list-for-emacs'."
1778 (interactive "kFind documentation for key:")
1779 (let ((command (key-binding key)))
1780 (cond ((null command)
1781 (message "%s is undefined" (key-description key)))
1782 ((and (interactive-p)
1783 (eq command 'execute-extended-command))
1784 (Info-goto-emacs-command-node
1785 (read-command "Find documentation for command: ")))
1787 (Info-goto-emacs-command-node command)))))
1789 (defvar Info-title-face-alist
1790 '((?* bold underline)
1791 (?= bold-italic underline)
1792 (?- italic underline))
1793 "*Alist of face or list of faces to use for pseudo-underlined titles.
1794 The alist key is the character the title is underlined with (?*, ?= or ?-).")
1796 (defun Info-fontify-node ()
1797 (save-excursion
1798 (let ((buffer-read-only nil))
1799 (goto-char (point-min))
1800 (if (looking-at "^File: [^,: \t]+,?[ \t]+")
1801 (progn
1802 (goto-char (match-end 0))
1803 (while
1804 (looking-at "[ \t]*[^:, \t\n]+:[ \t]+\\([^:,\t\n]+\\),?")
1805 (goto-char (match-end 0))
1806 (put-text-property (match-beginning 1) (match-end 1)
1807 'face 'info-xref)
1808 (put-text-property (match-beginning 1) (match-end 1)
1809 'mouse-face 'highlight))))
1810 (goto-char (point-min))
1811 (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*+\\|=+\\|-+\\)$"
1812 nil t)
1813 (put-text-property (match-beginning 1) (match-end 1)
1814 'face
1815 (cdr (assq (preceding-char) Info-title-face-alist)))
1816 (put-text-property (match-end 1) (match-end 2)
1817 'invisible t))
1818 (goto-char (point-min))
1819 (while (re-search-forward "\\*Note[ \n\t]+\\([^:]*\\):" nil t)
1820 (if (= (char-after (1- (match-beginning 0))) ?\") ; hack
1822 (put-text-property (match-beginning 1) (match-end 1)
1823 'face 'info-xref)
1824 (put-text-property (match-beginning 1) (match-end 1)
1825 'mouse-face 'highlight)))
1826 (goto-char (point-min))
1827 (if (and (search-forward "\n* Menu:" nil t)
1828 (not (string-match "\\<Index\\>" Info-current-node))
1829 ;; Don't take time to annotate huge menus
1830 (< (- (point-max) (point)) Info-fontify-maximum-menu-size))
1831 (let ((n 0))
1832 (while (re-search-forward "^\\* \\([^:\t\n]*\\):" nil t)
1833 (setq n (1+ n))
1834 (if (memq n '(5 9)) ; visual aids to help with 1-9 keys
1835 (put-text-property (match-beginning 0)
1836 (1+ (match-beginning 0))
1837 'face 'info-menu-5))
1838 (put-text-property (match-beginning 1) (match-end 1)
1839 'face 'info-node)
1840 (put-text-property (match-beginning 1) (match-end 1)
1841 'mouse-face 'highlight))))
1842 (set-buffer-modified-p nil))))
1844 (provide 'info)
1846 ;;; info.el ends here