Mercurial > emacs
annotate lisp/info.el @ 1971:b540866e8a79
(Info-insert-dir): Make menu items in Top node
pointing each of the other nodes.
(Info-insert-dir): New function.
(Info-find-node): Use Info-insert-dir to visit dir file.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 01 Mar 1993 09:25:44 +0000 |
parents | 04fb1d3d6992 |
children | 0582c70595f1 |
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 | |
680
f99c8512cd41
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
35 "*Non-nil means the \\<info-mode-map>\\[Info-edit] command in Info can edit the current node. |
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 | |
50 (defvar Info-directory-list nil | |
325 | 51 "List of directories to search for Info documentation files. |
540 | 52 nil means not yet initialized. In this case, Info uses the environment |
53 variable INFODIR to initialize it, or `Info-default-directory-list' | |
54 if there is no INFODIR variable in the environment.") | |
325 | 55 |
56 (defvar Info-current-file nil | |
57 "Info file that Info is now looking at, or nil.") | |
58 | |
59 (defvar Info-current-subfile nil | |
60 "Info subfile that is actually in the *info* buffer now, | |
61 or nil if current info file is not split into subfiles.") | |
62 | |
63 (defvar Info-current-node nil | |
64 "Name of node that Info is now looking at, or nil.") | |
65 | |
66 (defvar Info-tag-table-marker (make-marker) | |
67 "Marker pointing at beginning of current Info file's tag table. | |
68 Marker points nowhere if file has no tag table.") | |
69 | |
70 ;;;###autoload | |
71 (defun info (&optional file) | |
72 "Enter Info, the documentation browser. | |
73 Optional argument FILE specifies the file to examine; | |
74 the default is the top-level directory of Info. | |
75 | |
76 In interactive use, a prefix argument directs this command | |
77 to read a file name from the minibuffer." | |
78 (interactive (if current-prefix-arg | |
79 (list (read-file-name "Info file name: " nil nil t)))) | |
540 | 80 (or Info-directory-list |
81 (setq Info-directory-list | |
82 (let ((path (getenv "INFOPATH"))) | |
83 (if path | |
84 (let ((list nil) | |
85 idx) | |
86 (while (> (length path) 0) | |
87 (setq idx (or (string-match ":" path) (length path)) | |
88 list (cons (substring path 0 idx) list) | |
89 path (substring path (min (1+ idx) | |
90 (length path))))) | |
91 (nreverse list)) | |
92 Info-default-directory-list)))) | |
325 | 93 (if file |
94 (Info-goto-node (concat "(" file ")")) | |
95 (if (get-buffer "*info*") | |
96 (switch-to-buffer "*info*") | |
97 (Info-directory)))) | |
98 | |
99 ;; Go to an info node specified as separate filename and nodename. | |
100 ;; no-going-back is non-nil if recovering from an error in this function; | |
101 ;; it says do not attempt further (recursive) error recovery. | |
102 (defun Info-find-node (filename nodename &optional no-going-back) | |
103 ;; Convert filename to lower case if not found as specified. | |
104 ;; Expand it. | |
105 (if filename | |
106 (let (temp temp-downcase found) | |
107 (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
|
108 (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
|
109 (setq found t) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
110 (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
|
111 ;; 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
|
112 ;; 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
|
113 '("./") |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
114 Info-directory-list))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
115 ;; 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
|
116 (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
|
117 (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
|
118 (setq temp-downcase |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
119 (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
|
120 ;; Try several variants of specified name. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
121 ;; Try downcasing, appending `.info', or both. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
122 (cond ((file-exists-p temp) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
123 (setq found temp)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
124 ((file-exists-p temp-downcase) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
125 (setq found temp-downcase)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
126 ((file-exists-p (concat temp ".info")) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
127 (setq found (concat temp ".info"))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
128 ((file-exists-p (concat temp-downcase ".info")) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
129 (setq found (concat temp-downcase ".info")))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
130 (setq dirs (cdr dirs))))) |
325 | 131 (if found |
132 (setq filename found) | |
133 (error "Info file %s does not exist" filename)))) | |
134 ;; Record the node we are leaving. | |
135 (if (and Info-current-file (not no-going-back)) | |
136 (setq Info-history | |
137 (cons (list Info-current-file Info-current-node (point)) | |
138 Info-history))) | |
139 ;; Go into info buffer. | |
140 (switch-to-buffer "*info*") | |
1484
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
141 (buffer-disable-undo (current-buffer)) |
325 | 142 (or (eq major-mode 'Info-mode) |
143 (Info-mode)) | |
144 (widen) | |
145 (setq Info-current-node nil) | |
146 (unwind-protect | |
147 (progn | |
148 ;; Switch files if necessary | |
149 (or (null filename) | |
150 (equal Info-current-file filename) | |
151 (let ((buffer-read-only nil)) | |
152 (setq Info-current-file nil | |
153 Info-current-subfile nil | |
154 buffer-file-name nil) | |
155 (erase-buffer) | |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
156 (setq default-directory Info-directory) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
157 (if (eq filename t) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
158 (Info-insert-dir) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
159 (insert-file-contents filename t) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
160 (setq default-directory (file-name-directory filename))) |
325 | 161 (set-buffer-modified-p nil) |
162 ;; See whether file has a tag table. Record the location if yes. | |
163 (set-marker Info-tag-table-marker nil) | |
164 (goto-char (point-max)) | |
165 (forward-line -8) | |
166 (or (equal nodename "*") | |
167 (not (search-forward "\^_\nEnd tag table\n" nil t)) | |
168 (let (pos) | |
169 ;; We have a tag table. Find its beginning. | |
170 ;; Is this an indirect file? | |
171 (search-backward "\nTag table:\n") | |
172 (setq pos (point)) | |
173 (if (save-excursion | |
174 (forward-line 2) | |
175 (looking-at "(Indirect)\n")) | |
176 ;; It is indirect. Copy it to another buffer | |
177 ;; and record that the tag table is in that buffer. | |
178 (save-excursion | |
179 (let ((buf (current-buffer))) | |
180 (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
|
181 (buffer-disable-undo (current-buffer)) |
325 | 182 (setq case-fold-search t) |
183 (erase-buffer) | |
184 (insert-buffer-substring buf) | |
185 (set-marker Info-tag-table-marker | |
186 (match-end 0)))) | |
998 | 187 (set-marker Info-tag-table-marker pos)))) |
325 | 188 (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
|
189 (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
|
190 (file-name-sans-versions buffer-file-name))))) |
325 | 191 (if (equal nodename "*") |
192 (progn (setq Info-current-node nodename) | |
193 (Info-set-mode-line)) | |
194 ;; Search file for a suitable node. | |
990
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
195 (let ((guesspos (point-min)) |
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
196 (regexp (concat "Node: *" (regexp-quote nodename) " *[,\t\n\177]"))) |
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
197 ;; First get advice from tag table if file has one. |
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
198 ;; Also, if this is an indirect info file, |
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
199 ;; read the proper subfile into this buffer. |
325 | 200 (if (marker-position Info-tag-table-marker) |
201 (save-excursion | |
202 (set-buffer (marker-buffer Info-tag-table-marker)) | |
203 (goto-char Info-tag-table-marker) | |
990
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
204 (if (re-search-forward regexp nil t) |
325 | 205 (progn |
206 (setq guesspos (read (current-buffer))) | |
207 ;; If this is an indirect file, | |
208 ;; determine which file really holds this node | |
209 ;; and read it in. | |
210 (if (not (eq (current-buffer) (get-buffer "*info*"))) | |
211 (setq guesspos | |
212 (Info-read-subfile guesspos)))) | |
213 (error "No such node: \"%s\"" nodename)))) | |
990
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
214 (goto-char (max (point-min) (- guesspos 1000))) |
d76731ebdff0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
930
diff
changeset
|
215 ;; 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
|
216 ;; to find the actual node. |
325 | 217 (catch 'foo |
218 (while (search-forward "\n\^_" nil t) | |
219 (forward-line 1) | |
220 (let ((beg (point))) | |
221 (forward-line 1) | |
222 (if (re-search-backward regexp beg t) | |
223 (throw 'foo t)))) | |
224 (error "No such node: %s" nodename))) | |
225 (Info-select-node))) | |
226 ;; If we did not finish finding the specified node, | |
227 ;; go back to the previous one. | |
228 (or Info-current-node no-going-back | |
229 (let ((hist (car Info-history))) | |
230 (setq Info-history (cdr Info-history)) | |
231 (Info-find-node (nth 0 hist) (nth 1 hist) t) | |
232 (goto-char (nth 2 hist))))) | |
233 (goto-char (point-min))) | |
234 | |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
235 ;; Record the contents of the (virtual) dir file, |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
236 ;; once we have merged it for the first time, |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
237 ;; so we can save time subsequently. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
238 (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
|
239 |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
240 ;; Construct the Info directory node by merging the files named `dir' |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
241 ;; from various directories. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
242 (defun Info-insert-dir () |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
243 (if Info-dir-contents |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
244 (insert Info-dir-contents) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
245 (let ((dirs Info-directory-list) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
246 buffers buffer others nodes) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
247 ;; 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
|
248 (while dirs |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
249 (setq temp (expand-file-name "dir" (car dirs))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
250 ;; Try several variants of specified name. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
251 ;; Try downcasing, appending `.info', or both. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
252 (cond ((file-exists-p temp) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
253 (setq buffers (cons (find-file-noselect temp) buffers))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
254 ((file-exists-p (concat temp ".info")) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
255 (setq buffers (cons (find-file-noselect (concat temp ".info")) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
256 buffers)))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
257 (setq dirs (cdr dirs))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
258 ;; Distinguish the dir file that comes with Emacs |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
259 ;; from all the others. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
260 (setq buffer (car buffers) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
261 others (cdr buffers)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
262 ;; Insert the entire original dir file as a start. |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
263 (insert-buffer buffer) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
264 ;; 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
|
265 (while others |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
266 (let ((other (car others))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
267 ;; 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
|
268 (save-excursion |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
269 (set-buffer other) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
270 (goto-char (point-min)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
271 ;; 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
|
272 (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
|
273 (let (beg nodename end) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
274 (forward-line 1) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
275 (setq beg (point)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
276 (search-backward "\n") |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
277 (search-forward "Node: ") |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
278 (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
|
279 (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
|
280 (beginning-of-line) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
281 (setq end (point)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
282 (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
|
283 (setq others (cdr others))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
284 ;; 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
|
285 (re-search-forward "^\\* Menu:") |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
286 (forward-line 1) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
287 (let ((menu-items '("top")) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
288 (nodes nodes) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
289 (case-fold-search t) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
290 (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
|
291 (while nodes |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
292 (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
|
293 (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
|
294 (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
|
295 end t) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
296 (progn |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
297 (insert "* " nodename "\n") |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
298 (setq menu-items (cons nodename menu-item))))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
299 (setq nodes (cdr nodes)))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
300 ;; 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
|
301 ;; 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
|
302 (while nodes |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
303 (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
|
304 (goto-char (point-min)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
305 ;; 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
|
306 (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
|
307 (regexp-quote nodename) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
308 "[,\n\t]") |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
309 nil t) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
310 (progn |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
311 (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
|
312 (beginning-of-line)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
313 ;; 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
|
314 (goto-char (point-max)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
315 (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
|
316 ;; 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
|
317 ;; 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
|
318 (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
|
319 (insert "\n")) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
320 (setq nodes (cdr nodes))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
321 ;; 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
|
322 (while buffers |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
323 (kill-buffer (car buffers)) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
324 (setq buffers (cdr buffers)))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
325 (setq Info-dir-contents (buffer-string)))) |
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
326 |
325 | 327 (defun Info-read-subfile (nodepos) |
328 (set-buffer (marker-buffer Info-tag-table-marker)) | |
329 (goto-char (point-min)) | |
330 (search-forward "\n\^_") | |
331 (let (lastfilepos | |
332 lastfilename) | |
333 (forward-line 2) | |
334 (catch 'foo | |
335 (while (not (looking-at "\^_")) | |
336 (if (not (eolp)) | |
337 (let ((beg (point)) | |
338 thisfilepos thisfilename) | |
339 (search-forward ": ") | |
340 (setq thisfilename (buffer-substring beg (- (point) 2))) | |
341 (setq thisfilepos (read (current-buffer))) | |
342 ;; read in version 19 stops at the end of number. | |
343 ;; Advance to the next line. | |
344 (forward-line 1) | |
345 (if (> thisfilepos nodepos) | |
346 (throw 'foo t)) | |
347 (setq lastfilename thisfilename) | |
348 (setq lastfilepos thisfilepos)) | |
349 (forward-line 1)))) | |
350 (set-buffer (get-buffer "*info*")) | |
351 (or (equal Info-current-subfile lastfilename) | |
352 (let ((buffer-read-only nil)) | |
353 (setq buffer-file-name nil) | |
354 (widen) | |
355 (erase-buffer) | |
356 (insert-file-contents lastfilename) | |
357 (set-buffer-modified-p nil) | |
358 (setq Info-current-subfile lastfilename))) | |
359 (goto-char (point-min)) | |
360 (search-forward "\n\^_") | |
361 (+ (- nodepos lastfilepos) (point)))) | |
362 | |
363 ;; Select the info node that point is in. | |
364 (defun Info-select-node () | |
365 (save-excursion | |
366 ;; Find beginning of node. | |
367 (search-backward "\n\^_") | |
368 (forward-line 2) | |
369 ;; Get nodename spelled as it is in the node. | |
370 (re-search-forward "Node:[ \t]*") | |
371 (setq Info-current-node | |
372 (buffer-substring (point) | |
373 (progn | |
374 (skip-chars-forward "^,\t\n") | |
375 (point)))) | |
376 (Info-set-mode-line) | |
377 ;; Find the end of it, and narrow. | |
378 (beginning-of-line) | |
379 (let (active-expression) | |
380 (narrow-to-region (point) | |
381 (if (re-search-forward "\n[\^_\f]" nil t) | |
382 (prog1 | |
383 (1- (point)) | |
384 (if (looking-at "[\n\^_\f]*execute: ") | |
385 (progn | |
386 (goto-char (match-end 0)) | |
387 (setq active-expression | |
388 (read (current-buffer)))))) | |
389 (point-max))) | |
390 (if Info-enable-active-nodes (eval active-expression))))) | |
391 | |
392 (defun Info-set-mode-line () | |
393 (setq mode-line-buffer-identification | |
394 (concat | |
395 "Info: (" | |
396 (if Info-current-file | |
397 (file-name-nondirectory Info-current-file) | |
398 "") | |
399 ")" | |
400 (or Info-current-node "")))) | |
401 | |
402 ;; Go to an info node specified with a filename-and-nodename string | |
403 ;; of the sort that is found in pointers in nodes. | |
404 | |
405 (defun Info-goto-node (nodename) | |
406 "Go to info node named NAME. Give just NODENAME or (FILENAME)NODENAME." | |
407 (interactive "sGoto node: ") | |
408 (let (filename) | |
409 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)" | |
410 nodename) | |
411 (setq filename (if (= (match-beginning 1) (match-end 1)) | |
412 "" | |
413 (substring nodename (match-beginning 2) (match-end 2))) | |
414 nodename (substring nodename (match-beginning 3) (match-end 3))) | |
415 (let ((trim (string-match "\\s *\\'" filename))) | |
416 (if trim (setq filename (substring filename 0 trim)))) | |
417 (let ((trim (string-match "\\s *\\'" nodename))) | |
418 (if trim (setq nodename (substring nodename 0 trim)))) | |
419 (Info-find-node (if (equal filename "") nil filename) | |
420 (if (equal nodename "") "Top" nodename)))) | |
421 | |
540 | 422 (defun Info-restore-point (hl) |
423 "If this node has been visited, restore the point value when we left." | |
424 (if hl | |
425 (if (and (equal (nth 0 (car hl)) Info-current-file) | |
426 (equal (nth 1 (car hl)) Info-current-node)) | |
427 (goto-char (nth 2 (car hl))) | |
428 (Info-restore-point (cdr hl))))) | |
429 | |
325 | 430 (defvar Info-last-search nil |
431 "Default regexp for \\<info-mode-map>\\[Info-search] command to search for.") | |
432 | |
433 (defun Info-search (regexp) | |
434 "Search for REGEXP, starting from point, and select node it's found in." | |
435 (interactive "sSearch (regexp): ") | |
436 (if (equal regexp "") | |
437 (setq regexp Info-last-search) | |
438 (setq Info-last-search regexp)) | |
439 (let ((found ()) current | |
440 (onode Info-current-node) | |
441 (ofile Info-current-file) | |
442 (opoint (point)) | |
443 (osubfile Info-current-subfile)) | |
444 (save-excursion | |
445 (save-restriction | |
446 (widen) | |
447 (if (null Info-current-subfile) | |
448 (progn (re-search-forward regexp) (setq found (point))) | |
449 (condition-case err | |
450 (progn (re-search-forward regexp) (setq found (point))) | |
451 (search-failed nil))))) | |
452 (if (not found) ;can only happen in subfile case -- else would have erred | |
453 (unwind-protect | |
454 (let ((list ())) | |
455 (set-buffer (marker-buffer Info-tag-table-marker)) | |
456 (goto-char (point-min)) | |
457 (search-forward "\n\^_\nIndirect:") | |
458 (save-restriction | |
459 (narrow-to-region (point) | |
460 (progn (search-forward "\n\^_") | |
461 (1- (point)))) | |
462 (goto-char (point-min)) | |
463 (search-forward (concat "\n" osubfile ": ")) | |
464 (beginning-of-line) | |
465 (while (not (eobp)) | |
466 (re-search-forward "\\(^.*\\): [0-9]+$") | |
467 (goto-char (+ (match-end 1) 2)) | |
468 (setq list (cons (cons (read (current-buffer)) | |
469 (buffer-substring (match-beginning 1) | |
470 (match-end 1))) | |
471 list)) | |
472 (goto-char (1+ (match-end 0)))) | |
473 (setq list (nreverse list) | |
474 current (car (car list)) | |
475 list (cdr list))) | |
476 (while list | |
477 (message "Searching subfile %s..." (cdr (car list))) | |
478 (Info-read-subfile (car (car list))) | |
479 (setq list (cdr list)) | |
480 (goto-char (point-min)) | |
481 (if (re-search-forward regexp nil t) | |
482 (setq found (point) list ()))) | |
483 (if found | |
484 (message "") | |
485 (signal 'search-failed (list regexp)))) | |
486 (if (not found) | |
487 (progn (Info-read-subfile opoint) | |
488 (goto-char opoint) | |
489 (Info-select-node))))) | |
490 (widen) | |
491 (goto-char found) | |
492 (Info-select-node) | |
493 (or (and (equal onode Info-current-node) | |
494 (equal ofile Info-current-file)) | |
495 (setq Info-history (cons (list ofile onode opoint) | |
496 Info-history))))) | |
497 | |
498 ;; Extract the value of the node-pointer named NAME. | |
499 ;; If there is none, use ERRORNAME in the error message; | |
500 ;; if ERRORNAME is nil, just return nil. | |
501 (defun Info-extract-pointer (name &optional errorname) | |
502 (save-excursion | |
503 (goto-char (point-min)) | |
504 (forward-line 1) | |
505 (if (re-search-backward (concat name ":") nil t) | |
506 (progn | |
507 (goto-char (match-end 0)) | |
508 (Info-following-node-name)) | |
509 (if (eq errorname t) | |
510 nil | |
511 (error (concat "Node has no " (capitalize (or errorname name)))))))) | |
512 | |
1971
b540866e8a79
(Info-insert-dir): Make menu items in Top node
Richard M. Stallman <rms@gnu.org>
parents:
1821
diff
changeset
|
513 ;; 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
|
514 ;; 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
|
515 ;; saying which chas may appear in the node name. |
325 | 516 (defun Info-following-node-name (&optional allowedchars) |
517 (skip-chars-forward " \t") | |
518 (buffer-substring | |
519 (point) | |
520 (progn | |
521 (while (looking-at (concat "[" (or allowedchars "^,\t\n") "]")) | |
522 (skip-chars-forward (concat (or allowedchars "^,\t\n") "(")) | |
523 (if (looking-at "(") | |
524 (skip-chars-forward "^)"))) | |
525 (skip-chars-backward " ") | |
526 (point)))) | |
527 | |
528 (defun Info-next () | |
529 "Go to the next node of this node." | |
530 (interactive) | |
531 (Info-goto-node (Info-extract-pointer "next"))) | |
532 | |
533 (defun Info-prev () | |
534 "Go to the previous node of this node." | |
535 (interactive) | |
536 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous"))) | |
537 | |
538 (defun Info-up () | |
539 "Go to the superior node of this node." | |
540 (interactive) | |
540 | 541 (Info-goto-node (Info-extract-pointer "up")) |
542 (Info-restore-point Info-history)) | |
325 | 543 |
544 (defun Info-last () | |
545 "Go back to the last node visited." | |
546 (interactive) | |
547 (or Info-history | |
548 (error "This is the first Info node you looked at")) | |
549 (let (filename nodename opoint) | |
550 (setq filename (car (car Info-history))) | |
551 (setq nodename (car (cdr (car Info-history)))) | |
552 (setq opoint (car (cdr (cdr (car Info-history))))) | |
553 (setq Info-history (cdr Info-history)) | |
554 (Info-find-node filename nodename) | |
555 (setq Info-history (cdr Info-history)) | |
556 (goto-char opoint))) | |
557 | |
558 (defun Info-directory () | |
559 "Go to the Info directory node." | |
560 (interactive) | |
561 (Info-find-node "dir" "top")) | |
562 | |
563 (defun Info-follow-reference (footnotename) | |
564 "Follow cross reference named NAME to the node it refers to. | |
565 NAME may be an abbreviation of the reference name." | |
566 (interactive | |
567 (let ((completion-ignore-case t) | |
568 completions default (start-point (point)) str i) | |
569 (save-excursion | |
570 (goto-char (point-min)) | |
571 (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t) | |
572 (setq str (buffer-substring | |
573 (match-beginning 1) | |
574 (1- (point)))) | |
575 ;; See if this one should be the default. | |
576 (and (null default) | |
577 (< (match-beginning 0) start-point) | |
578 (<= start-point (point)) | |
579 (setq default t)) | |
580 (setq i 0) | |
581 (while (setq i (string-match "[ \n\t]+" str i)) | |
582 (setq str (concat (substring str 0 i) " " | |
583 (substring str (match-end 0)))) | |
584 (setq i (1+ i))) | |
585 ;; Record as a completion and perhaps as default. | |
586 (if (eq default t) (setq default str)) | |
587 (setq completions | |
588 (cons (cons str nil) | |
589 completions)))) | |
590 (if completions | |
591 (list (completing-read (if default | |
592 (concat "Follow reference named: (" | |
593 default ") ") | |
594 "Follow reference named: ") | |
595 completions default t)) | |
596 (error "No cross-references in this node")))) | |
597 (let (target beg i (str (concat "\\*note " footnotename))) | |
598 (while (setq i (string-match " " str i)) | |
599 (setq str (concat (substring str 0 i) "[ \t\n]+" (substring str (1+ i)))) | |
600 (setq i (+ i 6))) | |
601 (save-excursion | |
602 (goto-char (point-min)) | |
603 (or (re-search-forward str nil t) | |
604 (error "No cross-reference named %s" footnotename)) | |
605 (goto-char (+ (match-beginning 0) 5)) | |
606 (setq target | |
607 (Info-extract-menu-node-name "Bad format cross reference" t))) | |
608 (while (setq i (string-match "[ \t\n]+" target i)) | |
609 (setq target (concat (substring target 0 i) " " | |
610 (substring target (match-end 0)))) | |
611 (setq i (+ i 1))) | |
612 (Info-goto-node target))) | |
613 | |
614 (defun Info-extract-menu-node-name (&optional errmessage multi-line) | |
615 (skip-chars-forward " \t\n") | |
616 (let ((beg (point)) | |
617 str i) | |
618 (skip-chars-forward "^:") | |
619 (forward-char 1) | |
620 (setq str | |
621 (if (looking-at ":") | |
622 (buffer-substring beg (1- (point))) | |
623 (skip-chars-forward " \t\n") | |
624 (Info-following-node-name (if multi-line "^.,\t" "^.,\t\n")))) | |
625 (while (setq i (string-match "\n" str i)) | |
626 (aset str i ?\ )) | |
627 str)) | |
628 | |
1484
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
629 ;; 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
|
630 ;;(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
|
631 ;; (while list |
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
632 ;; (Info-menu-item (car list)) |
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
633 ;; (setq list (cdr list)))) |
325 | 634 |
635 (defun Info-menu (menu-item) | |
636 "Go to node for menu item named (or abbreviated) NAME. | |
637 Completion is allowed, and the menu item point is on is the default." | |
638 (interactive | |
639 (let ((completions '()) | |
640 ;; If point is within a menu item, use that item as the default | |
641 (default nil) | |
642 (p (point)) | |
643 (last nil)) | |
644 (save-excursion | |
645 (goto-char (point-min)) | |
646 (if (not (search-forward "\n* menu:" nil t)) | |
647 (error "No menu in this node")) | |
648 (while (re-search-forward | |
649 "\n\\* \\([^:\t\n]*\\):" nil t) | |
650 (if (and (null default) | |
651 (prog1 (if last (< last p) nil) | |
652 (setq last (match-beginning 0))) | |
653 (<= p last)) | |
654 (setq default (car (car completions)))) | |
655 (setq completions (cons (cons (buffer-substring | |
656 (match-beginning 1) | |
657 (match-end 1)) | |
658 (match-beginning 1)) | |
659 completions))) | |
660 (if (and (null default) last | |
661 (< last p) | |
662 (<= p (progn (end-of-line) (point)))) | |
663 (setq default (car (car completions))))) | |
664 (let ((item nil)) | |
665 (while (null item) | |
666 (setq item (let ((completion-ignore-case t)) | |
667 (completing-read (if default | |
668 (format "Menu item (default %s): " | |
669 default) | |
670 "Menu item: ") | |
671 completions nil t))) | |
540 | 672 ;; we rely on the fact that completing-read accepts an input |
673 ;; of "" even when the require-match argument is true and "" | |
674 ;; is not a valid possibility | |
325 | 675 (if (string= item "") |
676 (if default | |
677 (setq item default) | |
678 ;; ask again | |
679 (setq item nil)))) | |
680 (list item)))) | |
681 ;; there is a problem here in that if several menu items have the same | |
682 ;; name you can only go to the node of the first with this command. | |
683 (Info-goto-node (Info-extract-menu-item menu-item))) | |
684 | |
685 (defun Info-extract-menu-item (menu-item) | |
686 (setq menu-item (regexp-quote menu-item)) | |
687 (save-excursion | |
688 (goto-char (point-min)) | |
689 (or (search-forward "\n* menu:" nil t) | |
690 (error "No menu in this node")) | |
691 (or (re-search-forward (concat "\n* " menu-item ":") nil t) | |
692 (re-search-forward (concat "\n* " menu-item) nil t) | |
693 (error "No such item in menu")) | |
694 (beginning-of-line) | |
695 (forward-char 2) | |
696 (Info-extract-menu-node-name))) | |
697 | |
698 ;; If COUNT is nil, use the last item in the menu. | |
699 (defun Info-extract-menu-counting (count) | |
700 (save-excursion | |
701 (goto-char (point-min)) | |
702 (or (search-forward "\n* menu:" nil t) | |
703 (error "No menu in this node")) | |
704 (if count | |
705 (or (search-forward "\n* " nil t count) | |
706 (error "Too few items in menu")) | |
707 (while (search-forward "\n* " nil t) | |
708 nil)) | |
709 (Info-extract-menu-node-name))) | |
710 | |
1666
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
711 (defun Info-nth-menu-item () |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
712 "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
|
713 N is the digit argument used to invoke this command." |
325 | 714 (interactive) |
1666
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
715 (Info-goto-node |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
716 (Info-extract-menu-counting |
c12fbca81b63
(Info-{first,second,third,fourth,fifth}-menu-item): Removed.
Roland McGrath <roland@gnu.org>
parents:
1613
diff
changeset
|
717 (- (aref (this-command-keys) (1- (length (this-command-keys)))) ?0)))) |
325 | 718 |
719 (defun Info-top-node () | |
720 "Go to the Top node of this file." | |
721 (interactive) | |
722 (Info-goto-node "Top")) | |
723 | |
724 (defun Info-final-node () | |
725 "Go to the final node in this file." | |
726 (interactive) | |
727 (Info-goto-node "Top") | |
728 (let (Info-history) | |
729 ;; Go to the last node in the menu of Top. | |
730 (Info-goto-node (Info-extract-menu-counting nil)) | |
731 ;; If the last node in the menu is not last in pointer structure, | |
732 ;; move forward until we can't go any farther. | |
733 (while (Info-forward-node t t) nil) | |
734 ;; Then keep moving down to last subnode, unless we reach an index. | |
735 (while (and (not (string-match "\\<index\\>" Info-current-node)) | |
736 (save-excursion (search-forward "\n* Menu:" nil t))) | |
737 (Info-goto-node (Info-extract-menu-counting nil))))) | |
738 | |
739 (defun Info-forward-node (&optional not-down no-error) | |
740 "Go forward one node, considering all nodes as forming one sequence." | |
741 (interactive) | |
742 (goto-char (point-min)) | |
743 (forward-line 1) | |
744 ;; three possibilities, in order of priority: | |
745 ;; 1. next node is in a menu in this node (but not in an index) | |
746 ;; 2. next node is next at same level | |
747 ;; 3. next node is up and next | |
748 (cond ((and (not not-down) | |
749 (save-excursion (search-forward "\n* menu:" nil t)) | |
750 (not (string-match "\\<index\\>" Info-current-node))) | |
751 (Info-first-menu-item) | |
752 t) | |
753 ((save-excursion (search-backward "next:" nil t)) | |
754 (Info-next) | |
755 t) | |
756 ((and (save-excursion (search-backward "up:" nil t)) | |
757 (not (equal (downcase (Info-extract-pointer "up")) "top"))) | |
758 (let ((old-node Info-current-node)) | |
759 (Info-up) | |
760 (let (Info-history success) | |
761 (unwind-protect | |
762 (setq success (Info-forward-node t no-error)) | |
763 (or success (Info-goto-node old-node)))))) | |
764 (no-error nil) | |
765 (t (error "No pointer forward from this node")))) | |
766 | |
767 (defun Info-backward-node () | |
768 "Go backward one node, considering all nodes as forming one sequence." | |
769 (interactive) | |
770 (let ((prevnode (Info-extract-pointer "prev[ious]*" t)) | |
771 (upnode (Info-extract-pointer "up" t))) | |
772 (cond ((and upnode (string-match "(" upnode)) | |
773 (error "First node in file")) | |
774 ((and upnode (or (null prevnode) | |
775 (equal (downcase prevnode) (downcase upnode)))) | |
776 (Info-up)) | |
777 (prevnode | |
778 ;; If we move back at the same level, | |
779 ;; go down to find the last subnode*. | |
780 (Info-prev) | |
781 (let (Info-history) | |
782 (while (and (not (string-match "\\<index\\>" Info-current-node)) | |
783 (save-excursion (search-forward "\n* Menu:" nil t))) | |
784 (Info-goto-node (Info-extract-menu-counting nil))))) | |
785 (t | |
786 (error "No pointer backward from this node"))))) | |
787 | |
788 (defun Info-exit () | |
789 "Exit Info by selecting some other buffer." | |
790 (interactive) | |
791 (switch-to-buffer (prog1 (other-buffer (current-buffer)) | |
792 (bury-buffer (current-buffer))))) | |
793 | |
929
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
794 (defun Info-next-menu-item () |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
795 (interactive) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
796 (save-excursion |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
797 (forward-line -1) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
798 (search-forward "\n* menu:" nil t) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
799 (or (search-forward "\n* " nil t) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
800 (error "No more items in menu")) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
801 (Info-goto-node (Info-extract-menu-node-name)))) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
802 |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
803 (defun Info-last-menu-item () |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
804 (interactive) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
805 (save-excursion |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
806 (forward-line 1) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
807 (search-backward "\n* menu:" nil t) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
808 (or (search-backward "\n* " nil t) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
809 (error "No previous items in menu")) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
810 (Info-goto-node (Info-extract-menu-node-name)))) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
811 |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
812 (defmacro no-error (&rest body) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
813 (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
|
814 |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
815 (defun Info-next-preorder () |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
816 "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
|
817 (interactive) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
818 (cond ((no-error (Info-next-menu-item)) ) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
819 ((no-error (Info-up)) (forward-line 1)) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
820 (t (error "No more nodes")))) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
821 |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
822 (defun Info-last-preorder () |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
823 "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
|
824 (interactive) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
825 (cond ((no-error (Info-last-menu-item)) ) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
826 ((no-error (Info-up)) (forward-line -1)) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
827 (t (error "No previous nodes")))) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
828 |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
829 (defun Info-scroll-up () |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
830 "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
|
831 (interactive) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
832 (if (pos-visible-in-window-p (point-max)) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
833 (Info-next-preorder) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
834 (scroll-up)) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
835 ) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
836 |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
837 (defun Info-scroll-down () |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
838 "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
|
839 (interactive) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
840 (if (pos-visible-in-window-p (point-min)) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
841 (Info-last-preorder) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
842 (scroll-down)) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
843 ) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
844 |
325 | 845 (defun Info-undefined () |
846 "Make command be undefined in Info." | |
847 (interactive) | |
848 (ding)) | |
849 | |
850 (defun Info-help () | |
851 "Enter the Info tutorial." | |
852 (interactive) | |
853 (delete-other-windows) | |
854 (Info-find-node "info" | |
855 (if (< (window-height) 23) | |
856 "Help-Small-Screen" | |
857 "Help"))) | |
858 | |
859 (defun Info-summary () | |
860 "Display a brief summary of all Info commands." | |
861 (interactive) | |
862 (save-window-excursion | |
863 (switch-to-buffer "*Help*") | |
864 (erase-buffer) | |
865 (insert (documentation 'Info-mode)) | |
866 (goto-char (point-min)) | |
867 (let (ch flag) | |
868 (while (progn (setq flag (not (pos-visible-in-window-p (point-max)))) | |
869 (message (if flag "Type Space to see more" | |
870 "Type Space to return to Info")) | |
871 (if (/= ?\ (setq ch (read-char))) | |
1821
04fb1d3d6992
JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents:
1667
diff
changeset
|
872 (progn (setq unread-command-events (list ch)) nil) |
325 | 873 flag)) |
874 (scroll-up))))) | |
875 | |
876 (defun Info-get-token (pos start all &optional errorstring) | |
877 "Return the token around POS, | |
878 POS must be somewhere inside the token | |
879 START is a regular expression which will match the | |
880 beginning of the tokens delimited string | |
881 ALL is a regular expression with a single | |
882 parenthized subpattern which is the token to be | |
883 returned. E.g. '{\(.*\)}' would return any string | |
884 enclosed in braces around POS. | |
885 SIG optional fourth argument, controls action on no match | |
886 nil: return nil | |
887 t: beep | |
888 a string: signal an error, using that string." | |
889 (save-excursion | |
890 (goto-char pos) | |
891 (re-search-backward start (max (point-min) (- pos 200)) 'yes) | |
892 (while (and (re-search-forward all (min (point-max) (+ pos 200)) 'yes) | |
893 (not (and (<= (match-beginning 0) pos) | |
894 (> (match-end 0) pos))))) | |
895 (if (and (<= (match-beginning 0) pos) | |
896 (> (match-end 0) pos)) | |
897 (buffer-substring (match-beginning 1) (match-end 1)) | |
898 (cond ((null errorstring) | |
899 nil) | |
900 ((eq errorstring t) | |
901 (beep) | |
902 nil) | |
903 (t | |
904 (error "No %s around position %d" errorstring pos)))))) | |
905 | |
540 | 906 (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
|
907 "\\<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
|
908 Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click. |
325 | 909 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
|
910 (interactive "e") |
1484
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
911 (let* ((start (event-start click)) |
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
912 (window (car start)) |
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
913 (pos (car (cdr start)))) |
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
914 (select-window window) |
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
915 (goto-char pos)) |
325 | 916 (let (node) |
917 (cond | |
1309
aa286e6e7bec
(Info-follow-nearest-node): Handle line breaks after *note.
Richard M. Stallman <rms@gnu.org>
parents:
998
diff
changeset
|
918 ((setq node (Info-get-token (point) "\\*note[ \n]" "\\*note[ \n]\\([^:]*\\):" t)) |
325 | 919 (Info-follow-reference node)) |
920 ((setq node (Info-get-token (point) "\\* " "\\* \\([^:]*\\)::" t)) | |
921 (Info-goto-node node)) | |
922 ((setq node (Info-get-token (point) "\\* " "\\* \\([^:]*\\):" t)) | |
923 (Info-menu node)) | |
924 ((setq node (Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)" t)) | |
925 (Info-goto-node node)) | |
926 ((setq node (Info-get-token (point) "Next: " "Next: \\([^,\n\t]*\\)" t)) | |
927 (Info-goto-node node)) | |
928 ((setq node (Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)" t)) | |
929 (Info-goto-node "Top")) | |
930 ((setq node (Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)" t)) | |
931 (Info-goto-node node)) | |
932 ((save-excursion (forward-line 1) (eobp)) | |
933 (Info-next))) | |
934 )) | |
935 | |
936 (defvar Info-mode-map nil | |
937 "Keymap containing Info commands.") | |
938 (if Info-mode-map | |
939 nil | |
940 (setq Info-mode-map (make-keymap)) | |
941 (suppress-keymap Info-mode-map) | |
942 (define-key Info-mode-map "." 'beginning-of-buffer) | |
929
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
943 (define-key Info-mode-map " " 'Info-scroll-up) |
27262a6c632a
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
846
diff
changeset
|
944 (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
|
945 (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
|
946 (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
|
947 (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
|
948 (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
|
949 (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
|
950 (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
|
951 (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
|
952 (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
|
953 (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
|
954 (define-key Info-mode-map "0" 'undefined) |
325 | 955 (define-key Info-mode-map "?" 'Info-summary) |
956 (define-key Info-mode-map "]" 'Info-forward-node) | |
957 (define-key Info-mode-map "[" 'Info-backward-node) | |
958 (define-key Info-mode-map "<" 'Info-top-node) | |
959 (define-key Info-mode-map ">" 'Info-final-node) | |
960 (define-key Info-mode-map "b" 'beginning-of-buffer) | |
961 (define-key Info-mode-map "d" 'Info-directory) | |
962 (define-key Info-mode-map "e" 'Info-edit) | |
963 (define-key Info-mode-map "f" 'Info-follow-reference) | |
964 (define-key Info-mode-map "g" 'Info-goto-node) | |
965 (define-key Info-mode-map "h" 'Info-help) | |
966 (define-key Info-mode-map "l" 'Info-last) | |
967 (define-key Info-mode-map "m" 'Info-menu) | |
968 (define-key Info-mode-map "n" 'Info-next) | |
969 (define-key Info-mode-map "p" 'Info-prev) | |
970 (define-key Info-mode-map "q" 'Info-exit) | |
971 (define-key Info-mode-map "s" 'Info-search) | |
972 (define-key Info-mode-map "u" 'Info-up) | |
930
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
929
diff
changeset
|
973 (define-key Info-mode-map "\177" 'Info-scroll-down) |
1309
aa286e6e7bec
(Info-follow-nearest-node): Handle line breaks after *note.
Richard M. Stallman <rms@gnu.org>
parents:
998
diff
changeset
|
974 (define-key Info-mode-map [mouse-3] 'Info-follow-nearest-node) |
540 | 975 ) |
325 | 976 |
977 ;; Info mode is suitable only for specially formatted data. | |
978 (put 'info-mode 'mode-class 'special) | |
979 | |
980 (defun Info-mode () | |
981 "\\<Info-mode-map> | |
982 Info mode provides commands for browsing through the Info documentation tree. | |
983 Documentation in Info is divided into \"nodes\", each of which discusses | |
984 one topic and contains references to other nodes which discuss related | |
985 topics. Info has commands to follow the references and show you other nodes. | |
986 | |
987 \\[Info-help] Invoke the Info tutorial. | |
988 | |
989 Selecting other nodes: | |
990 \\[Info-next] Move to the \"next\" node of this node. | |
991 \\[Info-previous] Move to the \"previous\" node of this node. | |
992 \\[Info-up] Move \"up\" from this node. | |
993 \\[Info-menu] Pick menu item specified by name (or abbreviation). | |
994 Picking a menu item causes another node to be selected. | |
540 | 995 \\[Info-directory] Go to the Info directory node. |
325 | 996 \\[Info-follow-reference] Follow a cross reference. Reads name of reference. |
997 \\[Info-last] Move to the last node you were at. | |
998 | |
999 Moving within a node: | |
930
1dac458b5117
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
929
diff
changeset
|
1000 \\[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
|
1001 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
|
1002 \\[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
|
1003 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
|
1004 \\[beginning-of-buffer] Go to beginning of node. |
325 | 1005 |
1006 Advanced commands: | |
1007 \\[Info-exit] Quit Info: reselect previously selected buffer. | |
1008 \\[Info-edit] Edit contents of selected node. | |
1009 1 Pick first item in node's menu. | |
1010 2, 3, 4, 5 Pick second ... fifth item in node's menu. | |
1011 \\[Info-goto-node] Move to node specified by name. | |
1012 You may include a filename as well, as (FILENAME)NODENAME. | |
1013 \\[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
|
1014 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
|
1015 \\[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
|
1016 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
|
1017 he/she is done reading." |
325 | 1018 (kill-all-local-variables) |
1019 (setq major-mode 'Info-mode) | |
1020 (setq mode-name "Info") | |
1021 (use-local-map Info-mode-map) | |
1022 (set-syntax-table text-mode-syntax-table) | |
1023 (setq local-abbrev-table text-mode-abbrev-table) | |
1024 (setq case-fold-search t) | |
1025 (setq buffer-read-only t) | |
1026 (make-local-variable 'Info-current-file) | |
1027 (make-local-variable 'Info-current-subfile) | |
1028 (make-local-variable 'Info-current-node) | |
1029 (make-local-variable 'Info-tag-table-marker) | |
1030 (make-local-variable 'Info-history) | |
1031 (Info-set-mode-line) | |
1032 (run-hooks 'Info-mode-hook)) | |
1033 | |
1034 (defvar Info-edit-map nil | |
1035 "Local keymap used within `e' command of Info.") | |
1036 (if Info-edit-map | |
1037 nil | |
1038 (setq Info-edit-map (nconc (make-sparse-keymap) text-mode-map)) | |
1039 (define-key Info-edit-map "\C-c\C-c" 'Info-cease-edit)) | |
1040 | |
1041 ;; Info-edit mode is suitable only for specially formatted data. | |
1042 (put 'info-edit-mode 'mode-class 'special) | |
1043 | |
1044 (defun Info-edit-mode () | |
1045 "Major mode for editing the contents of an Info node. | |
1477 | 1046 Like text mode with the addition of `Info-cease-edit' |
325 | 1047 which returns to Info mode for browsing. |
1048 \\{Info-edit-map}" | |
1049 ) | |
1050 | |
1051 (defun Info-edit () | |
1052 "Edit the contents of this Info node. | |
1053 Allowed only if variable `Info-enable-edit' is non-nil." | |
1054 (interactive) | |
1055 (or Info-enable-edit | |
1056 (error "Editing info nodes is not enabled")) | |
1057 (use-local-map Info-edit-map) | |
1058 (setq major-mode 'Info-edit-mode) | |
1059 (setq mode-name "Info Edit") | |
1060 (kill-local-variable 'mode-line-buffer-identification) | |
1061 (setq buffer-read-only nil) | |
1062 ;; Make mode line update. | |
1063 (set-buffer-modified-p (buffer-modified-p)) | |
1064 (message (substitute-command-keys | |
1065 "Editing: Type \\<info-mode-map>\\[Info-cease-edit] to return to info"))) | |
1066 | |
1067 (defun Info-cease-edit () | |
1068 "Finish editing Info node; switch back to Info proper." | |
1069 (interactive) | |
1070 ;; Do this first, so nothing has changed if user C-g's at query. | |
1071 (and (buffer-modified-p) | |
1072 (y-or-n-p "Save the file? ") | |
1073 (save-buffer)) | |
1074 (use-local-map Info-mode-map) | |
1075 (setq major-mode 'Info-mode) | |
1076 (setq mode-name "Info") | |
1077 (Info-set-mode-line) | |
1078 (setq buffer-read-only t) | |
1079 ;; Make mode line update. | |
1080 (set-buffer-modified-p (buffer-modified-p)) | |
1081 (and (marker-position Info-tag-table-marker) | |
1082 (buffer-modified-p) | |
1083 (message "Tags may have changed. Use Info-tagify if necessary"))) | |
359 | 1084 |
1085 (defun Info-find-emacs-command-nodes (command) | |
1086 "Return a list of locations documenting COMMAND in the Emacs Info manual. | |
1087 The locations are of the format used in Info-history, i.e. | |
1088 \(FILENAME NODENAME BUFFERPOS\)." | |
1089 (require 'info) | |
1090 (let ((where '()) | |
1091 (cmd-desc (concat "^\\* " (regexp-quote (symbol-name command)) | |
1092 ":\\s *\\(.*\\)\\.$"))) | |
1093 (save-excursion | |
1094 (Info-find-node "emacs" "Command Index") | |
1095 ;; Take the index node off the Info history. | |
1096 (setq Info-history (cdr Info-history)) | |
1097 (goto-char (point-max)) | |
1098 (while (re-search-backward cmd-desc nil t) | |
1099 (setq where (cons (list Info-current-file | |
1100 (buffer-substring | |
1101 (match-beginning 1) | |
1102 (match-end 1)) | |
1103 0) | |
1104 where))) | |
1105 where))) | |
1106 | |
1107 ;;;###autoload | |
1108 (defun Info-goto-emacs-command-node (command) | |
1109 "Go to the Info node in the Emacs manual for command COMMAND." | |
1110 (interactive "CFind documentation for command: ") | |
1111 (or (commandp command) | |
1112 (signal 'wrong-type-argument (list 'commandp command))) | |
1113 (let ((where (Info-find-emacs-command-nodes command))) | |
1114 (if where | |
1115 (let ((num-matches (length where))) | |
1116 ;; Get Info running, and pop to it in another window. | |
1117 (save-window-excursion | |
1118 (info)) | |
1119 (pop-to-buffer "*info*") | |
1120 (Info-find-node (car (car where)) | |
1121 (car (cdr (car where)))) | |
1122 (if (> num-matches 1) | |
1123 (progn | |
1124 ;; Info-find-node already pushed (car where) onto | |
1125 ;; Info-history. Put the other nodes that were found on | |
1126 ;; the history. | |
1127 (setq Info-history (nconc (cdr where) Info-history)) | |
1128 (message (substitute-command-keys | |
1129 "Found %d other entr%. Use \\[Info-last] to see %s." | |
1130 (1- num-matches) | |
1131 (if (> num-matches 2) "ies" "y") | |
1132 (if (> num-matches 2) "them" "it")))))) | |
1133 (error "Couldn't find documentation for %s." command)))) | |
1134 | |
1135 ;;;###autoload | |
1136 (defun Info-goto-emacs-key-command-node (key) | |
1137 "Go to the Info node in the Emacs manual the command bound to KEY, a string. | |
1138 Interactively, if the binding is execute-extended-command, a command is read." | |
1139 (interactive "kFind documentation for key:") | |
1140 (let ((command (key-binding key))) | |
1141 (cond ((null command) | |
1484
6c2a714566d3
Rename buffer-flush-undo to buffer-disable-undo.
Richard M. Stallman <rms@gnu.org>
parents:
1477
diff
changeset
|
1142 (message "%s is undefined" (key-description key))) |
359 | 1143 ((and (interactive-p) |
1144 (eq command 'execute-extended-command)) | |
1145 (Info-goto-emacs-command-node | |
1146 (read-command "Find documentation for command: "))) | |
1147 (t | |
1148 (Info-goto-emacs-command-node command))))) | |
584 | 1149 |
1150 (provide 'info) | |
1151 | |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1152 ;;; info.el ends here |