1 ;;; info.el --- info package for Emacs.
3 ;; Copyright (C) 1985, 1986, 1992, 1993, 1994 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-fontify t
46 "*Non-nil enables highlighting and fonts in Info nodes.")
48 (defvar Info-fontify-maximum-menu-size
30000
49 "*Maximum size of menu to fontify if `Info-fontify' is non-nil.")
51 (defvar Info-directory-list
52 (let ((path (getenv "INFOPATH"))
53 ;; This is for older Emacs versions
54 ;; which might get this info.el from the Texinfo distribution.
55 (path-separator (if (boundp 'path-separator
) path-separator
56 (if (eq system-type
'ms-dos
) ";" ":")))
57 (sibling (if installation-directory
58 (expand-file-name "info/" installation-directory
))))
62 (while (> (length path
) 0)
63 (setq idx
(or (string-match path-separator path
) (length path
))
64 list
(cons (substring path
0 idx
) list
)
65 path
(substring path
(min (1+ idx
)
68 (if (or (null sibling
)
69 (member sibling Info-default-directory-list
)
70 (not (file-exists-p sibling
))
71 ;; On DOS/NT, we use movable executables always,
72 ;; and we must always find the Info dir at run time.
73 (if (or (eq system-type
'ms-dos
) (eq system-type
'windows-nt
))
75 ;; Use invocation-directory for Info only if we used it for
76 ;; exec-directory also.
77 (not (string= exec-directory
78 (expand-file-name "lib-src/"
79 installation-directory
)))))
80 Info-default-directory-list
81 (reverse (cons sibling
(cdr (reverse Info-default-directory-list
)))))))
82 "List of directories to search for Info documentation files.
83 nil means not yet initialized. In this case, Info uses the environment
84 variable INFOPATH to initialize it, or `Info-default-directory-list'
85 if there is no INFOPATH variable in the environment.
86 The last element of `Info-default-directory-list' is the directory
87 where Emacs installs the Info files that come with it.
89 If you run the Emacs executable from the `src' directory in the Emacs
90 source tree, the `info' directory in the source tree is used as the last
91 element, in place of the installation Info directory. This is useful
92 when you run a version of Emacs without installing it.")
94 (defvar Info-additional-directory-list nil
95 "List of additional directories to search for Info documentation files.
96 These directories are not searched for merging the `dir' file.")
98 (defvar Info-current-file nil
99 "Info file that Info is now looking at, or nil.
100 This is the name that was specified in Info, not the actual file name.
101 It doesn't contain directory names or file name extensions added by Info.")
103 (defvar Info-current-subfile nil
104 "Info subfile that is actually in the *info* buffer now,
105 or nil if current info file is not split into subfiles.")
107 (defvar Info-current-node nil
108 "Name of node that Info is now looking at, or nil.")
110 (defvar Info-tag-table-marker
(make-marker)
111 "Marker pointing at beginning of current Info file's tag table.
112 Marker points nowhere if file has no tag table.")
114 (defvar Info-current-file-completions nil
115 "Cached completion list for current Info file.")
117 (defvar Info-index-alternatives nil
118 "List of possible matches for last Info-index command.")
120 (defvar Info-standalone nil
121 "Non-nil if Emacs was started solely as an Info browser.")
123 (defvar Info-suffix-list
124 (if (eq system-type
'ms-dos
)
125 '( (".gz" .
"gunzip")
129 '( (".info.Z" .
"uncompress")
130 (".info.Y" .
"unyabba")
131 (".info.gz" .
"gunzip")
132 (".info.z" .
"gunzip")
134 (".Z" .
"uncompress")
139 "List of file name suffixes and associated decoding commands.
140 Each entry should be (SUFFIX . STRING); the file is given to
141 the command as standard input. If STRING is nil, no decoding is done.
142 Because the SUFFIXes are tried in order, the empty string should
143 be last in the list.")
145 ;; Concatenate SUFFIX onto FILENAME. SUFFIX should start with a dot.
146 ;; First, on ms-dos, delete some of the extension in FILENAME
148 (defun info-insert-file-contents-1 (filename suffix
)
149 (if (not (eq system-type
'ms-dos
))
150 (concat filename suffix
)
151 (let* ((sans-exts (file-name-sans-extension filename
))
152 ;; How long is the extension in FILENAME (not counting the dot).
153 (ext-len (max 0 (- (length filename
) (length sans-exts
) 1)))
155 ;; SUFFIX starts with a dot. If FILENAME already has one,
156 ;; get rid of the one in SUFFIX.
157 (or (and (<= ext-len
0)
158 (not (eq (aref filename
(1- (length filename
))) ?.
)))
159 (setq suffix
(substring suffix
1)))
160 ;; How many chars of that extension should we keep?
161 (setq ext-left
(min ext-len
(max 0 (- 3 (length suffix
)))))
162 ;; Get rid of the rest of the extension, and add SUFFIX.
163 (concat (substring filename
0 (- (length filename
)
164 (- ext-len ext-left
)))
167 (defun info-insert-file-contents (filename &optional visit
)
168 "Insert the contents of an info file in the current buffer.
169 Do the right thing if the file has been compressed or zipped."
170 (let ((tail Info-suffix-list
)
172 (if (file-exists-p filename
)
173 ;; FILENAME exists--see if that name contains a suffix.
174 ;; If so, set DECODE accordingly.
178 (concat (regexp-quote (car (car tail
))) "$")
180 (setq tail
(cdr tail
)))
181 (setq fullname filename
182 decoder
(cdr (car tail
))))
183 ;; Try adding suffixes to FILENAME and see if we can find something.
185 (not (file-exists-p (info-insert-file-contents-1
186 filename
(car (car tail
))))))
187 (setq tail
(cdr tail
)))
188 ;; If we found a file with a suffix, set DECODER according to the suffix
189 ;; and set FULLNAME to the file's actual name.
190 (setq fullname
(info-insert-file-contents-1 filename
(car (car tail
)))
191 decoder
(cdr (car tail
)))
193 (error "Can't find %s or any compressed version of it" filename
)))
194 ;; check for conflict with jka-compr
195 (if (and (featurep 'jka-compr
)
196 (jka-compr-installed-p)
197 (jka-compr-get-compression-info fullname
))
199 (insert-file-contents fullname visit
)
201 (let ((buffer-read-only nil
)
202 (default-directory (or (file-name-directory fullname
)
204 (call-process-region (point-min) (point-max) decoder t t
)))))
206 ;;;###autoload (add-hook 'same-window-buffer-names "*info*")
209 (defun info (&optional file
)
210 "Enter Info, the documentation browser.
211 Optional argument FILE specifies the file to examine;
212 the default is the top-level directory of Info.
214 In interactive use, a prefix argument directs this command
215 to read a file name from the minibuffer."
216 (interactive (if current-prefix-arg
217 (list (read-file-name "Info file name: " nil nil t
))))
219 (Info-goto-node (concat "(" file
")"))
220 (if (get-buffer "*info*")
221 (pop-to-buffer "*info*")
225 (defun info-standalone ()
226 "Run Emacs as a standalone Info reader.
227 Usage: emacs -f info-standalone [filename]
228 In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
229 (setq Info-standalone t
)
230 (if (and command-line-args-left
231 (not (string-match "^-" (car command-line-args-left
))))
234 (info (car command-line-args-left
))
235 (setq command-line-args-left
(cdr command-line-args-left
)))
236 (error (send-string-to-terminal
237 (format "%s\n" (if (eq (car-safe err
) 'error
)
239 (save-buffers-kill-emacs)))
242 ;; Go to an info node specified as separate filename and nodename.
243 ;; no-going-back is non-nil if recovering from an error in this function;
244 ;; it says do not attempt further (recursive) error recovery.
245 (defun Info-find-node (filename nodename
&optional no-going-back
)
246 ;; Convert filename to lower case if not found as specified.
249 (let (temp temp-downcase found
)
250 (setq filename
(substitute-in-file-name filename
))
251 (if (string= (downcase (file-name-nondirectory filename
)) "dir")
253 (let ((dirs (if (string-match "^\\./" filename
)
254 ;; If specified name starts with `./'
255 ;; then just try current directory.
257 (if (file-name-absolute-p filename
)
258 ;; No point in searching for an
259 ;; absolute file name
261 (if Info-additional-directory-list
262 (append Info-directory-list
263 Info-additional-directory-list
)
264 Info-directory-list
)))))
265 ;; Search the directory list for file FILENAME.
266 (while (and dirs
(not found
))
267 (setq temp
(expand-file-name filename
(car dirs
)))
269 (expand-file-name (downcase filename
) (car dirs
)))
270 ;; Try several variants of specified name.
271 (let ((suffix-list Info-suffix-list
))
272 (while (and suffix-list
(not found
))
273 (cond ((file-exists-p
274 (info-insert-file-contents-1
275 temp
(car (car suffix-list
))))
278 (info-insert-file-contents-1
279 temp-downcase
(car (car suffix-list
))))
280 (setq found temp-downcase
)))
281 (setq suffix-list
(cdr suffix-list
))))
282 (setq dirs
(cdr dirs
)))))
284 (setq filename found
)
285 (error "Info file %s does not exist" filename
))))
286 ;; Record the node we are leaving.
287 (if (and Info-current-file
(not no-going-back
))
289 (cons (list Info-current-file Info-current-node
(point))
291 ;; Go into info buffer.
292 (switch-to-buffer "*info*")
293 (buffer-disable-undo (current-buffer))
294 (or (eq major-mode
'Info-mode
)
297 (setq Info-current-node nil
)
300 ;; Switch files if necessary
302 (equal Info-current-file filename
)
303 (let ((buffer-read-only nil
))
304 (setq Info-current-file nil
305 Info-current-subfile nil
306 Info-current-file-completions nil
307 Info-index-alternatives nil
308 buffer-file-name nil
)
312 (info-insert-file-contents filename t
)
313 (setq default-directory
(file-name-directory filename
)))
314 (set-buffer-modified-p nil
)
315 ;; See whether file has a tag table. Record the location if yes.
316 (set-marker Info-tag-table-marker nil
)
317 (goto-char (point-max))
319 ;; Use string-equal, not equal, to ignore text props.
320 (or (string-equal nodename
"*")
321 (not (search-forward "\^_\nEnd tag table\n" nil t
))
323 ;; We have a tag table. Find its beginning.
324 ;; Is this an indirect file?
325 (search-backward "\nTag table:\n")
329 (looking-at "(Indirect)\n"))
330 ;; It is indirect. Copy it to another buffer
331 ;; and record that the tag table is in that buffer.
333 (let ((buf (current-buffer)))
334 (set-buffer (get-buffer-create " *info tag table*"))
335 (buffer-disable-undo (current-buffer))
336 (setq case-fold-search t
)
338 (insert-buffer-substring buf
)
339 (set-marker Info-tag-table-marker
341 (set-marker Info-tag-table-marker pos
))))
342 (setq Info-current-file
343 (if (eq filename t
) "dir" filename
))))
344 ;; Use string-equal, not equal, to ignore text props.
345 (if (string-equal nodename
"*")
346 (progn (setq Info-current-node nodename
)
347 (Info-set-mode-line))
348 ;; Search file for a suitable node.
349 (let ((guesspos (point-min))
350 (regexp (concat "Node: *" (regexp-quote nodename
) " *[,\t\n\177]")))
351 ;; First get advice from tag table if file has one.
352 ;; Also, if this is an indirect info file,
353 ;; read the proper subfile into this buffer.
354 (if (marker-position Info-tag-table-marker
)
356 (set-buffer (marker-buffer Info-tag-table-marker
))
357 (goto-char Info-tag-table-marker
)
358 (if (re-search-forward regexp nil t
)
360 (setq guesspos
(read (current-buffer)))
361 ;; If this is an indirect file,
362 ;; determine which file really holds this node
364 (if (not (eq (current-buffer) (get-buffer "*info*")))
366 (Info-read-subfile guesspos
))))
367 (error "No such node: \"%s\"" nodename
))))
368 (goto-char (max (point-min) (- guesspos
1000)))
369 ;; Now search from our advised position (or from beg of buffer)
370 ;; to find the actual node.
372 (while (search-forward "\n\^_" nil t
)
376 (if (re-search-backward regexp beg t
)
378 (error "No such node: %s" nodename
)))
380 ;; If we did not finish finding the specified node,
381 ;; go back to the previous one.
382 (or Info-current-node no-going-back
(null Info-history
)
383 (let ((hist (car Info-history
)))
384 (setq Info-history
(cdr Info-history
))
385 (Info-find-node (nth 0 hist
) (nth 1 hist
) t
)
386 (goto-char (nth 2 hist
)))))
387 (goto-char (point-min)))
389 ;; Cache the contents of the (virtual) dir file, once we have merged
390 ;; it for the first time, so we can save time subsequently.
391 (defvar Info-dir-contents nil
)
393 ;; Cache for the directory we decided to use for the default-directory
394 ;; of the merged dir text.
395 (defvar Info-dir-contents-directory nil
)
397 ;; Record the file attributes of all the files from which we
398 ;; constructed Info-dir-contents.
399 (defvar Info-dir-file-attributes nil
)
401 ;; Construct the Info directory node by merging the files named `dir'
402 ;; from various directories. Set the *info* buffer's
403 ;; default-directory to the first directory we actually get any text
405 (defun Info-insert-dir ()
406 (if (and Info-dir-contents Info-dir-file-attributes
407 ;; Verify that none of the files we used has changed
410 (mapcar '(lambda (elt)
411 (let ((curr (file-attributes (car elt
))))
412 ;; Don't compare the access time.
413 (if curr
(setcar (nthcdr 4 curr
) 0))
414 (setcar (nthcdr 4 (cdr elt
)) 0)
415 (equal (cdr elt
) curr
)))
416 Info-dir-file-attributes
))))
417 (insert Info-dir-contents
)
418 (let ((dirs Info-directory-list
)
419 buffers buffer others nodes dirs-done
)
421 (setq Info-dir-file-attributes nil
)
423 ;; Search the directory list for the directory file.
425 (let ((truename (file-truename (expand-file-name (car dirs
)))))
426 (or (member truename dirs-done
)
427 (member (directory-file-name truename
) dirs-done
)
428 ;; Try several variants of specified name.
429 ;; Try upcasing, appending `.info', or both.
433 (progn (setq file
(expand-file-name "dir" truename
))
434 (file-attributes file
))
435 (progn (setq file
(expand-file-name "DIR" truename
))
436 (file-attributes file
))
437 (progn (setq file
(expand-file-name "dir.info" truename
))
438 (file-attributes file
))
439 (progn (setq file
(expand-file-name "DIR.INFO" truename
))
440 (file-attributes file
)))))
443 (cons (directory-file-name truename
)
448 (message "Composing main Info directory..."))
449 (set-buffer (generate-new-buffer "info dir"))
450 (insert-file-contents file
)
451 (setq buffers
(cons (current-buffer) buffers
)
452 Info-dir-file-attributes
453 (cons (cons file attrs
)
454 Info-dir-file-attributes
))))))
455 (setq dirs
(cdr dirs
))))
458 (error "Can't find the info directory node"))
459 ;; Distinguish the dir file that comes with Emacs from all the
460 ;; others. Yes, that is really what this is supposed to do.
461 ;; If it doesn't work, fix it.
462 (setq buffer
(car buffers
)
463 others
(cdr buffers
))
465 ;; Insert the entire original dir file as a start; use its
466 ;; default directory as the default directory for the whole
468 (insert-buffer buffer
)
469 (setq Info-dir-contents-directory
(save-excursion
473 ;; Look at each of the other buffers one by one.
475 (let ((other (car others
)))
476 ;; In each, find all the menus.
479 (goto-char (point-min))
480 ;; Find each menu, and add an elt to NODES for it.
481 (while (re-search-forward "^\\* Menu:" nil t
)
482 (let (beg nodename end
)
485 (search-backward "\n\^_")
486 (search-forward "Node: ")
487 (setq nodename
(Info-following-node-name))
488 (search-forward "\n\^_" nil
'move
)
491 (setq nodes
(cons (list nodename other beg end
) nodes
))))))
492 (setq others
(cdr others
)))
493 ;; Add to the main menu a menu item for each other node.
494 (re-search-forward "^\\* Menu:")
496 (let ((menu-items '("top"))
499 (end (save-excursion (search-forward "\^_" nil t
) (point))))
501 (let ((nodename (car (car nodes
))))
503 (or (member (downcase nodename
) menu-items
)
504 (re-search-forward (concat "^\\* "
505 (regexp-quote nodename
)
509 (insert "* " nodename
"::" "\n")
510 (setq menu-items
(cons nodename menu-items
))))))
511 (setq nodes
(cdr nodes
))))
512 ;; Now take each node of each of the other buffers
513 ;; and merge it into the main buffer.
515 (let ((nodename (car (car nodes
))))
516 (goto-char (point-min))
517 ;; Find the like-named node in the main buffer.
518 (if (re-search-forward (concat "\n\^_.*\n.*Node: "
519 (regexp-quote nodename
)
523 (search-forward "\n\^_" nil
'move
)
526 ;; If none exists, add one.
527 (goto-char (point-max))
528 (insert "\^_\nFile: dir\tNode: " nodename
"\n\n* Menu:\n\n"))
529 ;; Merge the text from the other buffer's menu
530 ;; into the menu in the like-named node in the main buffer.
531 (apply 'insert-buffer-substring
(cdr (car nodes
))))
532 (setq nodes
(cdr nodes
)))
533 ;; Kill all the buffers we just made.
535 (kill-buffer (car buffers
))
536 (setq buffers
(cdr buffers
)))
537 (message "Composing main Info directory...done"))
538 (setq Info-dir-contents
(buffer-string)))
539 (setq default-directory Info-dir-contents-directory
))
541 (defun Info-read-subfile (nodepos)
542 (set-buffer (marker-buffer Info-tag-table-marker
))
543 (goto-char (point-min))
544 (search-forward "\n\^_")
549 (while (not (looking-at "\^_"))
552 thisfilepos thisfilename
)
553 (search-forward ": ")
554 (setq thisfilename
(buffer-substring beg
(- (point) 2)))
555 (setq thisfilepos
(read (current-buffer)))
556 ;; read in version 19 stops at the end of number.
557 ;; Advance to the next line.
559 (if (> thisfilepos nodepos
)
561 (setq lastfilename thisfilename
)
562 (setq lastfilepos thisfilepos
))
564 (set-buffer (get-buffer "*info*"))
565 (or (equal Info-current-subfile lastfilename
)
566 (let ((buffer-read-only nil
))
567 (setq buffer-file-name nil
)
570 (info-insert-file-contents lastfilename
)
571 (set-buffer-modified-p nil
)
572 (setq Info-current-subfile lastfilename
)))
573 (goto-char (point-min))
574 (search-forward "\n\^_")
575 (+ (- nodepos lastfilepos
) (point))))
577 ;; Select the info node that point is in.
578 (defun Info-select-node ()
580 ;; Find beginning of node.
581 (search-backward "\n\^_")
583 ;; Get nodename spelled as it is in the node.
584 (re-search-forward "Node:[ \t]*")
585 (setq Info-current-node
586 (buffer-substring-no-properties (point)
588 (skip-chars-forward "^,\t\n")
591 ;; Find the end of it, and narrow.
593 (let (active-expression)
594 (narrow-to-region (point)
595 (if (re-search-forward "\n[\^_\f]" nil t
)
598 (if (looking-at "[\n\^_\f]*execute: ")
600 (goto-char (match-end 0))
601 (setq active-expression
602 (read (current-buffer))))))
604 (if Info-enable-active-nodes
(eval active-expression
))
605 (if Info-fontify
(Info-fontify-node))
606 (run-hooks 'Info-selection-hook
))))
608 (defun Info-set-mode-line ()
609 (setq mode-line-buffer-identification
612 (if Info-current-file
613 (file-name-nondirectory Info-current-file
)
616 (or Info-current-node
""))))
618 ;; Go to an info node specified with a filename-and-nodename string
619 ;; of the sort that is found in pointers in nodes.
621 (defun Info-goto-node (nodename)
622 "Go to info node named NAME. Give just NODENAME or (FILENAME)NODENAME."
623 (interactive (list (Info-read-node-name "Goto node: ")))
625 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
627 (setq filename
(if (= (match-beginning 1) (match-end 1))
629 (substring nodename
(match-beginning 2) (match-end 2)))
630 nodename
(substring nodename
(match-beginning 3) (match-end 3)))
631 (let ((trim (string-match "\\s *\\'" filename
)))
632 (if trim
(setq filename
(substring filename
0 trim
))))
633 (let ((trim (string-match "\\s *\\'" nodename
)))
634 (if trim
(setq nodename
(substring nodename
0 trim
))))
635 (if transient-mark-mode
(deactivate-mark))
636 (Info-find-node (if (equal filename
"") nil filename
)
637 (if (equal nodename
"") "Top" nodename
))))
639 ;; This function is used as the "completion table" while reading a node name.
640 ;; It does completion using the alist in completion-table
641 ;; unless STRING starts with an open-paren.
642 (defun Info-read-node-name-1 (string predicate code
)
643 (let ((no-completion (and (> (length string
) 0) (eq (aref string
0) ?\
())))
647 (try-completion string completion-table predicate
)))
651 (all-completions string completion-table predicate
)))
655 (assoc string completion-table
))))))
657 (defun Info-read-node-name (prompt &optional default
)
658 (let* ((completion-ignore-case t
)
659 (completion-table (Info-build-node-completions))
660 (nodename (completing-read prompt
'Info-read-node-name-1
)))
661 (if (equal nodename
"")
663 (Info-read-node-name prompt
))
666 (defun Info-build-node-completions ()
667 (or Info-current-file-completions
671 (if (marker-buffer Info-tag-table-marker
)
673 (set-buffer (marker-buffer Info-tag-table-marker
))
675 (goto-char Info-tag-table-marker
)
676 (while (re-search-forward "\nNode: \\(.*\\)\177" nil t
)
678 (cons (list (buffer-substring (match-beginning 1)
682 (goto-char (point-min))
683 (while (search-forward "\n\^_" nil t
)
687 (if (re-search-backward "Node: *\\([^,\n]*\\) *[,\n\t]"
690 (cons (list (buffer-substring (match-beginning 1)
693 (setq Info-current-file-completions compl
))))
695 (defun Info-restore-point (hl)
696 "If this node has been visited, restore the point value when we left."
698 (if (and (equal (nth 0 (car hl
)) Info-current-file
)
699 ;; Use string-equal, not equal, to ignore text props.
700 (string-equal (nth 1 (car hl
)) Info-current-node
))
702 (goto-char (nth 2 (car hl
)))
703 (setq hl nil
)) ;terminate the while at next iter
704 (setq hl
(cdr hl
)))))
706 (defvar Info-last-search nil
707 "Default regexp for \\<Info-mode-map>\\[Info-search] command to search for.")
709 (defun Info-search (regexp)
710 "Search for REGEXP, starting from point, and select node it's found in."
711 (interactive "sSearch (regexp): ")
712 (if transient-mark-mode
(deactivate-mark))
713 (if (equal regexp
"")
714 (setq regexp Info-last-search
)
715 (setq Info-last-search regexp
))
716 (let ((found ()) current
717 (onode Info-current-node
)
718 (ofile Info-current-file
)
720 (osubfile Info-current-subfile
))
724 (if (null Info-current-subfile
)
725 (progn (re-search-forward regexp
) (setq found
(point)))
727 (progn (re-search-forward regexp
) (setq found
(point)))
728 (search-failed nil
)))))
729 (if (not found
) ;can only happen in subfile case -- else would have erred
732 (set-buffer (marker-buffer Info-tag-table-marker
))
733 (goto-char (point-min))
734 (search-forward "\n\^_\nIndirect:")
736 (narrow-to-region (point)
737 (progn (search-forward "\n\^_")
739 (goto-char (point-min))
740 (search-forward (concat "\n" osubfile
": "))
743 (re-search-forward "\\(^.*\\): [0-9]+$")
744 (goto-char (+ (match-end 1) 2))
745 (setq list
(cons (cons (read (current-buffer))
746 (buffer-substring (match-beginning 1)
749 (goto-char (1+ (match-end 0))))
750 (setq list
(nreverse list
)
751 current
(car (car list
))
754 (message "Searching subfile %s..." (cdr (car list
)))
755 (Info-read-subfile (car (car list
)))
756 (setq list
(cdr list
))
757 ;; (goto-char (point-min))
758 (if (re-search-forward regexp nil t
)
759 (setq found
(point) list
())))
762 (signal 'search-failed
(list regexp
))))
764 (progn (Info-read-subfile opoint
)
766 (Info-select-node)))))
770 ;; Use string-equal, not equal, to ignore text props.
771 (or (and (string-equal onode Info-current-node
)
772 (equal ofile Info-current-file
))
773 (setq Info-history
(cons (list ofile onode opoint
)
776 ;; Extract the value of the node-pointer named NAME.
777 ;; If there is none, use ERRORNAME in the error message;
778 ;; if ERRORNAME is nil, just return nil.
779 (defun Info-extract-pointer (name &optional errorname
)
781 (goto-char (point-min))
783 (if (re-search-backward (concat name
":") nil t
)
785 (goto-char (match-end 0))
786 (Info-following-node-name))
789 (error (concat "Node has no " (capitalize (or errorname name
))))))))
791 ;; Return the node name in the buffer following point.
792 ;; ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
793 ;; saying which chas may appear in the node name.
794 (defun Info-following-node-name (&optional allowedchars
)
795 (skip-chars-forward " \t")
796 (buffer-substring-no-properties
799 (while (looking-at (concat "[" (or allowedchars
"^,\t\n") "]"))
800 (skip-chars-forward (concat (or allowedchars
"^,\t\n") "("))
802 (skip-chars-forward "^)")))
803 (skip-chars-backward " ")
807 "Go to the next node of this node."
809 (Info-goto-node (Info-extract-pointer "next")))
812 "Go to the previous node of this node."
814 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous")))
817 "Go to the superior node of this node."
819 (Info-goto-node (Info-extract-pointer "up"))
820 (Info-restore-point Info-history
))
823 "Go back to the last node visited."
826 (error "This is the first Info node you looked at"))
827 (let (filename nodename opoint
)
828 (setq filename
(car (car Info-history
)))
829 (setq nodename
(car (cdr (car Info-history
))))
830 (setq opoint
(car (cdr (cdr (car Info-history
)))))
831 (setq Info-history
(cdr Info-history
))
832 (Info-find-node filename nodename
)
833 (setq Info-history
(cdr Info-history
))
836 (defun Info-directory ()
837 "Go to the Info directory node."
839 (Info-find-node "dir" "top"))
841 (defun Info-follow-reference (footnotename)
842 "Follow cross reference named NAME to the node it refers to.
843 NAME may be an abbreviation of the reference name."
845 (let ((completion-ignore-case t
)
846 completions default alt-default
(start-point (point)) str i bol eol
)
848 ;; Store end and beginning of line.
854 (goto-char (point-min))
855 (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t
)
856 (setq str
(buffer-substring
859 ;; See if this one should be the default.
861 (<= (match-beginning 0) start-point
)
862 (<= start-point
(point))
864 ;; See if this one should be the alternate default.
865 (and (null alt-default
)
866 (and (<= bol
(match-beginning 0))
868 (setq alt-default t
))
870 (while (setq i
(string-match "[ \n\t]+" str i
))
871 (setq str
(concat (substring str
0 i
) " "
872 (substring str
(match-end 0))))
874 ;; Record as a completion and perhaps as default.
875 (if (eq default t
) (setq default str
))
876 (if (eq alt-default t
) (setq alt-default str
))
880 ;; If no good default was found, try an alternate.
882 (setq default alt-default
))
883 ;; If only one cross-reference found, then make it default.
884 (if (eq (length completions
) 1)
885 (setq default
(car (car completions
))))
887 (let ((input (completing-read (if default
888 (concat "Follow reference named: ("
890 "Follow reference named: ")
892 (list (if (equal input
"")
894 (error "No cross-references in this node"))))
895 (let (target beg i
(str (concat "\\*note " (regexp-quote footnotename
))))
896 (while (setq i
(string-match " " str i
))
897 (setq str
(concat (substring str
0 i
) "[ \t\n]+" (substring str
(1+ i
))))
900 (goto-char (point-min))
901 (or (re-search-forward str nil t
)
902 (error "No cross-reference named %s" footnotename
))
903 (goto-char (+ (match-beginning 0) 5))
905 (Info-extract-menu-node-name "Bad format cross reference" t
)))
906 (while (setq i
(string-match "[ \t\n]+" target i
))
907 (setq target
(concat (substring target
0 i
) " "
908 (substring target
(match-end 0))))
910 (Info-goto-node target
)))
912 (defun Info-extract-menu-node-name (&optional errmessage multi-line
)
913 (skip-chars-forward " \t\n")
916 (skip-chars-forward "^:")
920 (buffer-substring-no-properties beg
(1- (point)))
921 (skip-chars-forward " \t\n")
922 (Info-following-node-name (if multi-line
"^.,\t" "^.,\t\n"))))
923 (while (setq i
(string-match "\n" str i
))
925 ;; Collapse multiple spaces.
926 (while (string-match " +" str
)
927 (setq str
(replace-match " " t t str
)))
930 ;; No one calls this.
931 ;;(defun Info-menu-item-sequence (list)
933 ;; (Info-menu (car list))
934 ;; (setq list (cdr list))))
936 (defun Info-complete-menu-item (string predicate action
)
937 (let ((case-fold-search t
))
938 (cond ((eq action nil
)
940 (pattern (concat "\n\\* \\("
941 (regexp-quote string
)
944 (set-buffer Info-complete-menu-buffer
)
945 (goto-char (point-min))
946 (while (re-search-forward pattern nil t
)
947 (setq completions
(cons (cons (format "%s"
953 (try-completion string completions predicate
)))
956 (pattern (concat "\n\\* \\("
957 (regexp-quote string
)
960 (set-buffer Info-complete-menu-buffer
)
961 (goto-char (point-min))
962 (while (re-search-forward pattern nil t
)
963 (setq completions
(cons (cons (format "%s"
969 (all-completions string completions predicate
)))
972 (set-buffer Info-complete-menu-buffer
)
973 (goto-char (point-min))
974 (re-search-forward (concat "\n\\* "
975 (regexp-quote string
)
980 (defun Info-menu (menu-item)
981 "Go to node for menu item named (or abbreviated) NAME.
982 Completion is allowed, and the menu item point is on is the default."
984 (let ((completions '())
985 ;; If point is within a menu item, use that item as the default
991 (goto-char (point-min))
992 (if (not (search-forward "\n* menu:" nil t
))
993 (error "No menu in this node"))
999 (re-search-backward "\n\\* \\([^:\t\n]*\\):" beg t
)
1000 (setq default
(format "%s" (buffer-substring
1005 (setq item
(let ((completion-ignore-case t
)
1006 (Info-complete-menu-buffer (current-buffer)))
1007 (completing-read (if default
1008 (format "Menu item (default %s): "
1011 'Info-complete-menu-item nil t
)))
1012 ;; we rely on the fact that completing-read accepts an input
1013 ;; of "" even when the require-match argument is true and ""
1014 ;; is not a valid possibility
1015 (if (string= item
"")
1021 ;; there is a problem here in that if several menu items have the same
1022 ;; name you can only go to the node of the first with this command.
1023 (Info-goto-node (Info-extract-menu-item menu-item
)))
1025 (defun Info-extract-menu-item (menu-item)
1026 (setq menu-item
(regexp-quote menu-item
))
1028 (goto-char (point-min))
1029 (or (search-forward "\n* menu:" nil t
)
1030 (error "No menu in this node"))
1031 (or (re-search-forward (concat "\n\\* " menu-item
":") nil t
)
1032 (re-search-forward (concat "\n\\* " menu-item
) nil t
)
1033 (error "No such item in menu"))
1036 (Info-extract-menu-node-name)))
1038 ;; If COUNT is nil, use the last item in the menu.
1039 (defun Info-extract-menu-counting (count)
1041 (goto-char (point-min))
1042 (or (search-forward "\n* menu:" nil t
)
1043 (error "No menu in this node"))
1045 (or (search-forward "\n* " nil t count
)
1046 (error "Too few items in menu"))
1047 (while (search-forward "\n* " nil t
)
1049 (Info-extract-menu-node-name)))
1051 (defun Info-nth-menu-item ()
1052 "Go to the node of the Nth menu item.
1053 N is the digit argument used to invoke this command."
1056 (Info-extract-menu-counting
1057 (- (aref (this-command-keys) (1- (length (this-command-keys)))) ?
0))))
1059 (defun Info-top-node ()
1060 "Go to the Top node of this file."
1062 (Info-goto-node "Top"))
1064 (defun Info-final-node ()
1065 "Go to the final node in this file."
1067 (Info-goto-node "Top")
1069 ;; Go to the last node in the menu of Top.
1070 (Info-goto-node (Info-extract-menu-counting nil
))
1071 ;; If the last node in the menu is not last in pointer structure,
1072 ;; move forward until we can't go any farther.
1073 (while (Info-forward-node t t
) nil
)
1074 ;; Then keep moving down to last subnode, unless we reach an index.
1075 (while (and (not (string-match "\\<index\\>" Info-current-node
))
1076 (save-excursion (search-forward "\n* Menu:" nil t
)))
1077 (Info-goto-node (Info-extract-menu-counting nil
)))))
1079 (defun Info-forward-node (&optional not-down no-error
)
1080 "Go forward one node, considering all nodes as forming one sequence."
1082 (goto-char (point-min))
1084 ;; three possibilities, in order of priority:
1085 ;; 1. next node is in a menu in this node (but not in an index)
1086 ;; 2. next node is next at same level
1087 ;; 3. next node is up and next
1088 (cond ((and (not not-down
)
1089 (save-excursion (search-forward "\n* menu:" nil t
))
1090 (not (string-match "\\<index\\>" Info-current-node
)))
1091 (Info-goto-node (Info-extract-menu-counting 1))
1093 ((save-excursion (search-backward "next:" nil t
))
1096 ((and (save-excursion (search-backward "up:" nil t
))
1097 ;; Use string-equal, not equal, to ignore text props.
1098 (not (string-equal (downcase (Info-extract-pointer "up"))
1100 (let ((old-node Info-current-node
))
1102 (let (Info-history success
)
1104 (setq success
(Info-forward-node t no-error
))
1105 (or success
(Info-goto-node old-node
))))))
1107 (t (error "No pointer forward from this node"))))
1109 (defun Info-backward-node ()
1110 "Go backward one node, considering all nodes as forming one sequence."
1112 (let ((prevnode (Info-extract-pointer "prev[ious]*" t
))
1113 (upnode (Info-extract-pointer "up" t
)))
1114 (cond ((and upnode
(string-match "(" upnode
))
1115 (error "First node in file"))
1116 ((and upnode
(or (null prevnode
)
1117 ;; Use string-equal, not equal,
1118 ;; to ignore text properties.
1119 (string-equal (downcase prevnode
)
1120 (downcase upnode
))))
1123 ;; If we move back at the same level,
1124 ;; go down to find the last subnode*.
1127 (while (and (not (string-match "\\<index\\>" Info-current-node
))
1128 (save-excursion (search-forward "\n* Menu:" nil t
)))
1129 (Info-goto-node (Info-extract-menu-counting nil
)))))
1131 (error "No pointer backward from this node")))))
1134 "Exit Info by selecting some other buffer."
1137 (save-buffers-kill-emacs)
1138 (switch-to-buffer (prog1 (other-buffer (current-buffer))
1139 (bury-buffer (current-buffer))))))
1141 (defun Info-next-menu-item ()
1145 (search-forward "\n* menu:" nil t
)
1146 (or (search-forward "\n* " nil t
)
1147 (error "No more items in menu"))
1148 (Info-goto-node (Info-extract-menu-node-name))))
1150 (defun Info-last-menu-item ()
1154 (let ((beg (save-excursion
1155 (and (search-backward "\n* menu:" nil t
)
1157 (or (and beg
(search-backward "\n* " beg t
))
1158 (error "No previous items in menu")))
1159 (Info-goto-node (save-excursion
1160 (goto-char (match-end 0))
1161 (Info-extract-menu-node-name)))))
1163 (defmacro Info-no-error
(&rest body
)
1164 (list 'condition-case nil
(cons 'progn
(append body
'(t))) '(error nil
)))
1166 (defun Info-next-preorder ()
1167 "Go to the next subnode or the next node, or go up a level."
1169 (cond ((Info-no-error (Info-next-menu-item)))
1170 ((Info-no-error (Info-next)))
1171 ((Info-no-error (Info-up))
1172 ;; Since we have already gone thru all the items in this menu,
1173 ;; go up to the end of this node.
1174 (goto-char (point-max)))
1176 (error "No more nodes"))))
1178 (defun Info-last-preorder ()
1179 "Go to the last node, popping up a level if there is none."
1181 (cond ((Info-no-error
1182 (Info-last-menu-item)
1183 ;; If we go down a menu item, go to the end of the node
1184 ;; so we can scroll back through it.
1185 (goto-char (point-max)))
1187 ((Info-no-error (Info-prev))
1188 (goto-char (point-max))
1190 ((Info-no-error (Info-up))
1191 (goto-char (point-min))
1192 (or (search-forward "\n* Menu:" nil t
)
1193 (goto-char (point-max))))
1194 (t (error "No previous nodes"))))
1196 (defun Info-scroll-up ()
1197 "Scroll one screenful forward in Info, considering all nodes as one sequence.
1198 Once you scroll far enough in a node that its menu appears on the screen,
1199 the next scroll moves into its first subnode. When you scroll past
1200 the end of a node, that goes to the next node or back up to the parent node."
1202 (if (or (< (window-start) (point-min))
1203 (> (window-start) (point-max)))
1204 (set-window-start (selected-window) (point)))
1205 (let ((virtual-end (save-excursion
1206 (goto-char (point-min))
1207 (if (search-forward "\n* Menu:" nil t
)
1210 (if (or (< virtual-end
(window-start))
1211 (pos-visible-in-window-p virtual-end
))
1212 (Info-next-preorder)
1215 (defun Info-scroll-down ()
1216 "Scroll one screenful back in Info, considering all nodes as one sequence.
1217 Within the menu of a node, this goes to its last subnode.
1218 When you scroll past the beginning of a node, that goes to the
1219 previous node or back up to the parent node."
1221 (if (or (< (window-start) (point-min))
1222 (> (window-start) (point-max)))
1223 (set-window-start (selected-window) (point)))
1224 (let ((virtual-end (save-excursion
1225 (goto-char (point-min))
1226 (search-forward "\n* Menu:" nil t
))))
1227 (if (or virtual-end
(pos-visible-in-window-p (point-min)))
1228 (Info-last-preorder)
1231 (defun Info-next-reference ()
1232 "Move cursor to the next cross-reference or menu item in the node."
1234 (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:")
1236 (or (eobp) (forward-char 1))
1237 (or (re-search-forward pat nil t
)
1239 (goto-char (point-min))
1240 (or (re-search-forward pat nil t
)
1243 (error "No cross references in this node")))))
1244 (goto-char (match-beginning 0))
1245 (if (looking-at "\\* Menu:")
1246 (Info-next-reference))))
1248 (defun Info-prev-reference ()
1249 "Move cursor to the previous cross-reference or menu item in the node."
1251 (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:")
1253 (or (re-search-backward pat nil t
)
1255 (goto-char (point-max))
1256 (or (re-search-backward pat nil t
)
1259 (error "No cross references in this node")))))
1260 (goto-char (match-beginning 0))
1261 (if (looking-at "\\* Menu:")
1262 (Info-prev-reference))))
1264 (defun Info-index (topic)
1265 "Look up a string in the index for this file.
1266 The index is defined as the first node in the top-level menu whose
1267 name contains the word \"Index\", plus any immediately following
1268 nodes whose names also contain the word \"Index\".
1269 If there are no exact matches to the specified topic, this chooses
1270 the first match which is a case-insensitive substring of a topic.
1271 Use the `,' command to see the other matches.
1272 Give a blank topic name to go to the Index node itself."
1273 (interactive "sIndex topic: ")
1274 (let ((orignode Info-current-node
)
1276 (pattern (format "\n\\* \\([^\n:]*%s[^\n:]*\\):[ \t]*\\([^.\n]*\\)\\.[ \t]*\\([0-9]*\\)"
1277 (regexp-quote topic
)))
1279 (Info-goto-node "Top")
1280 (or (search-forward "\n* menu:" nil t
)
1282 (or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t
)
1284 (goto-char (match-beginning 1))
1285 ;; Here, and subsequently in this function,
1286 ;; we bind Info-history to nil for internal node-switches
1287 ;; so that we don't put junk in the history.
1288 ;; In the first Info-goto-node call, above, we do update the history
1289 ;; because that is what the user's previous node choice into it.
1290 (let ((Info-history nil
))
1291 (Info-goto-node (Info-extract-menu-node-name)))
1292 (or (equal topic
"")
1299 (goto-char (point-min))
1300 (while (re-search-forward pattern nil t
)
1302 (cons (list (buffer-substring (match-beginning 1)
1304 (buffer-substring (match-beginning 2)
1307 (string-to-int (concat "0"
1312 (and (setq node
(Info-extract-pointer "next" t
))
1313 (string-match "\\<Index\\>" node
)))
1314 (Info-goto-node node
))
1318 (error "No \"%s\" in index" topic
)))
1319 ;; Here it is a feature that assoc is case-sensitive.
1320 (while (setq found
(assoc topic matches
))
1321 (setq exact
(cons found exact
)
1322 matches
(delq found matches
)))
1323 (setq Info-index-alternatives
(nconc exact
(nreverse matches
)))
1324 (Info-index-next 0)))))
1326 (defun Info-index-next (num)
1327 "Go to the next matching index item from the last `i' command."
1329 (or Info-index-alternatives
1330 (error "No previous `i' command in this file"))
1332 (setq num
(+ num
(length Info-index-alternatives
))))
1334 (setq Info-index-alternatives
1335 (nconc (cdr Info-index-alternatives
)
1336 (list (car Info-index-alternatives
)))
1338 (Info-goto-node (nth 1 (car Info-index-alternatives
)))
1339 (if (> (nth 3 (car Info-index-alternatives
)) 0)
1340 (forward-line (nth 3 (car Info-index-alternatives
)))
1341 (forward-line 3) ; don't search in headers
1342 (let ((name (car (car Info-index-alternatives
))))
1343 (if (or (re-search-forward (format
1344 "\\(Function\\|Command\\): %s\\( \\|$\\)"
1345 (regexp-quote name
)) nil t
)
1346 (search-forward (format "`%s'" name
) nil t
)
1347 (and (string-match "\\`.*\\( (.*)\\)\\'" name
)
1349 (format "`%s'" (substring name
0 (match-beginning 1)))
1351 (search-forward name nil t
))
1353 (goto-char (point-min)))))
1354 (message "Found \"%s\" in %s. %s"
1355 (car (car Info-index-alternatives
))
1356 (nth 2 (car Info-index-alternatives
))
1357 (if (cdr Info-index-alternatives
)
1358 "(Press `,' for more)"
1361 (defun Info-undefined ()
1362 "Make command be undefined in Info."
1367 "Enter the Info tutorial."
1369 (delete-other-windows)
1370 (Info-find-node "info"
1371 (if (< (window-height) 23)
1375 (defun Info-summary ()
1376 "Display a brief summary of all Info commands."
1378 (save-window-excursion
1379 (switch-to-buffer "*Help*")
1381 (insert (documentation 'Info-mode
))
1383 (goto-char (point-min))
1385 (while (progn (setq flag
(not (pos-visible-in-window-p (point-max))))
1386 (message (if flag
"Type Space to see more"
1387 "Type Space to return to Info"))
1388 (if (not (eq ?\
(setq ch
(read-event))))
1389 (progn (setq unread-command-events
(list ch
)) nil
)
1392 (bury-buffer "*Help*")))
1394 (defun Info-get-token (pos start all
&optional errorstring
)
1395 "Return the token around POS,
1396 POS must be somewhere inside the token
1397 START is a regular expression which will match the
1398 beginning of the tokens delimited string
1399 ALL is a regular expression with a single
1400 parenthized subpattern which is the token to be
1401 returned. E.g. '{\(.*\)}' would return any string
1402 enclosed in braces around POS.
1403 SIG optional fourth argument, controls action on no match
1406 a string: signal an error, using that string."
1409 (re-search-backward start
(max (point-min) (- pos
200)) 'yes
)
1411 (while (and (re-search-forward all
(min (point-max) (+ pos
200)) 'yes
)
1412 (not (setq found
(and (<= (match-beginning 0) pos
)
1413 (> (match-end 0) pos
))))))
1414 (if (and found
(<= (match-beginning 0) pos
)
1415 (> (match-end 0) pos
))
1416 (buffer-substring (match-beginning 1) (match-end 1))
1417 (cond ((null errorstring
)
1423 (error "No %s around position %d" errorstring pos
)))))))
1425 (defun Info-mouse-follow-nearest-node (click)
1426 "\\<Info-mode-map>Follow a node reference near point.
1427 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click.
1428 At end of the node's text, moves to the next node, or up if none."
1430 (let* ((start (event-start click
))
1431 (window (car start
))
1432 (pos (car (cdr start
))))
1433 (select-window window
)
1435 (and (not (Info-try-follow-nearest-node))
1436 (save-excursion (forward-line 1) (eobp))
1437 (Info-next-preorder)))
1439 (defun Info-follow-nearest-node ()
1440 "\\<Info-mode-map>Follow a node reference near point.
1441 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where point is.
1442 If no reference to follow, moves to the next node, or up if none."
1444 (or (Info-try-follow-nearest-node)
1445 (Info-next-preorder)))
1447 ;; Common subroutine.
1448 (defun Info-try-follow-nearest-node ()
1449 "Follow a node reference near point. Return non-nil if successful."
1452 ((setq node
(Info-get-token (point) "\\*note[ \n]"
1453 "\\*note[ \n]\\([^:]*\\):"))
1454 (Info-follow-reference node
))
1455 ((setq node
(Info-get-token (point) "\\* " "\\* \\([^:]*\\)::"))
1456 (Info-goto-node node
))
1457 ((setq node
(Info-get-token (point) "\\* " "\\* \\([^:]*\\):"))
1459 ((setq node
(Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)"))
1460 (Info-goto-node node
))
1461 ((setq node
(Info-get-token (point) "Next: " "Next: \\([^,\n\t]*\\)"))
1462 (Info-goto-node node
))
1463 ((setq node
(Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)"))
1464 (Info-goto-node "Top"))
1465 ((setq node
(Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)"))
1466 (Info-goto-node node
)))
1469 (defvar Info-mode-map nil
1470 "Keymap containing Info commands.")
1473 (setq Info-mode-map
(make-keymap))
1474 (suppress-keymap Info-mode-map
)
1475 (define-key Info-mode-map
"." 'beginning-of-buffer
)
1476 (define-key Info-mode-map
" " 'Info-scroll-up
)
1477 (define-key Info-mode-map
"\C-m" 'Info-follow-nearest-node
)
1478 (define-key Info-mode-map
"\t" 'Info-next-reference
)
1479 (define-key Info-mode-map
"\e\t" 'Info-prev-reference
)
1480 (define-key Info-mode-map
"1" 'Info-nth-menu-item
)
1481 (define-key Info-mode-map
"2" 'Info-nth-menu-item
)
1482 (define-key Info-mode-map
"3" 'Info-nth-menu-item
)
1483 (define-key Info-mode-map
"4" 'Info-nth-menu-item
)
1484 (define-key Info-mode-map
"5" 'Info-nth-menu-item
)
1485 (define-key Info-mode-map
"6" 'Info-nth-menu-item
)
1486 (define-key Info-mode-map
"7" 'Info-nth-menu-item
)
1487 (define-key Info-mode-map
"8" 'Info-nth-menu-item
)
1488 (define-key Info-mode-map
"9" 'Info-nth-menu-item
)
1489 (define-key Info-mode-map
"0" 'undefined
)
1490 (define-key Info-mode-map
"?" 'Info-summary
)
1491 (define-key Info-mode-map
"]" 'Info-forward-node
)
1492 (define-key Info-mode-map
"[" 'Info-backward-node
)
1493 (define-key Info-mode-map
"<" 'Info-top-node
)
1494 (define-key Info-mode-map
">" 'Info-final-node
)
1495 (define-key Info-mode-map
"b" 'beginning-of-buffer
)
1496 (define-key Info-mode-map
"d" 'Info-directory
)
1497 (define-key Info-mode-map
"e" 'Info-edit
)
1498 (define-key Info-mode-map
"f" 'Info-follow-reference
)
1499 (define-key Info-mode-map
"g" 'Info-goto-node
)
1500 (define-key Info-mode-map
"h" 'Info-help
)
1501 (define-key Info-mode-map
"i" 'Info-index
)
1502 (define-key Info-mode-map
"l" 'Info-last
)
1503 (define-key Info-mode-map
"m" 'Info-menu
)
1504 (define-key Info-mode-map
"n" 'Info-next
)
1505 (define-key Info-mode-map
"p" 'Info-prev
)
1506 (define-key Info-mode-map
"q" 'Info-exit
)
1507 (define-key Info-mode-map
"s" 'Info-search
)
1508 ;; For consistency with Rmail.
1509 (define-key Info-mode-map
"\M-s" 'Info-search
)
1510 (define-key Info-mode-map
"t" 'Info-top-node
)
1511 (define-key Info-mode-map
"u" 'Info-up
)
1512 (define-key Info-mode-map
"," 'Info-index-next
)
1513 (define-key Info-mode-map
"\177" 'Info-scroll-down
)
1514 (define-key Info-mode-map
[mouse-2
] 'Info-mouse-follow-nearest-node
)
1517 ;; Info mode is suitable only for specially formatted data.
1518 (put 'info-mode
'mode-class
'special
)
1522 Info mode provides commands for browsing through the Info documentation tree.
1523 Documentation in Info is divided into \"nodes\", each of which discusses
1524 one topic and contains references to other nodes which discuss related
1525 topics. Info has commands to follow the references and show you other nodes.
1527 \\[Info-help] Invoke the Info tutorial.
1529 Selecting other nodes:
1530 \\[Info-mouse-follow-nearest-node]
1531 Follow a node reference you click on.
1532 This works with menu items, cross references, and
1533 the \"next\", \"previous\" and \"up\", depending on where you click.
1534 \\[Info-next] Move to the \"next\" node of this node.
1535 \\[Info-prev] Move to the \"previous\" node of this node.
1536 \\[Info-up] Move \"up\" from this node.
1537 \\[Info-menu] Pick menu item specified by name (or abbreviation).
1538 Picking a menu item causes another node to be selected.
1539 \\[Info-directory] Go to the Info directory node.
1540 \\[Info-follow-reference] Follow a cross reference. Reads name of reference.
1541 \\[Info-last] Move to the last node you were at.
1542 \\[Info-index] Look up a topic in this file's Index and move to that node.
1543 \\[Info-index-next] (comma) Move to the next match from a previous `i' command.
1545 Moving within a node:
1546 \\[Info-scroll-up] Normally, scroll forward a full screen. If the end of the buffer is
1547 already visible, try to go to the next menu entry, or up if there is none.
1548 \\[Info-scroll-down] Normally, scroll backward. If the beginning of the buffer is
1549 already visible, try to go to the previous menu entry, or up if there is none.
1550 \\[beginning-of-buffer] Go to beginning of node.
1553 \\[Info-exit] Quit Info: reselect previously selected buffer.
1554 \\[Info-edit] Edit contents of selected node.
1555 1 Pick first item in node's menu.
1556 2, 3, 4, 5 Pick second ... fifth item in node's menu.
1557 \\[Info-goto-node] Move to node specified by name.
1558 You may include a filename as well, as (FILENAME)NODENAME.
1559 \\[universal-argument] \\[info] Move to new Info file with completion.
1560 \\[Info-search] Search through this Info file for specified regexp,
1561 and select the node in which the next occurrence is found.
1562 \\[Info-next-reference] Move cursor to next cross-reference or menu item.
1563 \\[Info-prev-reference] Move cursor to previous cross-reference or menu item."
1564 (kill-all-local-variables)
1565 (setq major-mode
'Info-mode
)
1566 (setq mode-name
"Info")
1567 (use-local-map Info-mode-map
)
1568 (set-syntax-table text-mode-syntax-table
)
1569 (setq local-abbrev-table text-mode-abbrev-table
)
1570 (setq case-fold-search t
)
1571 (setq buffer-read-only t
)
1572 (make-local-variable 'Info-current-file
)
1573 (make-local-variable 'Info-current-subfile
)
1574 (make-local-variable 'Info-current-node
)
1575 (make-local-variable 'Info-tag-table-marker
)
1576 (make-local-variable 'Info-history
)
1577 (make-local-variable 'Info-index-alternatives
)
1578 (if (memq (framep (selected-frame)) '(x pc
))
1580 (make-face 'info-node
)
1581 (make-face 'info-menu-5
)
1582 (make-face 'info-xref
)
1583 (or (face-differs-from-default-p 'info-node
)
1584 (if (face-differs-from-default-p 'bold-italic
)
1585 (copy-face 'bold-italic
'info-node
)
1586 (copy-face 'bold
'info-node
)))
1587 (or (face-differs-from-default-p 'info-menu-5
)
1588 (set-face-underline-p 'info-menu-5 t
))
1589 (or (face-differs-from-default-p 'info-xref
)
1590 (copy-face 'bold
'info-xref
)))
1591 (setq Info-fontify nil
))
1592 (Info-set-mode-line)
1593 (run-hooks 'Info-mode-hook
))
1595 (defvar Info-edit-map nil
1596 "Local keymap used within `e' command of Info.")
1599 (setq Info-edit-map
(nconc (make-sparse-keymap) text-mode-map
))
1600 (define-key Info-edit-map
"\C-c\C-c" 'Info-cease-edit
))
1602 ;; Info-edit mode is suitable only for specially formatted data.
1603 (put 'info-edit-mode
'mode-class
'special
)
1605 (defun Info-edit-mode ()
1606 "Major mode for editing the contents of an Info node.
1607 Like text mode with the addition of `Info-cease-edit'
1608 which returns to Info mode for browsing.
1610 (use-local-map Info-edit-map
)
1611 (setq major-mode
'Info-edit-mode
)
1612 (setq mode-name
"Info Edit")
1613 (kill-local-variable 'mode-line-buffer-identification
)
1614 (setq buffer-read-only nil
)
1615 (force-mode-line-update)
1616 (buffer-enable-undo (current-buffer))
1617 (run-hooks 'Info-edit-mode-hook
))
1620 "Edit the contents of this Info node.
1621 Allowed only if variable `Info-enable-edit' is non-nil."
1623 (or Info-enable-edit
1624 (error "Editing info nodes is not enabled"))
1626 (message (substitute-command-keys
1627 "Editing: Type \\<Info-edit-map>\\[Info-cease-edit] to return to info")))
1629 (defun Info-cease-edit ()
1630 "Finish editing Info node; switch back to Info proper."
1632 ;; Do this first, so nothing has changed if user C-g's at query.
1633 (and (buffer-modified-p)
1634 (y-or-n-p "Save the file? ")
1636 (use-local-map Info-mode-map
)
1637 (setq major-mode
'Info-mode
)
1638 (setq mode-name
"Info")
1639 (Info-set-mode-line)
1640 (setq buffer-read-only t
)
1641 (force-mode-line-update)
1642 (and (marker-position Info-tag-table-marker
)
1644 (message "Tags may have changed. Use Info-tagify if necessary")))
1646 (defvar Info-file-list-for-emacs
1647 '("ediff" "forms" "gnus" "info" ("mh" .
"mh-e") "sc")
1648 "List of Info files that describe Emacs commands.
1649 An element can be a file name, or a list of the form (PREFIX . FILE)
1650 where PREFIX is a name prefix and FILE is the file to look in.
1651 If the element is just a file name, the file name also serves as the prefix.")
1653 (defun Info-find-emacs-command-nodes (command)
1654 "Return a list of locations documenting COMMAND.
1655 The `info-file' property of COMMAND says which Info manual to search.
1656 If COMMAND has no property, the variable `Info-file-list-for-emacs'
1657 defines heuristics for which Info manual to try.
1658 The locations are of the format used in Info-history, i.e.
1659 \(FILENAME NODENAME BUFFERPOS\)."
1661 (cmd-desc (concat "^\\* " (regexp-quote (symbol-name command
))
1662 ":\\s *\\(.*\\)\\.$"))
1663 (info-file "emacs")) ;default
1664 ;; Determine which info file this command is documented in.
1665 (if (get command
'info-file
)
1666 (setq info-file
(get command
'info-file
))
1667 ;; If it doesn't say explicitly, test its name against
1668 ;; various prefixes that we know.
1669 (let ((file-list Info-file-list-for-emacs
))
1671 (let* ((elt (car file-list
))
1672 (name (if (consp elt
)
1675 (file (if (consp elt
) (cdr elt
) elt
))
1676 (regexp (concat "\\`" (regexp-quote name
)
1678 (if (string-match regexp
(symbol-name command
))
1679 (setq info-file file file-list nil
))
1680 (setq file-list
(cdr file-list
))))))
1683 (Info-find-node info-file
"Command Index")
1684 ;; Some manuals may not have a separate Command Index node,
1685 ;; so try just Index instead.
1687 (Info-find-node info-file
"Index")))
1688 ;; Take the index node off the Info history.
1689 (setq Info-history
(cdr Info-history
))
1690 (goto-char (point-max))
1691 (while (re-search-backward cmd-desc nil t
)
1692 (setq where
(cons (list Info-current-file
1701 (defun Info-goto-emacs-command-node (command)
1702 "Go to the Info node in the Emacs manual for command COMMAND.
1703 The command is found by looking up in Emacs manual's Command Index
1704 or in another manual found via COMMAND's `info-file' property or
1705 the variable `Info-file-list-for-emacs'."
1706 (interactive "CFind documentation for command: ")
1707 (or (commandp command
)
1708 (signal 'wrong-type-argument
(list 'commandp command
)))
1709 (let ((where (Info-find-emacs-command-nodes command
)))
1711 (let ((num-matches (length where
)))
1712 ;; Get Info running, and pop to it in another window.
1713 (save-window-excursion
1715 (pop-to-buffer "*info*")
1716 (Info-find-node (car (car where
))
1717 (car (cdr (car where
))))
1718 (if (> num-matches
1)
1720 ;; Info-find-node already pushed (car where) onto
1721 ;; Info-history. Put the other nodes that were found on
1723 (setq Info-history
(nconc (cdr where
) Info-history
))
1724 (message (substitute-command-keys
1725 "Found %d other entr%s. Use \\[Info-last] to see %s.")
1727 (if (> num-matches
2) "ies" "y")
1728 (if (> num-matches
2) "them" "it")))))
1729 (error "Couldn't find documentation for %s." command
))))
1732 (defun Info-goto-emacs-key-command-node (key)
1733 "Go to the Info node in the Emacs manual the command bound to KEY, a string.
1734 Interactively, if the binding is execute-extended-command, a command is read.
1735 The command is found by looking up in Emacs manual's Command Index
1736 or in another manual found via COMMAND's `info-file' property or
1737 the variable `Info-file-list-for-emacs'."
1738 (interactive "kFind documentation for key:")
1739 (let ((command (key-binding key
)))
1740 (cond ((null command
)
1741 (message "%s is undefined" (key-description key
)))
1742 ((and (interactive-p)
1743 (eq command
'execute-extended-command
))
1744 (Info-goto-emacs-command-node
1745 (read-command "Find documentation for command: ")))
1747 (Info-goto-emacs-command-node command
)))))
1749 (defvar Info-title-face-alist
1750 '((?
* bold underline
)
1751 (?
= bold-italic underline
)
1752 (?- italic underline
))
1753 "*Alist of face or list of faces to use for pseudo-underlined titles.
1754 The alist key is the character the title is underlined with (?*, ?= or ?-).")
1756 (defun Info-fontify-node ()
1758 (let ((buffer-read-only nil
))
1759 (goto-char (point-min))
1760 (if (looking-at "^File: [^,: \t]+,?[ \t]+")
1762 (goto-char (match-end 0))
1764 (looking-at "[ \t]*[^:, \t\n]+:[ \t]+\\([^:,\t\n]+\\),?")
1765 (goto-char (match-end 0))
1766 (put-text-property (match-beginning 1) (match-end 1)
1768 (put-text-property (match-beginning 1) (match-end 1)
1769 'mouse-face
'highlight
))))
1770 (goto-char (point-min))
1771 (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*+\\|=+\\|-+\\)$"
1773 (put-text-property (match-beginning 1) (match-end 1)
1775 (cdr (assq (preceding-char) Info-title-face-alist
)))
1776 (put-text-property (match-end 1) (match-end 2)
1778 (goto-char (point-min))
1779 (while (re-search-forward "\\*Note[ \n\t]+\\([^:]*\\):" nil t
)
1780 (if (= (char-after (1- (match-beginning 0))) ?
\") ; hack
1782 (put-text-property (match-beginning 1) (match-end 1)
1784 (put-text-property (match-beginning 1) (match-end 1)
1785 'mouse-face
'highlight
)))
1786 (goto-char (point-min))
1787 (if (and (search-forward "\n* Menu:" nil t
)
1788 (not (string-match "\\<Index\\>" Info-current-node
))
1789 ;; Don't take time to annotate huge menus
1790 (< (- (point-max) (point)) Info-fontify-maximum-menu-size
))
1792 (while (re-search-forward "^\\* \\([^:\t\n]*\\):" nil t
)
1794 (if (memq n
'(5 9)) ; visual aids to help with 1-9 keys
1795 (put-text-property (match-beginning 0)
1796 (1+ (match-beginning 0))
1797 'face
'info-menu-5
))
1798 (put-text-property (match-beginning 1) (match-end 1)
1800 (put-text-property (match-beginning 1) (match-end 1)
1801 'mouse-face
'highlight
))))
1802 (set-buffer-modified-p nil
))))
1806 ;;; info.el ends here