]> code.delx.au - gnu-emacs/blob - lisp/info.el
(Info-find-index-name): New subroutine, from Info-index-next.
[gnu-emacs] / lisp / info.el
1 ;;; info.el --- info package for Emacs.
2
3 ;; Copyright (C) 1985, 1986, 1992, 1993, 1994 Free Software Foundation, Inc.
4
5 ;; Maintainer: FSF
6 ;; Keywords: help
7
8 ;; This file is part of GNU Emacs.
9
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.
14
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.
19
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.
24
25 ;;; Commentary:
26
27 ;; Note that nowadays we expect info files to be made using makeinfo.
28
29 ;;; Code:
30
31 (defvar Info-history nil
32 "List of info nodes user has visited.
33 Each element of list is a list (FILENAME NODENAME BUFFERPOS).")
34
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.")
41
42 (defvar Info-enable-active-nodes t
43 "Non-nil allows Info to execute Lisp code associated with nodes.
44 The Lisp code is executed when the node is selected.")
45
46 (defvar Info-fontify t
47 "*Non-nil enables highlighting and fonts in Info nodes.")
48
49 (defvar Info-fontify-maximum-menu-size 30000
50 "*Maximum size of menu to fontify if `Info-fontify' is non-nil.")
51
52 (defvar Info-directory-list
53 (let ((path (getenv "INFOPATH"))
54 ;; This is for older Emacs versions
55 ;; which might get this info.el from the Texinfo distribution.
56 (path-separator (if (boundp 'path-separator) path-separator
57 (if (eq system-type 'ms-dos) ";" ":")))
58 (source (expand-file-name "info/" source-directory))
59 (sibling (if installation-directory
60 (expand-file-name "info/" installation-directory)))
61 alternative)
62 (if path
63 (let ((list nil)
64 idx)
65 (while (> (length path) 0)
66 (setq idx (or (string-match path-separator path) (length path))
67 list (cons (substring path 0 idx) list)
68 path (substring path (min (1+ idx)
69 (length path)))))
70 (nreverse list))
71 (if (and sibling (file-exists-p sibling))
72 (setq alternative sibling)
73 (setq alternative source))
74 (if (or (member alternative Info-default-directory-list)
75 (not (file-exists-p alternative))
76 ;; On DOS/NT, we use movable executables always,
77 ;; and we must always find the Info dir at run time.
78 (if (or (eq system-type 'ms-dos) (eq system-type 'windows-nt))
79 nil
80 ;; Use invocation-directory for Info only if we used it for
81 ;; exec-directory also.
82 (not (string= exec-directory
83 (expand-file-name "lib-src/"
84 installation-directory)))))
85 Info-default-directory-list
86 (reverse (cons alternative
87 (cdr (reverse Info-default-directory-list)))))))
88 "List of directories to search for Info documentation files.
89 nil means not yet initialized. In this case, Info uses the environment
90 variable INFOPATH to initialize it, or `Info-default-directory-list'
91 if there is no INFOPATH variable in the environment.
92 The last element of `Info-default-directory-list' is the directory
93 where Emacs installs the Info files that come with it.
94
95 If you run the Emacs executable from the `src' directory in the Emacs
96 source tree, the `info' directory in the source tree is used as the last
97 element, in place of the installation Info directory. This is useful
98 when you run a version of Emacs without installing it.")
99
100 (defvar Info-additional-directory-list nil
101 "List of additional directories to search for Info documentation files.
102 These directories are not searched for merging the `dir' file.")
103
104 (defvar Info-current-file nil
105 "Info file that Info is now looking at, or nil.
106 This is the name that was specified in Info, not the actual file name.
107 It doesn't contain directory names or file name extensions added by Info.")
108
109 (defvar Info-current-subfile nil
110 "Info subfile that is actually in the *info* buffer now,
111 or nil if current info file is not split into subfiles.")
112
113 (defvar Info-current-node nil
114 "Name of node that Info is now looking at, or nil.")
115
116 (defvar Info-tag-table-marker (make-marker)
117 "Marker pointing at beginning of current Info file's tag table.
118 Marker points nowhere if file has no tag table.")
119
120 (defvar Info-current-file-completions nil
121 "Cached completion list for current Info file.")
122
123 (defvar Info-index-alternatives nil
124 "List of possible matches for last Info-index command.")
125
126 (defvar Info-standalone nil
127 "Non-nil if Emacs was started solely as an Info browser.")
128
129 (defvar Info-suffix-list
130 (if (eq system-type 'ms-dos)
131 '( (".gz" . "gunzip")
132 (".z" . "gunzip")
133 (".inf" . nil)
134 ("" . nil))
135 '( (".info.Z" . "uncompress")
136 (".info.Y" . "unyabba")
137 (".info.gz" . "gunzip")
138 (".info.z" . "gunzip")
139 (".info" . nil)
140 (".Z" . "uncompress")
141 (".Y" . "unyabba")
142 (".gz" . "gunzip")
143 (".z" . "gunzip")
144 ("" . nil)))
145 "List of file name suffixes and associated decoding commands.
146 Each entry should be (SUFFIX . STRING); the file is given to
147 the command as standard input. If STRING is nil, no decoding is done.
148 Because the SUFFIXes are tried in order, the empty string should
149 be last in the list.")
150
151 ;; Concatenate SUFFIX onto FILENAME. SUFFIX should start with a dot.
152 ;; First, on ms-dos, delete some of the extension in FILENAME
153 ;; to make room.
154 (defun info-insert-file-contents-1 (filename suffix)
155 (if (not (eq system-type 'ms-dos))
156 (concat filename suffix)
157 (let* ((sans-exts (file-name-sans-extension filename))
158 ;; How long is the extension in FILENAME (not counting the dot).
159 (ext-len (max 0 (- (length filename) (length sans-exts) 1)))
160 ext-left)
161 ;; SUFFIX starts with a dot. If FILENAME already has one,
162 ;; get rid of the one in SUFFIX.
163 (or (and (<= ext-len 0)
164 (not (eq (aref filename (1- (length filename))) ?.)))
165 (setq suffix (substring suffix 1)))
166 ;; How many chars of that extension should we keep?
167 (setq ext-left (min ext-len (max 0 (- 3 (length suffix)))))
168 ;; Get rid of the rest of the extension, and add SUFFIX.
169 (concat (substring filename 0 (- (length filename)
170 (- ext-len ext-left)))
171 suffix))))
172
173 (defun info-insert-file-contents (filename &optional visit)
174 "Insert the contents of an info file in the current buffer.
175 Do the right thing if the file has been compressed or zipped."
176 (let ((tail Info-suffix-list)
177 fullname decoder)
178 (if (file-exists-p filename)
179 ;; FILENAME exists--see if that name contains a suffix.
180 ;; If so, set DECODE accordingly.
181 (progn
182 (while (and tail
183 (not (string-match
184 (concat (regexp-quote (car (car tail))) "$")
185 filename)))
186 (setq tail (cdr tail)))
187 (setq fullname filename
188 decoder (cdr (car tail))))
189 ;; Try adding suffixes to FILENAME and see if we can find something.
190 (while (and tail
191 (not (file-exists-p (info-insert-file-contents-1
192 filename (car (car tail))))))
193 (setq tail (cdr tail)))
194 ;; If we found a file with a suffix, set DECODER according to the suffix
195 ;; and set FULLNAME to the file's actual name.
196 (setq fullname (info-insert-file-contents-1 filename (car (car tail)))
197 decoder (cdr (car tail)))
198 (or tail
199 (error "Can't find %s or any compressed version of it" filename)))
200 ;; check for conflict with jka-compr
201 (if (and (featurep 'jka-compr)
202 (jka-compr-installed-p)
203 (jka-compr-get-compression-info fullname))
204 (setq decoder nil))
205 (insert-file-contents fullname visit)
206 (if decoder
207 (let ((buffer-read-only nil)
208 (default-directory (or (file-name-directory fullname)
209 default-directory)))
210 (call-process-region (point-min) (point-max) decoder t t)))))
211
212 ;;;###autoload (add-hook 'same-window-buffer-names "*info*")
213
214 ;;;###autoload
215 (defun info (&optional file)
216 "Enter Info, the documentation browser.
217 Optional argument FILE specifies the file to examine;
218 the default is the top-level directory of Info.
219
220 In interactive use, a prefix argument directs this command
221 to read a file name from the minibuffer.
222
223 The search path for Info files is in the variable `Info-directory-list'.
224 The top-level Info directory is made by combining all the files named `dir'
225 in all the directories in that path."
226 (interactive (if current-prefix-arg
227 (list (read-file-name "Info file name: " nil nil t))))
228 (if file
229 (Info-goto-node (concat "(" file ")"))
230 (if (get-buffer "*info*")
231 (pop-to-buffer "*info*")
232 (Info-directory))))
233
234 ;;;###autoload
235 (defun info-standalone ()
236 "Run Emacs as a standalone Info reader.
237 Usage: emacs -f info-standalone [filename]
238 In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
239 (setq Info-standalone t)
240 (if (and command-line-args-left
241 (not (string-match "^-" (car command-line-args-left))))
242 (condition-case err
243 (progn
244 (info (car command-line-args-left))
245 (setq command-line-args-left (cdr command-line-args-left)))
246 (error (send-string-to-terminal
247 (format "%s\n" (if (eq (car-safe err) 'error)
248 (nth 1 err) err)))
249 (save-buffers-kill-emacs)))
250 (info)))
251
252 ;; Go to an info node specified as separate filename and nodename.
253 ;; no-going-back is non-nil if recovering from an error in this function;
254 ;; it says do not attempt further (recursive) error recovery.
255 (defun Info-find-node (filename nodename &optional no-going-back)
256 ;; Convert filename to lower case if not found as specified.
257 ;; Expand it.
258 (if filename
259 (let (temp temp-downcase found)
260 (setq filename (substitute-in-file-name filename))
261 (if (string= (downcase (file-name-nondirectory filename)) "dir")
262 (setq found t)
263 (let ((dirs (if (string-match "^\\./" filename)
264 ;; If specified name starts with `./'
265 ;; then just try current directory.
266 '("./")
267 (if (file-name-absolute-p filename)
268 ;; No point in searching for an
269 ;; absolute file name
270 '(nil)
271 (if Info-additional-directory-list
272 (append Info-directory-list
273 Info-additional-directory-list)
274 Info-directory-list)))))
275 ;; Search the directory list for file FILENAME.
276 (while (and dirs (not found))
277 (setq temp (expand-file-name filename (car dirs)))
278 (setq temp-downcase
279 (expand-file-name (downcase filename) (car dirs)))
280 ;; Try several variants of specified name.
281 (let ((suffix-list Info-suffix-list))
282 (while (and suffix-list (not found))
283 (cond ((file-exists-p
284 (info-insert-file-contents-1
285 temp (car (car suffix-list))))
286 (setq found temp))
287 ((file-exists-p
288 (info-insert-file-contents-1
289 temp-downcase (car (car suffix-list))))
290 (setq found temp-downcase)))
291 (setq suffix-list (cdr suffix-list))))
292 (setq dirs (cdr dirs)))))
293 (if found
294 (setq filename found)
295 (error "Info file %s does not exist" filename))))
296 ;; Record the node we are leaving.
297 (if (and Info-current-file (not no-going-back))
298 (setq Info-history
299 (cons (list Info-current-file Info-current-node (point))
300 Info-history)))
301 ;; Go into info buffer.
302 (switch-to-buffer "*info*")
303 (buffer-disable-undo (current-buffer))
304 (or (eq major-mode 'Info-mode)
305 (Info-mode))
306 (widen)
307 (setq Info-current-node nil)
308 (unwind-protect
309 (progn
310 ;; Switch files if necessary
311 (or (null filename)
312 (equal Info-current-file filename)
313 (let ((buffer-read-only nil))
314 (setq Info-current-file nil
315 Info-current-subfile nil
316 Info-current-file-completions nil
317 Info-index-alternatives nil
318 buffer-file-name nil)
319 (erase-buffer)
320 (if (eq filename t)
321 (Info-insert-dir)
322 (info-insert-file-contents filename t)
323 (setq default-directory (file-name-directory filename)))
324 (set-buffer-modified-p nil)
325 ;; See whether file has a tag table. Record the location if yes.
326 (set-marker Info-tag-table-marker nil)
327 (goto-char (point-max))
328 (forward-line -8)
329 ;; Use string-equal, not equal, to ignore text props.
330 (or (string-equal nodename "*")
331 (not (search-forward "\^_\nEnd tag table\n" nil t))
332 (let (pos)
333 ;; We have a tag table. Find its beginning.
334 ;; Is this an indirect file?
335 (search-backward "\nTag table:\n")
336 (setq pos (point))
337 (if (save-excursion
338 (forward-line 2)
339 (looking-at "(Indirect)\n"))
340 ;; It is indirect. Copy it to another buffer
341 ;; and record that the tag table is in that buffer.
342 (save-excursion
343 (let ((buf (current-buffer)))
344 (set-buffer (get-buffer-create " *info tag table*"))
345 (buffer-disable-undo (current-buffer))
346 (setq case-fold-search t)
347 (erase-buffer)
348 (insert-buffer-substring buf)
349 (set-marker Info-tag-table-marker
350 (match-end 0))))
351 (set-marker Info-tag-table-marker pos))))
352 (setq Info-current-file
353 (if (eq filename t) "dir" filename))))
354 ;; Use string-equal, not equal, to ignore text props.
355 (if (string-equal nodename "*")
356 (progn (setq Info-current-node nodename)
357 (Info-set-mode-line))
358 ;; Search file for a suitable node.
359 (let ((guesspos (point-min))
360 (regexp (concat "Node: *" (regexp-quote nodename) " *[,\t\n\177]")))
361 ;; First get advice from tag table if file has one.
362 ;; Also, if this is an indirect info file,
363 ;; read the proper subfile into this buffer.
364 (if (marker-position Info-tag-table-marker)
365 (save-excursion
366 (set-buffer (marker-buffer Info-tag-table-marker))
367 (goto-char Info-tag-table-marker)
368 (if (re-search-forward regexp nil t)
369 (progn
370 (setq guesspos (read (current-buffer)))
371 ;; If this is an indirect file,
372 ;; determine which file really holds this node
373 ;; and read it in.
374 (if (not (eq (current-buffer) (get-buffer "*info*")))
375 (setq guesspos
376 (Info-read-subfile guesspos))))
377 (error "No such node: `%s'" nodename))))
378 (goto-char (max (point-min) (- guesspos 1000)))
379 ;; Now search from our advised position (or from beg of buffer)
380 ;; to find the actual node.
381 (catch 'foo
382 (while (search-forward "\n\^_" nil t)
383 (forward-line 1)
384 (let ((beg (point)))
385 (forward-line 1)
386 (if (re-search-backward regexp beg t)
387 (throw 'foo t))))
388 (error "No such node: %s" nodename)))
389 (Info-select-node)))
390 ;; If we did not finish finding the specified node,
391 ;; go back to the previous one.
392 (or Info-current-node no-going-back (null Info-history)
393 (let ((hist (car Info-history)))
394 (setq Info-history (cdr Info-history))
395 (Info-find-node (nth 0 hist) (nth 1 hist) t)
396 (goto-char (nth 2 hist)))))
397 (goto-char (point-min)))
398
399 ;; Cache the contents of the (virtual) dir file, once we have merged
400 ;; it for the first time, so we can save time subsequently.
401 (defvar Info-dir-contents nil)
402
403 ;; Cache for the directory we decided to use for the default-directory
404 ;; of the merged dir text.
405 (defvar Info-dir-contents-directory nil)
406
407 ;; Record the file attributes of all the files from which we
408 ;; constructed Info-dir-contents.
409 (defvar Info-dir-file-attributes nil)
410
411 ;; Construct the Info directory node by merging the files named `dir'
412 ;; from various directories. Set the *info* buffer's
413 ;; default-directory to the first directory we actually get any text
414 ;; from.
415 (defun Info-insert-dir ()
416 (if (and Info-dir-contents Info-dir-file-attributes
417 ;; Verify that none of the files we used has changed
418 ;; since we used it.
419 (eval (cons 'and
420 (mapcar '(lambda (elt)
421 (let ((curr (file-attributes (car elt))))
422 ;; Don't compare the access time.
423 (if curr (setcar (nthcdr 4 curr) 0))
424 (setcar (nthcdr 4 (cdr elt)) 0)
425 (equal (cdr elt) curr)))
426 Info-dir-file-attributes))))
427 (insert Info-dir-contents)
428 (let ((dirs Info-directory-list)
429 buffers buffer others nodes dirs-done)
430
431 (setq Info-dir-file-attributes nil)
432
433 ;; Search the directory list for the directory file.
434 (while dirs
435 (let ((truename (file-truename (expand-file-name (car dirs)))))
436 (or (member truename dirs-done)
437 (member (directory-file-name truename) dirs-done)
438 ;; Try several variants of specified name.
439 ;; Try upcasing, appending `.info', or both.
440 (let* (file
441 (attrs
442 (or
443 (progn (setq file (expand-file-name "dir" truename))
444 (file-attributes file))
445 (progn (setq file (expand-file-name "DIR" truename))
446 (file-attributes file))
447 (progn (setq file (expand-file-name "dir.info" truename))
448 (file-attributes file))
449 (progn (setq file (expand-file-name "DIR.INFO" truename))
450 (file-attributes file)))))
451 (setq dirs-done
452 (cons truename
453 (cons (directory-file-name truename)
454 dirs-done)))
455 (if attrs
456 (save-excursion
457 (or buffers
458 (message "Composing main Info directory..."))
459 (set-buffer (generate-new-buffer "info dir"))
460 (insert-file-contents file)
461 (setq buffers (cons (current-buffer) buffers)
462 Info-dir-file-attributes
463 (cons (cons file attrs)
464 Info-dir-file-attributes))))))
465 (setq dirs (cdr dirs))))
466
467 (or buffers
468 (error "Can't find the info directory node"))
469 ;; Distinguish the dir file that comes with Emacs from all the
470 ;; others. Yes, that is really what this is supposed to do.
471 ;; If it doesn't work, fix it.
472 (setq buffer (car buffers)
473 others (cdr buffers))
474
475 ;; Insert the entire original dir file as a start; use its
476 ;; default directory as the default directory for the whole
477 ;; concatenation.
478 (insert-buffer buffer)
479 (setq Info-dir-contents-directory (save-excursion
480 (set-buffer buffer)
481 default-directory))
482
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))
550
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))))
586
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))))
617
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)
624 "")
625 ")"
626 (or Info-current-node ""))))
627 \f
628 ;; Go to an info node specified with a filename-and-nodename string
629 ;; of the sort that is found in pointers in nodes.
630
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))
638 ""
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))))
648
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
660 nil
661 (all-completions string completion-table predicate)))
662 ((eq code 'lambda)
663 (if no-completion
664 t
665 (assoc string completion-table))))))
666
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)))
675
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))))
704 \f
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)))))
715 \f
716 (defvar Info-last-search nil
717 "Default regexp for \\<Info-mode-map>\\[Info-search] command to search for.")
718
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)))))
785 \f
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)
798 nil
799 (error "Node has no %s" (capitalize (or errorname name)))))))
800
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))))
815
816 (defun Info-next ()
817 "Go to the next node of this node."
818 (interactive)
819 (Info-goto-node (Info-extract-pointer "next")))
820
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")))
825
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))
831
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)))
845
846 (defun Info-directory ()
847 "Go to the Info directory node."
848 (interactive)
849 (Info-find-node "dir" "top"))
850 \f
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))
863
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)))
921
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))
939
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))))
945
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)))
982 (t
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))))))
991
992
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))
1001 beg
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)))
1037
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)))
1050
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)))
1063
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))))
1071
1072 (defun Info-top-node ()
1073 "Go to the Top node of this file."
1074 (interactive)
1075 (Info-goto-node "Top"))
1076
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)))))
1091
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))
1105 t)
1106 ((save-excursion (search-backward "next:" nil t))
1107 (Info-next)
1108 t)
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"))))
1121
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)))))
1143 (t
1144 (error "No pointer backward from this node")))))
1145
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))))))
1153
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))))
1162
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)))))
1175
1176 (defmacro Info-no-error (&rest body)
1177 (list 'condition-case nil (cons 'progn (append body '(t))) '(error nil)))
1178
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 (t
1189 (error "No more nodes"))))
1190
1191 (defun Info-last-preorder ()
1192 "Go to the last node, popping up a level if there is none."
1193 (interactive)
1194 (cond ((Info-no-error
1195 (Info-last-menu-item)
1196 ;; If we go down a menu item, go to the end of the node
1197 ;; so we can scroll back through it.
1198 (goto-char (point-max)))
1199 (recenter -1))
1200 ((Info-no-error (Info-prev))
1201 (goto-char (point-max))
1202 (recenter -1))
1203 ((Info-no-error (Info-up))
1204 (goto-char (point-min))
1205 (or (search-forward "\n* Menu:" nil t)
1206 (goto-char (point-max))))
1207 (t (error "No previous nodes"))))
1208
1209 (defun Info-scroll-up ()
1210 "Scroll one screenful forward in Info, considering all nodes as one sequence.
1211 Once you scroll far enough in a node that its menu appears on the screen,
1212 the next scroll moves into its first subnode. When you scroll past
1213 the end of a node, that goes to the next node or back up to the parent node."
1214 (interactive)
1215 (if (or (< (window-start) (point-min))
1216 (> (window-start) (point-max)))
1217 (set-window-start (selected-window) (point)))
1218 (let ((virtual-end (save-excursion
1219 (goto-char (point-min))
1220 (if (search-forward "\n* Menu:" nil t)
1221 (point)
1222 (point-max)))))
1223 (if (or (< virtual-end (window-start))
1224 (pos-visible-in-window-p virtual-end))
1225 (Info-next-preorder)
1226 (scroll-up))))
1227
1228 (defun Info-scroll-down ()
1229 "Scroll one screenful back in Info, considering all nodes as one sequence.
1230 Within the menu of a node, this goes to its last subnode.
1231 When you scroll past the beginning of a node, that goes to the
1232 previous node or back up to the parent node."
1233 (interactive)
1234 (if (or (< (window-start) (point-min))
1235 (> (window-start) (point-max)))
1236 (set-window-start (selected-window) (point)))
1237 (let ((virtual-end (save-excursion
1238 (goto-char (point-min))
1239 (search-forward "\n* Menu:" nil t))))
1240 (if (or virtual-end (pos-visible-in-window-p (point-min)))
1241 (Info-last-preorder)
1242 (scroll-down))))
1243
1244 (defun Info-next-reference ()
1245 "Move cursor to the next cross-reference or menu item in the node."
1246 (interactive)
1247 (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:")
1248 (old-pt (point)))
1249 (or (eobp) (forward-char 1))
1250 (or (re-search-forward pat nil t)
1251 (progn
1252 (goto-char (point-min))
1253 (or (re-search-forward pat nil t)
1254 (progn
1255 (goto-char old-pt)
1256 (error "No cross references in this node")))))
1257 (goto-char (match-beginning 0))
1258 (if (looking-at "\\* Menu:")
1259 (Info-next-reference))))
1260
1261 (defun Info-prev-reference ()
1262 "Move cursor to the previous cross-reference or menu item in the node."
1263 (interactive)
1264 (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:")
1265 (old-pt (point)))
1266 (or (re-search-backward pat nil t)
1267 (progn
1268 (goto-char (point-max))
1269 (or (re-search-backward pat nil t)
1270 (progn
1271 (goto-char old-pt)
1272 (error "No cross references in this node")))))
1273 (goto-char (match-beginning 0))
1274 (if (looking-at "\\* Menu:")
1275 (Info-prev-reference))))
1276
1277 (defun Info-index (topic)
1278 "Look up a string in the index for this file.
1279 The index is defined as the first node in the top-level menu whose
1280 name contains the word \"Index\", plus any immediately following
1281 nodes whose names also contain the word \"Index\".
1282 If there are no exact matches to the specified topic, this chooses
1283 the first match which is a case-insensitive substring of a topic.
1284 Use the `,' command to see the other matches.
1285 Give a blank topic name to go to the Index node itself."
1286 (interactive "sIndex topic: ")
1287 (let ((orignode Info-current-node)
1288 (rnode nil)
1289 (pattern (format "\n\\* \\([^\n:]*%s[^\n:]*\\):[ \t]*\\([^.\n]*\\)\\.[ \t]*\\([0-9]*\\)"
1290 (regexp-quote topic)))
1291 node)
1292 (Info-goto-node "Top")
1293 (or (search-forward "\n* menu:" nil t)
1294 (error "No index"))
1295 (or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t)
1296 (error "No index"))
1297 (goto-char (match-beginning 1))
1298 ;; Here, and subsequently in this function,
1299 ;; we bind Info-history to nil for internal node-switches
1300 ;; so that we don't put junk in the history.
1301 ;; In the first Info-goto-node call, above, we do update the history
1302 ;; because that is what the user's previous node choice into it.
1303 (let ((Info-history nil))
1304 (Info-goto-node (Info-extract-menu-node-name)))
1305 (or (equal topic "")
1306 (let ((matches nil)
1307 (exact nil)
1308 (Info-history nil)
1309 found)
1310 (while
1311 (progn
1312 (goto-char (point-min))
1313 (while (re-search-forward pattern nil t)
1314 (setq matches
1315 (cons (list (buffer-substring (match-beginning 1)
1316 (match-end 1))
1317 (buffer-substring (match-beginning 2)
1318 (match-end 2))
1319 Info-current-node
1320 (string-to-int (concat "0"
1321 (buffer-substring
1322 (match-beginning 3)
1323 (match-end 3)))))
1324 matches)))
1325 (and (setq node (Info-extract-pointer "next" t))
1326 (string-match "\\<Index\\>" node)))
1327 (Info-goto-node node))
1328 (or matches
1329 (progn
1330 (Info-last)
1331 (error "No `%s' in index" topic)))
1332 ;; Here it is a feature that assoc is case-sensitive.
1333 (while (setq found (assoc topic matches))
1334 (setq exact (cons found exact)
1335 matches (delq found matches)))
1336 (setq Info-index-alternatives (nconc exact (nreverse matches)))
1337 (Info-index-next 0)))))
1338
1339 (defun Info-index-next (num)
1340 "Go to the next matching index item from the last `i' command."
1341 (interactive "p")
1342 (or Info-index-alternatives
1343 (error "No previous `i' command in this file"))
1344 (while (< num 0)
1345 (setq num (+ num (length Info-index-alternatives))))
1346 (while (> num 0)
1347 (setq Info-index-alternatives
1348 (nconc (cdr Info-index-alternatives)
1349 (list (car Info-index-alternatives)))
1350 num (1- num)))
1351 (Info-goto-node (nth 1 (car Info-index-alternatives)))
1352 (if (> (nth 3 (car Info-index-alternatives)) 0)
1353 (forward-line (nth 3 (car Info-index-alternatives)))
1354 (forward-line 3) ; don't search in headers
1355 (let ((name (car (car Info-index-alternatives))))
1356 (Info-find-index-name name)))
1357 (message "Found `%s' in %s. %s"
1358 (car (car Info-index-alternatives))
1359 (nth 2 (car Info-index-alternatives))
1360 (if (cdr Info-index-alternatives)
1361 "(Press `,' for more)"
1362 "(Only match)")))
1363
1364 (defun Info-find-index-name (name)
1365 "Move point to the place within the current node where NAME is defined."
1366 (if (or (re-search-forward (format
1367 "[a-zA-Z]+: %s\\( \\|$\\)"
1368 (regexp-quote name)) nil t)
1369 (search-forward (format "`%s'" name) nil t)
1370 (and (string-match "\\`.*\\( (.*)\\)\\'" name)
1371 (search-forward
1372 (format "`%s'" (substring name 0 (match-beginning 1)))
1373 nil t))
1374 (search-forward name nil t))
1375 (beginning-of-line)
1376 (goto-char (point-min))))
1377
1378 (defun Info-undefined ()
1379 "Make command be undefined in Info."
1380 (interactive)
1381 (ding))
1382
1383 (defun Info-help ()
1384 "Enter the Info tutorial."
1385 (interactive)
1386 (delete-other-windows)
1387 (Info-find-node "info"
1388 (if (< (window-height) 23)
1389 "Help-Small-Screen"
1390 "Help")))
1391
1392 (defun Info-summary ()
1393 "Display a brief summary of all Info commands."
1394 (interactive)
1395 (save-window-excursion
1396 (switch-to-buffer "*Help*")
1397 (erase-buffer)
1398 (insert (documentation 'Info-mode))
1399 (help-mode)
1400 (goto-char (point-min))
1401 (let (ch flag)
1402 (while (progn (setq flag (not (pos-visible-in-window-p (point-max))))
1403 (message (if flag "Type Space to see more"
1404 "Type Space to return to Info"))
1405 (if (not (eq ?\ (setq ch (read-event))))
1406 (progn (setq unread-command-events (list ch)) nil)
1407 flag))
1408 (scroll-up)))
1409 (bury-buffer "*Help*")))
1410 \f
1411 (defun Info-get-token (pos start all &optional errorstring)
1412 "Return the token around POS,
1413 POS must be somewhere inside the token
1414 START is a regular expression which will match the
1415 beginning of the tokens delimited string
1416 ALL is a regular expression with a single
1417 parenthesized subpattern which is the token to be
1418 returned. E.g. '{\(.*\)}' would return any string
1419 enclosed in braces around POS.
1420 SIG optional fourth argument, controls action on no match
1421 nil: return nil
1422 t: beep
1423 a string: signal an error, using that string."
1424 (save-excursion
1425 (goto-char pos)
1426 (re-search-backward start (max (point-min) (- pos 200)) 'yes)
1427 (let (found)
1428 (while (and (re-search-forward all (min (point-max) (+ pos 200)) 'yes)
1429 (not (setq found (and (<= (match-beginning 0) pos)
1430 (> (match-end 0) pos))))))
1431 (if (and found (<= (match-beginning 0) pos)
1432 (> (match-end 0) pos))
1433 (buffer-substring (match-beginning 1) (match-end 1))
1434 (cond ((null errorstring)
1435 nil)
1436 ((eq errorstring t)
1437 (beep)
1438 nil)
1439 (t
1440 (error "No %s around position %d" errorstring pos)))))))
1441
1442 (defun Info-mouse-follow-nearest-node (click)
1443 "\\<Info-mode-map>Follow a node reference near point.
1444 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click.
1445 At end of the node's text, moves to the next node, or up if none."
1446 (interactive "e")
1447 (let* ((start (event-start click))
1448 (window (car start))
1449 (pos (car (cdr start))))
1450 (select-window window)
1451 (goto-char pos))
1452 (and (not (Info-try-follow-nearest-node))
1453 (save-excursion (forward-line 1) (eobp))
1454 (Info-next-preorder)))
1455
1456 (defun Info-follow-nearest-node ()
1457 "\\<Info-mode-map>Follow a node reference near point.
1458 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where point is.
1459 If no reference to follow, moves to the next node, or up if none."
1460 (interactive)
1461 (or (Info-try-follow-nearest-node)
1462 (Info-next-preorder)))
1463
1464 ;; Common subroutine.
1465 (defun Info-try-follow-nearest-node ()
1466 "Follow a node reference near point. Return non-nil if successful."
1467 (let (node)
1468 (cond
1469 ((setq node (Info-get-token (point) "\\*note[ \n]"
1470 "\\*note[ \n]\\([^:]*\\):"))
1471 (Info-follow-reference node))
1472 ((setq node (Info-get-token (point) "\\* " "\\* \\([^:]*\\)::"))
1473 (Info-goto-node node))
1474 ((setq node (Info-get-token (point) "\\* " "\\* \\([^:]*\\):"))
1475 (Info-menu node))
1476 ((setq node (Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)"))
1477 (Info-goto-node node))
1478 ((setq node (Info-get-token (point) "Next: " "Next: \\([^,\n\t]*\\)"))
1479 (Info-goto-node node))
1480 ((setq node (Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)"))
1481 (Info-goto-node "Top"))
1482 ((setq node (Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)"))
1483 (Info-goto-node node)))
1484 node))
1485 \f
1486 (defvar Info-mode-map nil
1487 "Keymap containing Info commands.")
1488 (if Info-mode-map
1489 nil
1490 (setq Info-mode-map (make-keymap))
1491 (suppress-keymap Info-mode-map)
1492 (define-key Info-mode-map "." 'beginning-of-buffer)
1493 (define-key Info-mode-map " " 'Info-scroll-up)
1494 (define-key Info-mode-map "\C-m" 'Info-follow-nearest-node)
1495 (define-key Info-mode-map "\t" 'Info-next-reference)
1496 (define-key Info-mode-map "\e\t" 'Info-prev-reference)
1497 (define-key Info-mode-map "1" 'Info-nth-menu-item)
1498 (define-key Info-mode-map "2" 'Info-nth-menu-item)
1499 (define-key Info-mode-map "3" 'Info-nth-menu-item)
1500 (define-key Info-mode-map "4" 'Info-nth-menu-item)
1501 (define-key Info-mode-map "5" 'Info-nth-menu-item)
1502 (define-key Info-mode-map "6" 'Info-nth-menu-item)
1503 (define-key Info-mode-map "7" 'Info-nth-menu-item)
1504 (define-key Info-mode-map "8" 'Info-nth-menu-item)
1505 (define-key Info-mode-map "9" 'Info-nth-menu-item)
1506 (define-key Info-mode-map "0" 'undefined)
1507 (define-key Info-mode-map "?" 'Info-summary)
1508 (define-key Info-mode-map "]" 'Info-forward-node)
1509 (define-key Info-mode-map "[" 'Info-backward-node)
1510 (define-key Info-mode-map "<" 'Info-top-node)
1511 (define-key Info-mode-map ">" 'Info-final-node)
1512 (define-key Info-mode-map "b" 'beginning-of-buffer)
1513 (define-key Info-mode-map "d" 'Info-directory)
1514 (define-key Info-mode-map "e" 'Info-edit)
1515 (define-key Info-mode-map "f" 'Info-follow-reference)
1516 (define-key Info-mode-map "g" 'Info-goto-node)
1517 (define-key Info-mode-map "h" 'Info-help)
1518 (define-key Info-mode-map "i" 'Info-index)
1519 (define-key Info-mode-map "l" 'Info-last)
1520 (define-key Info-mode-map "m" 'Info-menu)
1521 (define-key Info-mode-map "n" 'Info-next)
1522 (define-key Info-mode-map "p" 'Info-prev)
1523 (define-key Info-mode-map "q" 'Info-exit)
1524 (define-key Info-mode-map "s" 'Info-search)
1525 ;; For consistency with Rmail.
1526 (define-key Info-mode-map "\M-s" 'Info-search)
1527 (define-key Info-mode-map "t" 'Info-top-node)
1528 (define-key Info-mode-map "u" 'Info-up)
1529 (define-key Info-mode-map "," 'Info-index-next)
1530 (define-key Info-mode-map "\177" 'Info-scroll-down)
1531 (define-key Info-mode-map [mouse-2] 'Info-mouse-follow-nearest-node)
1532 )
1533 \f
1534 ;; Info mode is suitable only for specially formatted data.
1535 (put 'info-mode 'mode-class 'special)
1536
1537 (defun Info-mode ()
1538 "\\<Info-mode-map>
1539 Info mode provides commands for browsing through the Info documentation tree.
1540 Documentation in Info is divided into \"nodes\", each of which discusses
1541 one topic and contains references to other nodes which discuss related
1542 topics. Info has commands to follow the references and show you other nodes.
1543
1544 \\[Info-help] Invoke the Info tutorial.
1545
1546 Selecting other nodes:
1547 \\[Info-mouse-follow-nearest-node]
1548 Follow a node reference you click on.
1549 This works with menu items, cross references, and
1550 the \"next\", \"previous\" and \"up\", depending on where you click.
1551 \\[Info-next] Move to the \"next\" node of this node.
1552 \\[Info-prev] Move to the \"previous\" node of this node.
1553 \\[Info-up] Move \"up\" from this node.
1554 \\[Info-menu] Pick menu item specified by name (or abbreviation).
1555 Picking a menu item causes another node to be selected.
1556 \\[Info-directory] Go to the Info directory node.
1557 \\[Info-follow-reference] Follow a cross reference. Reads name of reference.
1558 \\[Info-last] Move to the last node you were at.
1559 \\[Info-index] Look up a topic in this file's Index and move to that node.
1560 \\[Info-index-next] (comma) Move to the next match from a previous `i' command.
1561
1562 Moving within a node:
1563 \\[Info-scroll-up] Normally, scroll forward a full screen. If the end of the buffer is
1564 already visible, try to go to the next menu entry, or up if there is none.
1565 \\[Info-scroll-down] Normally, scroll backward. If the beginning of the buffer is
1566 already visible, try to go to the previous menu entry, or up if there is none.
1567 \\[beginning-of-buffer] Go to beginning of node.
1568
1569 Advanced commands:
1570 \\[Info-exit] Quit Info: reselect previously selected buffer.
1571 \\[Info-edit] Edit contents of selected node.
1572 1 Pick first item in node's menu.
1573 2, 3, 4, 5 Pick second ... fifth item in node's menu.
1574 \\[Info-goto-node] Move to node specified by name.
1575 You may include a filename as well, as (FILENAME)NODENAME.
1576 \\[universal-argument] \\[info] Move to new Info file with completion.
1577 \\[Info-search] Search through this Info file for specified regexp,
1578 and select the node in which the next occurrence is found.
1579 \\[Info-next-reference] Move cursor to next cross-reference or menu item.
1580 \\[Info-prev-reference] Move cursor to previous cross-reference or menu item."
1581 (kill-all-local-variables)
1582 (setq major-mode 'Info-mode)
1583 (setq mode-name "Info")
1584 (use-local-map Info-mode-map)
1585 (set-syntax-table text-mode-syntax-table)
1586 (setq local-abbrev-table text-mode-abbrev-table)
1587 (setq case-fold-search t)
1588 (setq buffer-read-only t)
1589 (make-local-variable 'Info-current-file)
1590 (make-local-variable 'Info-current-subfile)
1591 (make-local-variable 'Info-current-node)
1592 (make-local-variable 'Info-tag-table-marker)
1593 (make-local-variable 'Info-history)
1594 (make-local-variable 'Info-index-alternatives)
1595 (if (memq (framep (selected-frame)) '(x pc))
1596 (progn
1597 (make-face 'info-node)
1598 (make-face 'info-menu-5)
1599 (make-face 'info-xref)
1600 (or (face-differs-from-default-p 'info-node)
1601 (if (face-differs-from-default-p 'bold-italic)
1602 (copy-face 'bold-italic 'info-node)
1603 (copy-face 'bold 'info-node)))
1604 (or (face-differs-from-default-p 'info-menu-5)
1605 (set-face-underline-p 'info-menu-5 t))
1606 (or (face-differs-from-default-p 'info-xref)
1607 (copy-face 'bold 'info-xref)))
1608 (setq Info-fontify nil))
1609 (Info-set-mode-line)
1610 (run-hooks 'Info-mode-hook))
1611
1612 (defvar Info-edit-map nil
1613 "Local keymap used within `e' command of Info.")
1614 (if Info-edit-map
1615 nil
1616 (setq Info-edit-map (nconc (make-sparse-keymap) text-mode-map))
1617 (define-key Info-edit-map "\C-c\C-c" 'Info-cease-edit))
1618
1619 ;; Info-edit mode is suitable only for specially formatted data.
1620 (put 'info-edit-mode 'mode-class 'special)
1621
1622 (defun Info-edit-mode ()
1623 "Major mode for editing the contents of an Info node.
1624 Like text mode with the addition of `Info-cease-edit'
1625 which returns to Info mode for browsing.
1626 \\{Info-edit-map}"
1627 (use-local-map Info-edit-map)
1628 (setq major-mode 'Info-edit-mode)
1629 (setq mode-name "Info Edit")
1630 (kill-local-variable 'mode-line-buffer-identification)
1631 (setq buffer-read-only nil)
1632 (force-mode-line-update)
1633 (buffer-enable-undo (current-buffer))
1634 (run-hooks 'Info-edit-mode-hook))
1635
1636 (defun Info-edit ()
1637 "Edit the contents of this Info node.
1638 Allowed only if variable `Info-enable-edit' is non-nil."
1639 (interactive)
1640 (or Info-enable-edit
1641 (error "Editing info nodes is not enabled"))
1642 (Info-edit-mode)
1643 (message "%s" (substitute-command-keys
1644 "Editing: Type \\<Info-edit-map>\\[Info-cease-edit] to return to info")))
1645
1646 (defun Info-cease-edit ()
1647 "Finish editing Info node; switch back to Info proper."
1648 (interactive)
1649 ;; Do this first, so nothing has changed if user C-g's at query.
1650 (and (buffer-modified-p)
1651 (y-or-n-p "Save the file? ")
1652 (save-buffer))
1653 (use-local-map Info-mode-map)
1654 (setq major-mode 'Info-mode)
1655 (setq mode-name "Info")
1656 (Info-set-mode-line)
1657 (setq buffer-read-only t)
1658 (force-mode-line-update)
1659 (and (marker-position Info-tag-table-marker)
1660 (buffer-modified-p)
1661 (message "Tags may have changed. Use Info-tagify if necessary")))
1662 \f
1663 (defvar Info-file-list-for-emacs
1664 '("ediff" "forms" "gnus" "info" ("mh" . "mh-e") "sc")
1665 "List of Info files that describe Emacs commands.
1666 An element can be a file name, or a list of the form (PREFIX . FILE)
1667 where PREFIX is a name prefix and FILE is the file to look in.
1668 If the element is just a file name, the file name also serves as the prefix.")
1669
1670 (defun Info-find-emacs-command-nodes (command)
1671 "Return a list of locations documenting COMMAND.
1672 The `info-file' property of COMMAND says which Info manual to search.
1673 If COMMAND has no property, the variable `Info-file-list-for-emacs'
1674 defines heuristics for which Info manual to try.
1675 The locations are of the format used in Info-history, i.e.
1676 \(FILENAME NODENAME BUFFERPOS\)."
1677 (let ((where '())
1678 (cmd-desc (concat "^\\* " (regexp-quote (symbol-name command))
1679 ":\\s *\\(.*\\)\\.$"))
1680 (info-file "emacs")) ;default
1681 ;; Determine which info file this command is documented in.
1682 (if (get command 'info-file)
1683 (setq info-file (get command 'info-file))
1684 ;; If it doesn't say explicitly, test its name against
1685 ;; various prefixes that we know.
1686 (let ((file-list Info-file-list-for-emacs))
1687 (while file-list
1688 (let* ((elt (car file-list))
1689 (name (if (consp elt)
1690 (car elt)
1691 elt))
1692 (file (if (consp elt) (cdr elt) elt))
1693 (regexp (concat "\\`" (regexp-quote name)
1694 "\\(\\'\\|-\\)")))
1695 (if (string-match regexp (symbol-name command))
1696 (setq info-file file file-list nil))
1697 (setq file-list (cdr file-list))))))
1698 (save-excursion
1699 (condition-case nil
1700 (Info-find-node info-file "Command Index")
1701 ;; Some manuals may not have a separate Command Index node,
1702 ;; so try just Index instead.
1703 (error
1704 (Info-find-node info-file "Index")))
1705 ;; Take the index node off the Info history.
1706 (setq Info-history (cdr Info-history))
1707 (goto-char (point-max))
1708 (while (re-search-backward cmd-desc nil t)
1709 (setq where (cons (list Info-current-file
1710 (buffer-substring
1711 (match-beginning 1)
1712 (match-end 1))
1713 0)
1714 where)))
1715 where)))
1716
1717 ;;;###autoload
1718 (defun Info-goto-emacs-command-node (command)
1719 "Go to the Info node in the Emacs manual for command COMMAND.
1720 The command is found by looking up in Emacs manual's Command Index
1721 or in another manual found via COMMAND's `info-file' property or
1722 the variable `Info-file-list-for-emacs'."
1723 (interactive "CFind documentation for command: ")
1724 (or (commandp command)
1725 (signal 'wrong-type-argument (list 'commandp command)))
1726 (let ((where (Info-find-emacs-command-nodes command)))
1727 (if where
1728 (let ((num-matches (length where)))
1729 ;; Get Info running, and pop to it in another window.
1730 (save-window-excursion
1731 (info))
1732 (pop-to-buffer "*info*")
1733 (Info-find-node (car (car where))
1734 (car (cdr (car where))))
1735 (if (> num-matches 1)
1736 (progn
1737 ;; Info-find-node already pushed (car where) onto
1738 ;; Info-history. Put the other nodes that were found on
1739 ;; the history.
1740 (setq Info-history (nconc (cdr where) Info-history))
1741 (message "Found %d other entr%s. Use %s to see %s."
1742 (1- num-matches)
1743 (if (> num-matches 2) "ies" "y")
1744 (substitute-command-keys "\\[Info-last]")
1745 (if (> num-matches 2) "them" "it")))))
1746 (error "Couldn't find documentation for %s" command))))
1747
1748 ;;;###autoload
1749 (defun Info-goto-emacs-key-command-node (key)
1750 "Go to the Info node in the Emacs manual the command bound to KEY, a string.
1751 Interactively, if the binding is execute-extended-command, a command is read.
1752 The command is found by looking up in Emacs manual's Command Index
1753 or in another manual found via COMMAND's `info-file' property or
1754 the variable `Info-file-list-for-emacs'."
1755 (interactive "kFind documentation for key:")
1756 (let ((command (key-binding key)))
1757 (cond ((null command)
1758 (message "%s is undefined" (key-description key)))
1759 ((and (interactive-p)
1760 (eq command 'execute-extended-command))
1761 (Info-goto-emacs-command-node
1762 (read-command "Find documentation for command: ")))
1763 (t
1764 (Info-goto-emacs-command-node command)))))
1765 \f
1766 (defvar Info-title-face-alist
1767 '((?* bold underline)
1768 (?= bold-italic underline)
1769 (?- italic underline))
1770 "*Alist of face or list of faces to use for pseudo-underlined titles.
1771 The alist key is the character the title is underlined with (?*, ?= or ?-).")
1772
1773 (defun Info-fontify-node ()
1774 (save-excursion
1775 (let ((buffer-read-only nil))
1776 (goto-char (point-min))
1777 (if (looking-at "^File: [^,: \t]+,?[ \t]+")
1778 (progn
1779 (goto-char (match-end 0))
1780 (while
1781 (looking-at "[ \t]*[^:, \t\n]+:[ \t]+\\([^:,\t\n]+\\),?")
1782 (goto-char (match-end 0))
1783 (put-text-property (match-beginning 1) (match-end 1)
1784 'face 'info-xref)
1785 (put-text-property (match-beginning 1) (match-end 1)
1786 'mouse-face 'highlight))))
1787 (goto-char (point-min))
1788 (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*+\\|=+\\|-+\\)$"
1789 nil t)
1790 (put-text-property (match-beginning 1) (match-end 1)
1791 'face
1792 (cdr (assq (preceding-char) Info-title-face-alist)))
1793 (put-text-property (match-end 1) (match-end 2)
1794 'invisible t))
1795 (goto-char (point-min))
1796 (while (re-search-forward "\\*Note[ \n\t]+\\([^:]*\\):" nil t)
1797 (if (= (char-after (1- (match-beginning 0))) ?\") ; hack
1798 nil
1799 (put-text-property (match-beginning 1) (match-end 1)
1800 'face 'info-xref)
1801 (put-text-property (match-beginning 1) (match-end 1)
1802 'mouse-face 'highlight)))
1803 (goto-char (point-min))
1804 (if (and (search-forward "\n* Menu:" nil t)
1805 (not (string-match "\\<Index\\>" Info-current-node))
1806 ;; Don't take time to annotate huge menus
1807 (< (- (point-max) (point)) Info-fontify-maximum-menu-size))
1808 (let ((n 0))
1809 (while (re-search-forward "^\\* \\([^:\t\n]*\\):" nil t)
1810 (setq n (1+ n))
1811 (if (memq n '(5 9)) ; visual aids to help with 1-9 keys
1812 (put-text-property (match-beginning 0)
1813 (1+ (match-beginning 0))
1814 'face 'info-menu-5))
1815 (put-text-property (match-beginning 1) (match-end 1)
1816 'face 'info-node)
1817 (put-text-property (match-beginning 1) (match-end 1)
1818 'mouse-face 'highlight))))
1819 (set-buffer-modified-p nil))))
1820
1821 (provide 'info)
1822
1823 ;;; info.el ends here