1 ;;; info.el --- info package for Emacs.
3 ;; Copyright (C) 1985, 1986, 1992, 1993 Free Software Foundation, Inc.
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)
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
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 ;;; Note that nowadays we expect info files to be made using makeinfo.
30 (defvar Info-history nil
31 "List of info nodes user has visited.
32 Each element of list is a list (FILENAME NODENAME BUFFERPOS).")
34 (defvar Info-enable-edit nil
35 "*Non-nil means the \\<Info-mode-map>\\[Info-edit] command in Info can edit the current node.
36 This is convenient if you want to write info files by hand.
37 However, we recommend that you not do this.
38 It is better to write a Texinfo file and generate the Info file from that,
39 because that gives you a printed manual as well.")
41 (defvar Info-enable-active-nodes t
42 "Non-nil allows Info to execute Lisp code associated with nodes.
43 The Lisp code is executed when the node is selected.")
45 (defvar Info-default-directory-list nil
46 "List of default directories to search for Info documentation files.
47 This value is used as the default for `Info-directory-list'. It is set
50 (defvar Info-fontify t
51 "*Non-nil enables highlighting and fonts in Info nodes.")
53 (defvar Info-directory-list
54 (let ((path (getenv "INFOPATH"))
55 (sibling (expand-file-name "../info/" (invocation-directory))))
59 (while (> (length path) 0)
60 (setq idx (or (string-match ":" path) (length path))
61 list (cons (substring path 0 idx) list)
62 path (substring path (min (1+ idx)
65 (if (or (member sibling Info-default-directory-list)
66 (not (file-exists-p sibling)))
67 Info-default-directory-list
68 (reverse (cons sibling (cdr (reverse Info-default-directory-list)))))))
69 "List of directories to search for Info documentation files.
70 nil means not yet initialized. In this case, Info uses the environment
71 variable INFOPATH to initialize it, or `Info-default-directory-list'
72 if there is no INFOPATH variable in the environment.")
74 (defvar Info-current-file nil
75 "Info file that Info is now looking at, or nil.")
77 (defvar Info-current-subfile nil
78 "Info subfile that is actually in the *info* buffer now,
79 or nil if current info file is not split into subfiles.")
81 (defvar Info-current-node nil
82 "Name of node that Info is now looking at, or nil.")
84 (defvar Info-tag-table-marker (make-marker)
85 "Marker pointing at beginning of current Info file's tag table.
86 Marker points nowhere if file has no tag table.")
88 (defvar Info-current-file-completions nil
89 "Cached completion list for current Info file.")
91 (defvar Info-index-alternatives nil
92 "List of possible matches for last Info-index command.")
94 (defvar Info-standalone nil
95 "Non-nil if Emacs was started solely as an Info browser.")
97 (defvar Info-suffix-list '( (".info" . nil)
103 (".info.Z" . "uncompress")
104 (".info.Y" . "unyabba")
105 (".info.gz" . "gunzip")
106 (".info.z" . "gunzip"))
107 "List of file name suffixes and associated decoding commands.
108 Each entry should be (SUFFIX . STRING); the file is given to
109 the command as standard input. If STRING is nil, no decoding is done.")
111 (defun info-insert-file-contents (filename &optional visit)
112 "Insert the contents of an info file in the current buffer.
113 Do the right thing if the file has been compressed or zipped."
118 (let ((compressed (concat filename (car x))))
119 (if (file-exists-p compressed)
121 (insert-file-contents compressed visit)
123 (let ((buffer-read-only nil))
124 (shell-command-on-region
125 (point-min) (point-max) (cdr x) t)))
129 (error "Can't find %s or any compressed version of it!" filename)))
132 (defun info (&optional file)
133 "Enter Info, the documentation browser.
134 Optional argument FILE specifies the file to examine;
135 the default is the top-level directory of Info.
137 In interactive use, a prefix argument directs this command
138 to read a file name from the minibuffer."
139 (interactive (if current-prefix-arg
140 (list (read-file-name "Info file name: " nil nil t))))
142 (Info-goto-node (concat "(" file ")"))
143 (if (get-buffer "*info*")
144 (switch-to-buffer "*info*")
148 (defun info-standalone ()
149 "Run Emacs as a standalone Info reader.
150 Usage: emacs -f info-standalone [filename]
151 In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
152 (setq Info-standalone t)
153 (if (and command-line-args-left
154 (not (string-match "^-" (car command-line-args-left))))
157 (info (car command-line-args-left))
158 (setq command-line-args-left (cdr command-line-args-left)))
159 (error (send-string-to-terminal
160 (format "%s\n" (if (eq (car-safe err) 'error)
162 (save-buffers-kill-emacs)))
165 ;; Go to an info node specified as separate filename and nodename.
166 ;; no-going-back is non-nil if recovering from an error in this function;
167 ;; it says do not attempt further (recursive) error recovery.
168 (defun Info-find-node (filename nodename &optional no-going-back)
169 ;; Convert filename to lower case if not found as specified.
172 (let (temp temp-downcase found)
173 (setq filename (substitute-in-file-name filename))
174 (if (string= (downcase (file-name-nondirectory filename)) "dir")
176 (let ((dirs (if (string-match "^\\./" filename)
177 ;; If specified name starts with `./'
178 ;; then just try current directory.
180 Info-directory-list)))
181 ;; Search the directory list for file FILENAME.
182 (while (and dirs (not found))
183 (setq temp (expand-file-name filename (car dirs)))
185 (expand-file-name (downcase filename) (car dirs)))
186 ;; Try several variants of specified name.
191 (if (file-exists-p (concat temp (car x)))
194 (throw 'foundit nil)))
195 (if (file-exists-p (concat temp-downcase (car x)))
197 (setq found temp-downcase)
198 (throw 'foundit nil)))))
200 (setq dirs (cdr dirs)))))
202 (setq filename found)
203 (error "Info file %s does not exist" filename))))
204 ;; Record the node we are leaving.
205 (if (and Info-current-file (not no-going-back))
207 (cons (list Info-current-file Info-current-node (point))
209 ;; Go into info buffer.
210 (switch-to-buffer "*info*")
211 (buffer-disable-undo (current-buffer))
212 (or (eq major-mode 'Info-mode)
215 (setq Info-current-node nil)
218 ;; Switch files if necessary
220 (equal Info-current-file filename)
221 (let ((buffer-read-only nil))
222 (setq Info-current-file nil
223 Info-current-subfile nil
224 Info-current-file-completions nil
225 Info-index-alternatives nil
226 buffer-file-name nil)
230 (info-insert-file-contents filename t)
231 (setq default-directory (file-name-directory filename)))
232 (set-buffer-modified-p nil)
233 ;; See whether file has a tag table. Record the location if yes.
234 (set-marker Info-tag-table-marker nil)
235 (goto-char (point-max))
237 (or (equal nodename "*")
238 (not (search-forward "\^_\nEnd tag table\n" nil t))
240 ;; We have a tag table. Find its beginning.
241 ;; Is this an indirect file?
242 (search-backward "\nTag table:\n")
246 (looking-at "(Indirect)\n"))
247 ;; It is indirect. Copy it to another buffer
248 ;; and record that the tag table is in that buffer.
250 (let ((buf (current-buffer)))
251 (set-buffer (get-buffer-create " *info tag table*"))
252 (buffer-disable-undo (current-buffer))
253 (setq case-fold-search t)
255 (insert-buffer-substring buf)
256 (set-marker Info-tag-table-marker
258 (set-marker Info-tag-table-marker pos))))
259 (setq Info-current-file
260 (if (eq filename t) "dir"
261 (file-name-sans-versions buffer-file-name)))))
262 (if (equal nodename "*")
263 (progn (setq Info-current-node nodename)
264 (Info-set-mode-line))
265 ;; Search file for a suitable node.
266 (let ((guesspos (point-min))
267 (regexp (concat "Node: *" (regexp-quote nodename) " *[,\t\n\177]")))
268 ;; First get advice from tag table if file has one.
269 ;; Also, if this is an indirect info file,
270 ;; read the proper subfile into this buffer.
271 (if (marker-position Info-tag-table-marker)
273 (set-buffer (marker-buffer Info-tag-table-marker))
274 (goto-char Info-tag-table-marker)
275 (if (re-search-forward regexp nil t)
277 (setq guesspos (read (current-buffer)))
278 ;; If this is an indirect file,
279 ;; determine which file really holds this node
281 (if (not (eq (current-buffer) (get-buffer "*info*")))
283 (Info-read-subfile guesspos))))
284 (error "No such node: \"%s\"" nodename))))
285 (goto-char (max (point-min) (- guesspos 1000)))
286 ;; Now search from our advised position (or from beg of buffer)
287 ;; to find the actual node.
289 (while (search-forward "\n\^_" nil t)
293 (if (re-search-backward regexp beg t)
295 (error "No such node: %s" nodename)))
297 ;; If we did not finish finding the specified node,
298 ;; go back to the previous one.
299 (or Info-current-node no-going-back
300 (let ((hist (car Info-history)))
301 (setq Info-history (cdr Info-history))
302 (Info-find-node (nth 0 hist) (nth 1 hist) t)
303 (goto-char (nth 2 hist)))))
304 (goto-char (point-min)))
306 ;; Cache the contents of the (virtual) dir file, once we have merged
307 ;; it for the first time, so we can save time subsequently.
308 (defvar Info-dir-contents nil)
310 ;; Cache for the directory we decided to use for the default-directory
311 ;; of the merged dir text.
312 (defvar Info-dir-contents-directory nil)
314 ;; Record the file attributes of all the files from which we
315 ;; constructed Info-dir-contents.
316 (defvar Info-dir-file-attributes nil)
318 ;; Construct the Info directory node by merging the files named `dir'
319 ;; from various directories. Set the *info* buffer's
320 ;; default-directory to the first directory we actually get any text
322 (defun Info-insert-dir ()
323 (if (and Info-dir-contents Info-dir-file-attributes
324 ;; Verify that none of the files we used has changed
327 (mapcar '(lambda (elt)
329 (file-attributes (car elt))))
330 Info-dir-file-attributes))))
331 (insert Info-dir-contents)
332 (let ((dirs Info-directory-list)
333 buffers buffer others nodes dirs-done)
335 ;; Search the directory list for the directory file.
337 (let ((truename (file-truename (expand-file-name (car dirs)))))
338 (or (member truename dirs-done)
339 (member (directory-file-name truename) dirs-done)
340 ;; Try several variants of specified name.
341 ;; Try upcasing, appending `.info', or both.
345 ((progn (setq temp (expand-file-name "DIR" (car dirs)))
346 (file-exists-p temp))
347 (find-file-noselect temp))
348 ((progn (setq temp (expand-file-name "dir" (car dirs)))
349 (file-exists-p temp))
350 (find-file-noselect temp))
351 ((progn (setq temp (expand-file-name "DIR.INFO" (car dirs)))
352 (file-exists-p temp))
353 (find-file-noselect temp))
354 ((progn (setq temp (expand-file-name "dir.info" (car dirs)))
355 (file-exists-p temp))
356 (find-file-noselect temp)))))
359 (cons (directory-file-name truename)
361 (if buffer (setq buffers (cons buffer buffers)
362 Info-dir-file-attributes
363 (cons (cons (buffer-file-name buffer)
364 (file-attributes (buffer-file-name buffer)))
365 Info-dir-file-attributes))))))
366 (setq dirs (cdr dirs)))
368 ;; Distinguish the dir file that comes with Emacs from all the
369 ;; others. Yes, that is really what this is supposed to do.
370 ;; If it doesn't work, fix it.
371 (setq buffer (car buffers)
372 others (cdr buffers))
374 ;; Insert the entire original dir file as a start; use its
375 ;; default directory as the default directory for the whole
377 (insert-buffer buffer)
378 (setq Info-dir-contents-directory (save-excursion
382 ;; Look at each of the other buffers one by one.
384 (let ((other (car others)))
385 ;; In each, find all the menus.
388 (goto-char (point-min))
389 ;; Find each menu, and add an elt to NODES for it.
390 (while (re-search-forward "^\\* Menu:" nil t)
391 (let (beg nodename end)
394 (search-backward "\n
\1f")
395 (search-forward "Node: ")
396 (setq nodename (Info-following-node-name))
397 (search-forward "\n
\1f" nil 'move)
400 (setq nodes (cons (list nodename other beg end) nodes))))))
401 (setq others (cdr others)))
402 ;; Add to the main menu a menu item for each other node.
403 (re-search-forward "^\\* Menu:")
405 (let ((menu-items '("top"))
408 (end (save-excursion (search-forward "
\1f" nil t) (point))))
410 (let ((nodename (car (car nodes))))
411 (or (member (downcase nodename) menu-items)
412 (re-search-forward (concat "^\\* " (regexp-quote nodename) ":")
415 (insert "* " nodename "::" "\n")
416 (setq menu-items (cons nodename menu-items)))))
417 (setq nodes (cdr nodes))))
418 ;; Now take each node of each of the other buffers
419 ;; and merge it into the main buffer.
421 (let ((nodename (car (car nodes))))
422 (goto-char (point-min))
423 ;; Find the like-named node in the main buffer.
424 (if (re-search-forward (concat "\n
\1f.*\n.*Node: "
425 (regexp-quote nodename)
429 (search-forward "\n
\1f" nil 'move)
431 ;; If none exists, add one.
432 (goto-char (point-max))
433 (insert "
\1f\nFile: dir\tnode: " nodename "\n\n* Menu:\n\n"))
434 ;; Merge the text from the other buffer's menu
435 ;; into the menu in the like-named node in the main buffer.
436 (apply 'insert-buffer-substring (cdr (car nodes)))
438 (setq nodes (cdr nodes)))
439 ;; Kill all the buffers we just made.
441 (kill-buffer (car buffers))
442 (setq buffers (cdr buffers))))
443 (setq Info-dir-contents (buffer-string)))
444 (setq default-directory Info-dir-contents-directory))
446 (defun Info-read-subfile (nodepos)
447 (set-buffer (marker-buffer Info-tag-table-marker))
448 (goto-char (point-min))
449 (search-forward "\n\^_")
454 (while (not (looking-at "\^_"))
457 thisfilepos thisfilename)
458 (search-forward ": ")
459 (setq thisfilename (buffer-substring beg (- (point) 2)))
460 (setq thisfilepos (read (current-buffer)))
461 ;; read in version 19 stops at the end of number.
462 ;; Advance to the next line.
464 (if (> thisfilepos nodepos)
466 (setq lastfilename thisfilename)
467 (setq lastfilepos thisfilepos))
469 (set-buffer (get-buffer "*info*"))
470 (or (equal Info-current-subfile lastfilename)
471 (let ((buffer-read-only nil))
472 (setq buffer-file-name nil)
475 (info-insert-file-contents lastfilename)
476 (set-buffer-modified-p nil)
477 (setq Info-current-subfile lastfilename)))
478 (goto-char (point-min))
479 (search-forward "\n\^_")
480 (+ (- nodepos lastfilepos) (point))))
482 ;; Select the info node that point is in.
483 (defun Info-select-node ()
485 ;; Find beginning of node.
486 (search-backward "\n\^_")
488 ;; Get nodename spelled as it is in the node.
489 (re-search-forward "Node:[ \t]*")
490 (setq Info-current-node
491 (buffer-substring (point)
493 (skip-chars-forward "^,\t\n")
496 ;; Find the end of it, and narrow.
498 (let (active-expression)
499 (narrow-to-region (point)
500 (if (re-search-forward "\n[\^_\f]" nil t)
503 (if (looking-at "[\n\^_\f]*execute: ")
505 (goto-char (match-end 0))
506 (setq active-expression
507 (read (current-buffer))))))
509 (if Info-enable-active-nodes (eval active-expression))
510 (if Info-fontify (Info-fontify-node))
511 (run-hooks 'Info-selection-hook))))
513 (defun Info-set-mode-line ()
514 (setq mode-line-buffer-identification
517 (if Info-current-file
518 (file-name-nondirectory Info-current-file)
521 (or Info-current-node ""))))
523 ;; Go to an info node specified with a filename-and-nodename string
524 ;; of the sort that is found in pointers in nodes.
526 (defun Info-goto-node (nodename)
527 "Go to info node named NAME. Give just NODENAME or (FILENAME)NODENAME."
528 (interactive (list (Info-read-node-name "Goto node: ")))
530 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
532 (setq filename (if (= (match-beginning 1) (match-end 1))
534 (substring nodename (match-beginning 2) (match-end 2)))
535 nodename (substring nodename (match-beginning 3) (match-end 3)))
536 (let ((trim (string-match "\\s *\\'" filename)))
537 (if trim (setq filename (substring filename 0 trim))))
538 (let ((trim (string-match "\\s *\\'" nodename)))
539 (if trim (setq nodename (substring nodename 0 trim))))
540 (Info-find-node (if (equal filename "") nil filename)
541 (if (equal nodename "") "Top" nodename))))
543 (defun Info-read-node-name (prompt &optional default)
544 (let* ((completion-ignore-case t)
545 (nodename (completing-read prompt (Info-build-node-completions))))
546 (if (equal nodename "")
548 (Info-read-node-name prompt))
551 (defun Info-build-node-completions ()
552 (or Info-current-file-completions
556 (if (marker-buffer Info-tag-table-marker)
558 (set-buffer (marker-buffer Info-tag-table-marker))
560 (goto-char Info-tag-table-marker)
561 (while (re-search-forward "\nNode: \\(.*\\)\177" nil t)
563 (cons (list (buffer-substring (match-beginning 1)
567 (goto-char (point-min))
568 (while (search-forward "\n\^_" nil t)
572 (if (re-search-backward "Node: *\\([^,\n]*\\) *[,\n\t]"
575 (cons (list (buffer-substring (match-beginning 1)
578 (setq Info-current-file-completions compl))))
580 (defun Info-restore-point (hl)
581 "If this node has been visited, restore the point value when we left."
583 (if (and (equal (nth 0 (car hl)) Info-current-file)
584 (equal (nth 1 (car hl)) Info-current-node))
586 (setq hl nil) ;terminate the while at next iter
587 (goto-char (nth 2 (car hl))))
588 (setq hl (cdr hl)))))
590 (defvar Info-last-search nil
591 "Default regexp for \\<Info-mode-map>\\[Info-search] command to search for.")
593 (defun Info-search (regexp)
594 "Search for REGEXP, starting from point, and select node it's found in."
595 (interactive "sSearch (regexp): ")
596 (if (equal regexp "")
597 (setq regexp Info-last-search)
598 (setq Info-last-search regexp))
599 (let ((found ()) current
600 (onode Info-current-node)
601 (ofile Info-current-file)
603 (osubfile Info-current-subfile))
607 (if (null Info-current-subfile)
608 (progn (re-search-forward regexp) (setq found (point)))
610 (progn (re-search-forward regexp) (setq found (point)))
611 (search-failed nil)))))
612 (if (not found) ;can only happen in subfile case -- else would have erred
615 (set-buffer (marker-buffer Info-tag-table-marker))
616 (goto-char (point-min))
617 (search-forward "\n\^_\nIndirect:")
619 (narrow-to-region (point)
620 (progn (search-forward "\n\^_")
622 (goto-char (point-min))
623 (search-forward (concat "\n" osubfile ": "))
626 (re-search-forward "\\(^.*\\): [0-9]+$")
627 (goto-char (+ (match-end 1) 2))
628 (setq list (cons (cons (read (current-buffer))
629 (buffer-substring (match-beginning 1)
632 (goto-char (1+ (match-end 0))))
633 (setq list (nreverse list)
634 current (car (car list))
637 (message "Searching subfile %s..." (cdr (car list)))
638 (Info-read-subfile (car (car list)))
639 (setq list (cdr list))
640 (goto-char (point-min))
641 (if (re-search-forward regexp nil t)
642 (setq found (point) list ())))
645 (signal 'search-failed (list regexp))))
647 (progn (Info-read-subfile opoint)
649 (Info-select-node)))))
653 (or (and (equal onode Info-current-node)
654 (equal ofile Info-current-file))
655 (setq Info-history (cons (list ofile onode opoint)
658 ;; Extract the value of the node-pointer named NAME.
659 ;; If there is none, use ERRORNAME in the error message;
660 ;; if ERRORNAME is nil, just return nil.
661 (defun Info-extract-pointer (name &optional errorname)
663 (goto-char (point-min))
665 (if (re-search-backward (concat name ":") nil t)
667 (goto-char (match-end 0))
668 (Info-following-node-name))
671 (error (concat "Node has no " (capitalize (or errorname name))))))))
673 ;; Return the node name in the buffer following point.
674 ;; ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
675 ;; saying which chas may appear in the node name.
676 (defun Info-following-node-name (&optional allowedchars)
677 (skip-chars-forward " \t")
681 (while (looking-at (concat "[" (or allowedchars "^,\t\n") "]"))
682 (skip-chars-forward (concat (or allowedchars "^,\t\n") "("))
684 (skip-chars-forward "^)")))
685 (skip-chars-backward " ")
689 "Go to the next node of this node."
691 (Info-goto-node (Info-extract-pointer "next")))
694 "Go to the previous node of this node."
696 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous")))
699 "Go to the superior node of this node."
701 (Info-goto-node (Info-extract-pointer "up"))
702 (Info-restore-point Info-history))
705 "Go back to the last node visited."
708 (error "This is the first Info node you looked at"))
709 (let (filename nodename opoint)
710 (setq filename (car (car Info-history)))
711 (setq nodename (car (cdr (car Info-history))))
712 (setq opoint (car (cdr (cdr (car Info-history)))))
713 (setq Info-history (cdr Info-history))
714 (Info-find-node filename nodename)
715 (setq Info-history (cdr Info-history))
718 (defun Info-directory ()
719 "Go to the Info directory node."
721 (Info-find-node "dir" "top"))
723 (defun Info-follow-reference (footnotename)
724 "Follow cross reference named NAME to the node it refers to.
725 NAME may be an abbreviation of the reference name."
727 (let ((completion-ignore-case t)
728 completions default alt-default (start-point (point)) str i bol eol)
730 ;; Store end and beginning of line.
736 (goto-char (point-min))
737 (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t)
738 (setq str (buffer-substring
741 ;; See if this one should be the default.
743 (<= (match-beginning 0) start-point)
744 (<= start-point (point))
746 ;; See if this one should be the alternate default.
747 (and (null alt-default)
748 (and (<= bol (match-beginning 0))
750 (setq alt-default t))
752 (while (setq i (string-match "[ \n\t]+" str i))
753 (setq str (concat (substring str 0 i) " "
754 (substring str (match-end 0))))
756 ;; Record as a completion and perhaps as default.
757 (if (eq default t) (setq default str))
758 (if (eq alt-default t) (setq alt-default str))
762 ;; If no good default was found, try an alternate.
764 (setq default alt-default))
765 ;; If only one cross-reference found, then make it default.
766 (if (eq (length completions) 1)
767 (setq default (car (car completions))))
769 (let ((input (completing-read (if default
770 (concat "Follow reference named: ("
772 "Follow reference named: ")
774 (list (if (equal input "")
776 (error "No cross-references in this node"))))
777 (let (target beg i (str (concat "\\*note " footnotename)))
778 (while (setq i (string-match " " str i))
779 (setq str (concat (substring str 0 i) "[ \t\n]+" (substring str (1+ i))))
782 (goto-char (point-min))
783 (or (re-search-forward str nil t)
784 (error "No cross-reference named %s" footnotename))
785 (goto-char (+ (match-beginning 0) 5))
787 (Info-extract-menu-node-name "Bad format cross reference" t)))
788 (while (setq i (string-match "[ \t\n]+" target i))
789 (setq target (concat (substring target 0 i) " "
790 (substring target (match-end 0))))
792 (Info-goto-node target)))
794 (defun Info-extract-menu-node-name (&optional errmessage multi-line)
795 (skip-chars-forward " \t\n")
798 (skip-chars-forward "^:")
802 (buffer-substring beg (1- (point)))
803 (skip-chars-forward " \t\n")
804 (Info-following-node-name (if multi-line "^.,\t" "^.,\t\n"))))
805 (while (setq i (string-match "\n" str i))
809 ;; No one calls this and Info-menu-item doesn't exist.
810 ;;(defun Info-menu-item-sequence (list)
812 ;; (Info-menu-item (car list))
813 ;; (setq list (cdr list))))
815 (defun Info-menu (menu-item)
816 "Go to node for menu item named (or abbreviated) NAME.
817 Completion is allowed, and the menu item point is on is the default."
819 (let ((completions '())
820 ;; If point is within a menu item, use that item as the default
825 (goto-char (point-min))
826 (if (not (search-forward "\n* menu:" nil t))
827 (error "No menu in this node"))
828 (while (re-search-forward
829 "\n\\* \\([^:\t\n]*\\):" nil t)
830 (if (and (null default)
831 (prog1 (if last (< last p) nil)
832 (setq last (match-beginning 0)))
834 (setq default (car (car completions))))
835 (setq completions (cons (cons (buffer-substring
840 (if (and (null default) last
842 (<= p (progn (end-of-line) (point))))
843 (setq default (car (car completions)))))
846 (setq item (let ((completion-ignore-case t))
847 (completing-read (if default
848 (format "Menu item (default %s): "
852 ;; we rely on the fact that completing-read accepts an input
853 ;; of "" even when the require-match argument is true and ""
854 ;; is not a valid possibility
855 (if (string= item "")
861 ;; there is a problem here in that if several menu items have the same
862 ;; name you can only go to the node of the first with this command.
863 (Info-goto-node (Info-extract-menu-item menu-item)))
865 (defun Info-extract-menu-item (menu-item)
866 (setq menu-item (regexp-quote menu-item))
868 (goto-char (point-min))
869 (or (search-forward "\n* menu:" nil t)
870 (error "No menu in this node"))
871 (or (re-search-forward (concat "\n\\* " menu-item ":") nil t)
872 (re-search-forward (concat "\n\\* " menu-item) nil t)
873 (error "No such item in menu"))
876 (Info-extract-menu-node-name)))
878 ;; If COUNT is nil, use the last item in the menu.
879 (defun Info-extract-menu-counting (count)
881 (goto-char (point-min))
882 (or (search-forward "\n* menu:" nil t)
883 (error "No menu in this node"))
885 (or (search-forward "\n* " nil t count)
886 (error "Too few items in menu"))
887 (while (search-forward "\n* " nil t)
889 (Info-extract-menu-node-name)))
891 (defun Info-nth-menu-item ()
892 "Go to the node of the Nth menu item.
893 N is the digit argument used to invoke this command."
896 (Info-extract-menu-counting
897 (- (aref (this-command-keys) (1- (length (this-command-keys)))) ?0))))
899 (defun Info-top-node ()
900 "Go to the Top node of this file."
902 (Info-goto-node "Top"))
904 (defun Info-final-node ()
905 "Go to the final node in this file."
907 (Info-goto-node "Top")
909 ;; Go to the last node in the menu of Top.
910 (Info-goto-node (Info-extract-menu-counting nil))
911 ;; If the last node in the menu is not last in pointer structure,
912 ;; move forward until we can't go any farther.
913 (while (Info-forward-node t t) nil)
914 ;; Then keep moving down to last subnode, unless we reach an index.
915 (while (and (not (string-match "\\<index\\>" Info-current-node))
916 (save-excursion (search-forward "\n* Menu:" nil t)))
917 (Info-goto-node (Info-extract-menu-counting nil)))))
919 (defun Info-forward-node (&optional not-down no-error)
920 "Go forward one node, considering all nodes as forming one sequence."
922 (goto-char (point-min))
924 ;; three possibilities, in order of priority:
925 ;; 1. next node is in a menu in this node (but not in an index)
926 ;; 2. next node is next at same level
927 ;; 3. next node is up and next
928 (cond ((and (not not-down)
929 (save-excursion (search-forward "\n* menu:" nil t))
930 (not (string-match "\\<index\\>" Info-current-node)))
931 (Info-goto-node (Info-extract-menu-counting 1))
933 ((save-excursion (search-backward "next:" nil t))
936 ((and (save-excursion (search-backward "up:" nil t))
937 (not (equal (downcase (Info-extract-pointer "up")) "top")))
938 (let ((old-node Info-current-node))
940 (let (Info-history success)
942 (setq success (Info-forward-node t no-error))
943 (or success (Info-goto-node old-node))))))
945 (t (error "No pointer forward from this node"))))
947 (defun Info-backward-node ()
948 "Go backward one node, considering all nodes as forming one sequence."
950 (let ((prevnode (Info-extract-pointer "prev[ious]*" t))
951 (upnode (Info-extract-pointer "up" t)))
952 (cond ((and upnode (string-match "(" upnode))
953 (error "First node in file"))
954 ((and upnode (or (null prevnode)
955 (equal (downcase prevnode) (downcase upnode))))
958 ;; If we move back at the same level,
959 ;; go down to find the last subnode*.
962 (while (and (not (string-match "\\<index\\>" Info-current-node))
963 (save-excursion (search-forward "\n* Menu:" nil t)))
964 (Info-goto-node (Info-extract-menu-counting nil)))))
966 (error "No pointer backward from this node")))))
969 "Exit Info by selecting some other buffer."
972 (save-buffers-kill-emacs)
973 (switch-to-buffer (prog1 (other-buffer (current-buffer))
974 (bury-buffer (current-buffer))))))
976 (defun Info-next-menu-item ()
980 (search-forward "\n* menu:" nil t)
981 (or (search-forward "\n* " nil t)
982 (error "No more items in menu"))
983 (Info-goto-node (Info-extract-menu-node-name))))
985 (defun Info-last-menu-item ()
989 (search-backward "\n* menu:" nil t)
990 (or (search-backward "\n* " nil t)
991 (error "No previous items in menu"))
992 (Info-goto-node (Info-extract-menu-node-name))))
994 (defmacro Info-no-error (&rest body)
995 (list 'condition-case nil (cons 'progn (append body '(t))) '(error nil)))
997 (defun Info-next-preorder ()
998 "Go to the next node, popping up a level if there is none."
1000 (cond ((looking-at "\\*note[ \n]*\\([^:]*\\):")
1001 (Info-follow-reference
1002 (buffer-substring (match-beginning 1) (match-end 1))))
1003 ((Info-no-error (Info-next-menu-item)) )
1004 ((Info-no-error (Info-up)) (forward-line 1))
1005 (t (error "No more nodes"))))
1007 (defun Info-last-preorder ()
1008 "Go to the last node, popping up a level if there is none."
1010 (cond ((Info-no-error (Info-last-menu-item)) )
1011 ((Info-no-error (Info-up)) (forward-line -1))
1012 (t (error "No previous nodes"))))
1014 (defun Info-scroll-up ()
1015 "Read the next screen. If end of buffer is visible, go to next entry."
1017 (if (pos-visible-in-window-p (point-max))
1018 (Info-next-preorder)
1022 (defun Info-scroll-down ()
1023 "Read the previous screen. If start of buffer is visible, go to last entry."
1025 (if (pos-visible-in-window-p (point-min))
1026 (Info-last-preorder)
1030 (defun Info-next-reference ()
1031 "Move cursor to the next cross-reference or menu item in the node."
1033 (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:")
1035 (or (eobp) (forward-char 1))
1036 (or (re-search-forward pat nil t)
1038 (goto-char (point-min))
1039 (or (re-search-forward pat nil t)
1042 (error "No cross references in this node")))))
1043 (goto-char (match-beginning 0))
1044 (if (looking-at "\\* Menu:")
1045 (Info-next-reference))))
1047 (defun Info-prev-reference ()
1048 "Move cursor to the previous cross-reference or menu item in the node."
1050 (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:")
1052 (or (re-search-backward pat nil t)
1054 (goto-char (point-max))
1055 (or (re-search-backward pat nil t)
1058 (error "No cross references in this node")))))
1059 (goto-char (match-beginning 0))
1060 (if (looking-at "\\* Menu:")
1061 (Info-prev-reference))))
1063 (defun Info-index (topic)
1064 "Look up a string in the index for this file.
1065 The index is defined as the first node in the top-level menu whose
1066 name contains the word \"Index\", plus any immediately following
1067 nodes whose names also contain the word \"Index\".
1068 If there are no exact matches to the specified topic, this chooses
1069 the first match which is a case-insensitive substring of a topic.
1070 Use the `,' command to see the other matches.
1071 Give a blank topic name to go to the Index node itself."
1072 (interactive "sIndex topic: ")
1073 (let ((orignode Info-current-node)
1075 (pattern (format "\n\\* \\([^\n:]*%s[^\n:]*\\):[ \t]*\\([^.\n]*\\)\\.[ t]*\\([0-9]*\\)"
1076 (regexp-quote topic)))
1078 (Info-goto-node "Top")
1079 (or (search-forward "\n* menu:" nil t)
1081 (or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t)
1083 (goto-char (match-beginning 1))
1084 (let ((Info-keeping-history nil))
1085 (Info-goto-node (Info-extract-menu-node-name)))
1086 (or (equal topic "")
1089 (Info-keeping-history nil)
1093 (goto-char (point-min))
1094 (while (re-search-forward pattern nil t)
1096 (cons (list (buffer-substring (match-beginning 1)
1098 (buffer-substring (match-beginning 2)
1101 (string-to-int (concat "0"
1106 (and (setq node (Info-extract-pointer "next" t))
1107 (string-match "\\<Index\\>" node)))
1108 (Info-goto-node node))
1112 (error "No \"%s\" in index" topic)))
1113 ;; Here it is a feature that assoc is case-sensitive.
1114 (while (setq found (assoc topic matches))
1115 (setq exact (cons found exact)
1116 matches (delq found matches)))
1117 (setq Info-index-alternatives (nconc exact (nreverse matches)))
1118 (Info-index-next 0)))))
1120 (defun Info-index-next (num)
1121 "Go to the next matching index item from the last `i' command."
1123 (or Info-index-alternatives
1124 (error "No previous `i' command in this file"))
1126 (setq num (+ num (length Info-index-alternatives))))
1128 (setq Info-index-alternatives
1129 (nconc (cdr Info-index-alternatives)
1130 (list (car Info-index-alternatives)))
1132 (Info-goto-node (nth 1 (car Info-index-alternatives)))
1133 (if (> (nth 3 (car Info-index-alternatives)) 0)
1134 (forward-line (nth 3 (car Info-index-alternatives)))
1135 (forward-line 3) ; don't search in headers
1136 (let ((name (car (car Info-index-alternatives))))
1137 (if (or (re-search-forward (format
1138 "\\(Function\\|Command\\): %s\\( \\|$\\)"
1139 (regexp-quote name)) nil t)
1140 (search-forward (format "`%s'" name) nil t)
1141 (and (string-match "\\`.*\\( (.*)\\)\\'" name)
1143 (format "`%s'" (substring name 0 (match-beginning 1)))
1145 (search-forward name nil t))
1147 (goto-char (point-min)))))
1148 (message "Found \"%s\" in %s. %s"
1149 (car (car Info-index-alternatives))
1150 (nth 2 (car Info-index-alternatives))
1151 (if (cdr Info-index-alternatives)
1152 "(Press `,' for more)"
1155 (defun Info-undefined ()
1156 "Make command be undefined in Info."
1161 "Enter the Info tutorial."
1163 (delete-other-windows)
1164 (Info-find-node "info"
1165 (if (< (window-height) 23)
1169 (defun Info-summary ()
1170 "Display a brief summary of all Info commands."
1172 (save-window-excursion
1173 (switch-to-buffer "*Help*")
1175 (insert (documentation 'Info-mode))
1176 (goto-char (point-min))
1178 (while (progn (setq flag (not (pos-visible-in-window-p (point-max))))
1179 (message (if flag "Type Space to see more"
1180 "Type Space to return to Info"))
1181 (if (not (eq ?\ (setq ch (read-event))))
1182 (progn (setq unread-command-events (list ch)) nil)
1185 (bury-buffer "*Help*")))
1187 (defun Info-get-token (pos start all &optional errorstring)
1188 "Return the token around POS,
1189 POS must be somewhere inside the token
1190 START is a regular expression which will match the
1191 beginning of the tokens delimited string
1192 ALL is a regular expression with a single
1193 parenthized subpattern which is the token to be
1194 returned. E.g. '{\(.*\)}' would return any string
1195 enclosed in braces around POS.
1196 SIG optional fourth argument, controls action on no match
1199 a string: signal an error, using that string."
1202 (re-search-backward start (max (point-min) (- pos 200)) 'yes)
1204 (while (and (re-search-forward all (min (point-max) (+ pos 200)) 'yes)
1205 (not (setq found (and (<= (match-beginning 0) pos)
1206 (> (match-end 0) pos))))))
1207 (if (and found (<= (match-beginning 0) pos)
1208 (> (match-end 0) pos))
1209 (buffer-substring (match-beginning 1) (match-end 1))
1210 (cond ((null errorstring)
1216 (error "No %s around position %d" errorstring pos)))))))
1218 (defun Info-follow-nearest-node (click)
1219 "\\<Info-mode-map>Follow a node reference near point.
1220 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click.
1221 At end of the node's text, moves to the next node."
1223 (let* ((start (event-start click))
1224 (window (car start))
1225 (pos (car (cdr start))))
1226 (select-window window)
1230 ((setq node (Info-get-token (point) "\\*note[ \n]" "\\*note[ \n]\\([^:]*\\):"))
1231 (Info-follow-reference node))
1232 ((setq node (Info-get-token (point) "\\* " "\\* \\([^:]*\\)::"))
1233 (Info-goto-node node))
1234 ((setq node (Info-get-token (point) "\\* " "\\* \\([^:]*\\):"))
1236 ((setq node (Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)"))
1237 (Info-goto-node node))
1238 ((setq node (Info-get-token (point) "Next: " "Next: \\([^,\n\t]*\\)"))
1239 (Info-goto-node node))
1240 ((setq node (Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)"))
1241 (Info-goto-node "Top"))
1242 ((setq node (Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)"))
1243 (Info-goto-node node))
1244 ((save-excursion (forward-line 1) (eobp))
1248 (defvar Info-mode-map nil
1249 "Keymap containing Info commands.")
1252 (setq Info-mode-map (make-keymap))
1253 (suppress-keymap Info-mode-map)
1254 (define-key Info-mode-map "." 'beginning-of-buffer)
1255 (define-key Info-mode-map " " 'Info-scroll-up)
1256 (define-key Info-mode-map "\C-m" 'Info-next-preorder)
1257 (define-key Info-mode-map "\t" 'Info-next-reference)
1258 (define-key Info-mode-map "\e\t" 'Info-prev-reference)
1259 (define-key Info-mode-map "1" 'Info-nth-menu-item)
1260 (define-key Info-mode-map "2" 'Info-nth-menu-item)
1261 (define-key Info-mode-map "3" 'Info-nth-menu-item)
1262 (define-key Info-mode-map "4" 'Info-nth-menu-item)
1263 (define-key Info-mode-map "5" 'Info-nth-menu-item)
1264 (define-key Info-mode-map "6" 'Info-nth-menu-item)
1265 (define-key Info-mode-map "7" 'Info-nth-menu-item)
1266 (define-key Info-mode-map "8" 'Info-nth-menu-item)
1267 (define-key Info-mode-map "9" 'Info-nth-menu-item)
1268 (define-key Info-mode-map "0" 'undefined)
1269 (define-key Info-mode-map "?" 'Info-summary)
1270 (define-key Info-mode-map "]" 'Info-forward-node)
1271 (define-key Info-mode-map "[" 'Info-backward-node)
1272 (define-key Info-mode-map "<" 'Info-top-node)
1273 (define-key Info-mode-map ">" 'Info-final-node)
1274 (define-key Info-mode-map "b" 'beginning-of-buffer)
1275 (define-key Info-mode-map "d" 'Info-directory)
1276 (define-key Info-mode-map "e" 'Info-edit)
1277 (define-key Info-mode-map "f" 'Info-follow-reference)
1278 (define-key Info-mode-map "g" 'Info-goto-node)
1279 (define-key Info-mode-map "h" 'Info-help)
1280 (define-key Info-mode-map "i" 'Info-index)
1281 (define-key Info-mode-map "l" 'Info-last)
1282 (define-key Info-mode-map "m" 'Info-menu)
1283 (define-key Info-mode-map "n" 'Info-next)
1284 (define-key Info-mode-map "p" 'Info-prev)
1285 (define-key Info-mode-map "q" 'Info-exit)
1286 (define-key Info-mode-map "s" 'Info-search)
1287 (define-key Info-mode-map "t" 'Info-top-node)
1288 (define-key Info-mode-map "u" 'Info-up)
1289 (define-key Info-mode-map "," 'Info-index-next)
1290 (define-key Info-mode-map "\177" 'Info-scroll-down)
1291 (define-key Info-mode-map [mouse-2] 'Info-follow-nearest-node)
1294 ;; Info mode is suitable only for specially formatted data.
1295 (put 'info-mode 'mode-class 'special)
1299 Info mode provides commands for browsing through the Info documentation tree.
1300 Documentation in Info is divided into \"nodes\", each of which discusses
1301 one topic and contains references to other nodes which discuss related
1302 topics. Info has commands to follow the references and show you other nodes.
1304 \\[Info-help] Invoke the Info tutorial.
1306 Selecting other nodes:
1307 \\[Info-next] Move to the \"next\" node of this node.
1308 \\[Info-prev] Move to the \"previous\" node of this node.
1309 \\[Info-up] Move \"up\" from this node.
1310 \\[Info-menu] Pick menu item specified by name (or abbreviation).
1311 Picking a menu item causes another node to be selected.
1312 \\[Info-directory] Go to the Info directory node.
1313 \\[Info-follow-reference] Follow a cross reference. Reads name of reference.
1314 \\[Info-last] Move to the last node you were at.
1315 \\[Info-index] Look up a topic in this file's Index and move to that node.
1316 \\[Info-index-next] (comma) Move to the next match from a previous `i' command.
1318 Moving within a node:
1319 \\[Info-scroll-up] Normally, scroll forward a full screen. If the end of the buffer is
1320 already visible, try to go to the next menu entry, or up if there is none.
1321 \\[Info-scroll-down] Normally, scroll backward. If the beginning of the buffer is
1322 already visible, try to go to the previous menu entry, or up if there is none.
1323 \\[beginning-of-buffer] Go to beginning of node.
1326 \\[Info-exit] Quit Info: reselect previously selected buffer.
1327 \\[Info-edit] Edit contents of selected node.
1328 1 Pick first item in node's menu.
1329 2, 3, 4, 5 Pick second ... fifth item in node's menu.
1330 \\[Info-goto-node] Move to node specified by name.
1331 You may include a filename as well, as (FILENAME)NODENAME.
1332 \\[universal-argument] \\[info] Move to new Info file with completion.
1333 \\[Info-search] Search through this Info file for specified regexp,
1334 and select the node in which the next occurrence is found.
1335 \\[Info-next-preorder] Next-preorder; that is, try to go to the next menu item,
1336 and if that fails try to move up, and if that fails, tell user
1337 he/she is done reading.
1338 \\[Info-next-reference] Move cursor to next cross-reference or menu item.
1339 \\[Info-prev-reference] Move cursor to previous cross-reference or menu item."
1340 (kill-all-local-variables)
1341 (setq major-mode 'Info-mode)
1342 (setq mode-name "Info")
1343 (use-local-map Info-mode-map)
1344 (set-syntax-table text-mode-syntax-table)
1345 (setq local-abbrev-table text-mode-abbrev-table)
1346 (setq case-fold-search t)
1347 (setq buffer-read-only t)
1348 (make-local-variable 'Info-current-file)
1349 (make-local-variable 'Info-current-subfile)
1350 (make-local-variable 'Info-current-node)
1351 (make-local-variable 'Info-tag-table-marker)
1352 (make-local-variable 'Info-history)
1353 (make-local-variable 'Info-index-alternatives)
1354 (if (fboundp 'make-face)
1356 (make-face 'info-node)
1357 (make-face 'info-menu-5)
1358 (make-face 'info-xref)
1359 (or (face-differs-from-default-p 'info-node)
1360 (if (face-differs-from-default-p 'bold-italic)
1361 (copy-face 'bold-italic 'info-node)
1362 (copy-face 'bold 'info-node)))
1363 (or (face-differs-from-default-p 'info-menu-5)
1364 (set-face-underline-p 'info-menu-5 t))
1365 (or (face-differs-from-default-p 'info-xref)
1366 (copy-face 'bold 'info-xref)))
1367 (setq Info-fontify nil))
1368 (Info-set-mode-line)
1369 (run-hooks 'Info-mode-hook))
1371 (defvar Info-edit-map nil
1372 "Local keymap used within `e' command of Info.")
1375 (setq Info-edit-map (nconc (make-sparse-keymap) text-mode-map))
1376 (define-key Info-edit-map "\C-c\C-c" 'Info-cease-edit))
1378 ;; Info-edit mode is suitable only for specially formatted data.
1379 (put 'info-edit-mode 'mode-class 'special)
1381 (defun Info-edit-mode ()
1382 "Major mode for editing the contents of an Info node.
1383 Like text mode with the addition of `Info-cease-edit'
1384 which returns to Info mode for browsing.
1389 "Edit the contents of this Info node.
1390 Allowed only if variable `Info-enable-edit' is non-nil."
1392 (or Info-enable-edit
1393 (error "Editing info nodes is not enabled"))
1394 (use-local-map Info-edit-map)
1395 (setq major-mode 'Info-edit-mode)
1396 (setq mode-name "Info Edit")
1397 (kill-local-variable 'mode-line-buffer-identification)
1398 (setq buffer-read-only nil)
1399 ;; Make mode line update.
1400 (set-buffer-modified-p (buffer-modified-p))
1401 (message (substitute-command-keys
1402 "Editing: Type \\<Info-edit-map>\\[Info-cease-edit] to return to info")))
1404 (defun Info-cease-edit ()
1405 "Finish editing Info node; switch back to Info proper."
1407 ;; Do this first, so nothing has changed if user C-g's at query.
1408 (and (buffer-modified-p)
1409 (y-or-n-p "Save the file? ")
1411 (use-local-map Info-mode-map)
1412 (setq major-mode 'Info-mode)
1413 (setq mode-name "Info")
1414 (Info-set-mode-line)
1415 (setq buffer-read-only t)
1416 ;; Make mode line update.
1417 (set-buffer-modified-p (buffer-modified-p))
1418 (and (marker-position Info-tag-table-marker)
1420 (message "Tags may have changed. Use Info-tagify if necessary")))
1422 (defun Info-find-emacs-command-nodes (command)
1423 "Return a list of locations documenting COMMAND in the Emacs Info manual.
1424 The locations are of the format used in Info-history, i.e.
1425 \(FILENAME NODENAME BUFFERPOS\)."
1428 (cmd-desc (concat "^\\* " (regexp-quote (symbol-name command))
1429 ":\\s *\\(.*\\)\\.$")))
1431 (Info-find-node "emacs" "Command Index")
1432 ;; Take the index node off the Info history.
1433 (setq Info-history (cdr Info-history))
1434 (goto-char (point-max))
1435 (while (re-search-backward cmd-desc nil t)
1436 (setq where (cons (list Info-current-file
1445 (defun Info-goto-emacs-command-node (command)
1446 "Go to the Info node in the Emacs manual for command COMMAND.
1447 The command is found by looking up in Emacs manual's Command Index."
1448 (interactive "CFind documentation for command: ")
1449 (or (commandp command)
1450 (signal 'wrong-type-argument (list 'commandp command)))
1451 (let ((where (Info-find-emacs-command-nodes command)))
1453 (let ((num-matches (length where)))
1454 ;; Get Info running, and pop to it in another window.
1455 (save-window-excursion
1457 (pop-to-buffer "*info*")
1458 (Info-find-node (car (car where))
1459 (car (cdr (car where))))
1460 (if (> num-matches 1)
1462 ;; Info-find-node already pushed (car where) onto
1463 ;; Info-history. Put the other nodes that were found on
1465 (setq Info-history (nconc (cdr where) Info-history))
1466 (message (substitute-command-keys
1467 "Found %d other entr%s. Use \\[Info-last] to see %s.")
1469 (if (> num-matches 2) "ies" "y")
1470 (if (> num-matches 2) "them" "it")))))
1471 (error "Couldn't find documentation for %s." command))))
1474 (defun Info-goto-emacs-key-command-node (key)
1475 "Go to the Info node in the Emacs manual the command bound to KEY, a string.
1476 Interactively, if the binding is execute-extended-command, a command is read.
1477 The command is found by looking up in Emacs manual's Command Index."
1478 (interactive "kFind documentation for key:")
1479 (let ((command (key-binding key)))
1480 (cond ((null command)
1481 (message "%s is undefined" (key-description key)))
1482 ((and (interactive-p)
1483 (eq command 'execute-extended-command))
1484 (Info-goto-emacs-command-node
1485 (read-command "Find documentation for command: ")))
1487 (Info-goto-emacs-command-node command)))))
1489 (defun Info-fontify-node ()
1491 (let ((buffer-read-only nil))
1492 (goto-char (point-min))
1493 (if (looking-at "^File: [^,: \t]+,?[ \t]+")
1495 (goto-char (match-end 0))
1497 (looking-at "[ \t]*[^:, \t\n]+:[ \t]+\\([^:,\t\n]+\\),?")
1498 (goto-char (match-end 0))
1499 (put-text-property (match-beginning 1) (match-end 1)
1500 'face 'info-xref))))
1501 (goto-char (point-min))
1502 (while (re-search-forward "\\*Note[ \n\t]*\\([^:]*\\):" nil t)
1503 (if (= (char-after (1- (match-beginning 0))) ?\") ; hack
1505 (put-text-property (match-beginning 1) (match-end 1)
1507 (goto-char (point-min))
1508 (if (and (search-forward "\n* Menu:" nil t)
1509 (not (string-match "\\<Index\\>" Info-current-node))
1510 ;; Don't take time to annotate huge menus
1511 (< (- (point-max) (point)) 10000))
1513 (while (re-search-forward "^\\* \\([^:\t\n]*\\):" nil t)
1515 (if (memq n '(5 9)) ; visual aids to help with 1-9 keys
1516 (put-text-property (match-beginning 0)
1517 (1+ (match-beginning 0))
1518 'face 'info-menu-5))
1519 (put-text-property (match-beginning 1) (match-end 1)
1520 'face 'info-node))))
1521 (set-buffer-modified-p nil))))
1525 ;;; info.el ends here