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 (source (expand-file-name "info/" source-directory
))
58 (sibling (if installation-directory
59 (expand-file-name "info/" installation-directory
)))
64 (while (> (length path
) 0)
65 (setq idx
(or (string-match path-separator path
) (length path
))
66 list
(cons (substring path
0 idx
) list
)
67 path
(substring path
(min (1+ idx
)
70 (if (and sibling
(file-exists-p sibling
))
71 (setq alternative sibling
)
72 (setq alternative source
))
73 (if (or (member alternative Info-default-directory-list
)
74 (not (file-exists-p alternative
))
75 ;; On DOS/NT, we use movable executables always,
76 ;; and we must always find the Info dir at run time.
77 (if (or (eq system-type
'ms-dos
) (eq system-type
'windows-nt
))
79 ;; Use invocation-directory for Info only if we used it for
80 ;; exec-directory also.
81 (not (string= exec-directory
82 (expand-file-name "lib-src/"
83 installation-directory
)))))
84 Info-default-directory-list
85 (reverse (cons alternative
86 (cdr (reverse Info-default-directory-list
)))))))
87 "List of directories to search for Info documentation files.
88 nil means not yet initialized. In this case, Info uses the environment
89 variable INFOPATH to initialize it, or `Info-default-directory-list'
90 if there is no INFOPATH variable in the environment.
91 The last element of `Info-default-directory-list' is the directory
92 where Emacs installs the Info files that come with it.
94 If you run the Emacs executable from the `src' directory in the Emacs
95 source tree, the `info' directory in the source tree is used as the last
96 element, in place of the installation Info directory. This is useful
97 when you run a version of Emacs without installing it.")
99 (defvar Info-additional-directory-list nil
100 "List of additional directories to search for Info documentation files.
101 These directories are not searched for merging the `dir' file.")
103 (defvar Info-current-file nil
104 "Info file that Info is now looking at, or nil.
105 This is the name that was specified in Info, not the actual file name.
106 It doesn't contain directory names or file name extensions added by Info.")
108 (defvar Info-current-subfile nil
109 "Info subfile that is actually in the *info* buffer now,
110 or nil if current info file is not split into subfiles.")
112 (defvar Info-current-node nil
113 "Name of node that Info is now looking at, or nil.")
115 (defvar Info-tag-table-marker
(make-marker)
116 "Marker pointing at beginning of current Info file's tag table.
117 Marker points nowhere if file has no tag table.")
119 (defvar Info-current-file-completions nil
120 "Cached completion list for current Info file.")
122 (defvar Info-index-alternatives nil
123 "List of possible matches for last Info-index command.")
125 (defvar Info-standalone nil
126 "Non-nil if Emacs was started solely as an Info browser.")
128 (defvar Info-suffix-list
129 (if (eq system-type
'ms-dos
)
130 '( (".gz" .
"gunzip")
134 '( (".info.Z" .
"uncompress")
135 (".info.Y" .
"unyabba")
136 (".info.gz" .
"gunzip")
137 (".info.z" .
"gunzip")
139 (".Z" .
"uncompress")
144 "List of file name suffixes and associated decoding commands.
145 Each entry should be (SUFFIX . STRING); the file is given to
146 the command as standard input. If STRING is nil, no decoding is done.
147 Because the SUFFIXes are tried in order, the empty string should
148 be last in the list.")
150 ;; Concatenate SUFFIX onto FILENAME. SUFFIX should start with a dot.
151 ;; First, on ms-dos, delete some of the extension in FILENAME
153 (defun info-insert-file-contents-1 (filename suffix
)
154 (if (not (eq system-type
'ms-dos
))
155 (concat filename suffix
)
156 (let* ((sans-exts (file-name-sans-extension filename
))
157 ;; How long is the extension in FILENAME (not counting the dot).
158 (ext-len (max 0 (- (length filename
) (length sans-exts
) 1)))
160 ;; SUFFIX starts with a dot. If FILENAME already has one,
161 ;; get rid of the one in SUFFIX.
162 (or (and (<= ext-len
0)
163 (not (eq (aref filename
(1- (length filename
))) ?.
)))
164 (setq suffix
(substring suffix
1)))
165 ;; How many chars of that extension should we keep?
166 (setq ext-left
(min ext-len
(max 0 (- 3 (length suffix
)))))
167 ;; Get rid of the rest of the extension, and add SUFFIX.
168 (concat (substring filename
0 (- (length filename
)
169 (- ext-len ext-left
)))
172 (defun info-insert-file-contents (filename &optional visit
)
173 "Insert the contents of an info file in the current buffer.
174 Do the right thing if the file has been compressed or zipped."
175 (let ((tail Info-suffix-list
)
177 (if (file-exists-p filename
)
178 ;; FILENAME exists--see if that name contains a suffix.
179 ;; If so, set DECODE accordingly.
183 (concat (regexp-quote (car (car tail
))) "$")
185 (setq tail
(cdr tail
)))
186 (setq fullname filename
187 decoder
(cdr (car tail
))))
188 ;; Try adding suffixes to FILENAME and see if we can find something.
190 (not (file-exists-p (info-insert-file-contents-1
191 filename
(car (car tail
))))))
192 (setq tail
(cdr tail
)))
193 ;; If we found a file with a suffix, set DECODER according to the suffix
194 ;; and set FULLNAME to the file's actual name.
195 (setq fullname
(info-insert-file-contents-1 filename
(car (car tail
)))
196 decoder
(cdr (car tail
)))
198 (error "Can't find %s or any compressed version of it" filename
)))
199 ;; check for conflict with jka-compr
200 (if (and (featurep 'jka-compr
)
201 (jka-compr-installed-p)
202 (jka-compr-get-compression-info fullname
))
204 (insert-file-contents fullname visit
)
206 (let ((buffer-read-only nil
)
207 (default-directory (or (file-name-directory fullname
)
209 (call-process-region (point-min) (point-max) decoder t t
)))))
211 ;;;###autoload (add-hook 'same-window-buffer-names "*info*")
214 (defun info (&optional file
)
215 "Enter Info, the documentation browser.
216 Optional argument FILE specifies the file to examine;
217 the default is the top-level directory of Info.
219 In interactive use, a prefix argument directs this command
220 to read a file name from the minibuffer."
221 (interactive (if current-prefix-arg
222 (list (read-file-name "Info file name: " nil nil t
))))
224 (Info-goto-node (concat "(" file
")"))
225 (if (get-buffer "*info*")
226 (pop-to-buffer "*info*")
230 (defun info-standalone ()
231 "Run Emacs as a standalone Info reader.
232 Usage: emacs -f info-standalone [filename]
233 In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
234 (setq Info-standalone t
)
235 (if (and command-line-args-left
236 (not (string-match "^-" (car command-line-args-left
))))
239 (info (car command-line-args-left
))
240 (setq command-line-args-left
(cdr command-line-args-left
)))
241 (error (send-string-to-terminal
242 (format "%s\n" (if (eq (car-safe err
) 'error
)
244 (save-buffers-kill-emacs)))
247 ;; Go to an info node specified as separate filename and nodename.
248 ;; no-going-back is non-nil if recovering from an error in this function;
249 ;; it says do not attempt further (recursive) error recovery.
250 (defun Info-find-node (filename nodename
&optional no-going-back
)
251 ;; Convert filename to lower case if not found as specified.
254 (let (temp temp-downcase found
)
255 (setq filename
(substitute-in-file-name filename
))
256 (if (string= (downcase (file-name-nondirectory filename
)) "dir")
258 (let ((dirs (if (string-match "^\\./" filename
)
259 ;; If specified name starts with `./'
260 ;; then just try current directory.
262 (if (file-name-absolute-p filename
)
263 ;; No point in searching for an
264 ;; absolute file name
266 (if Info-additional-directory-list
267 (append Info-directory-list
268 Info-additional-directory-list
)
269 Info-directory-list
)))))
270 ;; Search the directory list for file FILENAME.
271 (while (and dirs
(not found
))
272 (setq temp
(expand-file-name filename
(car dirs
)))
274 (expand-file-name (downcase filename
) (car dirs
)))
275 ;; Try several variants of specified name.
276 (let ((suffix-list Info-suffix-list
))
277 (while (and suffix-list
(not found
))
278 (cond ((file-exists-p
279 (info-insert-file-contents-1
280 temp
(car (car suffix-list
))))
283 (info-insert-file-contents-1
284 temp-downcase
(car (car suffix-list
))))
285 (setq found temp-downcase
)))
286 (setq suffix-list
(cdr suffix-list
))))
287 (setq dirs
(cdr dirs
)))))
289 (setq filename found
)
290 (error "Info file %s does not exist" filename
))))
291 ;; Record the node we are leaving.
292 (if (and Info-current-file
(not no-going-back
))
294 (cons (list Info-current-file Info-current-node
(point))
296 ;; Go into info buffer.
297 (switch-to-buffer "*info*")
298 (buffer-disable-undo (current-buffer))
299 (or (eq major-mode
'Info-mode
)
302 (setq Info-current-node nil
)
305 ;; Switch files if necessary
307 (equal Info-current-file filename
)
308 (let ((buffer-read-only nil
))
309 (setq Info-current-file nil
310 Info-current-subfile nil
311 Info-current-file-completions nil
312 Info-index-alternatives nil
313 buffer-file-name nil
)
317 (info-insert-file-contents filename t
)
318 (setq default-directory
(file-name-directory filename
)))
319 (set-buffer-modified-p nil
)
320 ;; See whether file has a tag table. Record the location if yes.
321 (set-marker Info-tag-table-marker nil
)
322 (goto-char (point-max))
324 ;; Use string-equal, not equal, to ignore text props.
325 (or (string-equal nodename
"*")
326 (not (search-forward "\^_\nEnd tag table\n" nil t
))
328 ;; We have a tag table. Find its beginning.
329 ;; Is this an indirect file?
330 (search-backward "\nTag table:\n")
334 (looking-at "(Indirect)\n"))
335 ;; It is indirect. Copy it to another buffer
336 ;; and record that the tag table is in that buffer.
338 (let ((buf (current-buffer)))
339 (set-buffer (get-buffer-create " *info tag table*"))
340 (buffer-disable-undo (current-buffer))
341 (setq case-fold-search t
)
343 (insert-buffer-substring buf
)
344 (set-marker Info-tag-table-marker
346 (set-marker Info-tag-table-marker pos
))))
347 (setq Info-current-file
348 (if (eq filename t
) "dir" filename
))))
349 ;; Use string-equal, not equal, to ignore text props.
350 (if (string-equal nodename
"*")
351 (progn (setq Info-current-node nodename
)
352 (Info-set-mode-line))
353 ;; Search file for a suitable node.
354 (let ((guesspos (point-min))
355 (regexp (concat "Node: *" (regexp-quote nodename
) " *[,\t\n\177]")))
356 ;; First get advice from tag table if file has one.
357 ;; Also, if this is an indirect info file,
358 ;; read the proper subfile into this buffer.
359 (if (marker-position Info-tag-table-marker
)
361 (set-buffer (marker-buffer Info-tag-table-marker
))
362 (goto-char Info-tag-table-marker
)
363 (if (re-search-forward regexp nil t
)
365 (setq guesspos
(read (current-buffer)))
366 ;; If this is an indirect file,
367 ;; determine which file really holds this node
369 (if (not (eq (current-buffer) (get-buffer "*info*")))
371 (Info-read-subfile guesspos
))))
372 (error "No such node: \"%s\"" nodename
))))
373 (goto-char (max (point-min) (- guesspos
1000)))
374 ;; Now search from our advised position (or from beg of buffer)
375 ;; to find the actual node.
377 (while (search-forward "\n\^_" nil t
)
381 (if (re-search-backward regexp beg t
)
383 (error "No such node: %s" nodename
)))
385 ;; If we did not finish finding the specified node,
386 ;; go back to the previous one.
387 (or Info-current-node no-going-back
(null Info-history
)
388 (let ((hist (car Info-history
)))
389 (setq Info-history
(cdr Info-history
))
390 (Info-find-node (nth 0 hist
) (nth 1 hist
) t
)
391 (goto-char (nth 2 hist
)))))
392 (goto-char (point-min)))
394 ;; Cache the contents of the (virtual) dir file, once we have merged
395 ;; it for the first time, so we can save time subsequently.
396 (defvar Info-dir-contents nil
)
398 ;; Cache for the directory we decided to use for the default-directory
399 ;; of the merged dir text.
400 (defvar Info-dir-contents-directory nil
)
402 ;; Record the file attributes of all the files from which we
403 ;; constructed Info-dir-contents.
404 (defvar Info-dir-file-attributes nil
)
406 ;; Construct the Info directory node by merging the files named `dir'
407 ;; from various directories. Set the *info* buffer's
408 ;; default-directory to the first directory we actually get any text
410 (defun Info-insert-dir ()
411 (if (and Info-dir-contents Info-dir-file-attributes
412 ;; Verify that none of the files we used has changed
415 (mapcar '(lambda (elt)
416 (let ((curr (file-attributes (car elt
))))
417 ;; Don't compare the access time.
418 (if curr
(setcar (nthcdr 4 curr
) 0))
419 (setcar (nthcdr 4 (cdr elt
)) 0)
420 (equal (cdr elt
) curr
)))
421 Info-dir-file-attributes
))))
422 (insert Info-dir-contents
)
423 (let ((dirs Info-directory-list
)
424 buffers buffer others nodes dirs-done
)
426 (setq Info-dir-file-attributes nil
)
428 ;; Search the directory list for the directory file.
430 (let ((truename (file-truename (expand-file-name (car dirs
)))))
431 (or (member truename dirs-done
)
432 (member (directory-file-name truename
) dirs-done
)
433 ;; Try several variants of specified name.
434 ;; Try upcasing, appending `.info', or both.
438 (progn (setq file
(expand-file-name "dir" truename
))
439 (file-attributes file
))
440 (progn (setq file
(expand-file-name "DIR" truename
))
441 (file-attributes file
))
442 (progn (setq file
(expand-file-name "dir.info" truename
))
443 (file-attributes file
))
444 (progn (setq file
(expand-file-name "DIR.INFO" truename
))
445 (file-attributes file
)))))
448 (cons (directory-file-name truename
)
453 (message "Composing main Info directory..."))
454 (set-buffer (generate-new-buffer "info dir"))
455 (insert-file-contents file
)
456 (setq buffers
(cons (current-buffer) buffers
)
457 Info-dir-file-attributes
458 (cons (cons file attrs
)
459 Info-dir-file-attributes
))))))
460 (setq dirs
(cdr dirs
))))
463 (error "Can't find the info directory node"))
464 ;; Distinguish the dir file that comes with Emacs from all the
465 ;; others. Yes, that is really what this is supposed to do.
466 ;; If it doesn't work, fix it.
467 (setq buffer
(car buffers
)
468 others
(cdr buffers
))
470 ;; Insert the entire original dir file as a start; use its
471 ;; default directory as the default directory for the whole
473 (insert-buffer buffer
)
474 (setq Info-dir-contents-directory
(save-excursion
478 ;; Look at each of the other buffers one by one.
480 (let ((other (car others
)))
481 ;; In each, find all the menus.
484 (goto-char (point-min))
485 ;; Find each menu, and add an elt to NODES for it.
486 (while (re-search-forward "^\\* Menu:" nil t
)
487 (let (beg nodename end
)
490 (search-backward "\n\^_")
491 (search-forward "Node: ")
492 (setq nodename
(Info-following-node-name))
493 (search-forward "\n\^_" nil
'move
)
496 (setq nodes
(cons (list nodename other beg end
) nodes
))))))
497 (setq others
(cdr others
)))
498 ;; Add to the main menu a menu item for each other node.
499 (re-search-forward "^\\* Menu:")
501 (let ((menu-items '("top"))
504 (end (save-excursion (search-forward "\^_" nil t
) (point))))
506 (let ((nodename (car (car nodes
))))
508 (or (member (downcase nodename
) menu-items
)
509 (re-search-forward (concat "^\\* "
510 (regexp-quote nodename
)
514 (insert "* " nodename
"::" "\n")
515 (setq menu-items
(cons nodename menu-items
))))))
516 (setq nodes
(cdr nodes
))))
517 ;; Now take each node of each of the other buffers
518 ;; and merge it into the main buffer.
520 (let ((nodename (car (car nodes
))))
521 (goto-char (point-min))
522 ;; Find the like-named node in the main buffer.
523 (if (re-search-forward (concat "\n\^_.*\n.*Node: "
524 (regexp-quote nodename
)
528 (search-forward "\n\^_" nil
'move
)
531 ;; If none exists, add one.
532 (goto-char (point-max))
533 (insert "\^_\nFile: dir\tNode: " nodename
"\n\n* Menu:\n\n"))
534 ;; Merge the text from the other buffer's menu
535 ;; into the menu in the like-named node in the main buffer.
536 (apply 'insert-buffer-substring
(cdr (car nodes
))))
537 (setq nodes
(cdr nodes
)))
538 ;; Kill all the buffers we just made.
540 (kill-buffer (car buffers
))
541 (setq buffers
(cdr buffers
)))
542 (message "Composing main Info directory...done"))
543 (setq Info-dir-contents
(buffer-string)))
544 (setq default-directory Info-dir-contents-directory
))
546 (defun Info-read-subfile (nodepos)
547 (set-buffer (marker-buffer Info-tag-table-marker
))
548 (goto-char (point-min))
549 (search-forward "\n\^_")
554 (while (not (looking-at "\^_"))
557 thisfilepos thisfilename
)
558 (search-forward ": ")
559 (setq thisfilename
(buffer-substring beg
(- (point) 2)))
560 (setq thisfilepos
(read (current-buffer)))
561 ;; read in version 19 stops at the end of number.
562 ;; Advance to the next line.
564 (if (> thisfilepos nodepos
)
566 (setq lastfilename thisfilename
)
567 (setq lastfilepos thisfilepos
))
569 (set-buffer (get-buffer "*info*"))
570 (or (equal Info-current-subfile lastfilename
)
571 (let ((buffer-read-only nil
))
572 (setq buffer-file-name nil
)
575 (info-insert-file-contents lastfilename
)
576 (set-buffer-modified-p nil
)
577 (setq Info-current-subfile lastfilename
)))
578 (goto-char (point-min))
579 (search-forward "\n\^_")
580 (+ (- nodepos lastfilepos
) (point))))
582 ;; Select the info node that point is in.
583 (defun Info-select-node ()
585 ;; Find beginning of node.
586 (search-backward "\n\^_")
588 ;; Get nodename spelled as it is in the node.
589 (re-search-forward "Node:[ \t]*")
590 (setq Info-current-node
591 (buffer-substring-no-properties (point)
593 (skip-chars-forward "^,\t\n")
596 ;; Find the end of it, and narrow.
598 (let (active-expression)
599 (narrow-to-region (point)
600 (if (re-search-forward "\n[\^_\f]" nil t
)
603 (if (looking-at "[\n\^_\f]*execute: ")
605 (goto-char (match-end 0))
606 (setq active-expression
607 (read (current-buffer))))))
609 (if Info-enable-active-nodes
(eval active-expression
))
610 (if Info-fontify
(Info-fontify-node))
611 (run-hooks 'Info-selection-hook
))))
613 (defun Info-set-mode-line ()
614 (setq mode-line-buffer-identification
617 (if Info-current-file
618 (file-name-nondirectory Info-current-file
)
621 (or Info-current-node
""))))
623 ;; Go to an info node specified with a filename-and-nodename string
624 ;; of the sort that is found in pointers in nodes.
626 (defun Info-goto-node (nodename)
627 "Go to info node named NAME. Give just NODENAME or (FILENAME)NODENAME."
628 (interactive (list (Info-read-node-name "Goto node: ")))
630 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
632 (setq filename
(if (= (match-beginning 1) (match-end 1))
634 (substring nodename
(match-beginning 2) (match-end 2)))
635 nodename
(substring nodename
(match-beginning 3) (match-end 3)))
636 (let ((trim (string-match "\\s *\\'" filename
)))
637 (if trim
(setq filename
(substring filename
0 trim
))))
638 (let ((trim (string-match "\\s *\\'" nodename
)))
639 (if trim
(setq nodename
(substring nodename
0 trim
))))
640 (if transient-mark-mode
(deactivate-mark))
641 (Info-find-node (if (equal filename
"") nil filename
)
642 (if (equal nodename
"") "Top" nodename
))))
644 ;; This function is used as the "completion table" while reading a node name.
645 ;; It does completion using the alist in completion-table
646 ;; unless STRING starts with an open-paren.
647 (defun Info-read-node-name-1 (string predicate code
)
648 (let ((no-completion (and (> (length string
) 0) (eq (aref string
0) ?\
())))
652 (try-completion string completion-table predicate
)))
656 (all-completions string completion-table predicate
)))
660 (assoc string completion-table
))))))
662 (defun Info-read-node-name (prompt &optional default
)
663 (let* ((completion-ignore-case t
)
664 (completion-table (Info-build-node-completions))
665 (nodename (completing-read prompt
'Info-read-node-name-1
)))
666 (if (equal nodename
"")
668 (Info-read-node-name prompt
))
671 (defun Info-build-node-completions ()
672 (or Info-current-file-completions
676 (if (marker-buffer Info-tag-table-marker
)
678 (set-buffer (marker-buffer Info-tag-table-marker
))
680 (goto-char Info-tag-table-marker
)
681 (while (re-search-forward "\nNode: \\(.*\\)\177" nil t
)
683 (cons (list (buffer-substring (match-beginning 1)
687 (goto-char (point-min))
688 (while (search-forward "\n\^_" nil t
)
692 (if (re-search-backward "Node: *\\([^,\n]*\\) *[,\n\t]"
695 (cons (list (buffer-substring (match-beginning 1)
698 (setq Info-current-file-completions compl
))))
700 (defun Info-restore-point (hl)
701 "If this node has been visited, restore the point value when we left."
703 (if (and (equal (nth 0 (car hl
)) Info-current-file
)
704 ;; Use string-equal, not equal, to ignore text props.
705 (string-equal (nth 1 (car hl
)) Info-current-node
))
707 (goto-char (nth 2 (car hl
)))
708 (setq hl nil
)) ;terminate the while at next iter
709 (setq hl
(cdr hl
)))))
711 (defvar Info-last-search nil
712 "Default regexp for \\<Info-mode-map>\\[Info-search] command to search for.")
714 (defun Info-search (regexp)
715 "Search for REGEXP, starting from point, and select node it's found in."
716 (interactive "sSearch (regexp): ")
717 (if transient-mark-mode
(deactivate-mark))
718 (if (equal regexp
"")
719 (setq regexp Info-last-search
)
720 (setq Info-last-search regexp
))
721 (let ((found ()) current
722 (onode Info-current-node
)
723 (ofile Info-current-file
)
725 (osubfile Info-current-subfile
))
729 (if (null Info-current-subfile
)
730 (progn (re-search-forward regexp
) (setq found
(point)))
732 (progn (re-search-forward regexp
) (setq found
(point)))
733 (search-failed nil
)))))
734 (if (not found
) ;can only happen in subfile case -- else would have erred
737 (set-buffer (marker-buffer Info-tag-table-marker
))
738 (goto-char (point-min))
739 (search-forward "\n\^_\nIndirect:")
741 (narrow-to-region (point)
742 (progn (search-forward "\n\^_")
744 (goto-char (point-min))
745 (search-forward (concat "\n" osubfile
": "))
748 (re-search-forward "\\(^.*\\): [0-9]+$")
749 (goto-char (+ (match-end 1) 2))
750 (setq list
(cons (cons (read (current-buffer))
751 (buffer-substring (match-beginning 1)
754 (goto-char (1+ (match-end 0))))
755 (setq list
(nreverse list
)
756 current
(car (car list
))
759 (message "Searching subfile %s..." (cdr (car list
)))
760 (Info-read-subfile (car (car list
)))
761 (setq list
(cdr list
))
762 ;; (goto-char (point-min))
763 (if (re-search-forward regexp nil t
)
764 (setq found
(point) list
())))
767 (signal 'search-failed
(list regexp
))))
769 (progn (Info-read-subfile opoint
)
771 (Info-select-node)))))
775 ;; Use string-equal, not equal, to ignore text props.
776 (or (and (string-equal onode Info-current-node
)
777 (equal ofile Info-current-file
))
778 (setq Info-history
(cons (list ofile onode opoint
)
781 ;; Extract the value of the node-pointer named NAME.
782 ;; If there is none, use ERRORNAME in the error message;
783 ;; if ERRORNAME is nil, just return nil.
784 (defun Info-extract-pointer (name &optional errorname
)
786 (goto-char (point-min))
788 (if (re-search-backward (concat name
":") nil t
)
790 (goto-char (match-end 0))
791 (Info-following-node-name))
794 (error (concat "Node has no " (capitalize (or errorname name
))))))))
796 ;; Return the node name in the buffer following point.
797 ;; ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
798 ;; saying which chas may appear in the node name.
799 (defun Info-following-node-name (&optional allowedchars
)
800 (skip-chars-forward " \t")
801 (buffer-substring-no-properties
804 (while (looking-at (concat "[" (or allowedchars
"^,\t\n") "]"))
805 (skip-chars-forward (concat (or allowedchars
"^,\t\n") "("))
807 (skip-chars-forward "^)")))
808 (skip-chars-backward " ")
812 "Go to the next node of this node."
814 (Info-goto-node (Info-extract-pointer "next")))
817 "Go to the previous node of this node."
819 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous")))
822 "Go to the superior node of this node."
824 (Info-goto-node (Info-extract-pointer "up"))
825 (Info-restore-point Info-history
))
828 "Go back to the last node visited."
831 (error "This is the first Info node you looked at"))
832 (let (filename nodename opoint
)
833 (setq filename
(car (car Info-history
)))
834 (setq nodename
(car (cdr (car Info-history
))))
835 (setq opoint
(car (cdr (cdr (car Info-history
)))))
836 (setq Info-history
(cdr Info-history
))
837 (Info-find-node filename nodename
)
838 (setq Info-history
(cdr Info-history
))
841 (defun Info-directory ()
842 "Go to the Info directory node."
844 (Info-find-node "dir" "top"))
846 (defun Info-follow-reference (footnotename)
847 "Follow cross reference named NAME to the node it refers to.
848 NAME may be an abbreviation of the reference name."
850 (let ((completion-ignore-case t
)
851 completions default alt-default
(start-point (point)) str i bol eol
)
853 ;; Store end and beginning of line.
859 (goto-char (point-min))
860 (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t
)
861 (setq str
(buffer-substring
864 ;; See if this one should be the default.
866 (<= (match-beginning 0) start-point
)
867 (<= start-point
(point))
869 ;; See if this one should be the alternate default.
870 (and (null alt-default
)
871 (and (<= bol
(match-beginning 0))
873 (setq alt-default t
))
875 (while (setq i
(string-match "[ \n\t]+" str i
))
876 (setq str
(concat (substring str
0 i
) " "
877 (substring str
(match-end 0))))
879 ;; Record as a completion and perhaps as default.
880 (if (eq default t
) (setq default str
))
881 (if (eq alt-default t
) (setq alt-default str
))
885 ;; If no good default was found, try an alternate.
887 (setq default alt-default
))
888 ;; If only one cross-reference found, then make it default.
889 (if (eq (length completions
) 1)
890 (setq default
(car (car completions
))))
892 (let ((input (completing-read (if default
893 (concat "Follow reference named: ("
895 "Follow reference named: ")
897 (list (if (equal input
"")
899 (error "No cross-references in this node"))))
900 (let (target beg i
(str (concat "\\*note " (regexp-quote footnotename
))))
901 (while (setq i
(string-match " " str i
))
902 (setq str
(concat (substring str
0 i
) "[ \t\n]+" (substring str
(1+ i
))))
905 (goto-char (point-min))
906 (or (re-search-forward str nil t
)
907 (error "No cross-reference named %s" footnotename
))
908 (goto-char (+ (match-beginning 0) 5))
910 (Info-extract-menu-node-name "Bad format cross reference" t
)))
911 (while (setq i
(string-match "[ \t\n]+" target i
))
912 (setq target
(concat (substring target
0 i
) " "
913 (substring target
(match-end 0))))
915 (Info-goto-node target
)))
917 (defun Info-extract-menu-node-name (&optional errmessage multi-line
)
918 (skip-chars-forward " \t\n")
921 (skip-chars-forward "^:")
925 (buffer-substring-no-properties beg
(1- (point)))
926 (skip-chars-forward " \t\n")
927 (Info-following-node-name (if multi-line
"^.,\t" "^.,\t\n"))))
928 (while (setq i
(string-match "\n" str i
))
930 ;; Collapse multiple spaces.
931 (while (string-match " +" str
)
932 (setq str
(replace-match " " t t str
)))
935 ;; No one calls this.
936 ;;(defun Info-menu-item-sequence (list)
938 ;; (Info-menu (car list))
939 ;; (setq list (cdr list))))
941 (defun Info-complete-menu-item (string predicate action
)
942 (let ((case-fold-search t
))
943 (cond ((eq action nil
)
945 (pattern (concat "\n\\* \\("
946 (regexp-quote string
)
949 (set-buffer Info-complete-menu-buffer
)
950 (goto-char (point-min))
951 (search-forward "\n* Menu:")
952 (while (re-search-forward pattern nil t
)
953 (setq completions
(cons (cons (format "%s"
959 (try-completion string completions predicate
)))
962 (pattern (concat "\n\\* \\("
963 (regexp-quote string
)
966 (set-buffer Info-complete-menu-buffer
)
967 (goto-char (point-min))
968 (search-forward "\n* Menu:")
969 (while (re-search-forward pattern nil t
)
970 (setq completions
(cons (cons (format "%s"
976 (all-completions string completions predicate
)))
979 (set-buffer Info-complete-menu-buffer
)
980 (goto-char (point-min))
981 (search-forward "\n* Menu:")
982 (re-search-forward (concat "\n\\* "
983 (regexp-quote string
)
988 (defun Info-menu (menu-item)
989 "Go to node for menu item named (or abbreviated) NAME.
990 Completion is allowed, and the menu item point is on is the default."
992 (let ((completions '())
993 ;; If point is within a menu item, use that item as the default
999 (goto-char (point-min))
1000 (if (not (search-forward "\n* menu:" nil t
))
1001 (error "No menu in this node"))
1007 (re-search-backward "\n\\* \\([^:\t\n]*\\):" beg t
)
1008 (setq default
(format "%s" (buffer-substring
1013 (setq item
(let ((completion-ignore-case t
)
1014 (Info-complete-menu-buffer (current-buffer)))
1015 (completing-read (if default
1016 (format "Menu item (default %s): "
1019 'Info-complete-menu-item nil t
)))
1020 ;; we rely on the fact that completing-read accepts an input
1021 ;; of "" even when the require-match argument is true and ""
1022 ;; is not a valid possibility
1023 (if (string= item
"")
1029 ;; there is a problem here in that if several menu items have the same
1030 ;; name you can only go to the node of the first with this command.
1031 (Info-goto-node (Info-extract-menu-item menu-item
)))
1033 (defun Info-extract-menu-item (menu-item)
1034 (setq menu-item
(regexp-quote menu-item
))
1036 (goto-char (point-min))
1037 (or (search-forward "\n* menu:" nil t
)
1038 (error "No menu in this node"))
1039 (or (re-search-forward (concat "\n\\* " menu-item
":") nil t
)
1040 (re-search-forward (concat "\n\\* " menu-item
) nil t
)
1041 (error "No such item in menu"))
1044 (Info-extract-menu-node-name)))
1046 ;; If COUNT is nil, use the last item in the menu.
1047 (defun Info-extract-menu-counting (count)
1049 (goto-char (point-min))
1050 (or (search-forward "\n* menu:" nil t
)
1051 (error "No menu in this node"))
1053 (or (search-forward "\n* " nil t count
)
1054 (error "Too few items in menu"))
1055 (while (search-forward "\n* " nil t
)
1057 (Info-extract-menu-node-name)))
1059 (defun Info-nth-menu-item ()
1060 "Go to the node of the Nth menu item.
1061 N is the digit argument used to invoke this command."
1064 (Info-extract-menu-counting
1065 (- (aref (this-command-keys) (1- (length (this-command-keys)))) ?
0))))
1067 (defun Info-top-node ()
1068 "Go to the Top node of this file."
1070 (Info-goto-node "Top"))
1072 (defun Info-final-node ()
1073 "Go to the final node in this file."
1075 (Info-goto-node "Top")
1077 ;; Go to the last node in the menu of Top.
1078 (Info-goto-node (Info-extract-menu-counting nil
))
1079 ;; If the last node in the menu is not last in pointer structure,
1080 ;; move forward until we can't go any farther.
1081 (while (Info-forward-node t t
) nil
)
1082 ;; Then keep moving down to last subnode, unless we reach an index.
1083 (while (and (not (string-match "\\<index\\>" Info-current-node
))
1084 (save-excursion (search-forward "\n* Menu:" nil t
)))
1085 (Info-goto-node (Info-extract-menu-counting nil
)))))
1087 (defun Info-forward-node (&optional not-down no-error
)
1088 "Go forward one node, considering all nodes as forming one sequence."
1090 (goto-char (point-min))
1092 ;; three possibilities, in order of priority:
1093 ;; 1. next node is in a menu in this node (but not in an index)
1094 ;; 2. next node is next at same level
1095 ;; 3. next node is up and next
1096 (cond ((and (not not-down
)
1097 (save-excursion (search-forward "\n* menu:" nil t
))
1098 (not (string-match "\\<index\\>" Info-current-node
)))
1099 (Info-goto-node (Info-extract-menu-counting 1))
1101 ((save-excursion (search-backward "next:" nil t
))
1104 ((and (save-excursion (search-backward "up:" nil t
))
1105 ;; Use string-equal, not equal, to ignore text props.
1106 (not (string-equal (downcase (Info-extract-pointer "up"))
1108 (let ((old-node Info-current-node
))
1110 (let (Info-history success
)
1112 (setq success
(Info-forward-node t no-error
))
1113 (or success
(Info-goto-node old-node
))))))
1115 (t (error "No pointer forward from this node"))))
1117 (defun Info-backward-node ()
1118 "Go backward one node, considering all nodes as forming one sequence."
1120 (let ((prevnode (Info-extract-pointer "prev[ious]*" t
))
1121 (upnode (Info-extract-pointer "up" t
)))
1122 (cond ((and upnode
(string-match "(" upnode
))
1123 (error "First node in file"))
1124 ((and upnode
(or (null prevnode
)
1125 ;; Use string-equal, not equal,
1126 ;; to ignore text properties.
1127 (string-equal (downcase prevnode
)
1128 (downcase upnode
))))
1131 ;; If we move back at the same level,
1132 ;; go down to find the last subnode*.
1135 (while (and (not (string-match "\\<index\\>" Info-current-node
))
1136 (save-excursion (search-forward "\n* Menu:" nil t
)))
1137 (Info-goto-node (Info-extract-menu-counting nil
)))))
1139 (error "No pointer backward from this node")))))
1142 "Exit Info by selecting some other buffer."
1145 (save-buffers-kill-emacs)
1146 (switch-to-buffer (prog1 (other-buffer (current-buffer))
1147 (bury-buffer (current-buffer))))))
1149 (defun Info-next-menu-item ()
1153 (search-forward "\n* menu:" nil t
)
1154 (or (search-forward "\n* " nil t
)
1155 (error "No more items in menu"))
1156 (Info-goto-node (Info-extract-menu-node-name))))
1158 (defun Info-last-menu-item ()
1162 (let ((beg (save-excursion
1163 (and (search-backward "\n* menu:" nil t
)
1165 (or (and beg
(search-backward "\n* " beg t
))
1166 (error "No previous items in menu")))
1167 (Info-goto-node (save-excursion
1168 (goto-char (match-end 0))
1169 (Info-extract-menu-node-name)))))
1171 (defmacro Info-no-error
(&rest body
)
1172 (list 'condition-case nil
(cons 'progn
(append body
'(t))) '(error nil
)))
1174 (defun Info-next-preorder ()
1175 "Go to the next subnode or the next node, or go up a level."
1177 (cond ((Info-no-error (Info-next-menu-item)))
1178 ((Info-no-error (Info-next)))
1179 ((Info-no-error (Info-up))
1180 ;; Since we have already gone thru all the items in this menu,
1181 ;; go up to the end of this node.
1182 (goto-char (point-max)))
1184 (error "No more nodes"))))
1186 (defun Info-last-preorder ()
1187 "Go to the last node, popping up a level if there is none."
1189 (cond ((Info-no-error
1190 (Info-last-menu-item)
1191 ;; If we go down a menu item, go to the end of the node
1192 ;; so we can scroll back through it.
1193 (goto-char (point-max)))
1195 ((Info-no-error (Info-prev))
1196 (goto-char (point-max))
1198 ((Info-no-error (Info-up))
1199 (goto-char (point-min))
1200 (or (search-forward "\n* Menu:" nil t
)
1201 (goto-char (point-max))))
1202 (t (error "No previous nodes"))))
1204 (defun Info-scroll-up ()
1205 "Scroll one screenful forward in Info, considering all nodes as one sequence.
1206 Once you scroll far enough in a node that its menu appears on the screen,
1207 the next scroll moves into its first subnode. When you scroll past
1208 the end of a node, that goes to the next node or back up to the parent node."
1210 (if (or (< (window-start) (point-min))
1211 (> (window-start) (point-max)))
1212 (set-window-start (selected-window) (point)))
1213 (let ((virtual-end (save-excursion
1214 (goto-char (point-min))
1215 (if (search-forward "\n* Menu:" nil t
)
1218 (if (or (< virtual-end
(window-start))
1219 (pos-visible-in-window-p virtual-end
))
1220 (Info-next-preorder)
1223 (defun Info-scroll-down ()
1224 "Scroll one screenful back in Info, considering all nodes as one sequence.
1225 Within the menu of a node, this goes to its last subnode.
1226 When you scroll past the beginning of a node, that goes to the
1227 previous node or back up to the parent node."
1229 (if (or (< (window-start) (point-min))
1230 (> (window-start) (point-max)))
1231 (set-window-start (selected-window) (point)))
1232 (let ((virtual-end (save-excursion
1233 (goto-char (point-min))
1234 (search-forward "\n* Menu:" nil t
))))
1235 (if (or virtual-end
(pos-visible-in-window-p (point-min)))
1236 (Info-last-preorder)
1239 (defun Info-next-reference ()
1240 "Move cursor to the next cross-reference or menu item in the node."
1242 (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:")
1244 (or (eobp) (forward-char 1))
1245 (or (re-search-forward pat nil t
)
1247 (goto-char (point-min))
1248 (or (re-search-forward pat nil t
)
1251 (error "No cross references in this node")))))
1252 (goto-char (match-beginning 0))
1253 (if (looking-at "\\* Menu:")
1254 (Info-next-reference))))
1256 (defun Info-prev-reference ()
1257 "Move cursor to the previous cross-reference or menu item in the node."
1259 (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:")
1261 (or (re-search-backward pat nil t
)
1263 (goto-char (point-max))
1264 (or (re-search-backward pat nil t
)
1267 (error "No cross references in this node")))))
1268 (goto-char (match-beginning 0))
1269 (if (looking-at "\\* Menu:")
1270 (Info-prev-reference))))
1272 (defun Info-index (topic)
1273 "Look up a string in the index for this file.
1274 The index is defined as the first node in the top-level menu whose
1275 name contains the word \"Index\", plus any immediately following
1276 nodes whose names also contain the word \"Index\".
1277 If there are no exact matches to the specified topic, this chooses
1278 the first match which is a case-insensitive substring of a topic.
1279 Use the `,' command to see the other matches.
1280 Give a blank topic name to go to the Index node itself."
1281 (interactive "sIndex topic: ")
1282 (let ((orignode Info-current-node
)
1284 (pattern (format "\n\\* \\([^\n:]*%s[^\n:]*\\):[ \t]*\\([^.\n]*\\)\\.[ \t]*\\([0-9]*\\)"
1285 (regexp-quote topic
)))
1287 (Info-goto-node "Top")
1288 (or (search-forward "\n* menu:" nil t
)
1290 (or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t
)
1292 (goto-char (match-beginning 1))
1293 ;; Here, and subsequently in this function,
1294 ;; we bind Info-history to nil for internal node-switches
1295 ;; so that we don't put junk in the history.
1296 ;; In the first Info-goto-node call, above, we do update the history
1297 ;; because that is what the user's previous node choice into it.
1298 (let ((Info-history nil
))
1299 (Info-goto-node (Info-extract-menu-node-name)))
1300 (or (equal topic
"")
1307 (goto-char (point-min))
1308 (while (re-search-forward pattern nil t
)
1310 (cons (list (buffer-substring (match-beginning 1)
1312 (buffer-substring (match-beginning 2)
1315 (string-to-int (concat "0"
1320 (and (setq node
(Info-extract-pointer "next" t
))
1321 (string-match "\\<Index\\>" node
)))
1322 (Info-goto-node node
))
1326 (error "No \"%s\" in index" topic
)))
1327 ;; Here it is a feature that assoc is case-sensitive.
1328 (while (setq found
(assoc topic matches
))
1329 (setq exact
(cons found exact
)
1330 matches
(delq found matches
)))
1331 (setq Info-index-alternatives
(nconc exact
(nreverse matches
)))
1332 (Info-index-next 0)))))
1334 (defun Info-index-next (num)
1335 "Go to the next matching index item from the last `i' command."
1337 (or Info-index-alternatives
1338 (error "No previous `i' command in this file"))
1340 (setq num
(+ num
(length Info-index-alternatives
))))
1342 (setq Info-index-alternatives
1343 (nconc (cdr Info-index-alternatives
)
1344 (list (car Info-index-alternatives
)))
1346 (Info-goto-node (nth 1 (car Info-index-alternatives
)))
1347 (if (> (nth 3 (car Info-index-alternatives
)) 0)
1348 (forward-line (nth 3 (car Info-index-alternatives
)))
1349 (forward-line 3) ; don't search in headers
1350 (let ((name (car (car Info-index-alternatives
))))
1351 (if (or (re-search-forward (format
1352 "\\(Function\\|Command\\): %s\\( \\|$\\)"
1353 (regexp-quote name
)) nil t
)
1354 (search-forward (format "`%s'" name
) nil t
)
1355 (and (string-match "\\`.*\\( (.*)\\)\\'" name
)
1357 (format "`%s'" (substring name
0 (match-beginning 1)))
1359 (search-forward name nil t
))
1361 (goto-char (point-min)))))
1362 (message "Found \"%s\" in %s. %s"
1363 (car (car Info-index-alternatives
))
1364 (nth 2 (car Info-index-alternatives
))
1365 (if (cdr Info-index-alternatives
)
1366 "(Press `,' for more)"
1369 (defun Info-undefined ()
1370 "Make command be undefined in Info."
1375 "Enter the Info tutorial."
1377 (delete-other-windows)
1378 (Info-find-node "info"
1379 (if (< (window-height) 23)
1383 (defun Info-summary ()
1384 "Display a brief summary of all Info commands."
1386 (save-window-excursion
1387 (switch-to-buffer "*Help*")
1389 (insert (documentation 'Info-mode
))
1391 (goto-char (point-min))
1393 (while (progn (setq flag
(not (pos-visible-in-window-p (point-max))))
1394 (message (if flag
"Type Space to see more"
1395 "Type Space to return to Info"))
1396 (if (not (eq ?\
(setq ch
(read-event))))
1397 (progn (setq unread-command-events
(list ch
)) nil
)
1400 (bury-buffer "*Help*")))
1402 (defun Info-get-token (pos start all
&optional errorstring
)
1403 "Return the token around POS,
1404 POS must be somewhere inside the token
1405 START is a regular expression which will match the
1406 beginning of the tokens delimited string
1407 ALL is a regular expression with a single
1408 parenthesized subpattern which is the token to be
1409 returned. E.g. '{\(.*\)}' would return any string
1410 enclosed in braces around POS.
1411 SIG optional fourth argument, controls action on no match
1414 a string: signal an error, using that string."
1417 (re-search-backward start
(max (point-min) (- pos
200)) 'yes
)
1419 (while (and (re-search-forward all
(min (point-max) (+ pos
200)) 'yes
)
1420 (not (setq found
(and (<= (match-beginning 0) pos
)
1421 (> (match-end 0) pos
))))))
1422 (if (and found
(<= (match-beginning 0) pos
)
1423 (> (match-end 0) pos
))
1424 (buffer-substring (match-beginning 1) (match-end 1))
1425 (cond ((null errorstring
)
1431 (error "No %s around position %d" errorstring pos
)))))))
1433 (defun Info-mouse-follow-nearest-node (click)
1434 "\\<Info-mode-map>Follow a node reference near point.
1435 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click.
1436 At end of the node's text, moves to the next node, or up if none."
1438 (let* ((start (event-start click
))
1439 (window (car start
))
1440 (pos (car (cdr start
))))
1441 (select-window window
)
1443 (and (not (Info-try-follow-nearest-node))
1444 (save-excursion (forward-line 1) (eobp))
1445 (Info-next-preorder)))
1447 (defun Info-follow-nearest-node ()
1448 "\\<Info-mode-map>Follow a node reference near point.
1449 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where point is.
1450 If no reference to follow, moves to the next node, or up if none."
1452 (or (Info-try-follow-nearest-node)
1453 (Info-next-preorder)))
1455 ;; Common subroutine.
1456 (defun Info-try-follow-nearest-node ()
1457 "Follow a node reference near point. Return non-nil if successful."
1460 ((setq node
(Info-get-token (point) "\\*note[ \n]"
1461 "\\*note[ \n]\\([^:]*\\):"))
1462 (Info-follow-reference node
))
1463 ((setq node
(Info-get-token (point) "\\* " "\\* \\([^:]*\\)::"))
1464 (Info-goto-node node
))
1465 ((setq node
(Info-get-token (point) "\\* " "\\* \\([^:]*\\):"))
1467 ((setq node
(Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)"))
1468 (Info-goto-node node
))
1469 ((setq node
(Info-get-token (point) "Next: " "Next: \\([^,\n\t]*\\)"))
1470 (Info-goto-node node
))
1471 ((setq node
(Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)"))
1472 (Info-goto-node "Top"))
1473 ((setq node
(Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)"))
1474 (Info-goto-node node
)))
1477 (defvar Info-mode-map nil
1478 "Keymap containing Info commands.")
1481 (setq Info-mode-map
(make-keymap))
1482 (suppress-keymap Info-mode-map
)
1483 (define-key Info-mode-map
"." 'beginning-of-buffer
)
1484 (define-key Info-mode-map
" " 'Info-scroll-up
)
1485 (define-key Info-mode-map
"\C-m" 'Info-follow-nearest-node
)
1486 (define-key Info-mode-map
"\t" 'Info-next-reference
)
1487 (define-key Info-mode-map
"\e\t" 'Info-prev-reference
)
1488 (define-key Info-mode-map
"1" 'Info-nth-menu-item
)
1489 (define-key Info-mode-map
"2" 'Info-nth-menu-item
)
1490 (define-key Info-mode-map
"3" 'Info-nth-menu-item
)
1491 (define-key Info-mode-map
"4" 'Info-nth-menu-item
)
1492 (define-key Info-mode-map
"5" 'Info-nth-menu-item
)
1493 (define-key Info-mode-map
"6" 'Info-nth-menu-item
)
1494 (define-key Info-mode-map
"7" 'Info-nth-menu-item
)
1495 (define-key Info-mode-map
"8" 'Info-nth-menu-item
)
1496 (define-key Info-mode-map
"9" 'Info-nth-menu-item
)
1497 (define-key Info-mode-map
"0" 'undefined
)
1498 (define-key Info-mode-map
"?" 'Info-summary
)
1499 (define-key Info-mode-map
"]" 'Info-forward-node
)
1500 (define-key Info-mode-map
"[" 'Info-backward-node
)
1501 (define-key Info-mode-map
"<" 'Info-top-node
)
1502 (define-key Info-mode-map
">" 'Info-final-node
)
1503 (define-key Info-mode-map
"b" 'beginning-of-buffer
)
1504 (define-key Info-mode-map
"d" 'Info-directory
)
1505 (define-key Info-mode-map
"e" 'Info-edit
)
1506 (define-key Info-mode-map
"f" 'Info-follow-reference
)
1507 (define-key Info-mode-map
"g" 'Info-goto-node
)
1508 (define-key Info-mode-map
"h" 'Info-help
)
1509 (define-key Info-mode-map
"i" 'Info-index
)
1510 (define-key Info-mode-map
"l" 'Info-last
)
1511 (define-key Info-mode-map
"m" 'Info-menu
)
1512 (define-key Info-mode-map
"n" 'Info-next
)
1513 (define-key Info-mode-map
"p" 'Info-prev
)
1514 (define-key Info-mode-map
"q" 'Info-exit
)
1515 (define-key Info-mode-map
"s" 'Info-search
)
1516 ;; For consistency with Rmail.
1517 (define-key Info-mode-map
"\M-s" 'Info-search
)
1518 (define-key Info-mode-map
"t" 'Info-top-node
)
1519 (define-key Info-mode-map
"u" 'Info-up
)
1520 (define-key Info-mode-map
"," 'Info-index-next
)
1521 (define-key Info-mode-map
"\177" 'Info-scroll-down
)
1522 (define-key Info-mode-map
[mouse-2
] 'Info-mouse-follow-nearest-node
)
1525 ;; Info mode is suitable only for specially formatted data.
1526 (put 'info-mode
'mode-class
'special
)
1530 Info mode provides commands for browsing through the Info documentation tree.
1531 Documentation in Info is divided into \"nodes\", each of which discusses
1532 one topic and contains references to other nodes which discuss related
1533 topics. Info has commands to follow the references and show you other nodes.
1535 \\[Info-help] Invoke the Info tutorial.
1537 Selecting other nodes:
1538 \\[Info-mouse-follow-nearest-node]
1539 Follow a node reference you click on.
1540 This works with menu items, cross references, and
1541 the \"next\", \"previous\" and \"up\", depending on where you click.
1542 \\[Info-next] Move to the \"next\" node of this node.
1543 \\[Info-prev] Move to the \"previous\" node of this node.
1544 \\[Info-up] Move \"up\" from this node.
1545 \\[Info-menu] Pick menu item specified by name (or abbreviation).
1546 Picking a menu item causes another node to be selected.
1547 \\[Info-directory] Go to the Info directory node.
1548 \\[Info-follow-reference] Follow a cross reference. Reads name of reference.
1549 \\[Info-last] Move to the last node you were at.
1550 \\[Info-index] Look up a topic in this file's Index and move to that node.
1551 \\[Info-index-next] (comma) Move to the next match from a previous `i' command.
1553 Moving within a node:
1554 \\[Info-scroll-up] Normally, scroll forward a full screen. If the end of the buffer is
1555 already visible, try to go to the next menu entry, or up if there is none.
1556 \\[Info-scroll-down] Normally, scroll backward. If the beginning of the buffer is
1557 already visible, try to go to the previous menu entry, or up if there is none.
1558 \\[beginning-of-buffer] Go to beginning of node.
1561 \\[Info-exit] Quit Info: reselect previously selected buffer.
1562 \\[Info-edit] Edit contents of selected node.
1563 1 Pick first item in node's menu.
1564 2, 3, 4, 5 Pick second ... fifth item in node's menu.
1565 \\[Info-goto-node] Move to node specified by name.
1566 You may include a filename as well, as (FILENAME)NODENAME.
1567 \\[universal-argument] \\[info] Move to new Info file with completion.
1568 \\[Info-search] Search through this Info file for specified regexp,
1569 and select the node in which the next occurrence is found.
1570 \\[Info-next-reference] Move cursor to next cross-reference or menu item.
1571 \\[Info-prev-reference] Move cursor to previous cross-reference or menu item."
1572 (kill-all-local-variables)
1573 (setq major-mode
'Info-mode
)
1574 (setq mode-name
"Info")
1575 (use-local-map Info-mode-map
)
1576 (set-syntax-table text-mode-syntax-table
)
1577 (setq local-abbrev-table text-mode-abbrev-table
)
1578 (setq case-fold-search t
)
1579 (setq buffer-read-only t
)
1580 (make-local-variable 'Info-current-file
)
1581 (make-local-variable 'Info-current-subfile
)
1582 (make-local-variable 'Info-current-node
)
1583 (make-local-variable 'Info-tag-table-marker
)
1584 (make-local-variable 'Info-history
)
1585 (make-local-variable 'Info-index-alternatives
)
1586 (if (memq (framep (selected-frame)) '(x pc
))
1588 (make-face 'info-node
)
1589 (make-face 'info-menu-5
)
1590 (make-face 'info-xref
)
1591 (or (face-differs-from-default-p 'info-node
)
1592 (if (face-differs-from-default-p 'bold-italic
)
1593 (copy-face 'bold-italic
'info-node
)
1594 (copy-face 'bold
'info-node
)))
1595 (or (face-differs-from-default-p 'info-menu-5
)
1596 (set-face-underline-p 'info-menu-5 t
))
1597 (or (face-differs-from-default-p 'info-xref
)
1598 (copy-face 'bold
'info-xref
)))
1599 (setq Info-fontify nil
))
1600 (Info-set-mode-line)
1601 (run-hooks 'Info-mode-hook
))
1603 (defvar Info-edit-map nil
1604 "Local keymap used within `e' command of Info.")
1607 (setq Info-edit-map
(nconc (make-sparse-keymap) text-mode-map
))
1608 (define-key Info-edit-map
"\C-c\C-c" 'Info-cease-edit
))
1610 ;; Info-edit mode is suitable only for specially formatted data.
1611 (put 'info-edit-mode
'mode-class
'special
)
1613 (defun Info-edit-mode ()
1614 "Major mode for editing the contents of an Info node.
1615 Like text mode with the addition of `Info-cease-edit'
1616 which returns to Info mode for browsing.
1618 (use-local-map Info-edit-map
)
1619 (setq major-mode
'Info-edit-mode
)
1620 (setq mode-name
"Info Edit")
1621 (kill-local-variable 'mode-line-buffer-identification
)
1622 (setq buffer-read-only nil
)
1623 (force-mode-line-update)
1624 (buffer-enable-undo (current-buffer))
1625 (run-hooks 'Info-edit-mode-hook
))
1628 "Edit the contents of this Info node.
1629 Allowed only if variable `Info-enable-edit' is non-nil."
1631 (or Info-enable-edit
1632 (error "Editing info nodes is not enabled"))
1634 (message (substitute-command-keys
1635 "Editing: Type \\<Info-edit-map>\\[Info-cease-edit] to return to info")))
1637 (defun Info-cease-edit ()
1638 "Finish editing Info node; switch back to Info proper."
1640 ;; Do this first, so nothing has changed if user C-g's at query.
1641 (and (buffer-modified-p)
1642 (y-or-n-p "Save the file? ")
1644 (use-local-map Info-mode-map
)
1645 (setq major-mode
'Info-mode
)
1646 (setq mode-name
"Info")
1647 (Info-set-mode-line)
1648 (setq buffer-read-only t
)
1649 (force-mode-line-update)
1650 (and (marker-position Info-tag-table-marker
)
1652 (message "Tags may have changed. Use Info-tagify if necessary")))
1654 (defvar Info-file-list-for-emacs
1655 '("ediff" "forms" "gnus" "info" ("mh" .
"mh-e") "sc")
1656 "List of Info files that describe Emacs commands.
1657 An element can be a file name, or a list of the form (PREFIX . FILE)
1658 where PREFIX is a name prefix and FILE is the file to look in.
1659 If the element is just a file name, the file name also serves as the prefix.")
1661 (defun Info-find-emacs-command-nodes (command)
1662 "Return a list of locations documenting COMMAND.
1663 The `info-file' property of COMMAND says which Info manual to search.
1664 If COMMAND has no property, the variable `Info-file-list-for-emacs'
1665 defines heuristics for which Info manual to try.
1666 The locations are of the format used in Info-history, i.e.
1667 \(FILENAME NODENAME BUFFERPOS\)."
1669 (cmd-desc (concat "^\\* " (regexp-quote (symbol-name command
))
1670 ":\\s *\\(.*\\)\\.$"))
1671 (info-file "emacs")) ;default
1672 ;; Determine which info file this command is documented in.
1673 (if (get command
'info-file
)
1674 (setq info-file
(get command
'info-file
))
1675 ;; If it doesn't say explicitly, test its name against
1676 ;; various prefixes that we know.
1677 (let ((file-list Info-file-list-for-emacs
))
1679 (let* ((elt (car file-list
))
1680 (name (if (consp elt
)
1683 (file (if (consp elt
) (cdr elt
) elt
))
1684 (regexp (concat "\\`" (regexp-quote name
)
1686 (if (string-match regexp
(symbol-name command
))
1687 (setq info-file file file-list nil
))
1688 (setq file-list
(cdr file-list
))))))
1691 (Info-find-node info-file
"Command Index")
1692 ;; Some manuals may not have a separate Command Index node,
1693 ;; so try just Index instead.
1695 (Info-find-node info-file
"Index")))
1696 ;; Take the index node off the Info history.
1697 (setq Info-history
(cdr Info-history
))
1698 (goto-char (point-max))
1699 (while (re-search-backward cmd-desc nil t
)
1700 (setq where
(cons (list Info-current-file
1709 (defun Info-goto-emacs-command-node (command)
1710 "Go to the Info node in the Emacs manual for command COMMAND.
1711 The command is found by looking up in Emacs manual's Command Index
1712 or in another manual found via COMMAND's `info-file' property or
1713 the variable `Info-file-list-for-emacs'."
1714 (interactive "CFind documentation for command: ")
1715 (or (commandp command
)
1716 (signal 'wrong-type-argument
(list 'commandp command
)))
1717 (let ((where (Info-find-emacs-command-nodes command
)))
1719 (let ((num-matches (length where
)))
1720 ;; Get Info running, and pop to it in another window.
1721 (save-window-excursion
1723 (pop-to-buffer "*info*")
1724 (Info-find-node (car (car where
))
1725 (car (cdr (car where
))))
1726 (if (> num-matches
1)
1728 ;; Info-find-node already pushed (car where) onto
1729 ;; Info-history. Put the other nodes that were found on
1731 (setq Info-history
(nconc (cdr where
) Info-history
))
1732 (message (substitute-command-keys
1733 "Found %d other entr%s. Use \\[Info-last] to see %s.")
1735 (if (> num-matches
2) "ies" "y")
1736 (if (> num-matches
2) "them" "it")))))
1737 (error "Couldn't find documentation for %s." command
))))
1740 (defun Info-goto-emacs-key-command-node (key)
1741 "Go to the Info node in the Emacs manual the command bound to KEY, a string.
1742 Interactively, if the binding is execute-extended-command, a command is read.
1743 The command is found by looking up in Emacs manual's Command Index
1744 or in another manual found via COMMAND's `info-file' property or
1745 the variable `Info-file-list-for-emacs'."
1746 (interactive "kFind documentation for key:")
1747 (let ((command (key-binding key
)))
1748 (cond ((null command
)
1749 (message "%s is undefined" (key-description key
)))
1750 ((and (interactive-p)
1751 (eq command
'execute-extended-command
))
1752 (Info-goto-emacs-command-node
1753 (read-command "Find documentation for command: ")))
1755 (Info-goto-emacs-command-node command
)))))
1757 (defvar Info-title-face-alist
1758 '((?
* bold underline
)
1759 (?
= bold-italic underline
)
1760 (?- italic underline
))
1761 "*Alist of face or list of faces to use for pseudo-underlined titles.
1762 The alist key is the character the title is underlined with (?*, ?= or ?-).")
1764 (defun Info-fontify-node ()
1766 (let ((buffer-read-only nil
))
1767 (goto-char (point-min))
1768 (if (looking-at "^File: [^,: \t]+,?[ \t]+")
1770 (goto-char (match-end 0))
1772 (looking-at "[ \t]*[^:, \t\n]+:[ \t]+\\([^:,\t\n]+\\),?")
1773 (goto-char (match-end 0))
1774 (put-text-property (match-beginning 1) (match-end 1)
1776 (put-text-property (match-beginning 1) (match-end 1)
1777 'mouse-face
'highlight
))))
1778 (goto-char (point-min))
1779 (while (re-search-forward "\n\\([^ \t\n].+\\)\n\\(\\*+\\|=+\\|-+\\)$"
1781 (put-text-property (match-beginning 1) (match-end 1)
1783 (cdr (assq (preceding-char) Info-title-face-alist
)))
1784 (put-text-property (match-end 1) (match-end 2)
1786 (goto-char (point-min))
1787 (while (re-search-forward "\\*Note[ \n\t]+\\([^:]*\\):" nil t
)
1788 (if (= (char-after (1- (match-beginning 0))) ?
\") ; hack
1790 (put-text-property (match-beginning 1) (match-end 1)
1792 (put-text-property (match-beginning 1) (match-end 1)
1793 'mouse-face
'highlight
)))
1794 (goto-char (point-min))
1795 (if (and (search-forward "\n* Menu:" nil t
)
1796 (not (string-match "\\<Index\\>" Info-current-node
))
1797 ;; Don't take time to annotate huge menus
1798 (< (- (point-max) (point)) Info-fontify-maximum-menu-size
))
1800 (while (re-search-forward "^\\* \\([^:\t\n]*\\):" nil t
)
1802 (if (memq n
'(5 9)) ; visual aids to help with 1-9 keys
1803 (put-text-property (match-beginning 0)
1804 (1+ (match-beginning 0))
1805 'face
'info-menu-5
))
1806 (put-text-property (match-beginning 1) (match-end 1)
1808 (put-text-property (match-beginning 1) (match-end 1)
1809 'mouse-face
'highlight
))))
1810 (set-buffer-modified-p nil
))))
1814 ;;; info.el ends here