Mercurial > emacs
annotate lisp/info.el @ 3711:5acf09035d16
(shut_down_emacs): New arg STUFF. Stuff input here.
(Fkill_emacs, fatal_error_signal): Pass new arg.
(main) [GETPGRP_NO_ARG]: Really pass no arg to getpgrp.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 13 Jun 1993 02:06:51 +0000 |
parents | bd87ecca04f6 |
children | 04f1cff889f4 |
rev | line source |
---|---|
754
b096f4af925c
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
732
diff
changeset
|
1 ;;; info.el --- info package for Emacs. |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
754
diff
changeset
|
2 |
1666
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
3 ;; Copyright (C) 1985, 1986, 1992 Free Software Foundation, Inc. |
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
811
diff
changeset
|
4 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
754
diff
changeset
|
5 ;; Maintainer: FSF |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
6 ;; Keywords: help |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
754
diff
changeset
|
7 |
325 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
754
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
325 | 13 ;; any later version. |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
754
diff
changeset
|
24 ;;; Commentary: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
754
diff
changeset
|
25 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
754
diff
changeset
|
26 ;;; Note that nowadays we expect info files to be made using makeinfo. |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
754
diff
changeset
|
27 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
754
diff
changeset
|
28 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
754
diff
changeset
|
29 |
325 | 30 (defvar Info-history nil |
31 "List of info nodes user has visited. | |
32 Each element of list is a list (FILENAME NODENAME BUFFERPOS).") | |
33 | |
34 (defvar Info-enable-edit nil | |
3084
a4341d92948a
(Info-edit, Info-last-search, Info-enable-edit):
Richard M. Stallman <rms@gnu.org>
parents:
3047
diff
changeset
|
35 "*Non-nil means the \\<Info-mode-map>\\[Info-edit] command in Info can edit the current node. |
680
f99c8512cd41
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
36 This is convenient if you want to write info files by hand. |
f99c8512cd41
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
37 However, we recommend that you not do this. |
f99c8512cd41
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
38 It is better to write a Texinfo file and generate the Info file from that, |
f99c8512cd41
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
39 because that gives you a printed manual as well.") |
325 | 40 |
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.") | |
44 | |
540 | 45 (defvar Info-default-directory-list nil |
46 "List of default directories to search for Info documentation files. | |
47 This value is used as the default for `Info-directory-list'. It is set | |
48 in paths.el.") | |
49 | |
3330
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
50 (defvar Info-directory-list |
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
51 (let ((path (getenv "INFOPATH"))) |
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
52 (if path |
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
53 (let ((list nil) |
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
54 idx) |
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
55 (while (> (length path) 0) |
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
56 (setq idx (or (string-match ":" path) (length path)) |
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
57 list (cons (substring path 0 idx) list) |
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
58 path (substring path (min (1+ idx) |
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
59 (length path))))) |
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
60 (nreverse list)) |
4fd13e6109e3
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3313
diff
changeset
|
61 Info-default-directory-list)) |
325 | 62 "List of directories to search for Info documentation files. |
540 | 63 nil means not yet initialized. In this case, Info uses the environment |
1979
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
64 variable INFOPATH to initialize it, or `Info-default-directory-list' |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
65 if there is no INFOPATH variable in the environment.") |
325 | 66 |
67 (defvar Info-current-file nil | |
68 "Info file that Info is now looking at, or nil.") | |
69 | |
70 (defvar Info-current-subfile nil | |
71 "Info subfile that is actually in the *info* buffer now, | |
72 or nil if current info file is not split into subfiles.") | |
73 | |
74 (defvar Info-current-node nil | |
75 "Name of node that Info is now looking at, or nil.") | |
76 | |
77 (defvar Info-tag-table-marker (make-marker) | |
78 "Marker pointing at beginning of current Info file's tag table. | |
79 Marker points nowhere if file has no tag table.") | |
80 | |
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
81 (defvar Info-index-alternatives nil |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
82 "List of possible matches for last Info-index command.") |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
83 |
3442
ef8ca321d049
(Info-suffix-list): Handle .gz suffix.
Richard M. Stallman <rms@gnu.org>
parents:
3351
diff
changeset
|
84 (defvar Info-suffix-list '( ("" . nil) |
ef8ca321d049
(Info-suffix-list): Handle .gz suffix.
Richard M. Stallman <rms@gnu.org>
parents:
3351
diff
changeset
|
85 (".info" . nil) |
ef8ca321d049
(Info-suffix-list): Handle .gz suffix.
Richard M. Stallman <rms@gnu.org>
parents:
3351
diff
changeset
|
86 (".Z" . "uncompress") |
ef8ca321d049
(Info-suffix-list): Handle .gz suffix.
Richard M. Stallman <rms@gnu.org>
parents:
3351
diff
changeset
|
87 (".Y" . "unyabba") |
ef8ca321d049
(Info-suffix-list): Handle .gz suffix.
Richard M. Stallman <rms@gnu.org>
parents:
3351
diff
changeset
|
88 (".gz" . "gunzip") |
ef8ca321d049
(Info-suffix-list): Handle .gz suffix.
Richard M. Stallman <rms@gnu.org>
parents:
3351
diff
changeset
|
89 (".z" . "gunzip") |
ef8ca321d049
(Info-suffix-list): Handle .gz suffix.
Richard M. Stallman <rms@gnu.org>
parents:
3351
diff
changeset
|
90 (".info.Z" . "uncompress") |
ef8ca321d049
(Info-suffix-list): Handle .gz suffix.
Richard M. Stallman <rms@gnu.org>
parents:
3351
diff
changeset
|
91 (".info.Y" . "unyabba") |
ef8ca321d049
(Info-suffix-list): Handle .gz suffix.
Richard M. Stallman <rms@gnu.org>
parents:
3351
diff
changeset
|
92 (".info.gz" . "gunzip") |
ef8ca321d049
(Info-suffix-list): Handle .gz suffix.
Richard M. Stallman <rms@gnu.org>
parents:
3351
diff
changeset
|
93 (".info.z" . "gunzip")) |
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
94 "List of file name suffixes and associated decoding commands. |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
95 Each entry should be (SUFFIX . STRING); the file is given to |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
96 the command as standard input. If STRING is nil, no decoding is done.") |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
97 |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
98 (defun info-insert-file-contents (filename &optional visit) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
99 "Insert the contents of an info file in the current buffer. |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
100 Do the right thing if the file has been compressed or zipped." |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
101 (if (null (catch 'ok |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
102 (mapcar |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
103 (function |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
104 (lambda (x) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
105 (let ((compressed (concat filename (car x)))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
106 (if (file-exists-p compressed) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
107 (progn |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
108 (insert-file-contents compressed visit) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
109 (if (cdr x) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
110 (let ((buffer-read-only nil)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
111 (shell-command-on-region |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
112 (point-min) (point-max) (cdr x) t))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
113 (throw 'ok t)))))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
114 Info-suffix-list) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
115 nil)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
116 (error "Can't find %s or any compressed version of it!" filename))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
117 |
325 | 118 ;;;###autoload |
119 (defun info (&optional file) | |
120 "Enter Info, the documentation browser. | |
121 Optional argument FILE specifies the file to examine; | |
122 the default is the top-level directory of Info. | |
123 | |
124 In interactive use, a prefix argument directs this command | |
125 to read a file name from the minibuffer." | |
126 (interactive (if current-prefix-arg | |
127 (list (read-file-name "Info file name: " nil nil t)))) | |
128 (if file | |
129 (Info-goto-node (concat "(" file ")")) | |
130 (if (get-buffer "*info*") | |
131 (switch-to-buffer "*info*") | |
132 (Info-directory)))) | |
133 | |
134 ;; Go to an info node specified as separate filename and nodename. | |
135 ;; no-going-back is non-nil if recovering from an error in this function; | |
136 ;; it says do not attempt further (recursive) error recovery. | |
137 (defun Info-find-node (filename nodename &optional no-going-back) | |
138 ;; Convert filename to lower case if not found as specified. | |
139 ;; Expand it. | |
140 (if filename | |
141 (let (temp temp-downcase found) | |
142 (setq filename (substitute-in-file-name filename)) | |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
143 (if (string= (downcase (file-name-nondirectory filename)) "dir") |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
144 (setq found t) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
145 (let ((dirs (if (string-match "^\\./" filename) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
146 ;; If specified name starts with `./' |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
147 ;; then just try current directory. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
148 '("./") |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
149 Info-directory-list))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
150 ;; Search the directory list for file FILENAME. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
151 (while (and dirs (not found)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
152 (setq temp (expand-file-name filename (car dirs))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
153 (setq temp-downcase |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
154 (expand-file-name (downcase filename) (car dirs))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
155 ;; Try several variants of specified name. |
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
156 (catch 'foundit |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
157 (mapcar |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
158 (function |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
159 (lambda (x) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
160 (if (file-exists-p (concat temp (car x))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
161 (progn |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
162 (setq found temp) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
163 (throw 'foundit nil))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
164 (if (file-exists-p (concat temp-downcase (car x))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
165 (progn |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
166 (setq found temp-downcase) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
167 (throw 'foundit nil))))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
168 Info-suffix-list)) |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
169 (setq dirs (cdr dirs))))) |
325 | 170 (if found |
171 (setq filename found) | |
172 (error "Info file %s does not exist" filename)))) | |
173 ;; Record the node we are leaving. | |
174 (if (and Info-current-file (not no-going-back)) | |
175 (setq Info-history | |
176 (cons (list Info-current-file Info-current-node (point)) | |
177 Info-history))) | |
178 ;; Go into info buffer. | |
179 (switch-to-buffer "*info*") | |
1484
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
180 (buffer-disable-undo (current-buffer)) |
325 | 181 (or (eq major-mode 'Info-mode) |
182 (Info-mode)) | |
183 (widen) | |
184 (setq Info-current-node nil) | |
185 (unwind-protect | |
186 (progn | |
187 ;; Switch files if necessary | |
188 (or (null filename) | |
189 (equal Info-current-file filename) | |
190 (let ((buffer-read-only nil)) | |
191 (setq Info-current-file nil | |
192 Info-current-subfile nil | |
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
193 Info-index-alternatives nil |
325 | 194 buffer-file-name nil) |
195 (erase-buffer) | |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
196 (if (eq filename t) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
197 (Info-insert-dir) |
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
198 (info-insert-file-contents filename t) |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
199 (setq default-directory (file-name-directory filename))) |
325 | 200 (set-buffer-modified-p nil) |
201 ;; See whether file has a tag table. Record the location if yes. | |
202 (set-marker Info-tag-table-marker nil) | |
203 (goto-char (point-max)) | |
204 (forward-line -8) | |
205 (or (equal nodename "*") | |
206 (not (search-forward "\^_\nEnd tag table\n" nil t)) | |
207 (let (pos) | |
208 ;; We have a tag table. Find its beginning. | |
209 ;; Is this an indirect file? | |
210 (search-backward "\nTag table:\n") | |
211 (setq pos (point)) | |
212 (if (save-excursion | |
213 (forward-line 2) | |
214 (looking-at "(Indirect)\n")) | |
215 ;; It is indirect. Copy it to another buffer | |
216 ;; and record that the tag table is in that buffer. | |
217 (save-excursion | |
218 (let ((buf (current-buffer))) | |
219 (set-buffer (get-buffer-create " *info tag table*")) | |
1484
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
220 (buffer-disable-undo (current-buffer)) |
325 | 221 (setq case-fold-search t) |
222 (erase-buffer) | |
223 (insert-buffer-substring buf) | |
224 (set-marker Info-tag-table-marker | |
225 (match-end 0)))) | |
998 | 226 (set-marker Info-tag-table-marker pos)))) |
325 | 227 (setq Info-current-file |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
228 (if (eq filename t) "dir" |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
229 (file-name-sans-versions buffer-file-name))))) |
325 | 230 (if (equal nodename "*") |
231 (progn (setq Info-current-node nodename) | |
232 (Info-set-mode-line)) | |
233 ;; Search file for a suitable node. | |
990
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
234 (let ((guesspos (point-min)) |
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
235 (regexp (concat "Node: *" (regexp-quote nodename) " *[,\t\n\177]"))) |
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
236 ;; First get advice from tag table if file has one. |
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
237 ;; Also, if this is an indirect info file, |
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
238 ;; read the proper subfile into this buffer. |
325 | 239 (if (marker-position Info-tag-table-marker) |
240 (save-excursion | |
241 (set-buffer (marker-buffer Info-tag-table-marker)) | |
242 (goto-char Info-tag-table-marker) | |
990
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
243 (if (re-search-forward regexp nil t) |
325 | 244 (progn |
245 (setq guesspos (read (current-buffer))) | |
246 ;; If this is an indirect file, | |
247 ;; determine which file really holds this node | |
248 ;; and read it in. | |
249 (if (not (eq (current-buffer) (get-buffer "*info*"))) | |
250 (setq guesspos | |
251 (Info-read-subfile guesspos)))) | |
252 (error "No such node: \"%s\"" nodename)))) | |
990
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
253 (goto-char (max (point-min) (- guesspos 1000))) |
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
254 ;; Now search from our advised position (or from beg of buffer) |
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
255 ;; to find the actual node. |
325 | 256 (catch 'foo |
257 (while (search-forward "\n\^_" nil t) | |
258 (forward-line 1) | |
259 (let ((beg (point))) | |
260 (forward-line 1) | |
261 (if (re-search-backward regexp beg t) | |
262 (throw 'foo t)))) | |
263 (error "No such node: %s" nodename))) | |
264 (Info-select-node))) | |
265 ;; If we did not finish finding the specified node, | |
266 ;; go back to the previous one. | |
267 (or Info-current-node no-going-back | |
268 (let ((hist (car Info-history))) | |
269 (setq Info-history (cdr Info-history)) | |
270 (Info-find-node (nth 0 hist) (nth 1 hist) t) | |
271 (goto-char (nth 2 hist))))) | |
272 (goto-char (point-min))) | |
273 | |
1979
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
274 ;; Cache the contents of the (virtual) dir file, once we have merged |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
275 ;; it for the first time, so we can save time subsequently. |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
276 (defvar Info-dir-contents nil) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
277 |
1979
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
278 ;; Cache for the directory we decided to use for the default-directory |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
279 ;; of the merged dir text. |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
280 (defvar Info-dir-contents-directory nil) |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
281 |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
282 ;; Construct the Info directory node by merging the files named `dir' |
1979
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
283 ;; from various directories. Set the *info* buffer's |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
284 ;; default-directory to the first directory we actually get any text |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
285 ;; from. |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
286 (defun Info-insert-dir () |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
287 (if Info-dir-contents |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
288 (insert Info-dir-contents) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
289 (let ((dirs Info-directory-list) |
3212
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
290 buffers buffer others nodes dirs-done) |
1979
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
291 |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
292 ;; Search the directory list for the directory file. |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
293 (while dirs |
3212
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
294 (or (member (file-truename (expand-file-name (car dirs))) dirs-done) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
295 (member (directory-file-name (file-truename (expand-file-name (car dirs)))) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
296 dirs-done) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
297 ;; Try several variants of specified name. |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
298 ;; Try upcasing, appending `.info', or both. |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
299 (let* (temp |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
300 (buffer |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
301 (cond |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
302 ((progn (setq temp (expand-file-name "DIR" (car dirs))) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
303 (file-exists-p temp)) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
304 (find-file-noselect temp)) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
305 ((progn (setq temp (expand-file-name "dir" (car dirs))) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
306 (file-exists-p temp)) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
307 (find-file-noselect temp)) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
308 ((progn (setq temp (expand-file-name "DIR.INFO" (car dirs))) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
309 (file-exists-p temp)) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
310 (find-file-noselect temp)) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
311 ((progn (setq temp (expand-file-name "dir.info" (car dirs))) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
312 (file-exists-p temp)) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
313 (find-file-noselect temp))))) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
314 (setq dirs-done |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
315 (cons (file-truename (expand-file-name (car dirs))) |
3225
1544ad5c9f99
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3212
diff
changeset
|
316 (cons (directory-file-name |
1544ad5c9f99
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3212
diff
changeset
|
317 (file-truename (expand-file-name (car dirs)))) |
1544ad5c9f99
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3212
diff
changeset
|
318 dirs-done))) |
3212
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
319 (if buffer (setq buffers (cons buffer buffers))))) |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
320 (setq dirs (cdr dirs))) |
1979
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
321 |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
322 ;; Distinguish the dir file that comes with Emacs from all the |
3212
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
323 ;; others. Yes, that is really what this is supposed to do. |
cd8f8468a190
(Info-insert-dir): Ignore duplicate directories.
Richard M. Stallman <rms@gnu.org>
parents:
3127
diff
changeset
|
324 ;; If it doesn't work, fix it. |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
325 (setq buffer (car buffers) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
326 others (cdr buffers)) |
1979
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
327 |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
328 ;; Insert the entire original dir file as a start; use its |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
329 ;; default directory as the default directory for the whole |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
330 ;; concatenation. |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
331 (insert-buffer buffer) |
1979
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
332 (setq Info-dir-contents-directory (save-excursion |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
333 (set-buffer buffer) |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
334 default-directory)) |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
335 |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
336 ;; Look at each of the other buffers one by one. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
337 (while others |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
338 (let ((other (car others))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
339 ;; In each, find all the menus. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
340 (save-excursion |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
341 (set-buffer other) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
342 (goto-char (point-min)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
343 ;; Find each menu, and add an elt to NODES for it. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
344 (while (re-search-forward "^\\* Menu:" nil t) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
345 (let (beg nodename end) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
346 (forward-line 1) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
347 (setq beg (point)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
348 (search-backward "\n") |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
349 (search-forward "Node: ") |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
350 (setq nodename (Info-following-node-name)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
351 (search-forward "\n" nil 'move) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
352 (beginning-of-line) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
353 (setq end (point)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
354 (setq nodes (cons (list nodename other beg end) nodes)))))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
355 (setq others (cdr others))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
356 ;; Add to the main menu a menu item for each other node. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
357 (re-search-forward "^\\* Menu:") |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
358 (forward-line 1) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
359 (let ((menu-items '("top")) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
360 (nodes nodes) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
361 (case-fold-search t) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
362 (end (save-excursion (search-forward "" nil t) (point)))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
363 (while nodes |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
364 (let ((nodename (car (car nodes)))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
365 (or (member (downcase nodename) menu-items) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
366 (re-search-forward (concat "^\\* " (regexp-quote nodename) ":") |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
367 end t) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
368 (progn |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
369 (insert "* " nodename "\n") |
2038
dd9ab1e9467e
(Info-insert-dir): Fix typo.
Richard M. Stallman <rms@gnu.org>
parents:
2036
diff
changeset
|
370 (setq menu-items (cons nodename menu-items))))) |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
371 (setq nodes (cdr nodes)))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
372 ;; Now take each node of each of the other buffers |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
373 ;; and merge it into the main buffer. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
374 (while nodes |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
375 (let ((nodename (car (car nodes)))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
376 (goto-char (point-min)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
377 ;; Find the like-named node in the main buffer. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
378 (if (re-search-forward (concat "\n.*\n.*Node: " |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
379 (regexp-quote nodename) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
380 "[,\n\t]") |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
381 nil t) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
382 (progn |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
383 (search-forward "\n" nil 'move) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
384 (beginning-of-line)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
385 ;; If none exists, add one. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
386 (goto-char (point-max)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
387 (insert "\nFile: dir\tnode: " nodename "\n\n* Menu:\n\n")) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
388 ;; Merge the text from the other buffer's menu |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
389 ;; into the menu in the like-named node in the main buffer. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
390 (apply 'insert-buffer-substring (cdr (car nodes))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
391 (insert "\n")) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
392 (setq nodes (cdr nodes))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
393 ;; Kill all the buffers we just made. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
394 (while buffers |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
395 (kill-buffer (car buffers)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
396 (setq buffers (cdr buffers)))) |
1979
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
397 (setq Info-dir-contents (buffer-string))) |
0582c70595f1
* info.el (Info-directory-list): Doc fix; it is set according to
Jim Blandy <jimb@redhat.com>
parents:
1971
diff
changeset
|
398 (setq default-directory Info-dir-contents-directory)) |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
399 |
325 | 400 (defun Info-read-subfile (nodepos) |
401 (set-buffer (marker-buffer Info-tag-table-marker)) | |
402 (goto-char (point-min)) | |
403 (search-forward "\n\^_") | |
404 (let (lastfilepos | |
405 lastfilename) | |
406 (forward-line 2) | |
407 (catch 'foo | |
408 (while (not (looking-at "\^_")) | |
409 (if (not (eolp)) | |
410 (let ((beg (point)) | |
411 thisfilepos thisfilename) | |
412 (search-forward ": ") | |
413 (setq thisfilename (buffer-substring beg (- (point) 2))) | |
414 (setq thisfilepos (read (current-buffer))) | |
415 ;; read in version 19 stops at the end of number. | |
416 ;; Advance to the next line. | |
417 (forward-line 1) | |
418 (if (> thisfilepos nodepos) | |
419 (throw 'foo t)) | |
420 (setq lastfilename thisfilename) | |
421 (setq lastfilepos thisfilepos)) | |
422 (forward-line 1)))) | |
423 (set-buffer (get-buffer "*info*")) | |
424 (or (equal Info-current-subfile lastfilename) | |
425 (let ((buffer-read-only nil)) | |
426 (setq buffer-file-name nil) | |
427 (widen) | |
428 (erase-buffer) | |
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
429 (info-insert-file-contents lastfilename) |
325 | 430 (set-buffer-modified-p nil) |
431 (setq Info-current-subfile lastfilename))) | |
432 (goto-char (point-min)) | |
433 (search-forward "\n\^_") | |
434 (+ (- nodepos lastfilepos) (point)))) | |
435 | |
436 ;; Select the info node that point is in. | |
437 (defun Info-select-node () | |
438 (save-excursion | |
439 ;; Find beginning of node. | |
440 (search-backward "\n\^_") | |
441 (forward-line 2) | |
442 ;; Get nodename spelled as it is in the node. | |
443 (re-search-forward "Node:[ \t]*") | |
444 (setq Info-current-node | |
445 (buffer-substring (point) | |
446 (progn | |
447 (skip-chars-forward "^,\t\n") | |
448 (point)))) | |
449 (Info-set-mode-line) | |
450 ;; Find the end of it, and narrow. | |
451 (beginning-of-line) | |
452 (let (active-expression) | |
453 (narrow-to-region (point) | |
454 (if (re-search-forward "\n[\^_\f]" nil t) | |
455 (prog1 | |
456 (1- (point)) | |
457 (if (looking-at "[\n\^_\f]*execute: ") | |
458 (progn | |
459 (goto-char (match-end 0)) | |
460 (setq active-expression | |
461 (read (current-buffer)))))) | |
462 (point-max))) | |
463 (if Info-enable-active-nodes (eval active-expression))))) | |
464 | |
465 (defun Info-set-mode-line () | |
466 (setq mode-line-buffer-identification | |
467 (concat | |
468 "Info: (" | |
469 (if Info-current-file | |
470 (file-name-nondirectory Info-current-file) | |
471 "") | |
472 ")" | |
473 (or Info-current-node "")))) | |
474 | |
475 ;; Go to an info node specified with a filename-and-nodename string | |
476 ;; of the sort that is found in pointers in nodes. | |
477 | |
478 (defun Info-goto-node (nodename) | |
479 "Go to info node named NAME. Give just NODENAME or (FILENAME)NODENAME." | |
480 (interactive "sGoto node: ") | |
481 (let (filename) | |
482 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)" | |
483 nodename) | |
484 (setq filename (if (= (match-beginning 1) (match-end 1)) | |
485 "" | |
486 (substring nodename (match-beginning 2) (match-end 2))) | |
487 nodename (substring nodename (match-beginning 3) (match-end 3))) | |
488 (let ((trim (string-match "\\s *\\'" filename))) | |
489 (if trim (setq filename (substring filename 0 trim)))) | |
490 (let ((trim (string-match "\\s *\\'" nodename))) | |
491 (if trim (setq nodename (substring nodename 0 trim)))) | |
492 (Info-find-node (if (equal filename "") nil filename) | |
493 (if (equal nodename "") "Top" nodename)))) | |
494 | |
540 | 495 (defun Info-restore-point (hl) |
496 "If this node has been visited, restore the point value when we left." | |
497 (if hl | |
498 (if (and (equal (nth 0 (car hl)) Info-current-file) | |
499 (equal (nth 1 (car hl)) Info-current-node)) | |
500 (goto-char (nth 2 (car hl))) | |
501 (Info-restore-point (cdr hl))))) | |
502 | |
325 | 503 (defvar Info-last-search nil |
3084
a4341d92948a
(Info-edit, Info-last-search, Info-enable-edit):
Richard M. Stallman <rms@gnu.org>
parents:
3047
diff
changeset
|
504 "Default regexp for \\<Info-mode-map>\\[Info-search] command to search for.") |
325 | 505 |
506 (defun Info-search (regexp) | |
507 "Search for REGEXP, starting from point, and select node it's found in." | |
508 (interactive "sSearch (regexp): ") | |
509 (if (equal regexp "") | |
510 (setq regexp Info-last-search) | |
511 (setq Info-last-search regexp)) | |
512 (let ((found ()) current | |
513 (onode Info-current-node) | |
514 (ofile Info-current-file) | |
515 (opoint (point)) | |
516 (osubfile Info-current-subfile)) | |
517 (save-excursion | |
518 (save-restriction | |
519 (widen) | |
520 (if (null Info-current-subfile) | |
521 (progn (re-search-forward regexp) (setq found (point))) | |
522 (condition-case err | |
523 (progn (re-search-forward regexp) (setq found (point))) | |
524 (search-failed nil))))) | |
525 (if (not found) ;can only happen in subfile case -- else would have erred | |
526 (unwind-protect | |
527 (let ((list ())) | |
528 (set-buffer (marker-buffer Info-tag-table-marker)) | |
529 (goto-char (point-min)) | |
530 (search-forward "\n\^_\nIndirect:") | |
531 (save-restriction | |
532 (narrow-to-region (point) | |
533 (progn (search-forward "\n\^_") | |
534 (1- (point)))) | |
535 (goto-char (point-min)) | |
536 (search-forward (concat "\n" osubfile ": ")) | |
537 (beginning-of-line) | |
538 (while (not (eobp)) | |
539 (re-search-forward "\\(^.*\\): [0-9]+$") | |
540 (goto-char (+ (match-end 1) 2)) | |
541 (setq list (cons (cons (read (current-buffer)) | |
542 (buffer-substring (match-beginning 1) | |
543 (match-end 1))) | |
544 list)) | |
545 (goto-char (1+ (match-end 0)))) | |
546 (setq list (nreverse list) | |
547 current (car (car list)) | |
548 list (cdr list))) | |
549 (while list | |
550 (message "Searching subfile %s..." (cdr (car list))) | |
551 (Info-read-subfile (car (car list))) | |
552 (setq list (cdr list)) | |
553 (goto-char (point-min)) | |
554 (if (re-search-forward regexp nil t) | |
555 (setq found (point) list ()))) | |
556 (if found | |
557 (message "") | |
558 (signal 'search-failed (list regexp)))) | |
559 (if (not found) | |
560 (progn (Info-read-subfile opoint) | |
561 (goto-char opoint) | |
562 (Info-select-node))))) | |
563 (widen) | |
564 (goto-char found) | |
565 (Info-select-node) | |
566 (or (and (equal onode Info-current-node) | |
567 (equal ofile Info-current-file)) | |
568 (setq Info-history (cons (list ofile onode opoint) | |
569 Info-history))))) | |
570 | |
571 ;; Extract the value of the node-pointer named NAME. | |
572 ;; If there is none, use ERRORNAME in the error message; | |
573 ;; if ERRORNAME is nil, just return nil. | |
574 (defun Info-extract-pointer (name &optional errorname) | |
575 (save-excursion | |
576 (goto-char (point-min)) | |
577 (forward-line 1) | |
578 (if (re-search-backward (concat name ":") nil t) | |
579 (progn | |
580 (goto-char (match-end 0)) | |
581 (Info-following-node-name)) | |
582 (if (eq errorname t) | |
583 nil | |
584 (error (concat "Node has no " (capitalize (or errorname name)))))))) | |
585 | |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
586 ;; Return the node name in the buffer following point. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
587 ;; ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
588 ;; saying which chas may appear in the node name. |
325 | 589 (defun Info-following-node-name (&optional allowedchars) |
590 (skip-chars-forward " \t") | |
591 (buffer-substring | |
592 (point) | |
593 (progn | |
594 (while (looking-at (concat "[" (or allowedchars "^,\t\n") "]")) | |
595 (skip-chars-forward (concat (or allowedchars "^,\t\n") "(")) | |
596 (if (looking-at "(") | |
597 (skip-chars-forward "^)"))) | |
598 (skip-chars-backward " ") | |
599 (point)))) | |
600 | |
601 (defun Info-next () | |
602 "Go to the next node of this node." | |
603 (interactive) | |
604 (Info-goto-node (Info-extract-pointer "next"))) | |
605 | |
606 (defun Info-prev () | |
607 "Go to the previous node of this node." | |
608 (interactive) | |
609 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous"))) | |
610 | |
611 (defun Info-up () | |
612 "Go to the superior node of this node." | |
613 (interactive) | |
540 | 614 (Info-goto-node (Info-extract-pointer "up")) |
615 (Info-restore-point Info-history)) | |
325 | 616 |
617 (defun Info-last () | |
618 "Go back to the last node visited." | |
619 (interactive) | |
620 (or Info-history | |
621 (error "This is the first Info node you looked at")) | |
622 (let (filename nodename opoint) | |
623 (setq filename (car (car Info-history))) | |
624 (setq nodename (car (cdr (car Info-history)))) | |
625 (setq opoint (car (cdr (cdr (car Info-history))))) | |
626 (setq Info-history (cdr Info-history)) | |
627 (Info-find-node filename nodename) | |
628 (setq Info-history (cdr Info-history)) | |
629 (goto-char opoint))) | |
630 | |
631 (defun Info-directory () | |
632 "Go to the Info directory node." | |
633 (interactive) | |
634 (Info-find-node "dir" "top")) | |
635 | |
636 (defun Info-follow-reference (footnotename) | |
637 "Follow cross reference named NAME to the node it refers to. | |
638 NAME may be an abbreviation of the reference name." | |
639 (interactive | |
640 (let ((completion-ignore-case t) | |
641 completions default (start-point (point)) str i) | |
642 (save-excursion | |
643 (goto-char (point-min)) | |
644 (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t) | |
645 (setq str (buffer-substring | |
646 (match-beginning 1) | |
647 (1- (point)))) | |
648 ;; See if this one should be the default. | |
649 (and (null default) | |
650 (< (match-beginning 0) start-point) | |
651 (<= start-point (point)) | |
652 (setq default t)) | |
653 (setq i 0) | |
654 (while (setq i (string-match "[ \n\t]+" str i)) | |
655 (setq str (concat (substring str 0 i) " " | |
656 (substring str (match-end 0)))) | |
657 (setq i (1+ i))) | |
658 ;; Record as a completion and perhaps as default. | |
659 (if (eq default t) (setq default str)) | |
660 (setq completions | |
661 (cons (cons str nil) | |
662 completions)))) | |
663 (if completions | |
3565
bd87ecca04f6
(Info-follow-reference): Fix completion defaulting.
Richard M. Stallman <rms@gnu.org>
parents:
3451
diff
changeset
|
664 (let ((input (completing-read (if default |
bd87ecca04f6
(Info-follow-reference): Fix completion defaulting.
Richard M. Stallman <rms@gnu.org>
parents:
3451
diff
changeset
|
665 (concat "Follow reference named: (" |
bd87ecca04f6
(Info-follow-reference): Fix completion defaulting.
Richard M. Stallman <rms@gnu.org>
parents:
3451
diff
changeset
|
666 default ") ") |
bd87ecca04f6
(Info-follow-reference): Fix completion defaulting.
Richard M. Stallman <rms@gnu.org>
parents:
3451
diff
changeset
|
667 "Follow reference named: ") |
bd87ecca04f6
(Info-follow-reference): Fix completion defaulting.
Richard M. Stallman <rms@gnu.org>
parents:
3451
diff
changeset
|
668 completions nil t))) |
bd87ecca04f6
(Info-follow-reference): Fix completion defaulting.
Richard M. Stallman <rms@gnu.org>
parents:
3451
diff
changeset
|
669 (list (if (equal input "") |
bd87ecca04f6
(Info-follow-reference): Fix completion defaulting.
Richard M. Stallman <rms@gnu.org>
parents:
3451
diff
changeset
|
670 default input))) |
325 | 671 (error "No cross-references in this node")))) |
672 (let (target beg i (str (concat "\\*note " footnotename))) | |
673 (while (setq i (string-match " " str i)) | |
674 (setq str (concat (substring str 0 i) "[ \t\n]+" (substring str (1+ i)))) | |
675 (setq i (+ i 6))) | |
676 (save-excursion | |
677 (goto-char (point-min)) | |
678 (or (re-search-forward str nil t) | |
679 (error "No cross-reference named %s" footnotename)) | |
680 (goto-char (+ (match-beginning 0) 5)) | |
681 (setq target | |
682 (Info-extract-menu-node-name "Bad format cross reference" t))) | |
683 (while (setq i (string-match "[ \t\n]+" target i)) | |
684 (setq target (concat (substring target 0 i) " " | |
685 (substring target (match-end 0)))) | |
686 (setq i (+ i 1))) | |
687 (Info-goto-node target))) | |
688 | |
689 (defun Info-extract-menu-node-name (&optional errmessage multi-line) | |
690 (skip-chars-forward " \t\n") | |
691 (let ((beg (point)) | |
692 str i) | |
693 (skip-chars-forward "^:") | |
694 (forward-char 1) | |
695 (setq str | |
696 (if (looking-at ":") | |
697 (buffer-substring beg (1- (point))) | |
698 (skip-chars-forward " \t\n") | |
699 (Info-following-node-name (if multi-line "^.,\t" "^.,\t\n")))) | |
700 (while (setq i (string-match "\n" str i)) | |
701 (aset str i ?\ )) | |
702 str)) | |
703 | |
1484
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
704 ;; No one calls this and Info-menu-item doesn't exist. |
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
705 ;;(defun Info-menu-item-sequence (list) |
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
706 ;; (while list |
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
707 ;; (Info-menu-item (car list)) |
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
708 ;; (setq list (cdr list)))) |
325 | 709 |
710 (defun Info-menu (menu-item) | |
711 "Go to node for menu item named (or abbreviated) NAME. | |
712 Completion is allowed, and the menu item point is on is the default." | |
713 (interactive | |
714 (let ((completions '()) | |
715 ;; If point is within a menu item, use that item as the default | |
716 (default nil) | |
717 (p (point)) | |
718 (last nil)) | |
719 (save-excursion | |
720 (goto-char (point-min)) | |
721 (if (not (search-forward "\n* menu:" nil t)) | |
722 (error "No menu in this node")) | |
723 (while (re-search-forward | |
724 "\n\\* \\([^:\t\n]*\\):" nil t) | |
725 (if (and (null default) | |
726 (prog1 (if last (< last p) nil) | |
727 (setq last (match-beginning 0))) | |
728 (<= p last)) | |
729 (setq default (car (car completions)))) | |
730 (setq completions (cons (cons (buffer-substring | |
731 (match-beginning 1) | |
732 (match-end 1)) | |
733 (match-beginning 1)) | |
734 completions))) | |
735 (if (and (null default) last | |
736 (< last p) | |
737 (<= p (progn (end-of-line) (point)))) | |
738 (setq default (car (car completions))))) | |
739 (let ((item nil)) | |
740 (while (null item) | |
741 (setq item (let ((completion-ignore-case t)) | |
742 (completing-read (if default | |
743 (format "Menu item (default %s): " | |
744 default) | |
745 "Menu item: ") | |
746 completions nil t))) | |
540 | 747 ;; we rely on the fact that completing-read accepts an input |
748 ;; of "" even when the require-match argument is true and "" | |
749 ;; is not a valid possibility | |
325 | 750 (if (string= item "") |
751 (if default | |
752 (setq item default) | |
753 ;; ask again | |
754 (setq item nil)))) | |
755 (list item)))) | |
756 ;; there is a problem here in that if several menu items have the same | |
757 ;; name you can only go to the node of the first with this command. | |
758 (Info-goto-node (Info-extract-menu-item menu-item))) | |
759 | |
760 (defun Info-extract-menu-item (menu-item) | |
761 (setq menu-item (regexp-quote menu-item)) | |
762 (save-excursion | |
763 (goto-char (point-min)) | |
764 (or (search-forward "\n* menu:" nil t) | |
765 (error "No menu in this node")) | |
766 (or (re-search-forward (concat "\n* " menu-item ":") nil t) | |
767 (re-search-forward (concat "\n* " menu-item) nil t) | |
768 (error "No such item in menu")) | |
769 (beginning-of-line) | |
770 (forward-char 2) | |
771 (Info-extract-menu-node-name))) | |
772 | |
773 ;; If COUNT is nil, use the last item in the menu. | |
774 (defun Info-extract-menu-counting (count) | |
775 (save-excursion | |
776 (goto-char (point-min)) | |
777 (or (search-forward "\n* menu:" nil t) | |
778 (error "No menu in this node")) | |
779 (if count | |
780 (or (search-forward "\n* " nil t count) | |
781 (error "Too few items in menu")) | |
782 (while (search-forward "\n* " nil t) | |
783 nil)) | |
784 (Info-extract-menu-node-name))) | |
785 | |
1666
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
786 (defun Info-nth-menu-item () |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
787 "Go to the node of the Nth menu item. |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
788 N is the digit argument used to invoke this command." |
325 | 789 (interactive) |
1666
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
790 (Info-goto-node |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
791 (Info-extract-menu-counting |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
792 (- (aref (this-command-keys) (1- (length (this-command-keys)))) ?0)))) |
325 | 793 |
794 (defun Info-top-node () | |
795 "Go to the Top node of this file." | |
796 (interactive) | |
797 (Info-goto-node "Top")) | |
798 | |
799 (defun Info-final-node () | |
800 "Go to the final node in this file." | |
801 (interactive) | |
802 (Info-goto-node "Top") | |
803 (let (Info-history) | |
804 ;; Go to the last node in the menu of Top. | |
805 (Info-goto-node (Info-extract-menu-counting nil)) | |
806 ;; If the last node in the menu is not last in pointer structure, | |
807 ;; move forward until we can't go any farther. | |
808 (while (Info-forward-node t t) nil) | |
809 ;; Then keep moving down to last subnode, unless we reach an index. | |
810 (while (and (not (string-match "\\<index\\>" Info-current-node)) | |
811 (save-excursion (search-forward "\n* Menu:" nil t))) | |
812 (Info-goto-node (Info-extract-menu-counting nil))))) | |
813 | |
814 (defun Info-forward-node (&optional not-down no-error) | |
815 "Go forward one node, considering all nodes as forming one sequence." | |
816 (interactive) | |
817 (goto-char (point-min)) | |
818 (forward-line 1) | |
819 ;; three possibilities, in order of priority: | |
820 ;; 1. next node is in a menu in this node (but not in an index) | |
821 ;; 2. next node is next at same level | |
822 ;; 3. next node is up and next | |
823 (cond ((and (not not-down) | |
824 (save-excursion (search-forward "\n* menu:" nil t)) | |
825 (not (string-match "\\<index\\>" Info-current-node))) | |
2036
a71101e5abff
(Info-forward-node): Properly go to first menu item.
Richard M. Stallman <rms@gnu.org>
parents:
2032
diff
changeset
|
826 (Info-goto-node (Info-extract-menu-counting 1)) |
325 | 827 t) |
828 ((save-excursion (search-backward "next:" nil t)) | |
829 (Info-next) | |
830 t) | |
831 ((and (save-excursion (search-backward "up:" nil t)) | |
832 (not (equal (downcase (Info-extract-pointer "up")) "top"))) | |
833 (let ((old-node Info-current-node)) | |
834 (Info-up) | |
835 (let (Info-history success) | |
836 (unwind-protect | |
837 (setq success (Info-forward-node t no-error)) | |
838 (or success (Info-goto-node old-node)))))) | |
839 (no-error nil) | |
840 (t (error "No pointer forward from this node")))) | |
841 | |
842 (defun Info-backward-node () | |
843 "Go backward one node, considering all nodes as forming one sequence." | |
844 (interactive) | |
845 (let ((prevnode (Info-extract-pointer "prev[ious]*" t)) | |
846 (upnode (Info-extract-pointer "up" t))) | |
847 (cond ((and upnode (string-match "(" upnode)) | |
848 (error "First node in file")) | |
849 ((and upnode (or (null prevnode) | |
850 (equal (downcase prevnode) (downcase upnode)))) | |
851 (Info-up)) | |
852 (prevnode | |
853 ;; If we move back at the same level, | |
854 ;; go down to find the last subnode*. | |
855 (Info-prev) | |
856 (let (Info-history) | |
857 (while (and (not (string-match "\\<index\\>" Info-current-node)) | |
858 (save-excursion (search-forward "\n* Menu:" nil t))) | |
859 (Info-goto-node (Info-extract-menu-counting nil))))) | |
860 (t | |
861 (error "No pointer backward from this node"))))) | |
862 | |
863 (defun Info-exit () | |
864 "Exit Info by selecting some other buffer." | |
865 (interactive) | |
866 (switch-to-buffer (prog1 (other-buffer (current-buffer)) | |
867 (bury-buffer (current-buffer))))) | |
868 | |
929
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
869 (defun Info-next-menu-item () |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
870 (interactive) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
871 (save-excursion |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
872 (forward-line -1) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
873 (search-forward "\n* menu:" nil t) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
874 (or (search-forward "\n* " nil t) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
875 (error "No more items in menu")) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
876 (Info-goto-node (Info-extract-menu-node-name)))) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
877 |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
878 (defun Info-last-menu-item () |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
879 (interactive) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
880 (save-excursion |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
881 (forward-line 1) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
882 (search-backward "\n* menu:" nil t) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
883 (or (search-backward "\n* " nil t) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
884 (error "No previous items in menu")) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
885 (Info-goto-node (Info-extract-menu-node-name)))) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
886 |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
887 (defmacro no-error (&rest body) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
888 (list 'condition-case nil (cons 'progn (append body '(t))) '(error nil))) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
889 |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
890 (defun Info-next-preorder () |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
891 "Go to the next node, popping up a level if there is none." |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
892 (interactive) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
893 (cond ((no-error (Info-next-menu-item)) ) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
894 ((no-error (Info-up)) (forward-line 1)) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
895 (t (error "No more nodes")))) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
896 |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
897 (defun Info-last-preorder () |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
898 "Go to the last node, popping up a level if there is none." |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
899 (interactive) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
900 (cond ((no-error (Info-last-menu-item)) ) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
901 ((no-error (Info-up)) (forward-line -1)) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
902 (t (error "No previous nodes")))) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
903 |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
904 (defun Info-scroll-up () |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
905 "Read the next screen. If end of buffer is visible, go to next entry." |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
906 (interactive) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
907 (if (pos-visible-in-window-p (point-max)) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
908 (Info-next-preorder) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
909 (scroll-up)) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
910 ) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
911 |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
912 (defun Info-scroll-down () |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
913 "Read the previous screen. If start of buffer is visible, go to last entry." |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
914 (interactive) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
915 (if (pos-visible-in-window-p (point-min)) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
916 (Info-last-preorder) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
917 (scroll-down)) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
918 ) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
919 |
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
920 (defun Info-index (topic) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
921 "Look up a string in the index for this file. |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
922 The index is defined as the first node in the top-level menu whose |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
923 name contains the word \"Index\", plus any immediately following |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
924 nodes whose names also contain the word \"Index\". |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
925 If there are no exact matches to the specified topic, this chooses |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
926 the first match which is a case-insensitive substring of a topic. |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
927 Use the `,' command to see the other matches. |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
928 Give a blank topic name to go to the Index node itself." |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
929 (interactive "sIndex topic: ") |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
930 (let ((orignode Info-current-node) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
931 (rnode nil) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
932 (pattern (format "\n\\* \\([^\n:]*%s[^\n:]*\\):[ \t]*\\([^.\n]*\\)\\.[ t]*\\([0-9]*\\)" |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
933 (regexp-quote topic))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
934 node) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
935 (Info-goto-node "Top") |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
936 (or (search-forward "\n* menu:" nil t) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
937 (error "No index")) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
938 (or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
939 (error "No index")) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
940 (goto-char (match-beginning 1)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
941 (let ((Info-keeping-history nil)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
942 (Info-goto-node (Info-extract-menu-node-name))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
943 (or (equal topic "") |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
944 (let ((matches nil) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
945 (exact nil) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
946 (Info-keeping-history nil) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
947 found) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
948 (while |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
949 (progn |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
950 (goto-char (point-min)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
951 (while (re-search-forward pattern nil t) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
952 (setq matches |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
953 (cons (list (buffer-substring (match-beginning 1) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
954 (match-end 1)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
955 (buffer-substring (match-beginning 2) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
956 (match-end 2)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
957 Info-current-node |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
958 (string-to-int (concat "0" |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
959 (buffer-substring |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
960 (match-beginning 3) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
961 (match-end 3))))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
962 matches))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
963 (and (setq node (Info-extract-pointer "next" t)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
964 (string-match "\\<Index\\>" node))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
965 (Info-goto-node node)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
966 (or matches |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
967 (progn |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
968 (Info-last) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
969 (error "No \"%s\" in index" topic))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
970 ;; Here it is a feature that assoc is case-sensitive. |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
971 (while (setq found (assoc topic matches)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
972 (setq exact (cons found exact) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
973 matches (delq found matches))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
974 (setq Info-index-alternatives (nconc exact (nreverse matches))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
975 (Info-index-next 0))))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
976 |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
977 (defun Info-index-next (num) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
978 "Go to the next matching index item from the last `i' command." |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
979 (interactive "p") |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
980 (or Info-index-alternatives |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
981 (error "No previous `i' command in this file")) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
982 (while (< num 0) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
983 (setq num (+ num (length Info-index-alternatives)))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
984 (while (> num 0) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
985 (setq Info-index-alternatives |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
986 (nconc (cdr Info-index-alternatives) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
987 (list (car Info-index-alternatives))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
988 num (1- num))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
989 (Info-goto-node (nth 1 (car Info-index-alternatives))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
990 (if (> (nth 3 (car Info-index-alternatives)) 0) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
991 (forward-line (nth 3 (car Info-index-alternatives))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
992 (forward-line 3) ; don't search in headers |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
993 (let ((name (car (car Info-index-alternatives)))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
994 (if (or (re-search-forward (format |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
995 "\\(Function\\|Command\\): %s\\( \\|$\\)" |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
996 (regexp-quote name)) nil t) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
997 (search-forward (format "`%s'" name) nil t) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
998 (and (string-match "\\`.*\\( (.*)\\)\\'" name) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
999 (search-forward |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1000 (format "`%s'" (substring name 0 (match-beginning 1))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1001 nil t)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1002 (search-forward name nil t)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1003 (beginning-of-line) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1004 (goto-char (point-min))))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1005 (message "Found \"%s\" in %s. %s" |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1006 (car (car Info-index-alternatives)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1007 (nth 2 (car Info-index-alternatives)) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1008 (if (cdr Info-index-alternatives) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1009 "(Press `,' for more)" |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1010 "(Only match)"))) |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1011 |
325 | 1012 (defun Info-undefined () |
1013 "Make command be undefined in Info." | |
1014 (interactive) | |
1015 (ding)) | |
1016 | |
1017 (defun Info-help () | |
1018 "Enter the Info tutorial." | |
1019 (interactive) | |
1020 (delete-other-windows) | |
1021 (Info-find-node "info" | |
1022 (if (< (window-height) 23) | |
1023 "Help-Small-Screen" | |
1024 "Help"))) | |
1025 | |
1026 (defun Info-summary () | |
1027 "Display a brief summary of all Info commands." | |
1028 (interactive) | |
1029 (save-window-excursion | |
1030 (switch-to-buffer "*Help*") | |
1031 (erase-buffer) | |
1032 (insert (documentation 'Info-mode)) | |
1033 (goto-char (point-min)) | |
1034 (let (ch flag) | |
1035 (while (progn (setq flag (not (pos-visible-in-window-p (point-max)))) | |
1036 (message (if flag "Type Space to see more" | |
1037 "Type Space to return to Info")) | |
2032
20cc6c34421c
(Info-summary): Handle any event when flushing the display.
Richard M. Stallman <rms@gnu.org>
parents:
1979
diff
changeset
|
1038 (if (not (eq ?\ (setq ch (read-event)))) |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1667
diff
changeset
|
1039 (progn (setq unread-command-events (list ch)) nil) |
325 | 1040 flag)) |
1041 (scroll-up))))) | |
1042 | |
1043 (defun Info-get-token (pos start all &optional errorstring) | |
1044 "Return the token around POS, | |
1045 POS must be somewhere inside the token | |
1046 START is a regular expression which will match the | |
1047 beginning of the tokens delimited string | |
1048 ALL is a regular expression with a single | |
1049 parenthized subpattern which is the token to be | |
1050 returned. E.g. '{\(.*\)}' would return any string | |
1051 enclosed in braces around POS. | |
1052 SIG optional fourth argument, controls action on no match | |
1053 nil: return nil | |
1054 t: beep | |
1055 a string: signal an error, using that string." | |
1056 (save-excursion | |
1057 (goto-char pos) | |
1058 (re-search-backward start (max (point-min) (- pos 200)) 'yes) | |
3351
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1059 (let (found) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1060 (while (and (re-search-forward all (min (point-max) (+ pos 200)) 'yes) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1061 (not (setq found (and (<= (match-beginning 0) pos) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1062 (> (match-end 0) pos)))))) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1063 (if (and found (<= (match-beginning 0) pos) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1064 (> (match-end 0) pos)) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1065 (buffer-substring (match-beginning 1) (match-end 1)) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1066 (cond ((null errorstring) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1067 nil) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1068 ((eq errorstring t) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1069 (beep) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1070 nil) |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1071 (t |
1795290d0fc8
(Info-get-token): Check that thesecond search succeeded.
Richard M. Stallman <rms@gnu.org>
parents:
3330
diff
changeset
|
1072 (error "No %s around position %d" errorstring pos))))))) |
325 | 1073 |
540 | 1074 (defun Info-follow-nearest-node (click) |
1309
aa286e6e7bec
(Info-follow-nearest-node): Handle line breaks after *note.
Richard M. Stallman <rms@gnu.org>
parents:
998
diff
changeset
|
1075 "\\<Info-mode-map>Follow a node reference near point. |
aa286e6e7bec
(Info-follow-nearest-node): Handle line breaks after *note.
Richard M. Stallman <rms@gnu.org>
parents:
998
diff
changeset
|
1076 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click. |
325 | 1077 At end of the node's text, moves to the next node." |
1309
aa286e6e7bec
(Info-follow-nearest-node): Handle line breaks after *note.
Richard M. Stallman <rms@gnu.org>
parents:
998
diff
changeset
|
1078 (interactive "e") |
1484
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
1079 (let* ((start (event-start click)) |
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
1080 (window (car start)) |
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
1081 (pos (car (cdr start)))) |
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
1082 (select-window window) |
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
1083 (goto-char pos)) |
325 | 1084 (let (node) |
1085 (cond | |
3127
dfbada800489
(Info-follow-nearest-node): Omit 4th arg to Info-get-token.
Richard M. Stallman <rms@gnu.org>
parents:
3084
diff
changeset
|
1086 ((setq node (Info-get-token (point) "\\*note[ \n]" "\\*note[ \n]\\([^:]*\\):")) |
325 | 1087 (Info-follow-reference node)) |
3127
dfbada800489
(Info-follow-nearest-node): Omit 4th arg to Info-get-token.
Richard M. Stallman <rms@gnu.org>
parents:
3084
diff
changeset
|
1088 ((setq node (Info-get-token (point) "\\* " "\\* \\([^:]*\\)::")) |
325 | 1089 (Info-goto-node node)) |
3127
dfbada800489
(Info-follow-nearest-node): Omit 4th arg to Info-get-token.
Richard M. Stallman <rms@gnu.org>
parents:
3084
diff
changeset
|
1090 ((setq node (Info-get-token (point) "\\* " "\\* \\([^:]*\\):")) |
325 | 1091 (Info-menu node)) |
3127
dfbada800489
(Info-follow-nearest-node): Omit 4th arg to Info-get-token.
Richard M. Stallman <rms@gnu.org>
parents:
3084
diff
changeset
|
1092 ((setq node (Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)")) |
325 | 1093 (Info-goto-node node)) |
3127
dfbada800489
(Info-follow-nearest-node): Omit 4th arg to Info-get-token.
Richard M. Stallman <rms@gnu.org>
parents:
3084
diff
changeset
|
1094 ((setq node (Info-get-token (point) "Next: " "Next: \\([^,\n\t]*\\)")) |
325 | 1095 (Info-goto-node node)) |
3127
dfbada800489
(Info-follow-nearest-node): Omit 4th arg to Info-get-token.
Richard M. Stallman <rms@gnu.org>
parents:
3084
diff
changeset
|
1096 ((setq node (Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)")) |
325 | 1097 (Info-goto-node "Top")) |
3127
dfbada800489
(Info-follow-nearest-node): Omit 4th arg to Info-get-token.
Richard M. Stallman <rms@gnu.org>
parents:
3084
diff
changeset
|
1098 ((setq node (Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)")) |
325 | 1099 (Info-goto-node node)) |
1100 ((save-excursion (forward-line 1) (eobp)) | |
1101 (Info-next))) | |
1102 )) | |
1103 | |
1104 (defvar Info-mode-map nil | |
1105 "Keymap containing Info commands.") | |
1106 (if Info-mode-map | |
1107 nil | |
1108 (setq Info-mode-map (make-keymap)) | |
1109 (suppress-keymap Info-mode-map) | |
1110 (define-key Info-mode-map "." 'beginning-of-buffer) | |
929
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
1111 (define-key Info-mode-map " " 'Info-scroll-up) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
1112 (define-key Info-mode-map "\C-m" 'Info-next-preorder) |
1666
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
1113 (define-key Info-mode-map "1" 'Info-nth-menu-item) |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
1114 (define-key Info-mode-map "2" 'Info-nth-menu-item) |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
1115 (define-key Info-mode-map "3" 'Info-nth-menu-item) |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
1116 (define-key Info-mode-map "4" 'Info-nth-menu-item) |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
1117 (define-key Info-mode-map "5" 'Info-nth-menu-item) |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
1118 (define-key Info-mode-map "6" 'Info-nth-menu-item) |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
1119 (define-key Info-mode-map "7" 'Info-nth-menu-item) |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
1120 (define-key Info-mode-map "8" 'Info-nth-menu-item) |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
1121 (define-key Info-mode-map "9" 'Info-nth-menu-item) |
1667
9c0e14881b8f
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1666
diff
changeset
|
1122 (define-key Info-mode-map "0" 'undefined) |
325 | 1123 (define-key Info-mode-map "?" 'Info-summary) |
1124 (define-key Info-mode-map "]" 'Info-forward-node) | |
1125 (define-key Info-mode-map "[" 'Info-backward-node) | |
1126 (define-key Info-mode-map "<" 'Info-top-node) | |
1127 (define-key Info-mode-map ">" 'Info-final-node) | |
1128 (define-key Info-mode-map "b" 'beginning-of-buffer) | |
1129 (define-key Info-mode-map "d" 'Info-directory) | |
1130 (define-key Info-mode-map "e" 'Info-edit) | |
1131 (define-key Info-mode-map "f" 'Info-follow-reference) | |
1132 (define-key Info-mode-map "g" 'Info-goto-node) | |
1133 (define-key Info-mode-map "h" 'Info-help) | |
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1134 (define-key Info-mode-map "i" 'Info-index) |
325 | 1135 (define-key Info-mode-map "l" 'Info-last) |
1136 (define-key Info-mode-map "m" 'Info-menu) | |
1137 (define-key Info-mode-map "n" 'Info-next) | |
1138 (define-key Info-mode-map "p" 'Info-prev) | |
1139 (define-key Info-mode-map "q" 'Info-exit) | |
1140 (define-key Info-mode-map "s" 'Info-search) | |
3313
34f2db3916fe
(Info-mode-map): Correct Info-top to Info-top-node.
Richard M. Stallman <rms@gnu.org>
parents:
3225
diff
changeset
|
1141 (define-key Info-mode-map "t" 'Info-top-node) |
325 | 1142 (define-key Info-mode-map "u" 'Info-up) |
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1143 (define-key Info-mode-map "," 'Info-index-next) |
930
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
929
diff
changeset
|
1144 (define-key Info-mode-map "\177" 'Info-scroll-down) |
3451
93757a9629cc
(Info-mode-map): Bind mouse-2, not mouse-3.
Richard M. Stallman <rms@gnu.org>
parents:
3442
diff
changeset
|
1145 (define-key Info-mode-map [mouse-2] 'Info-follow-nearest-node) |
540 | 1146 ) |
325 | 1147 |
1148 ;; Info mode is suitable only for specially formatted data. | |
1149 (put 'info-mode 'mode-class 'special) | |
1150 | |
1151 (defun Info-mode () | |
1152 "\\<Info-mode-map> | |
1153 Info mode provides commands for browsing through the Info documentation tree. | |
1154 Documentation in Info is divided into \"nodes\", each of which discusses | |
1155 one topic and contains references to other nodes which discuss related | |
1156 topics. Info has commands to follow the references and show you other nodes. | |
1157 | |
1158 \\[Info-help] Invoke the Info tutorial. | |
1159 | |
1160 Selecting other nodes: | |
1161 \\[Info-next] Move to the \"next\" node of this node. | |
3127
dfbada800489
(Info-follow-nearest-node): Omit 4th arg to Info-get-token.
Richard M. Stallman <rms@gnu.org>
parents:
3084
diff
changeset
|
1162 \\[Info-prev] Move to the \"previous\" node of this node. |
325 | 1163 \\[Info-up] Move \"up\" from this node. |
1164 \\[Info-menu] Pick menu item specified by name (or abbreviation). | |
1165 Picking a menu item causes another node to be selected. | |
540 | 1166 \\[Info-directory] Go to the Info directory node. |
325 | 1167 \\[Info-follow-reference] Follow a cross reference. Reads name of reference. |
1168 \\[Info-last] Move to the last node you were at. | |
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1169 \\[Info-index] Look up a topic in this file's Index and move to that node. |
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1170 \\[Info-index-next] (comma) Move to the next match from a previous `i' command. |
325 | 1171 |
1172 Moving within a node: | |
930
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
929
diff
changeset
|
1173 \\[scroll-up] Normally, scroll forward a full screen. If the end of the buffer is |
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
929
diff
changeset
|
1174 already visible, try to go to the next menu entry, or up if there is none. |
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
929
diff
changeset
|
1175 \\[scroll-down] Normally, scroll backward. If the beginning of the buffer is |
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
929
diff
changeset
|
1176 already visible, try to go to the previous menu entry, or up if there is none. |
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
929
diff
changeset
|
1177 \\[beginning-of-buffer] Go to beginning of node. |
325 | 1178 |
1179 Advanced commands: | |
1180 \\[Info-exit] Quit Info: reselect previously selected buffer. | |
1181 \\[Info-edit] Edit contents of selected node. | |
1182 1 Pick first item in node's menu. | |
1183 2, 3, 4, 5 Pick second ... fifth item in node's menu. | |
1184 \\[Info-goto-node] Move to node specified by name. | |
1185 You may include a filename as well, as (FILENAME)NODENAME. | |
1186 \\[Info-search] Search through this Info file for specified regexp, | |
930
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
929
diff
changeset
|
1187 and select the node in which the next occurrence is found. |
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
929
diff
changeset
|
1188 \\[Info-next-preorder] Next-preorder; that is, try to go to the next menu item, |
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
929
diff
changeset
|
1189 and if that fails try to move up, and if that fails, tell user |
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
929
diff
changeset
|
1190 he/she is done reading." |
325 | 1191 (kill-all-local-variables) |
1192 (setq major-mode 'Info-mode) | |
1193 (setq mode-name "Info") | |
1194 (use-local-map Info-mode-map) | |
1195 (set-syntax-table text-mode-syntax-table) | |
1196 (setq local-abbrev-table text-mode-abbrev-table) | |
1197 (setq case-fold-search t) | |
1198 (setq buffer-read-only t) | |
1199 (make-local-variable 'Info-current-file) | |
1200 (make-local-variable 'Info-current-subfile) | |
1201 (make-local-variable 'Info-current-node) | |
1202 (make-local-variable 'Info-tag-table-marker) | |
1203 (make-local-variable 'Info-history) | |
2561
1bd4cf98df68
(Info-find-node, Info-insert-subfile): Do the right thing if info files have
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2038
diff
changeset
|
1204 (make-local-variable 'Info-index-alternatives) |
325 | 1205 (Info-set-mode-line) |
1206 (run-hooks 'Info-mode-hook)) | |
1207 | |
1208 (defvar Info-edit-map nil | |
1209 "Local keymap used within `e' command of Info.") | |
1210 (if Info-edit-map | |
1211 nil | |
1212 (setq Info-edit-map (nconc (make-sparse-keymap) text-mode-map)) | |
1213 (define-key Info-edit-map "\C-c\C-c" 'Info-cease-edit)) | |
1214 | |
1215 ;; Info-edit mode is suitable only for specially formatted data. | |
1216 (put 'info-edit-mode 'mode-class 'special) | |
1217 | |
1218 (defun Info-edit-mode () | |
1219 "Major mode for editing the contents of an Info node. | |
1477 | 1220 Like text mode with the addition of `Info-cease-edit' |
325 | 1221 which returns to Info mode for browsing. |
1222 \\{Info-edit-map}" | |
1223 ) | |
1224 | |
1225 (defun Info-edit () | |
1226 "Edit the contents of this Info node. | |
1227 Allowed only if variable `Info-enable-edit' is non-nil." | |
1228 (interactive) | |
1229 (or Info-enable-edit | |
1230 (error "Editing info nodes is not enabled")) | |
1231 (use-local-map Info-edit-map) | |
1232 (setq major-mode 'Info-edit-mode) | |
1233 (setq mode-name "Info Edit") | |
1234 (kill-local-variable 'mode-line-buffer-identification) | |
1235 (setq buffer-read-only nil) | |
1236 ;; Make mode line update. | |
1237 (set-buffer-modified-p (buffer-modified-p)) | |
1238 (message (substitute-command-keys | |
3084
a4341d92948a
(Info-edit, Info-last-search, Info-enable-edit):
Richard M. Stallman <rms@gnu.org>
parents:
3047
diff
changeset
|
1239 "Editing: Type \\<Info-mode-map>\\[Info-cease-edit] to return to info"))) |
325 | 1240 |
1241 (defun Info-cease-edit () | |
1242 "Finish editing Info node; switch back to Info proper." | |
1243 (interactive) | |
1244 ;; Do this first, so nothing has changed if user C-g's at query. | |
1245 (and (buffer-modified-p) | |
1246 (y-or-n-p "Save the file? ") | |
1247 (save-buffer)) | |
1248 (use-local-map Info-mode-map) | |
1249 (setq major-mode 'Info-mode) | |
1250 (setq mode-name "Info") | |
1251 (Info-set-mode-line) | |
1252 (setq buffer-read-only t) | |
1253 ;; Make mode line update. | |
1254 (set-buffer-modified-p (buffer-modified-p)) | |
1255 (and (marker-position Info-tag-table-marker) | |
1256 (buffer-modified-p) | |
1257 (message "Tags may have changed. Use Info-tagify if necessary"))) | |
359 | 1258 |
1259 (defun Info-find-emacs-command-nodes (command) | |
1260 "Return a list of locations documenting COMMAND in the Emacs Info manual. | |
1261 The locations are of the format used in Info-history, i.e. | |
1262 \(FILENAME NODENAME BUFFERPOS\)." | |
1263 (require 'info) | |
1264 (let ((where '()) | |
1265 (cmd-desc (concat "^\\* " (regexp-quote (symbol-name command)) | |
1266 ":\\s *\\(.*\\)\\.$"))) | |
1267 (save-excursion | |
1268 (Info-find-node "emacs" "Command Index") | |
1269 ;; Take the index node off the Info history. | |
1270 (setq Info-history (cdr Info-history)) | |
1271 (goto-char (point-max)) | |
1272 (while (re-search-backward cmd-desc nil t) | |
1273 (setq where (cons (list Info-current-file | |
1274 (buffer-substring | |
1275 (match-beginning 1) | |
1276 (match-end 1)) | |
1277 0) | |
1278 where))) | |
1279 where))) | |
1280 | |
1281 ;;;###autoload | |
1282 (defun Info-goto-emacs-command-node (command) | |
1283 "Go to the Info node in the Emacs manual for command COMMAND." | |
1284 (interactive "CFind documentation for command: ") | |
1285 (or (commandp command) | |
1286 (signal 'wrong-type-argument (list 'commandp command))) | |
1287 (let ((where (Info-find-emacs-command-nodes command))) | |
1288 (if where | |
1289 (let ((num-matches (length where))) | |
1290 ;; Get Info running, and pop to it in another window. | |
1291 (save-window-excursion | |
1292 (info)) | |
1293 (pop-to-buffer "*info*") | |
1294 (Info-find-node (car (car where)) | |
1295 (car (cdr (car where)))) | |
1296 (if (> num-matches 1) | |
1297 (progn | |
1298 ;; Info-find-node already pushed (car where) onto | |
1299 ;; Info-history. Put the other nodes that were found on | |
1300 ;; the history. | |
1301 (setq Info-history (nconc (cdr where) Info-history)) | |
1302 (message (substitute-command-keys | |
1303 "Found %d other entr%. Use \\[Info-last] to see %s." | |
1304 (1- num-matches) | |
1305 (if (> num-matches 2) "ies" "y") | |
1306 (if (> num-matches 2) "them" "it")))))) | |
1307 (error "Couldn't find documentation for %s." command)))) | |
1308 | |
1309 ;;;###autoload | |
1310 (defun Info-goto-emacs-key-command-node (key) | |
1311 "Go to the Info node in the Emacs manual the command bound to KEY, a string. | |
1312 Interactively, if the binding is execute-extended-command, a command is read." | |
1313 (interactive "kFind documentation for key:") | |
1314 (let ((command (key-binding key))) | |
1315 (cond ((null command) | |
1484
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
1316 (message "%s is undefined" (key-description key))) |
359 | 1317 ((and (interactive-p) |
1318 (eq command 'execute-extended-command)) | |
1319 (Info-goto-emacs-command-node | |
1320 (read-command "Find documentation for command: "))) | |
1321 (t | |
1322 (Info-goto-emacs-command-node command))))) | |
584 | 1323 |
1324 (provide 'info) | |
1325 | |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1326 ;;; info.el ends here |