Mercurial > hg > xemacs-beta
annotate lisp/info.el @ 5887:6eca500211f4
Prototype for X509_check_host() has changed, detect this in configure.ac
ChangeLog addition:
2015-04-09 Aidan Kehoe <kehoea@parhasard.net>
* configure.ac:
If X509_check_host() is available, check the number of arguments
it takes. Don't use it if it takes any number of arguments other
than five. Also don't use it if <openssl/x509v3.h> does not
declare it, since if that is so there is no portable way to tell
how many arguments it should take, and so we would end up smashing
the stack.
* configure: Regenerate.
src/ChangeLog addition:
2015-04-09 Aidan Kehoe <kehoea@parhasard.net>
* tls.c:
#include <openssl/x509v3.h> for its prototype for
X509_check_host().
* tls.c (tls_open):
Pass the new fifth argument to X509_check_host().
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Thu, 09 Apr 2015 14:27:02 +0100 |
parents | bbe4146603db |
children |
rev | line source |
---|---|
428 | 1 ;;; info.el --- info package for Emacs. |
2 ;; Keywords: help | |
3 | |
4 ;; Copyright (C) 1985, 1986, 1993, 1997 Free Software Foundation, Inc. | |
771 | 5 ;; Copyright (C) 2002 Ben Wing. |
428 | 6 |
7 ;; Author: Dave Gillespie <daveg@synaptics.com> | |
8 ;; Richard Stallman <rms@gnu.ai.mit.edu> | |
9 ;; Maintainer: Dave Gillespie <daveg@synaptics.com> | |
502 | 10 ;; Version: diverged at version 1.07 of 7/22/93 |
428 | 11 ;; Keywords: docs, help |
12 | |
13 ;; This file is part of XEmacs. | |
14 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5270
diff
changeset
|
15 ;; XEmacs is free software: you can redistribute it and/or modify it |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5270
diff
changeset
|
16 ;; under the terms of the GNU General Public License as published by the |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5270
diff
changeset
|
17 ;; Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5270
diff
changeset
|
18 ;; option) any later version. |
428 | 19 |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5270
diff
changeset
|
20 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5270
diff
changeset
|
21 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5270
diff
changeset
|
22 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5270
diff
changeset
|
23 ;; for more details. |
428 | 24 |
25 ;; You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5270
diff
changeset
|
26 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>. |
428 | 27 |
502 | 28 ;;; Synched up with: Not synched with FSF. Highly divergent, and with |
29 ;;; many new features added for XEmacs. | |
428 | 30 |
31 ;; Commentary: | |
32 | |
33 ;; This is based on an early Emacs 19 info.el file. | |
34 ;; | |
35 ;; Note that Info-directory has been replaced by Info-directory-list, | |
36 ;; a search path of directories in which to find Info files. | |
37 ;; Also, Info tries adding ".info" to a file name if the name itself | |
38 ;; is not found. | |
39 ;; | |
502 | 40 ;; See the partial change log below for further details, and look into |
41 ;; ChangeLog for the rest. | |
428 | 42 |
43 | |
44 ;; LCD Archive Entry: | |
45 ;; info-dg|Dave Gillespie|daveg@synaptics.com | |
46 ;; |Info reader with many enhancements; replaces standard info.el. | |
47 ;; |93-07-22|1.07|~/modes/info.el | |
48 | |
49 ;; Also available from anonymous FTP on csvax.cs.caltech.edu. | |
50 | |
51 | |
52 ;; Change Log: | |
53 | |
54 ;; Modified 3/7/1991 by Dave Gillespie: | |
55 ;; (Author's address: daveg@synaptics.com or daveg@csvax.cs.caltech.edu) | |
56 ;; | |
57 ;; Added keys: i, t, <, >, [, ], {, }, 6, 7, 8, 9, 0. | |
58 ;; Look at help for info-mode (type ? in Info) for descriptions. | |
59 ;; | |
60 ;; If Info-directory-list is undefined and there is no INFOPATH | |
61 ;; in the environment, use value of Info-directory for compatibility | |
62 ;; with Emacs 18.57. | |
63 ;; | |
64 ;; All files named "localdir" found in the path are appended to "dir", | |
65 ;; the Info directory. For this to work, "dir" should contain only | |
66 ;; one node (Top), and each "localdir" should contain no ^_ or ^L | |
67 ;; characters. Generally they will contain only one or several | |
68 ;; additional lines for the top-level menu. Note that "dir" is | |
69 ;; modified in memory each time it is loaded, but not on disk. | |
70 ;; | |
71 ;; If "dir" contains a line of the form: "* Locals:" | |
72 ;; then the "localdir"s are inserted there instead of at the end. | |
73 | |
74 | |
75 ;; Modified 4/3/1991 by Dave Gillespie: | |
76 ;; | |
77 ;; Added Info-mode-hook (suggested by Sebastian Kremer). | |
78 ;; Also added epoch-info-startup/select-hooks from Simon Spero's info.el. | |
79 ;; | |
80 ;; Added automatic decoding of compressed Info files. | |
81 ;; See documentation for the variable Info-suffix-list. Default is to | |
82 ;; run "uncompress" on ".Z" files and "unyabba" on ".Y" files. | |
83 ;; (See comp.sources.unix v24i073-076 for yabba/unyabba, a free software | |
84 ;; alternative to compress/uncompress.) | |
85 ;; Note: "dir" and "localdir" files should not be compressed. | |
86 ;; | |
87 ;; Changed variables like Info-enable-edit to be settable by M-x set-variable. | |
88 ;; | |
89 ;; Added Info-auto-advance variable. If t, SPC and DEL will act like | |
90 ;; } and {, i.e., they advance to the next/previous node if at the end | |
91 ;; of the buffer. | |
92 ;; | |
93 ;; Changed `u' to restore point to most recent location in that node. | |
94 ;; Added `=' to do this manually at any time. (Suggested by David Fox). | |
95 ;; | |
96 ;; Changed `m' and `0-9' to try interpreting menu name as a file name | |
97 ;; if not found as a node name. This allows (dir) menus of the form, | |
98 ;; Emacs:: Cool text editor | |
99 ;; as a shorthand for | |
100 ;; Emacs:(emacs). Cool text editor | |
101 ;; | |
102 ;; Enhanced `i' to use line-number information in the index. | |
103 ;; Added `,' to move among all matches to a previous `i' command. | |
104 ;; | |
105 ;; Added `a' (Info-annotate) for adding personal notes to any Info node. | |
106 ;; Notes are not stored in the actual Info files, but in the user's own | |
107 ;; ~/.infonotes file. | |
108 ;; | |
109 ;; Added Info-footnote-tag, made default be "Ref" instead of "Note". | |
110 ;; | |
111 ;; Got mouse-click stuff to work under Emacs version 18. Check it out! | |
112 ;; Left and right clicks scroll the Info window. | |
113 ;; Middle click goes to clicked-on node, e.g., "Next:", a menu, or a note. | |
114 | |
115 | |
116 ;; Modified 6/29/1991 by Dave Gillespie: | |
117 ;; | |
118 ;; Renamed epoch-info-startup/select-hooks to Info-startup/select-hook. | |
119 ;; | |
120 ;; Made Info-select-node into a command on the `!' key. | |
121 ;; | |
122 ;; Added Info-mouse-support user option. | |
123 ;; | |
124 ;; Cleaned up the implementation of some routines. | |
125 ;; | |
126 ;; Added special treatment of quoted words in annotations: The `g' | |
127 ;; command for a nonexistent node name scans for an annotation | |
128 ;; (in any node of any file) containing that name in quotes: g foo RET | |
129 ;; looks for an annotation containing: "foo" or: <<foo>> | |
130 ;; If found, it goes to that file and node. | |
131 ;; | |
132 ;; Added a call to set up Info-directory-list in Info-find-node to | |
133 ;; work around a bug in GNUS where it calls Info-goto-node before info. | |
134 ;; | |
135 ;; Added completion for `g' command (inspired by Richard Kim's infox.el). | |
136 ;; Completion knows all node names for the current file, and all annotation | |
137 ;; tags (see above). It does not complete file names or node names in | |
138 ;; other files. | |
139 ;; | |
140 ;; Added `k' (Info-emacs-key) and `*' (Info-elisp-ref) commands. You may | |
141 ;; wish to bind these to global keys outside of Info mode. | |
142 ;; | |
143 ;; Allowed localdir files to be full dir-like files; only the menu part | |
144 ;; of each localdir is copied. Also, redundant menu items are omitted. | |
145 ;; | |
146 ;; Changed Info-history to hold only one entry at a time for each node, | |
147 ;; and to be circular so that multiple `l's come back again to the most | |
148 ;; recent node. Note that the format of Info-history entries has changed, | |
149 ;; which may interfere with external programs that try to operate on it. | |
150 ;; (Also inspired by Kim's infox.el). | |
151 ;; | |
152 ;; Changed `n', `]', `l', etc. to accept prefix arguments to move several | |
153 ;; steps at once. Most accept negative arguments to move oppositely. | |
154 ;; | |
155 ;; Changed `?' to bury *Help* buffer afterwards to keep it out of the way. | |
156 ;; | |
157 ;; Rearranged `?' key's display to be a little better for new users. | |
158 ;; | |
159 ;; Changed `a' to save whole window configuration and restore on C-c C-c. | |
160 ;; | |
161 ;; Fixed the bug reported by Bill Reynolds on gnu.emacs.bugs. | |
162 ;; | |
163 ;; Changed Info-last to restore window-start as well as cursor position. | |
164 ;; | |
165 ;; Changed middle mouse button in space after end of node to do Info-last | |
166 ;; if we got here by following a cross reference, else do Info-global-next. | |
167 ;; | |
168 ;; Added some new mouse bindings: shift-left = Info-global-next, | |
169 ;; shift-right = Info-global-prev, shift-middle = Info-last. | |
170 ;; | |
171 ;; Fixed Info-follow-reference not to make assumptions about length | |
172 ;; of Info-footnote-tag [Linus Tolke]. | |
173 ;; | |
174 ;; Changed default for Info-auto-advance mode to be press-twice-for-next-node. | |
175 ;; | |
176 ;; Modified x-mouse-ignore to preserve last-command variable, so that | |
177 ;; press-twice Info-auto-advance mode works with the mouse. | |
178 | |
179 | |
180 ;; Modified 3/4/1992 by Dave Gillespie: | |
181 ;; | |
182 ;; Added an "autoload" command to help autoload.el. | |
183 ;; | |
184 ;; Changed `*' command to look for file `elisp' as well as for `lispref'. | |
185 ;; | |
186 ;; Fixed a bug involving footnote names containing regexp special characters. | |
187 ;; | |
188 ;; Fixed a bug in completion during `f' (or `r') command. | |
189 ;; | |
190 ;; Added TAB (Info-next-reference), M-TAB, and RET keys to Info mode. | |
191 ;; | |
192 ;; Added new bindings, `C-h C-k' for Info-emacs-key and `C-h C-f' for | |
193 ;; Info-elisp-ref. These bindings are made when info.el is loaded, and | |
194 ;; only if those key sequences were previously unbound. These bindings | |
195 ;; work at any time, not just when Info is already running. | |
196 | |
197 | |
198 ;; Modified 3/8/1992 by Dave Gillespie: | |
199 ;; | |
200 ;; Fixed some long lines that were causing trouble with mailers. | |
201 | |
202 | |
203 ;; Modified 3/9/1992 by Dave Gillespie: | |
204 ;; | |
205 ;; Added `C-h C-i' (Info-query). | |
206 ;; | |
207 ;; Added Info-novice mode, warns if the user attempts to switch to | |
208 ;; a different Info file. | |
209 ;; | |
210 ;; Fixed a bug that caused problems using compressed Info files | |
211 ;; and Info-directory-list at the same time. | |
212 ;; | |
213 ;; Disabled Info-mouse-support by default if Epoch or Hyperbole is in use. | |
214 ;; | |
215 ;; Added an expand-file-name call to Info-find-node to fix a small bug. | |
216 | |
217 | |
218 ;; Modified 5/22/1992 by Dave Gillespie: | |
219 ;; | |
220 ;; Added "standalone" operation: "emacs -f info" runs Emacs specifically | |
221 ;; for use as an Info browser. In this mode, the `q' key quits Emacs | |
222 ;; itself. Also, "emacs -f info arg" starts in Info file "arg" instead | |
223 ;; of "dir". | |
224 ;; | |
225 ;; Changed to prefer "foo.info" over "foo". If both exist, "foo" is | |
226 ;; probably a directory or executable program! | |
227 ;; | |
228 ;; Made control-mouse act like regular-mouse does in other buffers. | |
229 ;; (In most systems, this will be set-cursor for left-mouse, x-cut | |
230 ;; for right-mouse, and x-paste, which will be an error, for | |
231 ;; middle-mouse.) | |
232 ;; | |
233 ;; Improved prompting and searching for `,' key. | |
234 ;; | |
235 ;; Fixed a bug where some "* Menu:" lines disappeared when "dir" | |
236 ;; contained several nodes. | |
237 | |
238 | |
239 ;; Modified 9/10/1992 by Dave Gillespie: | |
240 ;; | |
241 ;; Mixed in support for XEmacs. Mouse works the same as in | |
242 ;; the other Emacs versions by default; added Info-lucid-mouse-style | |
243 ;; variable, which enables mouse operation similar to XEmacs's default. | |
244 ;; | |
245 ;; Fixed a bug where RET couldn't understand "* Foo::" if "Foo" was a | |
246 ;; file name instead of a node name. | |
247 ;; | |
248 ;; Added `x' (Info-bookmark), a simple interface to the annotation | |
249 ;; tags feature. Added `j' (Info-goto-bookmark), like `g' but only | |
250 ;; completes bookmarks. | |
251 ;; | |
252 ;; Added `<<tag>>' as alternate to `"tag"' in annotations. | |
253 ;; | |
254 ;; Added `v' (Info-visit-file), like Info-goto-node but specialized | |
255 ;; for going to a new Info file (with file name completion). | |
256 ;; | |
257 ;; Added recognition of gzip'd ".z" files. | |
258 | |
259 | |
260 ;; Modified 5/9/1993 by Dave Gillespie: | |
261 ;; | |
262 ;; Merged in various things from FSF's latest Emacs 19 info.el. | |
263 | |
264 ;; Modified 6/2/1993 by Dave Gillespie: | |
265 ;; | |
266 ;; Changed to use new suffix ".gz" for gzip files. | |
267 | |
268 | |
269 ;; Modified 7/22/1993 by Dave Gillespie: | |
270 ;; | |
271 ;; Changed Info-footnote-tag to "See" instead of "Ref". | |
272 ;; | |
273 ;; Extended Info-fontify-node to work with FSF version of Emacs 19. | |
274 | |
275 ;; Modified 7/30/1993 by Jamie Zawinski: | |
276 ;; | |
277 ;; Commented out the tty and fsf19 mouse support, because why bother. | |
278 ;; Commented out the politically incorrect version of XEmacs mouse support. | |
279 ;; Commented out mouse scrolling bindings because the party line on that | |
280 ;; is "scrollbars are coming soon." | |
281 ;; Commented out munging of help-for-help's doc; put it in help.el. | |
282 ;; Did Info-edit-map the modern XEmacs way. | |
283 ;; Pruned extra cruft from fontification and mouse handling code. | |
284 ;; Fixed ASCII-centric bogosity in unreading of events. | |
285 | |
286 ;; Modified 8/11/95 by Chuck Thompson: | |
287 ;; | |
288 ;; Removed any pretense of ever referencing Info-directory since it | |
289 ;; wasn't working anyhow. | |
290 | |
291 ;; Modified 4/5/97 by Tomasz J. Cholewo: | |
292 ;; | |
293 ;; Modified Info-search to use with-caps-disable-folding | |
294 | |
295 ;; Modified 6/21/97 by Hrvoje Niksic | |
296 ;; | |
297 ;; Fixed up Info-next-reference to work sanely when n < 0. | |
298 ;; Added S-tab binding. | |
299 | |
300 ;; Modified 1997-07-10 by Karl M. Hegbloom | |
301 ;; | |
302 ;; Added `Info-minibuffer-history' | |
303 ;; (also added to defaults in "lisp/utils/savehist.el") | |
304 ;; Other changes in main ChangeLog. | |
305 | |
306 ;; Modified 1998-03-29 by Oscar Figueiredo | |
307 ;; | |
308 ;; Added automatic dir/localdir (re)building capability for directories that | |
309 ;; contain none or when it has become older than info files in the same | |
310 ;; directory. | |
311 | |
442 | 312 ;; Modified 1998-09-23 by Didier Verna <didier@xemacs.org> |
428 | 313 ;; |
314 ;; Use the new macro `with-search-caps-disable-folding' | |
315 | |
316 ;; Code: | |
317 (eval-when-compile | |
318 (condition-case nil (require 'browse-url) (error nil))) | |
319 | |
320 (defgroup info nil | |
321 "The info package for Emacs." | |
322 :group 'help | |
323 :group 'docs) | |
324 | |
325 (defgroup info-faces nil | |
326 "The faces used by info browser." | |
327 :group 'info | |
328 :group 'faces) | |
329 | |
330 | |
331 (defcustom Info-inhibit-toolbar nil | |
332 "*Non-nil means don't use the specialized Info toolbar." | |
333 :type 'boolean | |
334 :group 'info) | |
335 | |
336 (defcustom Info-novice nil | |
337 "*Non-nil means to ask for confirmation before switching Info files." | |
338 :type 'boolean | |
339 :group 'info) | |
340 | |
341 (defvar Info-history nil | |
342 "List of info nodes user has visited. | |
343 Each element of list is a list (\"(FILENAME)NODENAME\" BUFPOS WINSTART).") | |
344 | |
345 (defvar Info-keeping-history t | |
346 "Non-nil if Info-find-node should modify Info-history. | |
347 This is for use only by certain internal Info routines.") | |
348 | |
349 (defvar Info-minibuffer-history nil | |
350 "Minibuffer history for Info.") | |
351 | |
352 (defcustom Info-enable-edit nil | |
353 "*Non-nil means the \\<Info-mode-map>\\[Info-edit] command in Info | |
354 can edit the current node. | |
355 This is convenient if you want to write info files by hand. | |
356 However, we recommend that you not do this. | |
357 It is better to write a Texinfo file and generate the Info file from that, | |
358 because that gives you a printed manual as well." | |
359 :type 'boolean | |
360 :group 'info) | |
361 | |
362 (defcustom Info-enable-active-nodes t | |
363 "*Non-nil allows Info to execute Lisp code associated with nodes. | |
364 The Lisp code is executed when the node is selected." | |
365 :type 'boolean | |
366 :group 'info) | |
367 | |
368 (defcustom Info-restoring-point t | |
369 "*Non-nil means to restore the cursor position when re-entering a node." | |
370 :type 'boolean | |
371 :group 'info) | |
372 | |
373 (defcustom Info-auto-advance 'twice | |
374 "*Control what SPC and DEL do when they can't scroll any further. | |
375 If nil, they beep and remain in the current node. | |
376 If t, they move to the next node (like Info-global-next/prev). | |
377 If anything else, they must be pressed twice to move to the next node." | |
378 :type '(choice (const :tag "off" nil) | |
379 (const :tag "advance" t) | |
380 (const :tag "confirm" twice)) | |
381 :group 'info) | |
382 | |
383 (defcustom Info-fontify t | |
384 "*Non-nil enables font features in XEmacs. | |
385 This variable is ignored unless running under XEmacs." | |
386 :type 'boolean | |
387 :group 'info) | |
388 | |
389 (defcustom Info-additional-search-directory-list nil | |
390 "*List of additional directories to search for Info documentation | |
391 files. These directories are not searched for merging the `dir' | |
392 file. An example might be something like: | |
2421 | 393 \"/usr/local/lib/xemacs/xemacs-packages/lisp/calc/\"" |
428 | 394 :type '(repeat directory) |
395 :group 'info) | |
396 | |
723 | 397 (defcustom Info-auto-generate-directory 'if-outdated |
428 | 398 "*When to auto generate an info directory listing. |
399 Possible values are: | |
400 nil or `never' never auto-generate a directory listing, | |
401 use any existing `dir' or `localdir' file and ignore info | |
402 directories containing none | |
403 `always' auto-generate a directory listing ignoring existing | |
404 `dir' and `localdir' files | |
405 `if-missing', the default, auto-generates a directory listing | |
442 | 406 if no `dir' or `localdir' file is present. Otherwise the |
428 | 407 contents of any of these files is used instead. |
408 `if-outdated' auto-generates a directory listing if the `dir' | |
442 | 409 and `localdir' are either inexistent or outdated (touched |
428 | 410 less recently than an info file in the same directory)." |
411 :type '(choice (const :tag "never" never) | |
412 (const :tag "always" always) | |
413 (const :tag "if-missing" if-missing) | |
414 (const :tag "if-outdated" if-outdated)) | |
415 :group 'info) | |
416 | |
442 | 417 (defcustom Info-save-auto-generated-dir 'never |
428 | 418 "*Whether an auto-generated info directory listing should be saved. |
419 Possible values are: | |
442 | 420 nil or `never', the default, auto-generated info directory |
428 | 421 information will never be saved. |
422 `always', auto-generated info directory information will be saved to | |
423 a `dir' file in the same directory overwriting it if it exists | |
424 `conservative', auto-generated info directory information will be saved | |
442 | 425 to a `dir' file in the same directory but the user is asked before |
428 | 426 overwriting any existing file." |
427 :type '(choice (const :tag "never" never) | |
428 (const :tag "always" always) | |
429 (const :tag "conservative" conservative)) | |
430 :group 'info) | |
431 | |
444 | 432 (defconst Info-emacs-info-file-name "xemacs.info" |
433 "The filename of the XEmacs info for `Info-goto-emacs-command-node' | |
434 (`\\<help-mode-map>\\[Info-goto-emacs-command-node]')") | |
428 | 435 |
436 ;;;###autoload | |
437 (defvar Info-directory-list nil | |
438 "List of directories to search for Info documentation files. | |
439 | |
440 The first directory in this list, the \"dir\" file there will become | |
438 | 441 the (dir)Top node of the Info documentation tree. |
442 | |
443 Note: DO NOT use the `customize' interface to change the value of this | |
444 variable. Its value is created dynamically on each startup, depending | |
445 on XEmacs packages installed on the system. If you want to change the | |
446 search path, make the needed modifications on the variable's value | |
447 from .emacs. For instance: | |
448 | |
449 (setq Info-directory-list (cons \"~/info\" Info-directory-list))") | |
428 | 450 |
444 | 451 ;; This could as well be hard-coded since ${srcdir}/info/dir is in CVS --dv |
452 (defconst Info-localdir-heading-regexp "^Local Packages:$" | |
428 | 453 "The menu part of localdir files will be inserted below this topic |
444 | 454 heading.") |
428 | 455 |
456 (defface info-node '((t (:bold t :italic t))) | |
457 "Face used for node links in info." | |
458 :group 'info-faces) | |
459 | |
460 (defface info-xref '((t (:bold t))) | |
461 "Face used for cross-references in info." | |
462 :group 'info-faces) | |
463 | |
444 | 464 ;; This list is based on Karl Berry-s advice about extensions `info' itself |
465 ;; might encounter. --dv | |
466 (defcustom Info-suffix-list '(("" . nil) | |
467 (".info" . nil) | |
468 (".gz" . "gzip -dc %s") | |
469 (".info.gz" . "gzip -dc %s") | |
470 (".z" . "gzip -dc %s") | |
471 (".info.z" . "gzip -dc %s") | |
472 (".bz2" . "bzip2 -dc %s") | |
473 (".info.bz2" . "bzip2 -dc %s") | |
474 (".Z" . "uncompress -c %s") | |
475 (".info.Z" . "uncompress -c %s") | |
476 (".zip" . "unzip -c %s") | |
477 (".info.zip" . "unzip -c %s") | |
478 (".y" . "cat %s | unyabba") | |
479 ("info.y" . "cat %s | unyabba") | |
4409
3ff01259c4a2
Support LZMA compression in info.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3693
diff
changeset
|
480 ;; Mandriva Linux uses lzma. |
3ff01259c4a2
Support LZMA compression in info.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3693
diff
changeset
|
481 (".lzma" . "unlzma --stdout %s") |
3ff01259c4a2
Support LZMA compression in info.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3693
diff
changeset
|
482 (".info.lzma" . "unlzma --stdout %s") |
444 | 483 ;; These ones are for MS-DOS filenames. |
484 (".inf" . nil) | |
485 (".igz" . "gzip -dc %s") | |
486 (".inz" . "gzip -c %s")) | |
487 "*List of file name suffixes and associated decoding commands. | |
428 | 488 Each entry should be (SUFFIX . STRING); if STRING contains %s, that is |
489 changed to name of the file to decode, otherwise the file is given to | |
444 | 490 the command as standard input. If STRING is nil, no decoding is done." |
491 :type '(repeat (cons (string :tag "suffix") | |
492 (choice :tag "command" | |
493 (const :tag "none" :value nil) | |
494 (string :tag "")))) | |
495 :group 'info) | |
428 | 496 |
444 | 497 (defcustom Info-footnote-tag "Note" |
428 | 498 "*Symbol that identifies a footnote or cross-reference. |
444 | 499 All \"*Note\" references will be changed to use this word instead." |
500 :type 'string | |
501 :group 'info) | |
428 | 502 |
503 (defvar Info-current-file nil | |
504 "Info file that Info is now looking at, or nil. | |
505 This is the name that was specified in Info, not the actual file name. | |
506 It doesn't contain directory names or file name extensions added by Info.") | |
507 | |
508 (defvar Info-current-subfile nil | |
509 "Info subfile that is actually in the *info* buffer now, | |
510 or nil if current info file is not split into subfiles.") | |
511 | |
512 (defvar Info-current-node nil | |
513 "Name of node that Info is now looking at, or nil.") | |
514 | |
442 | 515 (defvar Info-tag-table-marker nil |
428 | 516 "Marker pointing at beginning of current Info file's tag table. |
517 Marker points nowhere if file has no tag table.") | |
518 | |
442 | 519 (defvar Info-tag-table-buffer nil) |
520 | |
428 | 521 (defvar Info-current-file-completions nil |
522 "Cached completion list for current Info file.") | |
523 | |
524 (defvar Info-current-annotation-completions nil | |
525 "Cached completion list for current annotation files.") | |
526 | |
527 (defvar Info-index-alternatives nil | |
528 "List of possible matches for last Info-index command.") | |
444 | 529 |
428 | 530 (defvar Info-index-first-alternative nil) |
531 | |
532 (defcustom Info-annotations-path | |
533 (list | |
534 (paths-construct-path (list user-init-directory "info.notes")) | |
535 (paths-construct-path '("~" ".infonotes")) | |
536 (paths-construct-path '("usr" "lib" "info.notes") | |
537 (char-to-string directory-sep-char))) | |
538 "*Names of files that contain annotations for different Info nodes. | |
539 By convention, the first one should reside in your personal directory. | |
540 The last should be a world-writable \"public\" annotations file." | |
541 :type '(repeat file) | |
542 :group 'info) | |
543 | |
544 (defcustom Info-button1-follows-hyperlink nil | |
545 "*Non-nil means mouse button1 click will follow hyperlink." | |
546 :type 'boolean | |
547 :group 'info) | |
548 | |
549 (defvar Info-standalone nil | |
550 "Non-nil if Emacs was started solely as an Info browser.") | |
551 | |
552 (defvar Info-in-cross-reference nil) | |
553 (defvar Info-window-configuration nil) | |
554 | |
555 (defvar Info-dir-prologue "-*- Text -*- | |
556 This is the file .../info/dir, which contains the topmost node of the | |
557 Info hierarchy. The first time you invoke Info you start off | |
558 looking at that node, which is (dir)Top. | |
559 | |
560 File: dir Node: Top This is the top of the INFO tree | |
442 | 561 This (the Directory node) gives a menu of major topics. |
428 | 562 |
563 * Menu: The list of major topics begins on the next line. | |
564 | |
565 ") | |
566 | |
444 | 567 (defcustom Info-no-description-string "[No description available]" |
568 "*Description string for info files that have none" | |
569 :type 'string | |
570 :group 'info) | |
428 | 571 |
572 ;;;###autoload | |
573 (defun info (&optional file) | |
574 "Enter Info, the documentation browser. | |
575 Optional argument FILE specifies the file to examine; | |
576 the default is the top-level directory of Info. | |
577 | |
1425 | 578 Called from a program, FILE may specify an Info node of the form |
579 `(FILENAME)NODENAME'. | |
580 | |
428 | 581 In interactive use, a prefix argument directs this command |
582 to read a file name from the minibuffer." | |
583 (interactive (if current-prefix-arg | |
584 (list (read-file-name "Info file name: " nil nil t)))) | |
585 (let ((p command-line-args)) | |
586 (while p | |
587 (and (string-match "^-[fe]" (car p)) | |
588 (equal (nth 1 p) "info") | |
589 (not Info-standalone) | |
590 (setq Info-standalone t) | |
5366
f00192e1cd49
Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents:
5270
diff
changeset
|
591 (eql (length p) 3) |
428 | 592 (not (string-match "^-" (nth 2 p))) |
593 (setq file (nth 2 p)) | |
594 (setq command-line-args-left nil)) | |
595 (setq p (cdr p)))) | |
596 ; (Info-setup-x) ??? What was this going to be? Can anyone tell karlheg? | |
597 (if file | |
598 (unwind-protect | |
1425 | 599 (progn |
600 (pop-to-buffer "*info*") | |
601 ;; If argument already contains parentheses, don't add another set | |
602 ;; since the argument will then be parsed improperly. This also | |
603 ;; has the added benefit of allowing node names to be included | |
604 ;; following the parenthesized filename. | |
605 (if (and (stringp file) (string-match "(.*)" file)) | |
606 (Info-goto-node file) | |
607 (Info-goto-node (concat "(" file ")")))) | |
428 | 608 (and Info-standalone (info))) |
609 (if (get-buffer "*info*") | |
610 (switch-to-buffer "*info*") | |
611 (Info-directory)))) | |
612 | |
613 ;;;###autoload | |
614 (defun Info-query (file) | |
615 "Enter Info, the documentation browser. Prompt for name of Info file." | |
616 (interactive "sInfo topic (default = menu): ") | |
617 (info) | |
618 (if (equal file "") | |
619 (Info-goto-node "(dir)") | |
620 (Info-goto-node (concat "(" file ")")))) | |
621 | |
622 (defun Info-setup-initial () | |
623 (let ((f Info-annotations-path)) | |
624 (while f | |
625 (if (and (file-exists-p (car f)) (not (get-file-buffer (car f)))) | |
626 (bury-buffer (find-file-noselect (car f)))) | |
627 (setq f (cdr f))))) | |
628 | |
442 | 629 ;;;###autoload |
428 | 630 (defun Info-find-node (filename &optional nodename no-going-back tryfile line) |
631 "Go to an info node specified as separate FILENAME and NODENAME. | |
632 Look for a plausible filename, or if not found then look for URL's and | |
771 | 633 dispatch to the appropriate fn. NO-GOING-BACK is non-nil if recovering |
634 from an error in this function; it says do not attempt further (recursive) | |
635 error recovery. TRYFILE indicates that NODENAME might actually be a | |
636 filename, so if we can't find a node of this name, try going to the `Top' | |
637 node of a file of this name." | |
428 | 638 |
639 (Info-setup-initial) | |
640 | |
641 (cond | |
642 ;; empty filename is simple case | |
643 ((null filename) | |
644 (Info-find-file-node nil nodename no-going-back tryfile line)) | |
645 ;; Convert filename to lower case if not found as specified. | |
646 ;; Expand it, look harder... | |
444 | 647 ((let ((fname (substitute-in-file-name filename)) |
648 temp found) | |
428 | 649 (let ((dirs (cond |
444 | 650 ;; If specified name starts with `./', then just try |
651 ;; current directory. No point in searching for an absolute | |
652 ;; file name | |
653 ((string-match "^\\./" fname) | |
654 (list default-directory)) | |
428 | 655 ((file-name-absolute-p fname) |
444 | 656 '(nil)) |
428 | 657 (Info-additional-search-directory-list |
658 (append Info-directory-list | |
659 Info-additional-search-directory-list)) | |
660 (t Info-directory-list)))) | |
661 ;; Search the directory list for file FNAME. | |
662 (while (and dirs (not found)) | |
663 (setq temp (expand-file-name fname (car dirs))) | |
444 | 664 (setq found (Info-suffixed-file temp)) |
428 | 665 (setq dirs (cdr dirs))) |
442 | 666 (if found |
428 | 667 (progn (setq filename (expand-file-name found)) |
668 t)))) | |
669 (Info-find-file-node filename nodename no-going-back tryfile line)) | |
670 ;; Look for a URL. This pattern is stolen from w3.el to prevent | |
671 ;; loading it if we won't need it. | |
672 ((string-match (concat "^\\(wais\\|solo\\|x-exec\\|newspost\\|www\\|" | |
673 "mailto\\|news\\|tn3270\\|ftp\\|http\\|file\\|" | |
674 "telnet\\|gopher\\):") | |
675 filename) | |
776 | 676 (if-fboundp 'browse-url |
428 | 677 (browse-url filename) |
776 | 678 (error 'unimplemented "no `browse-url' package; Cannot follow URLs in this XEmacs"))) |
428 | 679 (t |
680 (error "Info file %s does not exist" filename)))) | |
681 | |
682 (defun Info-find-file-node (filename nodename | |
683 &optional no-going-back tryfile line) | |
684 ;; This is the guts of what was Info-find-node. Whoever wrote this | |
685 ;; should be locked up where they can't do any more harm. | |
686 | |
687 ;; Go into info buffer. | |
442 | 688 (or (eq major-mode 'Info-mode) |
689 (switch-to-buffer "*info*")) | |
428 | 690 (buffer-disable-undo (current-buffer)) |
691 (run-hooks 'Info-startup-hook) | |
692 (or (eq major-mode 'Info-mode) | |
693 (Info-mode)) | |
694 (or (null filename) | |
695 (equal Info-current-file filename) | |
696 (not Info-novice) | |
697 (string= "dir" (file-name-nondirectory Info-current-file)) | |
442 | 698 (if (y-or-n-p |
428 | 699 (format "Leave Info file `%s'? " |
700 (file-name-nondirectory Info-current-file))) | |
701 (message "") | |
702 (keyboard-quit))) | |
703 ;; Record the node we are leaving. | |
704 (if (and Info-current-file (not no-going-back)) | |
705 (Info-history-add Info-current-file Info-current-node (point))) | |
706 (widen) | |
707 (setq Info-current-node nil | |
708 Info-in-cross-reference nil) | |
709 (unwind-protect | |
710 (progn | |
711 ;; Switch files if necessary | |
712 (or (null filename) | |
713 (equal Info-current-file filename) | |
714 (let ((buffer-read-only nil)) | |
715 (setq Info-current-file nil | |
716 Info-current-subfile nil | |
717 Info-current-file-completions nil | |
771 | 718 ;; Nooooooooooo! Info-index can extend across more |
719 ;; than one file (e.g. XEmacs, Lispref) | |
720 ;; Info-index-alternatives nil | |
3693 | 721 buffer-file-name nil |
722 buffer-file-truename nil) | |
428 | 723 (erase-buffer) |
724 (if (string= "dir" (file-name-nondirectory filename)) | |
725 (Info-insert-dir) | |
726 (Info-insert-file-contents filename t) | |
727 (setq default-directory (file-name-directory filename))) | |
728 (set-buffer-modified-p nil) | |
729 ;; See whether file has a tag table. Record the location if yes. | |
730 (set-marker Info-tag-table-marker nil) | |
731 (goto-char (point-max)) | |
732 (forward-line -8) | |
733 (or (equal nodename "*") | |
734 (not (search-forward "\^_\nEnd tag table\n" nil t)) | |
735 (let (pos) | |
736 ;; We have a tag table. Find its beginning. | |
737 ;; Is this an indirect file? | |
738 (search-backward "\nTag table:\n") | |
739 (setq pos (point)) | |
740 (if (save-excursion | |
741 (forward-line 2) | |
742 (looking-at "(Indirect)\n")) | |
743 ;; It is indirect. Copy it to another buffer | |
744 ;; and record that the tag table is in that buffer. | |
442 | 745 (let ((buf (current-buffer)) |
746 (m Info-tag-table-marker)) | |
747 (or | |
748 Info-tag-table-buffer | |
749 (setq | |
750 Info-tag-table-buffer | |
751 (generate-new-buffer " *info tag table*"))) | |
752 (save-excursion | |
753 (set-buffer Info-tag-table-buffer) | |
754 (buffer-disable-undo (current-buffer)) | |
755 (setq case-fold-search t) | |
756 (erase-buffer) | |
757 (insert-buffer-substring buf) | |
758 (set-marker m (match-end 0)))) | |
428 | 759 (set-marker Info-tag-table-marker pos)))) |
760 (setq Info-current-file | |
761 (file-name-sans-versions buffer-file-name)))) | |
762 (if (equal nodename "*") | |
763 (progn (setq Info-current-node nodename) | |
764 (Info-set-mode-line) | |
765 (goto-char (point-min))) | |
766 ;; Search file for a suitable node. | |
767 (let* ((qnode (regexp-quote nodename)) | |
768 (regexp (concat "Node: *" qnode " *[,\t\n\177]")) | |
769 (guesspos (point-min)) | |
770 (found t)) | |
771 ;; First get advice from tag table if file has one. | |
772 ;; Also, if this is an indirect info file, | |
773 ;; read the proper subfile into this buffer. | |
774 (if (marker-position Info-tag-table-marker) | |
442 | 775 (let (foun found-mode (m Info-tag-table-marker)) |
776 (save-excursion | |
777 (set-buffer (marker-buffer Info-tag-table-marker)) | |
778 (goto-char m) | |
779 (setq foun (re-search-forward regexp nil t)) | |
444 | 780 (if foun |
442 | 781 (setq guesspos (read (current-buffer)))) |
782 (setq found-mode major-mode)) | |
444 | 783 (if foun |
442 | 784 ;; If this is an indirect file, |
785 ;; determine which file really holds this node | |
786 ;; and read it in. | |
787 (if (not (eq major-mode found-mode)) | |
788 (setq guesspos | |
789 (Info-read-subfile guesspos)))))) | |
428 | 790 (goto-char (max (point-min) (- guesspos 1000))) |
791 ;; Now search from our advised position (or from beg of buffer) | |
792 ;; to find the actual node. | |
793 (catch 'foo | |
794 (while (search-forward "\n\^_" nil t) | |
795 (forward-line 1) | |
796 (let ((beg (point))) | |
797 (forward-line 1) | |
798 (if (re-search-backward regexp beg t) | |
799 (throw 'foo t)))) | |
800 (setq found nil) | |
5652
cc6f0266bc36
Avoid #'delq in core Lisp, for the sake of style, a very slightly smaller binary
Aidan Kehoe <kehoea@parhasard.net>
parents:
5567
diff
changeset
|
801 (let ((bufs (delete* nil (mapcar 'get-file-buffer |
428 | 802 Info-annotations-path))) |
803 (pattern (if (string-match "\\`<<.*>>\\'" qnode) qnode | |
804 (format "\"%s\"\\|<<%s>>" qnode qnode))) | |
805 (pat2 (concat "------ *File: *\\([^ ].*[^ ]\\) *Node: " | |
806 "*\\([^ ].*[^ ]\\) *Line: *\\([0-9]+\\)")) | |
807 (afile nil) anode aline) | |
808 (while (and bufs (not anode)) | |
809 (save-excursion | |
810 (set-buffer (car bufs)) | |
811 (goto-char (point-min)) | |
812 (if (re-search-forward pattern nil t) | |
813 (if (re-search-backward pat2 nil t) | |
814 (setq afile (buffer-substring (match-beginning 1) | |
815 (match-end 1)) | |
816 anode (buffer-substring (match-beginning 2) | |
817 (match-end 2)) | |
818 aline (string-to-int | |
819 (buffer-substring (match-beginning 3) | |
820 (match-end 3))))))) | |
821 (setq bufs (cdr bufs))) | |
822 (if anode | |
823 (Info-find-node afile anode t nil aline) | |
824 (if tryfile | |
825 (condition-case nil | |
826 (Info-find-node nodename "Top" t) | |
827 (error nil))))) | |
828 (or Info-current-node | |
829 (error "No such node: %s" nodename))) | |
830 (if found | |
831 (progn | |
832 (Info-select-node) | |
833 (goto-char (point-min)) | |
834 (if line (forward-line line))))))) | |
835 ;; If we did not finish finding the specified node, | |
836 ;; go back to the previous one. | |
837 (or Info-current-node no-going-back | |
838 (let ((hist (car Info-history))) | |
839 ;; The following is no longer safe with new Info-history system | |
840 ;; (setq Info-history (cdr Info-history)) | |
841 (Info-goto-node (car hist) t) | |
842 (goto-char (+ (point-min) (nth 1 hist))))))) | |
843 | |
844 ;; Cache the contents of the (virtual) dir file, once we have merged | |
845 ;; it for the first time, so we can save time subsequently. | |
846 (defvar Info-dir-contents nil) | |
847 | |
848 ;; Cache for the directory we decided to use for the default-directory | |
849 ;; of the merged dir text. | |
850 (defvar Info-dir-contents-directory nil) | |
851 | |
852 ;; Record the file attributes of all the files from which we | |
853 ;; constructed Info-dir-contents. | |
854 (defvar Info-dir-file-attributes nil) | |
855 | |
856 (defun Info-insert-dir () | |
857 "Construct the Info directory node by merging the files named | |
444 | 858 \"dir\" or \"localdir\" from the directories in `Info-directory-list'. |
428 | 859 The \"dir\" files will take precedence in cases where both exist. It |
860 sets the *info* buffer's `default-directory' to the first directory we | |
861 actually get any text from." | |
862 (if (and Info-dir-contents Info-dir-file-attributes | |
863 ;; Verify that none of the files we used has changed | |
864 ;; since we used it. | |
5270
3acaa0fc09be
Use #'some, #'every, etc. for composing boolean operations on lists.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4409
diff
changeset
|
865 (every #'(lambda (elt) |
3acaa0fc09be
Use #'some, #'every, etc. for composing boolean operations on lists.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4409
diff
changeset
|
866 (let ((curr (file-attributes (car elt)))) |
3acaa0fc09be
Use #'some, #'every, etc. for composing boolean operations on lists.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4409
diff
changeset
|
867 ;; Don't compare the access time. |
3acaa0fc09be
Use #'some, #'every, etc. for composing boolean operations on lists.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4409
diff
changeset
|
868 (if curr (setcar (nthcdr 4 curr) 0)) |
3acaa0fc09be
Use #'some, #'every, etc. for composing boolean operations on lists.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4409
diff
changeset
|
869 (setcar (nthcdr 4 (cdr elt)) 0) |
3acaa0fc09be
Use #'some, #'every, etc. for composing boolean operations on lists.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4409
diff
changeset
|
870 (equal (cdr elt) curr))) |
3acaa0fc09be
Use #'some, #'every, etc. for composing boolean operations on lists.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4409
diff
changeset
|
871 Info-dir-file-attributes)) |
428 | 872 (insert Info-dir-contents) |
873 (let ((dirs (reverse Info-directory-list)) | |
874 buffers lbuffers buffer others nodes dirs-done) | |
875 | |
876 (setq Info-dir-file-attributes nil) | |
877 | |
878 ;; Search the directory list for the directory file. | |
879 (while dirs | |
880 (let ((truename (file-truename (expand-file-name (car dirs))))) | |
881 (or (member truename dirs-done) | |
882 (member (directory-file-name truename) dirs-done) | |
444 | 883 ;; Karl Berry recently added the ability all possibilities for |
884 ;; extension as for normal info files. This code however is | |
885 ;; still unsatisfactory: if one day, we find a compressed dir | |
886 ;; file (which looks possible), we should be able to handle it | |
887 ;; (which means decompress and read it, update it, save and | |
888 ;; recompress it). --dv | |
889 (let ((trials '("dir" "DIR" | |
890 "dir.info" "DIR.INFO" | |
891 "dir.inf" "DIR.INF" | |
892 "localdir" "LOCALDIR" | |
893 "localdir.info" "LOCALDIR.INFO" | |
894 "localdir.inf" "LOCALDIR.INF")) | |
895 buf file attrs) | |
896 (catch 'found | |
897 (while (setq file (pop trials)) | |
898 (setq file (expand-file-name file truename)) | |
899 (and (setq attrs (file-attributes file)) | |
900 (throw 'found t)))) | |
901 (unless file | |
902 (setq file (expand-file-name "dir" truename))) | |
428 | 903 (setq dirs-done |
904 (cons truename | |
905 (cons (directory-file-name truename) | |
906 dirs-done))) | |
907 (Info-maybe-update-dir file) | |
908 (setq attrs (file-attributes file)) | |
909 (if (or (setq buf (find-buffer-visiting file)) | |
910 attrs) | |
911 (save-excursion | |
912 (or buffers | |
913 (message "Composing main Info directory...")) | |
914 (set-buffer (or buf | |
915 (generate-new-buffer | |
5882
bbe4146603db
Reduce regexp usage, now CL-oriented non-regexp code available, core Lisp
Aidan Kehoe <kehoea@parhasard.net>
parents:
5652
diff
changeset
|
916 (if (search "localdir" file |
bbe4146603db
Reduce regexp usage, now CL-oriented non-regexp code available, core Lisp
Aidan Kehoe <kehoea@parhasard.net>
parents:
5652
diff
changeset
|
917 :test #'equalp) |
428 | 918 "localdir" |
919 "info dir")))) | |
442 | 920 (if (not buf) |
428 | 921 (insert-file-contents file)) |
5882
bbe4146603db
Reduce regexp usage, now CL-oriented non-regexp code available, core Lisp
Aidan Kehoe <kehoea@parhasard.net>
parents:
5652
diff
changeset
|
922 (if (search "localdir" (buffer-name) :test #'equalp) |
428 | 923 (setq lbuffers (cons (current-buffer) lbuffers)) |
924 (setq buffers (cons (current-buffer) buffers))) | |
925 (if attrs | |
926 (setq Info-dir-file-attributes | |
927 (cons (cons file attrs) | |
928 Info-dir-file-attributes))))))) | |
929 (or (cdr dirs) (setq Info-dir-contents-directory (car dirs))) | |
930 (setq dirs (cdr dirs)))) | |
442 | 931 |
428 | 932 ;; ensure that the localdir files are inserted last, and reverse |
933 ;; the list of them so that when they get pushed in, they appear | |
934 ;; in the same order they got specified in the path, from top to | |
935 ;; bottom. | |
936 (nconc buffers (reverse lbuffers)) | |
442 | 937 |
428 | 938 (or buffers |
939 (error "Can't find the Info directory node")) | |
940 ;; Distinguish the dir file that comes with Emacs from all the | |
941 ;; others. Yes, that is really what this is supposed to do. | |
942 ;; If it doesn't work, fix it. | |
943 (setq buffer (car buffers) | |
944 ;; reverse it since they are pushed down from the top. the | |
945 ;; `Info-directory-list can be specified in natural order | |
946 ;; this way. | |
947 others (reverse (cdr buffers))) | |
948 | |
949 ;; Insert the entire original dir file as a start; note that we've | |
950 ;; already saved its default directory to use as the default | |
951 ;; directory for the whole concatenation. | |
952 (insert-buffer buffer) | |
953 | |
954 ;; Look at each of the other buffers one by one. | |
955 (while others | |
956 (let ((other (car others)) | |
957 (info-buffer (current-buffer))) | |
5882
bbe4146603db
Reduce regexp usage, now CL-oriented non-regexp code available, core Lisp
Aidan Kehoe <kehoea@parhasard.net>
parents:
5652
diff
changeset
|
958 (if (search "localdir" (buffer-name other)) |
428 | 959 (save-excursion |
960 (set-buffer info-buffer) | |
961 (goto-char (point-max)) | |
962 (cond | |
963 ((re-search-backward "^ *\\* *Locals *: *$" nil t) | |
964 (delete-region (match-beginning 0) (match-end 0))) | |
965 ;; look for a line like |Local XEmacs packages: | |
966 ;; or mismatch on some text ... | |
967 ((re-search-backward Info-localdir-heading-regexp nil t) | |
968 ;; This is for people who underline topic headings with | |
969 ;; equal signs or dashes. | |
970 (when (save-excursion | |
971 (forward-line 1) | |
972 (beginning-of-line) | |
973 (looking-at "^[ \t]*[-=*]+")) | |
974 (forward-line 1)) | |
975 (forward-line 1) | |
976 (beginning-of-line)) | |
977 (t (search-backward "\^L" nil t))) | |
978 ;; Insert menu part of the file | |
979 (let* ((pt (point)) | |
980 (len (length (buffer-string nil nil other)))) | |
981 (insert (buffer-string nil nil other)) | |
982 (goto-char (+ pt len)) | |
983 (save-excursion | |
984 (goto-char pt) | |
985 (if (search-forward "* Menu:" (+ pt len) t) | |
986 (progn | |
987 (forward-line 1) | |
988 (delete-region pt (point))))))) | |
989 ;; In each, find all the menus. | |
990 (save-excursion | |
991 (set-buffer other) | |
992 (goto-char (point-min)) | |
993 ;; Find each menu, and add an elt to NODES for it. | |
994 (while (re-search-forward "^\\* Menu:" nil t) | |
995 (let (beg nodename end) | |
996 (forward-line 1) | |
997 (setq beg (point)) | |
998 (search-backward "\n\^_") | |
999 (search-forward "Node: ") | |
1000 (setq nodename (Info-following-node-name)) | |
1001 (search-forward "\n\^_" nil 'move) | |
1002 (beginning-of-line) | |
1003 (setq end (point)) | |
1004 (setq nodes (cons (list nodename other beg end) nodes)))))) | |
1005 (setq others (cdr others)))) | |
442 | 1006 |
428 | 1007 ;; Add to the main menu a menu item for each other node. |
1008 (re-search-forward "^\\* Menu:" nil t) | |
1009 (forward-line 1) | |
1010 (let ((menu-items '("top")) | |
1011 (nodes nodes) | |
1012 (case-fold-search t) | |
1013 (end (save-excursion (search-forward "\^_" nil t) (point)))) | |
1014 (while nodes | |
1015 (let ((nodename (car (car nodes)))) | |
1016 (save-excursion | |
1017 (or (member (downcase nodename) menu-items) | |
1018 (re-search-forward (concat "^\\* " | |
1019 (regexp-quote nodename) | |
1020 "::") | |
1021 end t) | |
1022 (progn | |
1023 (insert "* " nodename "::" "\n") | |
1024 (setq menu-items (cons nodename menu-items)))))) | |
1025 (setq nodes (cdr nodes)))) | |
1026 ;; Now take each node of each of the other buffers | |
1027 ;; and merge it into the main buffer. | |
1028 (while nodes | |
1029 (let ((nodename (car (car nodes)))) | |
1030 (goto-char (point-min)) | |
1031 ;; Find the like-named node in the main buffer. | |
1032 (if (re-search-forward (concat "\n\^_.*\n.*Node: " | |
1033 (regexp-quote nodename) | |
1034 "[,\n\t]") | |
1035 nil t) | |
1036 (progn | |
1037 (search-forward "\n\^_" nil 'move) | |
1038 (beginning-of-line) | |
1039 (insert "\n")) | |
1040 ;; If none exists, add one. | |
1041 (goto-char (point-max)) | |
1042 (insert "\^_\nFile: dir\tNode: " nodename "\n\n* Menu:\n\n")) | |
1043 ;; Merge the text from the other buffer's menu | |
1044 ;; into the menu in the like-named node in the main buffer. | |
1045 (apply 'insert-buffer-substring (cdr (car nodes)))) | |
1046 (setq nodes (cdr nodes))) | |
1047 ;; Kill all the buffers we just made. | |
1048 (while buffers | |
1049 (kill-buffer (car buffers)) | |
1050 (setq buffers (cdr buffers))) | |
1051 (while lbuffers | |
1052 (kill-buffer (car lbuffers)) | |
1053 (setq lbuffers (cdr lbuffers))) | |
1054 (message "Composing main Info directory...done")) | |
1055 (setq Info-dir-contents (buffer-string))) | |
1232 | 1056 (setq default-directory (file-name-as-directory Info-dir-contents-directory)) |
3693 | 1057 (setq buffer-file-name (caar Info-dir-file-attributes) |
1058 buffer-file-truename (file-truename buffer-file-name))) | |
428 | 1059 |
444 | 1060 (defmacro Info-directory-files (dir-file &optional all full nosort files-only) |
1061 "Return a list of Info files living in the same directory as DIR-FILE. | |
1062 This list actually contains the files living in this directory, except for | |
1063 the dir file itself and the secondary info files (foo-1 foo-2 etc). | |
1064 | |
1065 If the optional argument ALL is non nil, the secondary info files are also | |
1066 included in the list. | |
1067 | |
1068 Please refer to the function `directory-files' for the meaning of the other | |
1069 optional arguments." | |
1070 `(let* ((dir (file-name-directory ,dir-file)) | |
1071 (all-files (remove ,dir-file (directory-files dir ',full nil ',nosort | |
1072 ',files-only)))) | |
1073 (setq all-files | |
1074 (if ,full | |
1075 (remove (concat dir ".") | |
1076 (remove (concat dir "..") all-files)) | |
1077 (remove "." | |
1078 (remove ".." all-files)))) | |
1079 (if ,all | |
1080 all-files | |
1081 (let ((suff-match | |
1082 (concat "-[0-9]+\\(" | |
1083 ;; Extract all known compression suffixes from | |
1084 ;; Info-suffix-list. These suffixes can typically be | |
1085 ;; found in entries of the form `.info.something'. | |
1086 (let ((suff-list Info-suffix-list) | |
1087 suff regexp) | |
1088 (while (setq suff (pop suff-list)) | |
1089 (and (string-match "^\\.info" (car suff)) | |
1090 (setq regexp (concat regexp | |
1091 (regexp-quote | |
1092 (substring | |
1093 (car suff) 5)) | |
1094 (and suff-list "\\|"))))) | |
1095 regexp) | |
1096 "\\)?$")) | |
1097 info-files file) | |
1098 (while (setq file (pop all-files)) | |
1099 (or (string-match suff-match file) | |
1100 (push file info-files))) | |
1101 (reverse info-files) | |
1102 )) | |
1103 )) | |
1104 | |
428 | 1105 (defun Info-maybe-update-dir (file) |
1106 "Rebuild dir or localdir according to `Info-auto-generate-directory'." | |
1107 (unless (or (not (file-exists-p (file-name-directory file))) | |
444 | 1108 (null (Info-directory-files file 'all))) |
428 | 1109 (if (not (find-buffer-visiting file)) |
1110 (if (not (file-exists-p file)) | |
747 | 1111 (if (or (memq Info-auto-generate-directory |
1112 '(always if-missing if-outdated))) | |
428 | 1113 (Info-build-dir-anew (file-name-directory file))) |
1114 (if (or (eq Info-auto-generate-directory 'always) | |
1115 (and (eq Info-auto-generate-directory 'if-outdated) | |
1116 (Info-dir-outdated-p file))) | |
1117 (Info-rebuild-dir file)))))) | |
1118 | |
1119 ;; Record which *.info files are newer than the dir file | |
1120 (defvar Info-dir-newer-info-files nil) | |
1121 | |
1122 (defun Info-dir-outdated-p (file) | |
1123 "Return non-nil if dir or localdir is outdated. | |
1124 dir or localdir are outdated when an info file in the same | |
1125 directory has been modified more recently." | |
1126 (let ((dir-mod-time (nth 5 (file-attributes file))) | |
444 | 1127 f-mod-time newer) |
428 | 1128 (setq Info-dir-newer-info-files nil) |
5369
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1129 (mapc |
428 | 1130 #'(lambda (f) |
1131 (prog2 | |
1132 (setq f-mod-time (nth 5 (file-attributes f))) | |
1133 (setq newer (or (> (car f-mod-time) (car dir-mod-time)) | |
1134 (and (= (car f-mod-time) (car dir-mod-time)) | |
444 | 1135 (> (car (cdr f-mod-time)) |
1136 (car (cdr dir-mod-time)))))) | |
1137 (if (and (file-readable-p f) newer) | |
442 | 1138 (setq Info-dir-newer-info-files |
428 | 1139 (cons f Info-dir-newer-info-files))))) |
444 | 1140 (Info-directory-files file nil 'fullname 'nosort t)) |
428 | 1141 Info-dir-newer-info-files)) |
1142 | |
1143 (defun Info-extract-dir-entry-from (file) | |
1144 "Extract the dir entry from the info FILE. | |
1145 The dir entry is delimited by the markers `START-INFO-DIR-ENTRY' | |
444 | 1146 and `END-INFO-DIR-ENTRY'." |
428 | 1147 (save-excursion |
1148 (set-buffer (get-buffer-create " *Info-tmp*")) | |
1149 (when (file-readable-p file) | |
1150 (insert-file-contents file nil nil nil t) | |
1151 (goto-char (point-min)) | |
1152 (let (beg) | |
1153 (unless (null (re-search-forward "^START-INFO-DIR-ENTRY" nil t)) | |
1154 (forward-line 1) | |
1155 (setq beg (point)) | |
1156 (unless (null (re-search-forward "^END-INFO-DIR-ENTRY" nil t)) | |
1157 (goto-char (match-beginning 0)) | |
1158 (car (Info-parse-dir-entries beg (point))))))))) | |
1159 | |
444 | 1160 ;; Parse dir entries contained between START and END into a list of the form |
428 | 1161 ;; (filename topic node (description-line-1 description-line-2 ...)) |
444 | 1162 (defun Info-parse-dir-entries (start end) |
428 | 1163 (let (entry entries) |
1164 (save-excursion | |
1165 (save-restriction | |
444 | 1166 (narrow-to-region start end) |
1167 (goto-char start) | |
1168 (while (re-search-forward | |
1169 "^\\* \\([^:]+\\):\\([ \t]*(\\([^)]*\\))\\w*\\.\\|:\\)" nil t) | |
428 | 1170 (setq entry (list (match-string 2) |
1171 (match-string 1) | |
1172 (downcase (or (match-string 3) | |
1173 (match-string 1))))) | |
442 | 1174 (setq entry |
1175 (cons (nreverse | |
1176 (cdr | |
1177 (nreverse | |
1178 (split-string | |
1179 (buffer-substring | |
428 | 1180 (re-search-forward "[ \t]*" nil t) |
1181 (or (and (re-search-forward "^[^ \t]" nil t) | |
1182 (goto-char (match-beginning 0))) | |
1183 (point-max))) | |
1184 "[ \t]*\n[ \t]*")))) | |
1185 entry)) | |
1186 (setq entries (cons (nreverse entry) entries))))) | |
1187 (nreverse entries))) | |
1188 | |
1189 (defun Info-dump-dir-entries (entries) | |
1190 (let ((tab-width 8) | |
1191 (description-col 0) | |
1192 len) | |
5369
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1193 (mapc #'(lambda (e) |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1194 (setq e (cdr e)) ; Drop filename |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1195 (setq len (length (concat (car e) |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1196 (car (cdr e))))) |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1197 (if (> len description-col) |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1198 (setq description-col len))) |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1199 entries) |
442 | 1200 (setq description-col (+ 5 description-col)) |
5369
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1201 (mapc #'(lambda (e) |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1202 (setq e (cdr e)) ; Drop filename |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1203 (insert "* " (car e) ":" (car (cdr e))) |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1204 (setq e (car (cdr (cdr e)))) |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1205 (while e |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1206 (indent-to-column description-col) |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1207 (insert (car e) "\n") |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1208 (setq e (cdr e)))) |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1209 entries) |
428 | 1210 (insert "\n"))) |
1211 | |
1212 | |
1213 (defun Info-build-dir-anew (directory) | |
1214 "Build info directory information for DIRECTORY. | |
442 | 1215 The generated directory listing may be saved to a `dir' according |
444 | 1216 to the value of `Info-save-auto-generated-dir'." |
428 | 1217 (save-excursion |
1218 (let* ((dirfile (expand-file-name "dir" directory)) | |
1219 (to-temp (or (null Info-save-auto-generated-dir) | |
1220 (eq Info-save-auto-generated-dir 'never) | |
1221 (and (not (file-writable-p dirfile)) | |
444 | 1222 (message "File not writable %s. Using temporary." |
1223 dirfile)))) | |
1224 (info-files (Info-directory-files dirfile nil 'fullname nil t))) | |
428 | 1225 (if to-temp |
1226 (message "Creating temporary dir in %s..." directory) | |
1227 (message "Creating %s..." dirfile)) | |
1228 (set-buffer (find-file-noselect dirfile t)) | |
1229 (setq buffer-read-only nil) | |
1230 (erase-buffer) | |
444 | 1231 (insert Info-dir-prologue "Info files in " directory ":\n\n") |
442 | 1232 (Info-dump-dir-entries |
1233 (mapcar | |
428 | 1234 #'(lambda (f) |
1235 (or (Info-extract-dir-entry-from f) | |
1236 (list 'dummy | |
444 | 1237 (progn (string-match "\\([^.]*\\)\\(\\..*\\)?$" |
1238 (file-name-nondirectory f)) | |
1239 (capitalize | |
1240 (match-string 1 (file-name-nondirectory f)))) | |
428 | 1241 ":" |
1242 (list Info-no-description-string)))) | |
1243 info-files)) | |
1244 (if to-temp | |
1245 (set-buffer-modified-p nil) | |
1246 (save-buffer)) | |
1247 (if to-temp | |
1248 (message "Creating temporary dir in %s...done" directory) | |
1249 (message "Creating %s...done" dirfile))))) | |
1250 | |
1251 | |
1252 (defun Info-rebuild-dir (file) | |
1253 "Build info directory information in the directory of dir FILE. | |
442 | 1254 Description of info files are merged from the info files in the |
428 | 1255 directory and the contents of FILE with the description in info files |
442 | 1256 taking precedence over descriptions in FILE. |
1257 The generated directory listing may be saved to a `dir' according to | |
444 | 1258 the value of `Info-save-auto-generated-dir'." |
428 | 1259 (save-excursion |
1260 (save-restriction | |
1261 (let (dir-section-contents dir-full-contents | |
1262 dir-entry | |
1263 file-dir-entry | |
1264 mark next-section | |
1265 not-first-section | |
442 | 1266 (to-temp |
428 | 1267 (or (null Info-save-auto-generated-dir) |
1268 (eq Info-save-auto-generated-dir 'never) | |
1269 (and (eq Info-save-auto-generated-dir 'always) | |
1270 (not (file-writable-p file)) | |
1271 (message "File not writable %s. Using temporary." file)) | |
1272 (and (eq Info-save-auto-generated-dir 'conservative) | |
1273 (or (and (not (file-writable-p file)) | |
444 | 1274 (message |
1275 "File not writable %s. Using temporary." file)) | |
442 | 1276 (not (y-or-n-p |
1277 (message "%s is outdated. Overwrite ? " | |
428 | 1278 file)))))))) |
1279 (set-buffer (find-file-noselect file t)) | |
1280 (setq buffer-read-only nil) | |
1281 (if to-temp | |
1282 (message "Rebuilding temporary %s..." file) | |
1283 (message "Rebuilding %s..." file)) | |
1284 (catch 'done | |
1285 (setq buffer-read-only nil) | |
1286 (goto-char (point-min)) | |
1287 (unless (and (search-forward "\^_") | |
1288 (re-search-forward "^\\* Menu:.*$" nil t) | |
1289 (setq mark (and (re-search-forward "^\\* " nil t) | |
1290 (match-beginning 0)))) | |
1291 (throw 'done nil)) | |
1292 (setq dir-full-contents (Info-parse-dir-entries mark (point-max))) | |
444 | 1293 (setq next-section (or (and (re-search-forward "^[^* \t].*:[ \t]*$" |
1294 nil t) | |
428 | 1295 (match-beginning 0)) |
1296 (point-max))) | |
1297 (while next-section | |
1298 (narrow-to-region mark next-section) | |
444 | 1299 (setq dir-section-contents (nreverse (Info-parse-dir-entries |
1300 (point-min) (point-max)))) | |
5369
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1301 (mapc |
428 | 1302 #'(lambda (file) |
1303 (setq dir-entry (assoc (downcase | |
1304 (file-name-sans-extension | |
1305 (file-name-nondirectory file))) | |
1306 dir-section-contents) | |
1307 file-dir-entry (Info-extract-dir-entry-from file)) | |
1308 (if dir-entry | |
1309 (if file-dir-entry | |
444 | 1310 ;; A dir entry in the info file takes precedence over |
1311 ;; an existing entry in the dir file | |
428 | 1312 (setcdr dir-entry (cdr file-dir-entry))) |
1313 (unless (or not-first-section | |
1314 (assoc (downcase | |
1315 (file-name-sans-extension | |
1316 (file-name-nondirectory file))) | |
1317 dir-full-contents)) | |
1318 (if file-dir-entry | |
444 | 1319 (setq dir-section-contents |
1320 (cons file-dir-entry dir-section-contents)) | |
442 | 1321 (setq dir-section-contents |
428 | 1322 (cons (list 'dummy |
1323 (capitalize (file-name-sans-extension | |
444 | 1324 (file-name-nondirectory |
1325 file))) | |
428 | 1326 ":" |
442 | 1327 (list Info-no-description-string)) |
428 | 1328 dir-section-contents)))))) |
1329 Info-dir-newer-info-files) | |
1330 (delete-region (point-min) (point-max)) | |
1331 (Info-dump-dir-entries (nreverse dir-section-contents)) | |
1332 (widen) | |
1333 (if (= next-section (point-max)) | |
1334 (setq next-section nil) | |
1335 (or (setq mark (and (re-search-forward "^\\* " nil t) | |
1336 (match-beginning 0))) | |
1337 (throw 'done nil)) | |
444 | 1338 (setq next-section (or (and (re-search-forward |
1339 "^[^* \t].*:[ \t]*$" nil t) | |
428 | 1340 (match-beginning 0)) |
1341 (point-max)))) | |
1342 (setq not-first-section t))) | |
1343 (if to-temp | |
1344 (progn | |
1345 (set-buffer-modified-p nil) | |
1346 (message "Rebuilding temporary %s...done" file)) | |
1347 (save-buffer) | |
1348 (message "Rebuilding %s...done" file)))))) | |
1349 | |
442 | 1350 ;;;###autoload |
428 | 1351 (defun Info-batch-rebuild-dir () |
444 | 1352 "(Re)build `dir' files in the directories remaining on the command line. |
1353 Use this from the command line, with `-batch', it won't work in an | |
1354 interactive XEmacs. | |
1355 | |
1356 Each file is processed even if an error occurred previously. For example, | |
1357 invoke \"xemacs -batch -f Info-batch-rebuild-dir /usr/local/info\"." | |
428 | 1358 ;; command-line-args-left is what is left of the command line (from |
1359 ;; startup.el) | |
1360 (defvar command-line-args-left) ; Avoid 'free variable' warning | |
1361 (if (not noninteractive) | |
1362 (error "`Info-batch-rebuild-dir' is to be used only with -batch")) | |
1363 (let ((Info-save-auto-generated-dir 'always) | |
1364 dir localdir) | |
1365 (while command-line-args-left | |
1366 (if (not (file-directory-p (car command-line-args-left))) | |
1367 (message "Warning: Skipped %s. Not a directory." | |
1368 (car command-line-args-left)) | |
1369 (setq dir (expand-file-name "dir" (car command-line-args-left))) | |
444 | 1370 (setq localdir (expand-file-name "localdir" |
1371 (car command-line-args-left))) | |
442 | 1372 (cond |
428 | 1373 ((file-exists-p dir) |
1374 (Info-rebuild-dir dir)) | |
1375 ((file-exists-p localdir) | |
1376 (Info-rebuild-dir localdir)) | |
1377 (t | |
1378 (Info-build-dir-anew (car command-line-args-left))))) | |
1379 (setq command-line-args-left (cdr command-line-args-left))) | |
1380 (message "Done") | |
1381 (kill-emacs 0))) | |
1382 | |
1383 (defun Info-history-add (file node point) | |
1384 (if Info-keeping-history | |
1385 (let* ((name (format "(%s)%s" (Info-file-name-only file) node)) | |
1386 (found (assoc name Info-history))) | |
1387 (if found | |
5652
cc6f0266bc36
Avoid #'delq in core Lisp, for the sake of style, a very slightly smaller binary
Aidan Kehoe <kehoea@parhasard.net>
parents:
5567
diff
changeset
|
1388 (setq Info-history (delete* found Info-history))) |
428 | 1389 (setq Info-history (cons (list name (- point (point-min)) |
1390 (and (eq (window-buffer) | |
1391 (current-buffer)) | |
1392 (- (window-start) (point-min)))) | |
1393 Info-history))))) | |
1394 | |
1395 (defun Info-file-name-only (file) | |
1396 (let ((dir (file-name-directory file)) | |
1397 (p Info-directory-list)) | |
1398 (while (and p (not (equal (car p) dir))) | |
1399 (setq p (cdr p))) | |
1400 (if p (file-name-nondirectory file) file))) | |
1401 | |
1402 (defun Info-read-subfile (nodepos) | |
1403 (let (lastfilepos | |
1404 lastfilename) | |
442 | 1405 (save-excursion |
1406 (set-buffer (marker-buffer Info-tag-table-marker)) | |
1407 (goto-char (point-min)) | |
1408 (search-forward "\n\^_") | |
1409 (forward-line 2) | |
1410 (catch 'foo | |
1411 (while (not (looking-at "\^_")) | |
1412 (if (not (eolp)) | |
444 | 1413 (let ((start (point)) |
442 | 1414 thisfilepos thisfilename) |
1415 (search-forward ": ") | |
444 | 1416 (setq thisfilename (buffer-substring start (- (point) 2))) |
442 | 1417 (setq thisfilepos (read (current-buffer))) |
1418 ;; read in version 19 stops at the end of number. | |
1419 ;; Advance to the next line. | |
1420 (if (eolp) | |
1421 (forward-line 1)) | |
1422 (if (> thisfilepos nodepos) | |
1423 (throw 'foo t)) | |
1424 (setq lastfilename thisfilename) | |
1425 (setq lastfilepos thisfilepos)) | |
1426 (throw 'foo t))))) | |
428 | 1427 (or (equal Info-current-subfile lastfilename) |
1428 (let ((buffer-read-only nil)) | |
3693 | 1429 (setq buffer-file-name nil |
1430 buffer-file-truename nil) | |
428 | 1431 (widen) |
1432 (erase-buffer) | |
1433 (Info-insert-file-contents (Info-suffixed-file | |
1434 (expand-file-name lastfilename | |
1435 (file-name-directory | |
444 | 1436 Info-current-file)) |
1437 'exact) | |
428 | 1438 t) |
1439 (set-buffer-modified-p nil) | |
1440 (setq Info-current-subfile lastfilename))) | |
1441 (goto-char (point-min)) | |
1442 (search-forward "\n\^_") | |
1443 (+ (- nodepos lastfilepos) (point)))) | |
1444 | |
444 | 1445 (defun Info-all-case-regexp (str) |
1446 (let ((regexp "") | |
1447 (len (length str)) | |
1448 (i 0) | |
1449 c) | |
1450 (while (< i len) | |
1451 (setq c (aref str i)) | |
1452 (cond ((or (and (>= c ?A) (<= c ?Z)) | |
1453 (and (>= c ?a) (<= c ?z))) | |
1454 (setq regexp (concat regexp | |
1455 "[" | |
1456 (char-to-string (downcase c)) | |
1457 "\\|" | |
1458 (char-to-string (upcase c)) | |
1459 "]"))) | |
1460 (t | |
1461 (setq regexp (concat regexp (char-to-string c))))) | |
1462 (setq i (1+ i))) | |
1463 regexp)) | |
1464 | |
1465 (defun Info-suffixed-file (name &optional exact) | |
1466 "Look for an info file named NAME. This function tries to be smart in | |
1467 finding the file corresponding to NAME: if it doesn't exist, several | |
1468 variants are looked for, notably by appending suffixes from | |
1469 `Info-suffix-list' and by trying to change the characters case in NAME. | |
1470 | |
1471 The optional argument EXACT prevents this function from trying different case | |
1472 versions of NAME. Only the suffixes are tried." | |
1473 (catch 'found | |
1474 ;; First, try NAME alone: | |
1475 (and (file-regular-p name) (throw 'found name)) | |
1476 ;; Then, try different variants | |
1477 (let ((suff-match (concat "\\(" | |
1478 (let ((suff-list Info-suffix-list) | |
1479 suff regexp) | |
1480 (while (setq suff (pop suff-list)) | |
1481 (setq regexp | |
1482 (concat regexp | |
1483 (regexp-quote (car suff)) | |
1484 (and suff-list "\\|")))) | |
1485 regexp) | |
1486 "\\)?$")) | |
1487 (dir (file-name-directory name)) | |
1488 file files) | |
1489 (setq name (file-name-nondirectory name)) | |
1490 (setq files | |
793 | 1491 (with-trapping-errors ;; protect against invalid directory |
1492 :operation (format "directory `%s'" dir) | |
1493 :class 'info | |
1494 :error-form nil | |
1495 :no-backtrace t | |
1496 ;; First, try NAME[.<suffix>] | |
1497 (append | |
1498 (directory-files dir 'fullname | |
1499 (concat "^" (regexp-quote name) suff-match) | |
1500 nil t) | |
1501 (if exact | |
1502 nil | |
5384
3889ef128488
Fix misspelled words, and some grammar, across the entire source tree.
Jerry James <james@xemacs.org>
parents:
5369
diff
changeset
|
1503 ;; Then, try to match the name independently of the |
793 | 1504 ;; characters case. |
444 | 1505 (directory-files dir 'fullname |
793 | 1506 (Info-all-case-regexp |
1507 (concat "^" | |
1508 (regexp-quote name) | |
1509 suff-match)) | |
1510 nil t))))) | |
444 | 1511 (while (setq file (pop files)) |
1512 (and (file-regular-p file) | |
1513 (throw 'found file))) | |
1514 ))) | |
428 | 1515 |
1516 (defun Info-insert-file-contents (file &optional visit) | |
1517 (setq file (expand-file-name file default-directory)) | |
444 | 1518 (let ((suff Info-suffix-list) |
1519 len) | |
1520 (while (and suff | |
1521 (setq len (length (car (car suff)))) | |
1522 (or (<= (length file) len) | |
1523 (not (or | |
1524 (equal (substring file (- len)) | |
1525 (car (car suff))) | |
1526 (equal (substring file (- len)) | |
1527 (upcase (car (car suff))))) | |
1528 ))) | |
428 | 1529 (setq suff (cdr suff))) |
1530 (if (stringp (cdr (car suff))) | |
5882
bbe4146603db
Reduce regexp usage, now CL-oriented non-regexp code available, core Lisp
Aidan Kehoe <kehoea@parhasard.net>
parents:
5652
diff
changeset
|
1531 (let ((command (if (search "%s" (cdr (car suff))) |
428 | 1532 (format (cdr (car suff)) file) |
1533 (concat (cdr (car suff)) " < " file)))) | |
1534 (message "%s..." command) | |
1870 | 1535 (call-process shell-file-name nil t nil shell-command-switch command) |
428 | 1536 (message "") |
1537 (when visit | |
3693 | 1538 (setq buffer-file-name file |
1539 buffer-file-truename (file-truename buffer-file-name)) | |
428 | 1540 (set-buffer-modified-p nil) |
1541 (clear-visited-file-modtime))) | |
1542 (insert-file-contents file visit)))) | |
1543 | |
1544 (defun Info-select-node () | |
1545 "Select the node that point is in, after using `g *' to select whole file." | |
1546 (interactive) | |
1547 (widen) | |
1548 (save-excursion | |
1549 ;; Find beginning of node. | |
1550 (search-backward "\n\^_") | |
1551 (forward-line 2) | |
1552 ;; Get nodename spelled as it is in the node. | |
1553 (re-search-forward "Node:[ \t]*") | |
1554 (setq Info-current-node | |
1555 (buffer-substring (point) | |
1556 (progn | |
1557 (skip-chars-forward "^,\t\n") | |
1558 (point)))) | |
1559 (Info-set-mode-line) | |
1560 ;; Find the end of it, and narrow. | |
1561 (beginning-of-line) | |
1562 (let (active-expression) | |
1563 (narrow-to-region (point) | |
1564 (if (re-search-forward "\n[\^_\f]" nil t) | |
1565 (prog1 | |
1566 (1- (point)) | |
1567 (if (looking-at "[\n\^_\f]*execute: ") | |
1568 (progn | |
1569 (goto-char (match-end 0)) | |
1570 (setq active-expression | |
1571 (read (current-buffer)))))) | |
1572 (point-max))) | |
1573 (or (equal Info-footnote-tag "Note") | |
1574 (progn | |
1575 (goto-char (point-min)) | |
1576 (let ((buffer-read-only nil) | |
1577 (bufmod (buffer-modified-p)) | |
1578 (case-fold-search t)) | |
1579 (while (re-search-forward "\\*[Nn]ote\\([ \n]\\)" nil t) | |
1580 (replace-match (concat "*" Info-footnote-tag "\ "))) | |
1581 (set-buffer-modified-p bufmod)))) | |
1582 (Info-reannotate-node) | |
1583 ;; XEmacs: remove v19 test | |
1584 (and Info-fontify | |
1585 (Info-fontify-node)) | |
1586 (run-hooks 'Info-select-hook) | |
1587 (if Info-enable-active-nodes (eval active-expression))))) | |
1588 | |
1589 (defun Info-set-mode-line () | |
1590 (setq modeline-buffer-identification | |
1591 (list (cons modeline-buffer-id-left-extent "Info: ") | |
1592 (cons modeline-buffer-id-right-extent | |
1593 (concat | |
1594 "(" | |
1595 (if Info-current-file | |
444 | 1596 (let ((name (file-name-nondirectory |
1597 Info-current-file))) | |
1598 (if (string-match "^\\([^.]*\\)\\..*$" name) | |
1599 (match-string 1 name) | |
428 | 1600 name)) |
1601 "") | |
1602 ")" | |
1603 (or Info-current-node "")))))) | |
771 | 1604 |
428 | 1605 |
1606 ;; Go to an info node specified with a filename-and-nodename string | |
1607 ;; of the sort that is found in pointers in nodes. | |
1608 | |
1609 ;;;###autoload | |
1610 (defun Info-goto-node (nodename &optional no-going-back tryfile) | |
1611 "Go to info node named NAME. Give just NODENAME or (FILENAME)NODENAME. | |
1612 Actually, the following interpretations of NAME are tried in order: | |
1613 (FILENAME)NODENAME | |
1614 (FILENAME) (using Top node) | |
1615 NODENAME (in current file) | |
1616 TAGNAME (see below) | |
1617 FILENAME (using Top node) | |
1618 where TAGNAME is a string that appears in quotes: \"TAGNAME\", in an | |
1619 annotation for any node of any file. (See `a' and `x' commands.)" | |
1620 (interactive (list (Info-read-node-name "Goto node, file or tag: ") | |
1621 nil t)) | |
1622 (let (filename) | |
1623 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)" | |
1624 nodename) | |
1625 (setq filename (if (= (match-beginning 1) (match-end 1)) | |
1626 "" | |
1627 (substring nodename (match-beginning 2) (match-end 2))) | |
1628 nodename (substring nodename (match-beginning 3) (match-end 3))) | |
1629 (let ((trim (string-match "\\s *\\'" filename))) | |
1630 (if trim (setq filename (substring filename 0 trim)))) | |
1631 (let ((trim (string-match "\\s *\\'" nodename))) | |
1632 (if trim (setq nodename (substring nodename 0 trim)))) | |
1633 (Info-find-node (if (equal filename "") nil filename) | |
1634 (if (equal nodename "") "Top" nodename) | |
1635 no-going-back (and tryfile (equal filename ""))))) | |
1636 | |
1637 (defun Info-goto-bookmark () | |
1638 (interactive) | |
1639 (let ((completion-ignore-case nil) | |
1640 (tag (completing-read "Goto tag: " | |
1641 (Info-build-annotation-completions) | |
1642 nil t nil | |
1643 'Info-minibuffer-history))) | |
1644 (or (equal tag "") (Info-find-node nil (format "<<%s>>" tag))))) | |
1645 | |
1646 ;;;###autoload | |
438 | 1647 (defun Info-visit-file (file) |
428 | 1648 "Directly visit an info file." |
438 | 1649 (interactive "fVisit Info file: ") |
1650 (Info-find-node (expand-file-name file) "Top")) | |
428 | 1651 |
1652 (defun Info-restore-point (&optional always) | |
1653 "Restore point to same location it had last time we were in this node." | |
1654 (interactive "p") | |
1655 (if (or Info-restoring-point always) | |
1656 (let* ((name (format "(%s)%s" | |
1657 (Info-file-name-only Info-current-file) | |
1658 Info-current-node)) | |
1659 (p (assoc name Info-history))) | |
1660 (if p (Info-restore-history-entry p))))) | |
1661 | |
1662 (defun Info-restore-history-entry (entry) | |
1663 (goto-char (+ (nth 1 entry) (point-min))) | |
1664 (and (nth 2 entry) | |
1665 (get-buffer-window (current-buffer)) | |
1666 (set-window-start (get-buffer-window (current-buffer)) | |
1667 (+ (nth 2 entry) (point-min))))) | |
1668 | |
438 | 1669 (defvar Info-read-node-completion-table) |
1670 | |
1671 ;; This function is used as the "completion table" while reading a node name. | |
1672 ;; It does completion using the alist in Info-read-node-completion-table | |
1673 ;; unless STRING starts with an open-paren. | |
1674 (defun Info-read-node-name-1 (string predicate code) | |
1675 (let ((no-completion (and (> (length string) 0) (eq (aref string 0) ?\()))) | |
1676 (cond ((eq code nil) | |
1677 (if no-completion | |
1678 string | |
444 | 1679 (try-completion string Info-read-node-completion-table |
1680 predicate))) | |
438 | 1681 ((eq code t) |
1682 (if no-completion | |
1683 nil | |
444 | 1684 (all-completions string Info-read-node-completion-table |
1685 predicate))) | |
438 | 1686 ((eq code 'lambda) |
1687 (if no-completion | |
1688 t | |
1689 (assoc string Info-read-node-completion-table)))))) | |
1690 | |
428 | 1691 (defun Info-read-node-name (prompt &optional default) |
1692 (Info-setup-initial) | |
1693 (let* ((completion-ignore-case t) | |
438 | 1694 (Info-read-node-completion-table (Info-build-node-completions)) |
1695 (nodename (completing-read prompt 'Info-read-node-name-1 | |
1696 nil t nil 'Info-minibuffer-history | |
1697 default))) | |
428 | 1698 (if (equal nodename "") |
1699 (or default | |
1700 (Info-read-node-name prompt)) | |
1701 nodename))) | |
1702 | |
1703 (defun Info-build-annotation-completions () | |
1704 (or Info-current-annotation-completions | |
1705 (save-excursion | |
5652
cc6f0266bc36
Avoid #'delq in core Lisp, for the sake of style, a very slightly smaller binary
Aidan Kehoe <kehoea@parhasard.net>
parents:
5567
diff
changeset
|
1706 (let ((bufs (delete* nil (mapcar 'get-file-buffer |
428 | 1707 Info-annotations-path))) |
1708 (compl nil)) | |
1709 (while bufs | |
1710 (set-buffer (car bufs)) | |
1711 (goto-char (point-min)) | |
1712 (while (re-search-forward "<<\\(.*\\)>>" nil t) | |
1713 (setq compl (cons (list (buffer-substring (match-beginning 1) | |
1714 (match-end 1))) | |
1715 compl))) | |
1716 (setq bufs (cdr bufs))) | |
1717 (setq Info-current-annotation-completions compl))))) | |
1718 | |
1719 (defun Info-build-node-completions () | |
1720 (or Info-current-file-completions | |
442 | 1721 (let ((m Info-tag-table-marker) |
1722 (compl (Info-build-annotation-completions))) | |
428 | 1723 (save-excursion |
1724 (save-restriction | |
1725 (widen) | |
1726 (if (marker-buffer Info-tag-table-marker) | |
1727 (progn | |
1728 (set-buffer (marker-buffer Info-tag-table-marker)) | |
442 | 1729 (goto-char m) |
428 | 1730 (while (re-search-forward "\nNode: \\(.*\\)\177" nil t) |
1731 (setq compl | |
1732 (cons (list (buffer-substring (match-beginning 1) | |
1733 (match-end 1))) | |
1734 compl)))) | |
1735 (goto-char (point-min)) | |
1736 (while (search-forward "\n\^_" nil t) | |
1737 (forward-line 1) | |
444 | 1738 (let ((start (point))) |
428 | 1739 (forward-line 1) |
1740 (if (re-search-backward "Node: *\\([^,\n]*\\) *[,\n\t]" | |
444 | 1741 start t) |
442 | 1742 (setq compl |
428 | 1743 (cons (list (buffer-substring (match-beginning 1) |
1744 (match-end 1))) | |
1745 compl)))))))) | |
1746 (setq Info-current-file-completions compl)))) | |
1747 | |
1748 (defvar Info-last-search nil | |
1749 "Default regexp for \\<Info-mode-map>\\[Info-search] command to search for.") | |
1750 | |
1751 | |
1752 ;;;###autoload | |
1753 (defun Info-search (regexp) | |
1754 "Search for REGEXP, starting from point, and select node it's found in." | |
438 | 1755 (interactive (list |
1756 (read-from-minibuffer | |
1757 (if Info-last-search | |
1758 (format "Search (regexp, default %s): " | |
1759 Info-last-search) | |
1760 "Search (regexp): ") | |
1761 nil nil nil nil nil Info-last-search))) | |
1762 (setq Info-last-search regexp) | |
428 | 1763 (with-search-caps-disable-folding regexp t |
1764 (let ((found ()) | |
1765 (onode Info-current-node) | |
1766 (ofile Info-current-file) | |
1767 (opoint (point)) | |
1768 (osubfile Info-current-subfile)) | |
1769 (save-excursion | |
1770 (save-restriction | |
1771 (widen) | |
1772 (if (null Info-current-subfile) | |
1773 (progn (re-search-forward regexp) (setq found (point))) | |
1774 (condition-case nil | |
1775 (progn (re-search-forward regexp) (setq found (point))) | |
1776 (search-failed nil))))) | |
444 | 1777 (if (not found) |
1778 ;; can only happen in subfile case -- else would have erred | |
428 | 1779 (unwind-protect |
1780 (let ((list ())) | |
442 | 1781 (save-excursion |
1782 (set-buffer (marker-buffer Info-tag-table-marker)) | |
1783 (goto-char (point-min)) | |
1784 (search-forward "\n\^_\nIndirect:") | |
1785 (save-restriction | |
1786 (narrow-to-region (point) | |
1787 (progn (search-forward "\n\^_") | |
1788 (1- (point)))) | |
1789 (goto-char (point-min)) | |
1790 (search-forward (concat "\n" osubfile ": ")) | |
1791 (beginning-of-line) | |
1792 (while (not (eobp)) | |
1793 (re-search-forward "\\(^.*\\): [0-9]+$") | |
1794 (goto-char (+ (match-end 1) 2)) | |
1795 (setq list (cons (cons (read (current-buffer)) | |
444 | 1796 (buffer-substring |
1797 (match-beginning 1) | |
1798 (match-end 1))) | |
442 | 1799 list)) |
1800 (goto-char (1+ (match-end 0)))) | |
1801 (setq list (nreverse list) | |
1802 list (cdr list)))) | |
428 | 1803 (while list |
1804 (message "Searching subfile %s..." (cdr (car list))) | |
1805 (Info-read-subfile (car (car list))) | |
1806 (setq list (cdr list)) | |
1807 (goto-char (point-min)) | |
1808 (if (re-search-forward regexp nil t) | |
1809 (setq found (point) list ()))) | |
1810 (if found | |
1811 (message "") | |
1812 (signal 'search-failed (list regexp)))) | |
1813 (if (not found) | |
1814 (progn (Info-read-subfile opoint) | |
1815 (goto-char opoint) | |
1816 (Info-select-node))))) | |
1817 (widen) | |
1818 (goto-char found) | |
1819 (Info-select-node) | |
1820 (or (and (equal onode Info-current-node) | |
1821 (equal ofile Info-current-file)) | |
502 | 1822 (Info-history-add ofile onode opoint)))) |
1823 (message "Found \"%s\" in %s. Press `z' to continue search." | |
1824 regexp Info-current-node) | |
1825 ) | |
1826 | |
1827 (defun Info-search-next () | |
1828 "Repeat search starting from point with last regexp used in `Info-search'." | |
1829 (interactive) | |
1830 (Info-search Info-last-search)) | |
1831 | |
428 | 1832 |
1833 ;; Extract the value of the node-pointer named NAME. | |
442 | 1834 ;; If there is none, use ERRORNAME in the error message; |
428 | 1835 ;; if ERRORNAME is nil, just return nil. |
1836 (defun Info-extract-pointer (name &optional errorname) | |
1837 (save-excursion | |
1838 (goto-char (point-min)) | |
1839 (forward-line 4) | |
1840 (let ((case-fold-search t)) | |
1841 (if (re-search-backward (concat name ":") nil t) | |
1842 (progn | |
1843 (goto-char (match-end 0)) | |
1844 (Info-following-node-name)) | |
1845 (if (eq errorname t) | |
1846 nil | |
1847 (error (concat "Node has no " (capitalize (or errorname name))))))))) | |
1848 | |
1849 ;; Return the node name in the buffer following point. | |
1850 ;; ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp | |
440 | 1851 ;; saying which chars may appear in the node name. |
428 | 1852 (defun Info-following-node-name (&optional allowedchars) |
1853 (skip-chars-forward " \t") | |
1854 (buffer-substring | |
1855 (point) | |
1856 (progn | |
1857 (while (looking-at (concat "[" (or allowedchars "^,\t\n") "]")) | |
1858 (skip-chars-forward (concat (or allowedchars "^,\t\n") "(")) | |
1859 (if (looking-at "(") | |
1860 (skip-chars-forward "^)"))) | |
438 | 1861 (skip-chars-backward " .") |
428 | 1862 (point)))) |
1863 | |
1864 (defun Info-next (&optional n) | |
1865 "Go to the next node of this node. | |
1866 A positive or negative prefix argument moves by multiple nodes." | |
1867 (interactive "p") | |
1868 (or n (setq n 1)) | |
1869 (if (< n 0) | |
1870 (Info-prev (- n)) | |
1871 (while (>= (setq n (1- n)) 0) | |
1872 (Info-goto-node (Info-extract-pointer "next"))))) | |
1873 | |
1874 (defun Info-prev (&optional n) | |
1875 "Go to the previous node of this node. | |
1876 A positive or negative prefix argument moves by multiple nodes." | |
1877 (interactive "p") | |
1878 (or n (setq n 1)) | |
1879 (if (< n 0) | |
1880 (Info-next (- n)) | |
1881 (while (>= (setq n (1- n)) 0) | |
1882 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous"))))) | |
1883 | |
1884 (defun Info-up (&optional n) | |
1885 "Go to the superior node of this node. | |
1886 A positive prefix argument moves up several times." | |
1887 (interactive "p") | |
1888 (or n (setq n 1)) | |
1889 (while (>= (setq n (1- n)) 0) | |
1890 (Info-goto-node (Info-extract-pointer "up"))) | |
1891 (if (interactive-p) (Info-restore-point))) | |
1892 | |
1893 (defun Info-last (&optional n) | |
1894 "Go back to the last node visited. | |
1895 With a prefix argument, go to Nth most recently visited node. History is | |
1896 circular; after oldest node, history comes back around to most recent one. | |
1897 Argument can be negative to go through the circle in the other direction. | |
1898 \(In other words, `l' is like \"undo\" and `C-u - l' is like \"redo\".)" | |
1899 (interactive "p") | |
1900 (or n (setq n 1)) | |
1901 (or Info-history | |
1902 (error "This is the first Info node you looked at")) | |
1903 (let ((len (1+ (length Info-history)))) | |
1904 (setq n (% (+ n (* len 100)) len))) | |
1905 (if (> n 0) | |
1906 (let ((entry (nth (1- n) Info-history))) | |
1907 (Info-history-add Info-current-file Info-current-node (point)) | |
1908 (while (>= (setq n (1- n)) 0) | |
1909 (setq Info-history (nconc (cdr Info-history) | |
1910 (list (car Info-history))))) | |
1911 (setq Info-history (cdr Info-history)) | |
1912 (let ((Info-keeping-history nil)) | |
1913 (Info-goto-node (car entry))) | |
1914 (Info-restore-history-entry entry)))) | |
1915 | |
1916 (defun Info-directory () | |
1917 "Go to the Info directory node." | |
1918 (interactive) | |
1919 (Info-find-node "dir" "top")) | |
1920 | |
1921 (defun Info-follow-reference (footnotename) | |
1922 "Follow cross reference named NAME to the node it refers to. | |
1923 NAME may be an abbreviation of the reference name." | |
1924 (interactive | |
1925 (let ((completion-ignore-case t) | |
1926 completions default (start-point (point)) str i) | |
1927 (save-excursion | |
1928 (goto-char (point-min)) | |
1929 (while (re-search-forward (format "\\*%s[ \n\t]*\\([^:]*\\):" | |
1930 Info-footnote-tag) | |
1931 nil t) | |
1932 (setq str (buffer-substring | |
1933 (match-beginning 1) | |
1934 (1- (point)))) | |
1935 ;; See if this one should be the default. | |
1936 (and (null default) | |
1937 (< (match-beginning 0) start-point) | |
1938 (<= start-point (point)) | |
1939 (setq default t)) | |
1940 (setq i 0) | |
1941 (while (setq i (string-match "[ \n\t]+" str i)) | |
1942 (setq str (concat (substring str 0 i) " " | |
1943 (substring str (match-end 0)))) | |
1944 (setq i (1+ i))) | |
1945 ;; Record as a completion and perhaps as default. | |
1946 (if (eq default t) (setq default str)) | |
1947 (setq completions | |
1948 (cons (cons str nil) | |
1949 completions)))) | |
1950 (if completions | |
1951 (let ((item (completing-read (if default | |
1952 (concat "Follow reference named: (" | |
1953 default ") ") | |
1954 "Follow reference named: ") | |
1955 completions nil t nil | |
438 | 1956 'Info-minibuffer-history |
1957 default))) | |
428 | 1958 (if (and (string= item "") default) |
1959 (list default) | |
1960 (list item))) | |
1961 (error "No cross-references in this node")))) | |
5882
bbe4146603db
Reduce regexp usage, now CL-oriented non-regexp code available, core Lisp
Aidan Kehoe <kehoea@parhasard.net>
parents:
5652
diff
changeset
|
1962 (let (target (i 0) (str (concat "\\*" Info-footnote-tag " " |
bbe4146603db
Reduce regexp usage, now CL-oriented non-regexp code available, core Lisp
Aidan Kehoe <kehoea@parhasard.net>
parents:
5652
diff
changeset
|
1963 (regexp-quote footnotename)))) |
bbe4146603db
Reduce regexp usage, now CL-oriented non-regexp code available, core Lisp
Aidan Kehoe <kehoea@parhasard.net>
parents:
5652
diff
changeset
|
1964 (while (setq i (position ?\ str :start i)) |
428 | 1965 (setq str (concat (substring str 0 i) "\\([ \t\n]+\\)" |
1966 (substring str (1+ i)))) | |
1967 (setq i (+ i 10))) | |
1968 (save-excursion | |
1969 (goto-char (point-min)) | |
1970 (or (re-search-forward str nil t) | |
1971 (error "No cross-reference named %s" footnotename)) | |
1972 (goto-char (match-end 1)) | |
1973 (setq target | |
1974 (Info-extract-menu-node-name "Bad format cross reference" t))) | |
1975 (while (setq i (string-match "[ \t\n]+" target i)) | |
1976 (setq target (concat (substring target 0 i) " " | |
1977 (substring target (match-end 0)))) | |
1978 (setq i (+ i 1))) | |
1979 (Info-goto-node target) | |
1980 (setq Info-in-cross-reference t))) | |
1981 | |
1982 (defun Info-next-reference (n) | |
1983 (interactive "p") | |
1984 (let ((pat (format "\\*%s[ \n\t]*\\([^:]*\\):\\|^\\* .*:\\|<<.*>>" | |
1985 Info-footnote-tag)) | |
1986 (old-pt (point)) | |
1987 wrapped found-nomenu) | |
1988 (while (< n 0) | |
1989 (unless (re-search-backward pat nil t) | |
1990 ;; Don't wrap more than once in a buffer where only the | |
1991 ;; menu references are found. | |
1992 (when (and wrapped (not found-nomenu)) | |
1993 (goto-char old-pt) | |
1994 (error "No cross references in this node")) | |
1995 (setq wrapped t) | |
1996 (goto-char (point-max)) | |
1997 (unless (re-search-backward pat nil t) | |
1998 (goto-char old-pt) | |
1999 (error "No cross references in this node"))) | |
2000 (unless (save-excursion | |
2001 (goto-char (match-beginning 0)) | |
2002 (when (looking-at "\\* Menu:") | |
2003 (decf n))) | |
2004 (setq found-nomenu t)) | |
2005 (incf n)) | |
2006 (while (> n 0) | |
2007 (or (eobp) (forward-char 1)) | |
2008 (unless (re-search-forward pat nil t) | |
2009 (when (and wrapped (not found-nomenu)) | |
2010 (goto-char old-pt) | |
2011 (error "No cross references in this node")) | |
2012 (setq wrapped t) | |
2013 (goto-char (point-min)) | |
2014 (unless (re-search-forward pat nil t) | |
2015 (goto-char old-pt) | |
2016 (error "No cross references in this node"))) | |
2017 (unless (save-excursion | |
2018 (goto-char (match-beginning 0)) | |
2019 (when (looking-at "\\* Menu:") | |
2020 (incf n))) | |
2021 (setq found-nomenu t)) | |
2022 (decf n)) | |
2023 (when (looking-at "\\* Menu:") | |
2024 (error "No cross references in this node")) | |
2025 (goto-char (match-beginning 0)))) | |
2026 | |
2027 (defun Info-prev-reference (n) | |
2028 (interactive "p") | |
2029 (Info-next-reference (- n))) | |
2030 | |
2031 (defun Info-extract-menu-node-name (&optional errmessage multi-line) | |
2032 (skip-chars-forward " \t\n") | |
5882
bbe4146603db
Reduce regexp usage, now CL-oriented non-regexp code available, core Lisp
Aidan Kehoe <kehoea@parhasard.net>
parents:
5652
diff
changeset
|
2033 (let ((start (point)) str) |
428 | 2034 (skip-chars-forward "^:") |
2035 (forward-char 1) | |
2036 (setq str | |
2037 (if (looking-at ":") | |
444 | 2038 (buffer-substring start (1- (point))) |
428 | 2039 (skip-chars-forward " \t\n") |
438 | 2040 ;; Kludge. |
2041 ;; Allow dots in node name not followed by whitespace. | |
2042 (re-search-forward | |
446 | 2043 (concat "\\(([^)]+)[^.," |
438 | 2044 (if multi-line "" "\n") |
2045 "]*\\|\\([^.,\t" | |
2046 (if multi-line "" "\n") | |
2047 ;; We consider dots followed by newline as | |
2048 ;; end of nodename even if multil-line. | |
2049 ;; Also stops at .). It is generated by @pxref. | |
2050 ;; Skips sequential dots. | |
2051 "]\\|\\.+[^ \t\n)]\\)+\\)")) | |
2052 (match-string 1))) | |
5882
bbe4146603db
Reduce regexp usage, now CL-oriented non-regexp code available, core Lisp
Aidan Kehoe <kehoea@parhasard.net>
parents:
5652
diff
changeset
|
2053 (substitute ?\ ?\n str))) |
428 | 2054 |
2055 (defun Info-menu (menu-item) | |
2056 "Go to node for menu item named (or abbreviated) NAME. | |
2057 Completion is allowed, and the menu item point is on is the default." | |
2058 (interactive | |
2059 (let ((completions '()) | |
2060 ;; If point is within a menu item, use that item as the default | |
2061 (default nil) | |
2062 (p (point)) | |
2063 (last nil)) | |
2064 (save-excursion | |
2065 (goto-char (point-min)) | |
2066 (let ((case-fold-search t)) | |
2067 (if (not (search-forward "\n* menu:" nil t)) | |
2068 (error "No menu in this node"))) | |
2069 (while (re-search-forward | |
2070 "\n\\* \\([^:\t\n]*\\):" nil t) | |
2071 (if (and (null default) | |
2072 (prog1 (if last (< last p) nil) | |
2073 (setq last (match-beginning 0))) | |
2074 (<= p last)) | |
2075 (setq default (car (car completions)))) | |
2076 (setq completions (cons (cons (buffer-substring | |
2077 (match-beginning 1) | |
2078 (match-end 1)) | |
2079 (match-beginning 1)) | |
2080 completions))) | |
2081 (if (and (null default) last | |
2082 (< last p) | |
2083 (<= p (progn (end-of-line) (point)))) | |
2084 (setq default (car (car completions))))) | |
2085 (let ((item nil)) | |
2086 (while (null item) | |
2087 (setq item (let ((completion-ignore-case t)) | |
2088 (completing-read (if default | |
2089 (format "Menu item (default %s): " | |
2090 default) | |
2091 "Menu item: ") | |
2092 completions nil t nil | |
438 | 2093 'Info-minibuffer-history |
2094 default))) | |
428 | 2095 ;; we rely on the fact that completing-read accepts an input |
2096 ;; of "" even when the require-match argument is true and "" | |
2097 ;; is not a valid possibility | |
2098 (if (string= item "") | |
2099 (if default | |
2100 (setq item default) | |
2101 ;; ask again | |
2102 (setq item nil)))) | |
2103 (list item)))) | |
2104 ;; there is a problem here in that if several menu items have the same | |
2105 ;; name you can only go to the node of the first with this command. | |
2106 (Info-goto-node (Info-extract-menu-item menu-item) nil t)) | |
442 | 2107 |
428 | 2108 (defun Info-extract-menu-item (menu-item &optional noerror) |
2109 (save-excursion | |
2110 (goto-char (point-min)) | |
2111 (if (let ((case-fold-search t)) | |
2112 (search-forward "\n* menu:" nil t)) | |
2113 (if (or (search-forward (concat "\n* " menu-item ":") nil t) | |
2114 (search-forward (concat "\n* " menu-item) nil t)) | |
2115 (progn | |
2116 (beginning-of-line) | |
2117 (forward-char 2) | |
2118 (Info-extract-menu-node-name)) | |
2119 (and (not noerror) (error "No such item in menu"))) | |
2120 (and (not noerror) (error "No menu in this node"))))) | |
2121 | |
2122 ;; If COUNT is nil, use the last item in the menu. | |
2123 (defun Info-extract-menu-counting (count &optional noerror noindex) | |
2124 (save-excursion | |
2125 (goto-char (point-min)) | |
2126 (if (let ((case-fold-search t)) | |
2127 (and (search-forward "\n* menu:" nil t) | |
2128 (or (not noindex) | |
2129 (not (string-match "\\<Index\\>" Info-current-node))))) | |
2130 (if (search-forward "\n* " nil t count) | |
2131 (progn | |
2132 (or count | |
2133 (while (search-forward "\n* " nil t))) | |
2134 (Info-extract-menu-node-name)) | |
2135 (and (not noerror) (error "Too few items in menu"))) | |
2136 (and (not noerror) (error "No menu in this node"))))) | |
2137 | |
2138 (defun Info-nth-menu-item (n) | |
2139 "Go to the node of the Nth menu item." | |
2140 (interactive "P") | |
2141 (or n (setq n (- last-command-char ?0))) | |
2142 (if (< n 1) (error "Index must be at least 1")) | |
2143 (Info-goto-node (Info-extract-menu-counting n) nil t)) | |
2144 | |
2145 (defun Info-last-menu-item () | |
2146 "Go to the node of the tenth menu item." | |
2147 (interactive) | |
2148 (Info-goto-node (Info-extract-menu-counting nil) nil t)) | |
2149 | |
2150 (defun Info-top () | |
2151 "Go to the Top node of this file." | |
2152 (interactive) | |
2153 (Info-goto-node "Top")) | |
2154 | |
2155 (defun Info-end () | |
2156 "Go to the final node in this file." | |
2157 (interactive) | |
2158 (Info-top) | |
2159 (let ((Info-keeping-history nil) | |
2160 node) | |
2161 (Info-last-menu-item) | |
2162 (while (setq node (or (Info-extract-pointer "next" t) | |
2163 (Info-extract-menu-counting nil t t))) | |
2164 (Info-goto-node node)) | |
2165 (or (equal (Info-extract-pointer "up" t) "Top") | |
2166 (let ((executing-kbd-macro "")) ; suppress messages | |
2167 (condition-case nil | |
2168 (Info-global-next 10000) | |
2169 (error nil)))))) | |
2170 | |
2171 (defun Info-global-next (&optional n) | |
2172 "Go to the next node in this file, traversing node structure as necessary. | |
2173 This works only if the Info file is structured as a hierarchy of nodes. | |
2174 A positive or negative prefix argument moves by multiple nodes." | |
2175 (interactive "p") | |
2176 (or n (setq n 1)) | |
2177 (if (< n 0) | |
2178 (Info-global-prev (- n)) | |
2179 (while (>= (setq n (1- n)) 0) | |
2180 (let (node) | |
2181 (cond ((and (string-match "^Top$" Info-current-node) | |
2182 (setq node (Info-extract-pointer "next" t)) | |
2183 (Info-extract-menu-item node t)) | |
2184 (Info-goto-node node)) | |
2185 ((setq node (Info-extract-menu-counting 1 t t)) | |
2186 (message "Going down...") | |
2187 (Info-goto-node node)) | |
2188 (t | |
2189 (let ((Info-keeping-history Info-keeping-history) | |
2190 (orignode Info-current-node) | |
2191 (ups "")) | |
2192 (while (not (Info-extract-pointer "next" t)) | |
2193 (if (and (setq node (Info-extract-pointer "up" t)) | |
2194 (not (equal node "Top"))) | |
2195 (progn | |
2196 (message "Going%s..." (setq ups (concat ups " up"))) | |
2197 (Info-goto-node node) | |
2198 (setq Info-keeping-history nil)) | |
2199 (if orignode | |
2200 (let ((Info-keeping-history nil)) | |
2201 (Info-goto-node orignode))) | |
2202 (error "Last node in file"))) | |
2203 (Info-next)))))))) | |
2204 | |
2205 (defun Info-page-next (&optional n) | |
2206 "Scroll forward one screenful, or go to next global node. | |
2207 A positive or negative prefix argument moves by multiple screenfuls." | |
2208 (interactive "p") | |
2209 (or n (setq n 1)) | |
2210 (if (< n 0) | |
2211 (Info-page-prev (- n)) | |
2212 (while (>= (setq n (1- n)) 0) | |
2213 (if (pos-visible-in-window-p (point-max)) | |
2214 (progn | |
2215 (Info-global-next) | |
2216 (message "Node: %s" Info-current-node)) | |
2217 (scroll-up))))) | |
2218 | |
2219 (defun Info-scroll-next (arg) | |
2220 (interactive "P") | |
2221 (if Info-auto-advance | |
2222 (if (and (pos-visible-in-window-p (point-max)) | |
2223 (not (eq Info-auto-advance t)) | |
2224 (not (eq last-command this-command))) | |
2225 (message "Hit %s again to go to next node" | |
2226 (if (= last-command-char 0) | |
2227 "mouse button" | |
2228 (key-description (char-to-string last-command-char)))) | |
2229 (Info-page-next) | |
2230 (setq this-command 'Info)) | |
2231 (scroll-up arg))) | |
2232 | |
2233 (defun Info-global-prev (&optional n) | |
2234 "Go to the previous node in this file, traversing structure as necessary. | |
2235 This works only if the Info file is structured as a hierarchy of nodes. | |
2236 A positive or negative prefix argument moves by multiple nodes." | |
2237 (interactive "p") | |
2238 (or n (setq n 1)) | |
2239 (if (< n 0) | |
2240 (Info-global-next (- n)) | |
2241 (while (>= (setq n (1- n)) 0) | |
2242 (let ((upnode (Info-extract-pointer "up" t)) | |
2243 (prevnode (Info-extract-pointer "prev[ious]*" t))) | |
2244 (if (or (not prevnode) | |
2245 (equal prevnode upnode)) | |
2246 (if (string-match "^Top$" Info-current-node) | |
2247 (error "First node in file") | |
2248 (message "Going up...") | |
2249 (Info-up)) | |
2250 (Info-goto-node prevnode) | |
2251 (let ((downs "") | |
2252 (Info-keeping-history nil) | |
2253 node) | |
2254 (while (setq node (Info-extract-menu-counting nil t t)) | |
2255 (message "Going%s..." (setq downs (concat downs " down"))) | |
2256 (Info-goto-node node)))))))) | |
2257 | |
2258 (defun Info-page-prev (&optional n) | |
2259 "Scroll backward one screenful, or go to previous global node. | |
2260 A positive or negative prefix argument moves by multiple screenfuls." | |
2261 (interactive "p") | |
2262 (or n (setq n 1)) | |
2263 (if (< n 0) | |
2264 (Info-page-next (- n)) | |
2265 (while (>= (setq n (1- n)) 0) | |
2266 (if (pos-visible-in-window-p (point-min)) | |
2267 (progn | |
2268 (Info-global-prev) | |
2269 (message "Node: %s" Info-current-node) | |
2270 (goto-char (point-max)) | |
2271 (recenter -1) | |
2272 (move-to-window-line 0)) | |
2273 (scroll-down))))) | |
2274 | |
2275 (defun Info-scroll-prev (arg) | |
2276 (interactive "P") | |
2277 (if Info-auto-advance | |
2278 (if (and (pos-visible-in-window-p (point-min)) | |
2279 (not (eq Info-auto-advance t)) | |
2280 (not (eq last-command this-command))) | |
2281 (message "Hit %s again to go to previous node" | |
2282 (if (mouse-event-p last-command-event) | |
2283 "mouse button" | |
2284 (key-description (event-key last-command-event)))) | |
2285 (Info-page-prev) | |
2286 (setq this-command 'Info)) | |
2287 (scroll-down arg))) | |
502 | 2288 |
428 | 2289 |
502 | 2290 (defun Info-find-index-alternatives (topic) |
428 | 2291 (let ((pattern (format "\n\\* \\([^\n:]*%s[^\n:]*\\):[ \t]*%s" |
2292 (regexp-quote topic) | |
830 | 2293 "\\(.*\\)\\.[ \t]*\\([0-9]*\\)$")) |
428 | 2294 node) |
2295 (message "Searching index for `%s'..." topic) | |
2296 (Info-goto-node "Top") | |
2297 (let ((case-fold-search t)) | |
2298 (or (search-forward "\n* menu:" nil t) | |
2299 (error "No index")) | |
2300 (or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t) | |
2301 (error "No index"))) | |
2302 (goto-char (match-beginning 1)) | |
2303 (let ((Info-keeping-history nil) | |
2304 (Info-fontify (and Info-fontify (equal topic "")))) | |
2305 (Info-goto-node (Info-extract-menu-node-name))) | |
2306 (or (equal topic "") | |
2307 (let ((matches nil) | |
502 | 2308 (Info-keeping-history nil)) |
428 | 2309 (while |
2310 (progn | |
2311 (goto-char (point-min)) | |
2312 (while (re-search-forward pattern nil t) | |
2313 (setq matches | |
2314 (cons (list (buffer-substring (match-beginning 1) | |
2315 (match-end 1)) | |
771 | 2316 (format "(%s)%s" Info-current-file |
2317 (buffer-substring | |
2318 (match-beginning 2) | |
2319 (match-end 2))) | |
428 | 2320 Info-current-node |
2321 (string-to-int (concat "0" | |
2322 (buffer-substring | |
2323 (match-beginning 3) | |
2324 (match-end 3))))) | |
2325 matches))) | |
2326 (and (setq node (Info-extract-pointer "next" t)) | |
2327 (string-match "\\<Index\\>" node))) | |
2328 (let ((Info-fontify nil)) | |
2329 (Info-goto-node node))) | |
502 | 2330 (nreverse matches))))) |
2331 | |
2332 (defun Info-index (topic &optional starting-nodes) | |
2333 "Look up a string in the index for this file. | |
2334 The index is defined as the first node in the top-level menu whose | |
2335 name contains the word \"Index\", plus any immediately following | |
2336 nodes whose names also contain the word \"Index\". | |
2337 If there are no exact matches to the specified topic, this chooses | |
2338 the first match which is a case-insensitive substring of a topic. | |
2339 Use the `,' command to see the other matches. | |
2340 Give a blank topic name to go to the Index node itself. | |
2341 | |
2342 If STARTING-NODES is given, it should be a list of nodes specifying | |
2343 files in which the indices will be searched. The results will be | |
2344 combined together." | |
2345 (interactive "sIndex topic: ") | |
2346 (let ((matches (if starting-nodes | |
2347 (mapcan #'(lambda (node) | |
2348 (Info-goto-node node) | |
2349 (Info-find-index-alternatives topic)) | |
2350 starting-nodes) | |
2351 (Info-find-index-alternatives topic))) | |
2352 exact found) | |
2353 (or matches | |
2354 (progn | |
2355 (if (or (not starting-nodes) (< (length starting-nodes) 2)) | |
2356 (Info-last)) | |
2357 (error "No \"%s\" in index" topic))) | |
2358 ;; Here it is a feature that assoc is case-sensitive. | |
2359 (while (setq found (assoc topic matches)) | |
2360 (setq exact (cons found exact) | |
5652
cc6f0266bc36
Avoid #'delq in core Lisp, for the sake of style, a very slightly smaller binary
Aidan Kehoe <kehoea@parhasard.net>
parents:
5567
diff
changeset
|
2361 matches (delete* found matches))) |
502 | 2362 (setq Info-index-alternatives (nconc exact matches) |
2363 Info-index-first-alternative (car Info-index-alternatives)) | |
2364 (Info-index-next 0))) | |
428 | 2365 |
2366 (defun Info-index-next (num) | |
2367 "Go to the next matching index item from the last `i' command." | |
2368 (interactive "p") | |
2369 (or Info-index-alternatives | |
2370 (error "No previous `i' command in this file")) | |
2371 (while (< num 0) | |
2372 (setq num (+ num (length Info-index-alternatives)))) | |
2373 (while (> num 0) | |
2374 (setq Info-index-alternatives | |
2375 (nconc (cdr Info-index-alternatives) | |
2376 (list (car Info-index-alternatives))) | |
2377 num (1- num))) | |
2378 (Info-goto-node (nth 1 (car Info-index-alternatives))) | |
2379 (if (> (nth 3 (car Info-index-alternatives)) 0) | |
2380 (forward-line (nth 3 (car Info-index-alternatives))) | |
2381 (forward-line 3) ; don't search in headers | |
2382 (let ((name (car (car Info-index-alternatives)))) | |
2383 (if (or (re-search-forward (format | |
2384 "\\(Function\\|Command\\): %s\\( \\|$\\)" | |
2385 (regexp-quote name)) nil t) | |
2386 (re-search-forward (format "^`%s[ ']" (regexp-quote name)) nil t) | |
2387 (search-forward (format "`%s'" name) nil t) | |
2388 (and (string-match "\\`.*\\( (.*)\\)\\'" name) | |
2389 (search-forward | |
2390 (format "`%s'" (substring name 0 (match-beginning 1))) | |
2391 nil t)) | |
2392 (search-forward name nil t)) | |
2393 (beginning-of-line) | |
2394 (goto-char (point-min))))) | |
2395 (message "Found \"%s\" in %s. %s" | |
2396 (car (car Info-index-alternatives)) | |
2397 (nth 2 (car Info-index-alternatives)) | |
2398 (if (cdr Info-index-alternatives) | |
2399 (if (eq (car (cdr Info-index-alternatives)) | |
2400 Info-index-first-alternative) | |
2401 "(Press `,' to repeat)" | |
2402 (format "(Press `,' for %d more)" | |
2403 (- (1- (length Info-index-alternatives)) | |
2404 (length (memq Info-index-first-alternative | |
2405 (cdr Info-index-alternatives)))))) | |
2406 "(Only match)"))) | |
2407 | |
2408 | |
2409 ;;;###autoload | |
2410 (defun Info-emacs-command (command) | |
2411 "Look up an Emacs command in the Emacs manual in the Info system. | |
2412 This command is designed to be used whether you are already in Info or not." | |
2413 (interactive "CLook up command in Emacs manual: ") | |
2414 (save-window-excursion | |
2415 (info) | |
2416 (Info-find-node Info-emacs-info-file-name "Top") | |
2417 (Info-index (symbol-name command))) | |
2418 (pop-to-buffer "*info*")) | |
2419 | |
2420 | |
2421 ;;;###autoload | |
2422 (defun Info-goto-emacs-command-node (key) | |
2423 "Look up an Emacs command in the Emacs manual in the Info system. | |
2424 This command is designed to be used whether you are already in Info or not." | |
2425 (interactive "CLook up command in Emacs manual: ") | |
2426 (Info-emacs-command key)) | |
2427 | |
2428 ;;;###autoload | |
2429 (defun Info-goto-emacs-key-command-node (key) | |
2430 "Look up an Emacs key sequence in the Emacs manual in the Info system. | |
2431 This command is designed to be used whether you are already in Info or not." | |
2432 (interactive "kLook up key in Emacs manual: ") | |
2433 (let ((command (key-binding key))) | |
2434 (cond ((eq command 'keyboard-quit) | |
2435 (keyboard-quit)) | |
2436 ((null command) | |
2437 (error "%s is undefined" (key-description key))) | |
2438 ((and (interactive-p) (eq command 'execute-extended-command)) | |
2439 (call-interactively 'Info-goto-emacs-command-node)) | |
2440 (t | |
2441 (Info-goto-emacs-command-node command))))) | |
2442 | |
2443 ;;;###autoload | |
2444 (defun Info-emacs-key (key) | |
2445 "Look up an Emacs key sequence in the Emacs manual in the Info system. | |
2446 This command is designed to be used whether you are already in Info or not." | |
2447 (interactive "kLook up key in Emacs manual: ") | |
2448 (cond ((eq (key-binding key) 'keyboard-quit) | |
2449 (keyboard-quit)) | |
2450 ((and (interactive-p) (eq (key-binding key) 'execute-extended-command)) | |
2451 (call-interactively 'Info-goto-emacs-command-node)) | |
2452 (t | |
2453 (save-window-excursion | |
2454 (info) | |
2455 (Info-find-node Info-emacs-info-file-name "Top") | |
2456 (setq key (key-description key)) | |
2457 (let (p) | |
2458 (if (setq p (string-match "[@{}]" key)) | |
2459 (setq key (concat (substring key 0 p) "@" (substring key p)))) | |
2460 (if (string-match "^ESC " key) | |
2461 (setq key (concat "M-" (substring key 4)))) | |
2462 (if (string-match "^M-C-" key) | |
2463 (setq key (concat "C-M-" (substring key 4))))) | |
2464 (Info-index key)) | |
2465 (pop-to-buffer "*info*")))) | |
2466 | |
2467 ;;;###autoload | |
2468 (defun Info-elisp-ref (func) | |
2469 "Look up an Emacs Lisp function in the Elisp manual in the Info system. | |
2470 This command is designed to be used whether you are already in Info or not." | |
2471 (interactive (let ((fn (function-at-point)) | |
442 | 2472 (enable-recursive-minibuffers t) |
428 | 2473 val) |
2474 (setq val (completing-read | |
2475 (format "Look up Emacs Lisp function%s: " | |
2476 (if fn | |
2477 (format " (default %s)" fn) | |
2478 "")) | |
456 | 2479 obarray 'fboundp t |
2480 nil nil (and fn (symbol-name fn)))) | |
428 | 2481 (list (if (equal val "") |
2482 fn (intern val))))) | |
2483 (save-window-excursion | |
2484 (info) | |
2485 (condition-case nil | |
2486 (Info-find-node "lispref" "Top") | |
2487 (error (Info-find-node "elisp" "Top"))) | |
2488 (Info-index (symbol-name func))) | |
2489 (pop-to-buffer "*info*")) | |
502 | 2490 |
2491 (defun Info-read-search-text-regexp () | |
2492 (read-from-minibuffer | |
2493 (if (and (boundp 'Info-last-search) Info-last-search) | |
2494 (format "Search (regexp, default %s): " | |
2495 Info-last-search) | |
2496 "Search (regexp): ") | |
2497 nil nil nil nil nil (and (boundp 'Info-last-search) Info-last-search))) | |
2498 | |
2499 ;;;###autoload | |
2500 (defun Info-search-text-in-lispref (regexp) | |
2501 "Search for REGEXP in Lispref text and select node it's found in." | |
2502 (interactive (list (Info-read-search-text-regexp))) | |
2503 (Info-goto-node "(Lispref)") | |
2504 (Info-search regexp)) | |
2505 | |
2506 ;;;###autoload | |
2507 (defun Info-search-text-in-xemacs (regexp) | |
2508 "Search for REGEXP in User's Manual text and select node it's found in." | |
2509 (interactive (list (Info-read-search-text-regexp))) | |
2510 (Info-goto-node "(XEmacs)") | |
2511 (Info-search regexp)) | |
2512 | |
2513 ;;;###autoload | |
2514 (defun Info-search-index-in-lispref (regexp) | |
2515 "Search for REGEXP in Lispref index and select node it's found in." | |
2516 (interactive "sIndex topic: ") | |
2517 (Info-goto-node "(Lispref)") | |
2518 (Info-index regexp)) | |
2519 | |
2520 ;;;###autoload | |
2521 (defun Info-search-index-in-xemacs-and-lispref (regexp) | |
2522 "Search for REGEXP in both User's Manual and Lispref indices. | |
2523 Select node it's found in." | |
2524 (interactive "sIndex topic: ") | |
2525 (Info-index regexp '("(XEmacs)" "(Lispref)"))) | |
2526 | |
428 | 2527 |
2528 (defun Info-reannotate-node () | |
5652
cc6f0266bc36
Avoid #'delq in core Lisp, for the sake of style, a very slightly smaller binary
Aidan Kehoe <kehoea@parhasard.net>
parents:
5567
diff
changeset
|
2529 (let ((bufs (delete* nil (mapcar 'get-file-buffer Info-annotations-path)))) |
428 | 2530 (if bufs |
2531 (let ((ibuf (current-buffer)) | |
2532 (file (concat "\\(" (regexp-quote | |
2533 (file-name-nondirectory Info-current-file)) | |
2534 "\\|" (regexp-quote Info-current-file) "\\)")) | |
2535 (node (regexp-quote Info-current-node)) | |
2536 (savept (point))) | |
2537 (goto-char (point-min)) | |
2538 (if (search-forward "\n------ NOTE:\n" nil t) | |
2539 (let ((buffer-read-only nil) | |
2540 (bufmod (buffer-modified-p)) | |
2541 top) | |
2542 (setq savept (copy-marker savept)) | |
2543 (goto-char (point-min)) | |
2544 (while (search-forward "\n------ NOTE:" nil t) | |
2545 (setq top (1+ (match-beginning 0))) | |
2546 (if (search-forward "\n------\n" nil t) | |
2547 (delete-region top (point))) | |
2548 (backward-char 1)) | |
2549 (set-buffer-modified-p bufmod))) | |
2550 (save-excursion | |
2551 (while bufs | |
2552 (set-buffer (car bufs)) | |
2553 (goto-char (point-min)) | |
2554 (while (re-search-forward | |
2555 (format | |
2556 "------ *File: *%s *Node: *%s *Line: *\\([0-9]+\\) *\n" | |
2557 file node) | |
2558 nil t) | |
2559 (let ((line (string-to-int | |
2560 (buffer-substring (match-beginning 2) | |
2561 (match-end 2)))) | |
2562 (top (point)) | |
2563 bot) | |
2564 (search-forward "\n------\n" nil t) | |
2565 (setq bot (point)) | |
2566 (save-excursion | |
2567 (set-buffer ibuf) | |
2568 (if (integerp savept) (setq savept (copy-marker savept))) | |
2569 (if (= line 0) | |
2570 (goto-char (point-max)) | |
2571 (goto-char (point-min)) | |
2572 (forward-line line)) | |
2573 (let ((buffer-read-only nil) | |
2574 (bufmod (buffer-modified-p))) | |
2575 (insert "------ NOTE:\n") | |
2576 (insert-buffer-substring (car bufs) top bot) | |
2577 (set-buffer-modified-p bufmod))))) | |
2578 (setq bufs (cdr bufs)))) | |
2579 (goto-char savept))))) | |
2580 | |
2581 (defvar Info-annotate-map nil | |
2582 "Local keymap used within `a' command of Info.") | |
444 | 2583 |
428 | 2584 (if Info-annotate-map |
2585 nil | |
2586 ;; (setq Info-annotate-map (nconc (make-sparse-keymap) text-mode-map)) | |
2587 (setq Info-annotate-map (copy-keymap text-mode-map)) | |
2588 (define-key Info-annotate-map "\C-c\C-c" 'Info-cease-annotate)) | |
2589 | |
2590 (defun Info-annotate-mode () | |
2591 "Major mode for adding an annotation to an Info node. | |
2592 Like text mode with the addition of Info-cease-annotate | |
2593 which returns to Info mode for browsing. | |
2594 \\{Info-annotate-map}") | |
2595 | |
2596 (defun Info-annotate (arg) | |
2597 "Add a personal annotation to the current Info node. | |
2598 Only you will be able to see this annotation. Annotations are stored | |
2599 in the file \"~/.xemacs/info.notes\" by default. If point is inside | |
2600 an existing annotation, edit that annotation. A prefix argument | |
2601 specifies which annotations file (from `Info-annotations-path') is to | |
2602 be edited; default is 1." | |
2603 (interactive "p") | |
2604 (setq arg (1- arg)) | |
2605 (if (or (< arg 0) (not (nth arg Info-annotations-path))) | |
2606 (if (= arg 0) | |
2607 (setq Info-annotations-path | |
2608 (list (read-file-name | |
2609 "Annotations file: " "~/" "~/.infonotes"))) | |
2610 (error "File number must be in the range from 1 to %d" | |
2611 (length Info-annotations-path)))) | |
2612 (let ((which nil) | |
2613 (file (file-name-nondirectory Info-current-file)) | |
2614 (d Info-directory-list) | |
2615 where pt) | |
2616 (while (and d (not (equal (expand-file-name file (car d)) | |
2617 Info-current-file))) | |
2618 (setq d (cdr d))) | |
2619 (or d (setq file Info-current-file)) | |
2620 (if (and (save-excursion | |
2621 (goto-char (min (point-max) (+ (point) 13))) | |
2622 (and (search-backward "------ NOTE:\n" nil t) | |
2623 (setq pt (match-end 0)) | |
2624 (search-forward "\n------\n" nil t))) | |
2625 (< (point) (match-end 0))) | |
2626 (setq which (format "File: *%s *Node: *%s *Line:.*\n%s" | |
2627 (regexp-quote file) | |
2628 (regexp-quote Info-current-node) | |
2629 (regexp-quote | |
2630 (buffer-substring pt (match-beginning 0)))) | |
2631 where (max (- (point) pt) 0))) | |
2632 (let ((node Info-current-node) | |
2633 (line (if (looking-at "[ \n]*\\'") 0 | |
2634 (count-lines (point-min) (point))))) | |
2635 (or which | |
2636 (let ((buffer-read-only nil) | |
2637 (bufmod (buffer-modified-p))) | |
2638 (beginning-of-line) | |
2639 (if (bobp) (goto-char (point-max))) | |
2640 (insert "------ NOTE:\n------\n") | |
2641 (backward-char 20) | |
2642 (set-buffer-modified-p bufmod))) | |
2643 ;; (setq Info-window-start (window-start)) | |
2644 (setq Info-window-configuration (current-window-configuration)) | |
2645 (pop-to-buffer (find-file-noselect (nth arg Info-annotations-path))) | |
2646 (use-local-map Info-annotate-map) | |
2647 (setq major-mode 'Info-annotate-mode) | |
2648 (setq mode-name "Info Annotate") | |
2649 (if which | |
2650 (if (save-excursion | |
2651 (goto-char (point-min)) | |
2652 (re-search-forward which nil t)) | |
2653 (progn | |
2654 (goto-char (match-beginning 0)) | |
2655 (forward-line 1) | |
2656 (forward-char where))) | |
2657 (let ((bufmod (buffer-modified-p))) | |
2658 (goto-char (point-max)) | |
2659 (insert (format "\n------ File: %s Node: %s Line: %d\n" | |
2660 file node line)) | |
2661 (setq pt (point)) | |
2662 (insert "\n------\n" | |
2663 "\nPress C-c C-c to save and return to Info.\n") | |
2664 (goto-char pt) | |
2665 (set-buffer-modified-p bufmod)))))) | |
2666 | |
2667 (defun Info-cease-annotate () | |
2668 (interactive) | |
2669 (let ((bufmod (buffer-modified-p))) | |
2670 (while (save-excursion | |
2671 (goto-char (point-min)) | |
2672 (re-search-forward "\n\n?Press .* to save and return to Info.\n" | |
2673 nil t)) | |
2674 (delete-region (1+ (match-beginning 0)) (match-end 0))) | |
2675 (while (save-excursion | |
2676 (goto-char (point-min)) | |
2677 (re-search-forward "\n------ File:.*Node:.*Line:.*\n+------\n" | |
2678 nil t)) | |
2679 (delete-region (match-beginning 0) (match-end 0))) | |
2680 (set-buffer-modified-p bufmod)) | |
2681 (save-buffer) | |
2682 (fundamental-mode) | |
2683 (bury-buffer) | |
2684 (or (one-window-p) (delete-window)) | |
2685 (info) | |
2686 (setq Info-current-annotation-completions nil) | |
2687 (set-window-configuration Info-window-configuration) | |
2688 (Info-reannotate-node)) | |
2689 | |
2690 (defun Info-bookmark (arg tag) | |
2691 (interactive "p\nsBookmark name: ") | |
2692 (Info-annotate arg) | |
2693 (if (or (string-match "^\"\\(.*\\)\"$" tag) | |
2694 (string-match "^<<\\(.*\\)>>$" tag)) | |
2695 (setq tag (substring tag (match-beginning 1) (match-end 1)))) | |
2696 (let ((pt (point))) | |
2697 (search-forward "\n------\n") | |
2698 (let ((end (- (point) 8))) | |
2699 (goto-char pt) | |
2700 (if (re-search-forward "<<[^>\n]*>>" nil t) | |
2701 (delete-region (match-beginning 0) (match-end 0)) | |
2702 (goto-char end)) | |
2703 (or (equal tag "") | |
2704 (insert "<<" tag ">>")))) | |
2705 (Info-cease-annotate)) | |
2706 | |
2707 (defun Info-exit () | |
2708 "Exit Info by selecting some other buffer." | |
2709 (interactive) | |
2710 (if Info-standalone | |
2711 (save-buffers-kill-emacs) | |
2712 (bury-buffer (current-buffer)) | |
2713 (if (and (featurep 'toolbar) | |
2714 (boundp 'toolbar-info-frame) | |
2715 (eq toolbar-info-frame (selected-frame))) | |
2716 (condition-case () | |
2717 (delete-frame toolbar-info-frame) | |
2718 (error (bury-buffer))) | |
2719 (switch-to-buffer (other-buffer (current-buffer)))))) | |
2720 | |
2721 (defun Info-undefined () | |
2722 "Make command be undefined in Info." | |
2723 (interactive) | |
2724 (ding)) | |
2725 | |
2726 (defun Info-help () | |
2727 "Enter the Info tutorial." | |
2728 (interactive) | |
2729 (delete-other-windows) | |
2730 (Info-find-node "info" | |
2731 (if (< (window-height) 23) | |
2732 "Help-Small-Screen" | |
2733 "Help"))) | |
2734 | |
2735 (defun Info-summary () | |
2736 "Display a brief summary of all Info commands." | |
2737 (interactive) | |
2738 (save-window-excursion | |
2739 (switch-to-buffer "*Help*") | |
2740 (erase-buffer) | |
2741 (insert (documentation 'Info-mode)) | |
2742 (goto-char (point-min)) | |
2743 (let (flag) | |
2744 (while (progn (setq flag (not (pos-visible-in-window-p (point-max)))) | |
2745 (message (if flag "Type Space to see more" | |
2746 "Type Space to return to Info")) | |
2747 (let ((e (next-command-event))) | |
2748 (if (/= ?\ (event-to-character e)) | |
2749 (progn (setq unread-command-event e) nil) | |
2750 flag))) | |
2751 (scroll-up))) | |
2752 (message "") | |
2753 (bury-buffer "*Help*"))) | |
2754 | |
2755 (defun Info-get-token (pos start all &optional errorstring) | |
2756 "Return the token around POS, | |
2757 POS must be somewhere inside the token | |
2758 START is a regular expression which will match the | |
2759 beginning of the tokens delimited string | |
2760 ALL is a regular expression with a single | |
2761 parenthized subpattern which is the token to be | |
2762 returned. E.g. '{\(.*\)}' would return any string | |
2763 enclosed in braces around POS. | |
2764 SIG optional fourth argument, controls action on no match | |
2765 nil: return nil | |
2766 t: beep | |
2767 a string: signal an error, using that string." | |
2768 (save-excursion | |
2769 (goto-char (point-min)) | |
2770 (re-search-backward "\\`") ; Bug fix due to Nicholas J. Foskett. | |
2771 (goto-char pos) | |
2772 (re-search-backward start (max (point-min) (- pos 200)) 'yes) | |
2773 (let (found) | |
2774 (while (and (re-search-forward all (min (point-max) (+ pos 200)) 'yes) | |
2775 (not (setq found (and (<= (match-beginning 0) pos) | |
2776 (> (match-end 0) pos)))))) | |
2777 (if (and found (<= (match-beginning 0) pos) | |
2778 (> (match-end 0) pos)) | |
2779 (buffer-substring (match-beginning 1) (match-end 1)) | |
2780 (cond ((null errorstring) | |
2781 nil) | |
2782 ((eq errorstring t) | |
2783 (beep) | |
2784 nil) | |
2785 (t | |
2786 (error "No %s around position %d" errorstring pos))))))) | |
2787 | |
2788 (defun Info-follow-clicked-node (event) | |
2789 "Follow a node reference near clicked point. Like M, F, N, P or U command. | |
2790 At end of the node's text, moves to the next node." | |
2791 (interactive "@e") | |
2792 (or (and (event-point event) | |
2793 (Info-follow-nearest-node | |
2794 (max (progn | |
2795 (select-window (event-window event)) | |
2796 (event-point event)) | |
2797 (1+ (point-min))))) | |
2798 (error "click on a cross-reference to follow"))) | |
2799 | |
2800 (defun Info-maybe-follow-clicked-node (event &optional click-count) | |
2801 "Follow a node reference (if any) near clicked point. | |
2802 Like M, F, N, P or U command. At end of the node's text, moves to the | |
2803 next node. No error is given if there is no node to follow." | |
2804 (interactive "@e") | |
2805 (and Info-button1-follows-hyperlink | |
2806 (event-point event) | |
2807 (Info-follow-nearest-node | |
2808 (max (progn | |
2809 (select-window (event-window event)) | |
2810 (event-point event)) | |
2811 (1+ (point-min)))))) | |
2812 | |
2813 (defun Info-find-nearest-node (point) | |
2814 (let (node) | |
2815 (cond | |
2816 ((= point (point-min)) nil) ; don't trigger on accidental RET. | |
2817 ((setq node (Info-get-token point | |
2818 (format "\\*%s[ \n]" Info-footnote-tag) | |
2819 (format "\\*%s[ \n]\\([^:]*\\):" | |
2820 Info-footnote-tag))) | |
2821 (list "Following cross-reference %s..." | |
2822 (list 'Info-follow-reference node))) | |
2823 ((setq node (Info-get-token point "\\* " "\\* \\([^:]*\\)::")) | |
2824 (list "Selecting menu item %s..." | |
2825 (list 'Info-goto-node node nil t))) | |
2826 ((setq node (Info-get-token point "\\* " "\\* \\([^:]*\\):")) | |
2827 (list "Selecting menu item %s..." | |
2828 (list 'Info-menu node))) | |
2829 ((setq node (Info-get-token point "Up: " "Up: \\([^,\n\t]*\\)")) | |
2830 (list "Going up..." | |
2831 (list 'Info-goto-node node))) | |
2832 ((setq node (Info-get-token point "Next: " "Next: \\([^,\n\t]*\\)")) | |
2833 (list "Next node..." | |
2834 (list 'Info-goto-node node))) | |
2835 ((setq node (Info-get-token point "File: " "File: \\([^,\n\t]*\\)")) | |
2836 (list "Top node..." | |
2837 (list 'Info-goto-node "Top"))) | |
2838 ((setq node (Info-get-token point "Prev[ious]*: " | |
2839 "Prev[ious]*: \\([^,\n\t]*\\)")) | |
2840 (list "Previous node..." | |
2841 (list 'Info-goto-node node))) | |
2842 ((setq node (Info-get-token point "Node: " "Node: \\([^,\n\t]*\\)")) | |
2843 (list "Reselecting %s..." | |
2844 (list 'Info-goto-node node))) | |
2845 ((save-excursion (goto-char point) (looking-at "[ \n]*\\'")) | |
2846 (if Info-in-cross-reference | |
2847 (list "Back to last node..." | |
2848 '(Info-last)) | |
2849 (list "Next node..." | |
2850 '(Info-global-next))))) | |
2851 )) | |
2852 | |
2853 (defun Info-follow-nearest-node (point) | |
2854 "Follow a node reference near point. Like M, F, N, P or U command. | |
2855 At end of the node's text, moves to the next node." | |
2856 (interactive "d") | |
2857 (let ((data (Info-find-nearest-node point))) | |
2858 (if (null data) | |
2859 nil | |
2860 (let ((msg (format (car data) (nth 1 (nth 1 data))))) | |
2861 (message "%s" msg) | |
2862 (eval (nth 1 data)) | |
2863 (message "%sdone" msg)) | |
2864 t))) | |
2865 | |
2866 (defun Info-indicated-node (event) | |
2867 (condition-case () | |
2868 (save-excursion | |
2869 (cond ((eventp event) | |
2870 (set-buffer (event-buffer event)) | |
2871 (setq event (event-point event)))) | |
2872 (let* ((data (Info-find-nearest-node event)) | |
2873 (name (nth 1 (nth 1 data)))) | |
2874 (and name (nth 1 data)))) | |
2875 (error nil))) | |
2876 | |
2877 (defun Info-mouse-track-double-click-hook (event click-count) | |
2878 "Handle double-clicks by turning pages, like the `gv' ghostscript viewer" | |
2879 (if (/= click-count 2) | |
2880 ;; Return nil so any other hooks are performed. | |
2881 nil | |
2882 (let* ((fw (face-width 'default)) | |
2883 (fh (face-height 'default)) | |
2884 (x (/ (event-x-pixel event) fw)) | |
2885 (y (/ (event-y-pixel event) fw)) | |
2886 (w (/ (window-pixel-width (event-window event)) fw)) | |
2887 (h (/ (window-pixel-height (event-window event)) fh)) | |
2888 (bx 3) | |
2889 (by 2)) | |
2890 (cond | |
2891 ((<= y by) (Info-up) t) | |
2892 ((>= y (- h by)) (Info-nth-menu-item 1) t) | |
2893 ((<= x bx) (Info-prev) t) | |
2894 ((>= x (- w bx)) (Info-next) t) | |
2895 (t nil))))) | |
2896 | |
2897 (defvar Info-mode-map nil | |
2898 "Keymap containing Info commands.") | |
444 | 2899 |
428 | 2900 (if Info-mode-map |
2901 nil | |
2902 (setq Info-mode-map (make-sparse-keymap)) | |
2903 (suppress-keymap Info-mode-map) | |
2904 (define-key Info-mode-map "." 'beginning-of-buffer) | |
2905 (define-key Info-mode-map " " 'Info-scroll-next) | |
2906 (define-key Info-mode-map "1" 'Info-nth-menu-item) | |
2907 (define-key Info-mode-map "2" 'Info-nth-menu-item) | |
2908 (define-key Info-mode-map "3" 'Info-nth-menu-item) | |
2909 (define-key Info-mode-map "4" 'Info-nth-menu-item) | |
2910 (define-key Info-mode-map "5" 'Info-nth-menu-item) | |
2911 (define-key Info-mode-map "6" 'Info-nth-menu-item) | |
2912 (define-key Info-mode-map "7" 'Info-nth-menu-item) | |
2913 (define-key Info-mode-map "8" 'Info-nth-menu-item) | |
2914 (define-key Info-mode-map "9" 'Info-nth-menu-item) | |
2915 (define-key Info-mode-map "0" 'Info-last-menu-item) | |
2916 (define-key Info-mode-map "?" 'Info-summary) | |
2917 (define-key Info-mode-map "a" 'Info-annotate) | |
2918 (define-key Info-mode-map "b" 'beginning-of-buffer) | |
2919 (define-key Info-mode-map "d" 'Info-directory) | |
2920 (define-key Info-mode-map "e" 'Info-edit) | |
2921 (define-key Info-mode-map "f" 'Info-follow-reference) | |
2922 (define-key Info-mode-map "g" 'Info-goto-node) | |
2923 (define-key Info-mode-map "h" 'Info-help) | |
2924 (define-key Info-mode-map "i" 'Info-index) | |
2925 (define-key Info-mode-map "j" 'Info-goto-bookmark) | |
2926 (define-key Info-mode-map "k" 'Info-emacs-key) | |
2927 (define-key Info-mode-map "l" 'Info-last) | |
2928 (define-key Info-mode-map "m" 'Info-menu) | |
2929 (define-key Info-mode-map "n" 'Info-next) | |
2930 (define-key Info-mode-map "p" 'Info-prev) | |
2931 (define-key Info-mode-map "q" 'Info-exit) | |
2932 (define-key Info-mode-map "r" 'Info-follow-reference) | |
2933 (define-key Info-mode-map "s" 'Info-search) | |
2934 (define-key Info-mode-map "t" 'Info-top) | |
2935 (define-key Info-mode-map "u" 'Info-up) | |
2936 (define-key Info-mode-map "v" 'Info-visit-file) | |
2937 (define-key Info-mode-map "x" 'Info-bookmark) | |
502 | 2938 (define-key Info-mode-map "z" 'Info-search-next) |
428 | 2939 (define-key Info-mode-map "<" 'Info-top) |
2940 (define-key Info-mode-map ">" 'Info-end) | |
2941 (define-key Info-mode-map "[" 'Info-global-prev) | |
2942 (define-key Info-mode-map "]" 'Info-global-next) | |
2943 (define-key Info-mode-map "{" 'Info-page-prev) | |
2944 (define-key Info-mode-map "}" 'Info-page-next) | |
2945 (define-key Info-mode-map "=" 'Info-restore-point) | |
2946 (define-key Info-mode-map "!" 'Info-select-node) | |
2947 (define-key Info-mode-map "@" 'Info-follow-nearest-node) | |
2948 (define-key Info-mode-map "," 'Info-index-next) | |
2949 (define-key Info-mode-map "*" 'Info-elisp-ref) | |
2950 (define-key Info-mode-map [tab] 'Info-next-reference) | |
2951 (define-key Info-mode-map [(meta tab)] 'Info-prev-reference) | |
2952 (define-key Info-mode-map [(shift tab)] 'Info-prev-reference) | |
2953 (define-key Info-mode-map "\r" 'Info-follow-nearest-node) | |
2954 ;; XEmacs addition | |
2955 (define-key Info-mode-map 'backspace 'Info-scroll-prev) | |
2956 (define-key Info-mode-map 'delete 'Info-scroll-prev) | |
2957 (define-key Info-mode-map 'button2 'Info-follow-clicked-node) | |
2958 (define-key Info-mode-map 'button3 'Info-select-node-menu)) | |
2959 | |
2960 | |
2961 ;; Info mode is suitable only for specially formatted data. | |
2962 (put 'info-mode 'mode-class 'special) | |
2963 | |
2964 (defun Info-mode () | |
2965 "Info mode is for browsing through the Info documentation tree. | |
2966 Documentation in Info is divided into \"nodes\", each of which | |
2967 discusses one topic and contains references to other nodes | |
2968 which discuss related topics. Info has commands to follow | |
2969 the references and show you other nodes. | |
2970 | |
2971 h Invoke the Info tutorial. | |
2972 q Quit Info: return to the previously selected file or buffer. | |
2973 | |
2974 Selecting other nodes: | |
2975 n Move to the \"next\" node of this node. | |
2976 p Move to the \"previous\" node of this node. | |
2977 m Pick menu item specified by name (or abbreviation). | |
2978 1-9, 0 Pick first..ninth, last item in node's menu. | |
2979 Menu items select nodes that are \"subsections\" of this node. | |
2980 u Move \"up\" from this node (i.e., from a subsection to a section). | |
2981 f or r Follow a cross reference by name (or abbrev). Type `l' to get back. | |
2982 RET Follow cross reference or menu item indicated by cursor. | |
2983 i Look up a topic in this file's Index and move to that node. | |
2984 , (comma) Move to the next match from a previous `i' command. | |
2985 l (letter L) Move back to the last node you were in. | |
2986 | |
2987 Moving within a node: | |
2988 Space Scroll forward a full screen. DEL Scroll backward. | |
2989 b Go to beginning of node. Meta-> Go to end of node. | |
2990 TAB Go to next cross-reference. Meta-TAB Go to previous ref. | |
2991 | |
2992 Mouse commands: | |
2993 Left Button Set point (usual text-mode functionality) | |
2994 Middle Button Click on a highlighted node reference to go to it. | |
2995 Right Button Pop up a menu of applicable Info commands. | |
2996 | |
2997 Left Button Double Click in window edges: | |
2998 Top edge: Go up to the parent node, like `u'. | |
2999 Left edge: Go to the previous node, like `p'. | |
3000 Right edge: Go to the next node, like `n'. | |
3001 Bottom edge: Follow first menu item, like `1'. | |
3002 | |
3003 Advanced commands: | |
3004 g Move to node, file, or annotation tag specified by name. | |
3005 Examples: `g Rectangles' `g (Emacs)Rectangles' `g Emacs'. | |
3006 v Move to file, with filename completion. | |
3007 k Look up a key sequence in Emacs manual (also C-h C-k at any time). | |
3008 * Look up a function name in Emacs Lisp manual (also C-h C-f). | |
3009 d Go to the main directory of Info files. | |
3010 < or t Go to Top (first) node of this file. | |
3011 > Go to last node in this file. | |
3012 \[ Go to previous node, treating file as one linear document. | |
3013 \] Go to next node, treating file as one linear document. | |
3014 { Scroll backward, or go to previous node if at top. | |
3015 } Scroll forward, or go to next node if at bottom. | |
3016 = Restore cursor position from last time in this node. | |
3017 a Add a private note (annotation) to the current node. | |
3018 x, j Add, jump to a bookmark (annotation tag). | |
3019 s Search this Info file for a node containing the specified regexp. | |
3020 e Edit the contents of the current node." | |
3021 (kill-all-local-variables) | |
3022 (setq major-mode 'Info-mode) | |
3023 (setq mode-name "Info") | |
3024 (use-local-map Info-mode-map) | |
3025 (set-syntax-table text-mode-syntax-table) | |
3026 (setq local-abbrev-table text-mode-abbrev-table) | |
3027 (setq case-fold-search t) | |
3028 (setq buffer-read-only t) | |
3029 ; (setq buffer-mouse-map Info-mode-mouse-map) | |
3030 (make-local-variable 'Info-current-file) | |
3031 (make-local-variable 'Info-current-subfile) | |
3032 (make-local-variable 'Info-current-node) | |
3033 (make-local-variable 'Info-tag-table-marker) | |
442 | 3034 (setq Info-tag-table-marker (make-marker)) |
3035 (make-local-variable 'Info-tag-table-buffer) | |
3036 (setq Info-tag-table-buffer nil) | |
428 | 3037 (make-local-variable 'Info-current-file-completions) |
3038 (make-local-variable 'Info-current-annotation-completions) | |
3039 (make-local-variable 'Info-index-alternatives) | |
3040 (make-local-variable 'Info-history) | |
3041 ;; Faces are now defined by `defface'... | |
548 | 3042 (make-local-hook 'mouse-track-click-hook) |
3043 (add-hook 'mouse-track-click-hook 'Info-maybe-follow-clicked-node t t) | |
3044 (add-hook 'mouse-track-click-hook 'Info-mouse-track-double-click-hook t t) | |
428 | 3045 ;; #### The console-on-window-system-p check is to allow this to |
3046 ;; work on tty's. The real problem here is that featurep really | |
3047 ;; needs to have some device/console domain knowledge added to it. | |
3048 (defvar info::toolbar) | |
3049 (if (and (featurep 'toolbar) | |
3050 (console-on-window-system-p) | |
3051 (not Info-inhibit-toolbar)) | |
3052 (set-specifier default-toolbar (cons (current-buffer) info::toolbar))) | |
3053 (if (featurep 'menubar) | |
3054 (progn | |
3055 ;; make a local copy of the menubar, so our modes don't | |
3056 ;; change the global menubar | |
3057 (easy-menu-add '("Info" :filter Info-menu-filter)))) | |
3058 (run-hooks 'Info-mode-hook) | |
3059 (Info-set-mode-line)) | |
3060 | |
3061 (defvar Info-edit-map nil | |
3062 "Local keymap used within `e' command of Info.") | |
444 | 3063 |
428 | 3064 (if Info-edit-map |
3065 nil | |
3066 ;; XEmacs: remove FSF stuff | |
3067 (setq Info-edit-map (make-sparse-keymap)) | |
3068 (set-keymap-name Info-edit-map 'Info-edit-map) | |
3069 (set-keymap-parents Info-edit-map (list text-mode-map)) | |
3070 (define-key Info-edit-map "\C-c\C-c" 'Info-cease-edit)) | |
3071 | |
3072 ;; Info-edit mode is suitable only for specially formatted data. | |
3073 (put 'info-edit-mode 'mode-class 'special) | |
3074 | |
3075 (defun Info-edit-mode () | |
3076 "Major mode for editing the contents of an Info node. | |
3077 Like text mode with the addition of `Info-cease-edit' | |
3078 which returns to Info mode for browsing. | |
3079 \\{Info-edit-map}" | |
3080 ) | |
3081 | |
3082 (defun Info-edit () | |
3083 "Edit the contents of this Info node. | |
3084 Allowed only if variable `Info-enable-edit' is non-nil." | |
3085 (interactive) | |
3086 (or Info-enable-edit | |
3087 (error "Editing info nodes is not enabled")) | |
3088 (use-local-map Info-edit-map) | |
3089 (setq major-mode 'Info-edit-mode) | |
3090 (setq mode-name "Info Edit") | |
3091 (kill-local-variable 'modeline-buffer-identification) | |
3092 (setq buffer-read-only nil) | |
3093 ;; Make mode line update. | |
3094 (set-buffer-modified-p (buffer-modified-p)) | |
3095 (message (substitute-command-keys | |
3096 "Editing: Type \\[Info-cease-edit] to return to info"))) | |
3097 | |
3098 (defun Info-cease-edit () | |
3099 "Finish editing Info node; switch back to Info proper." | |
3100 (interactive) | |
3101 ;; Do this first, so nothing has changed if user C-g's at query. | |
3102 (and (buffer-modified-p) | |
442 | 3103 (y-or-n-p "Save the file? ") |
428 | 3104 (save-buffer)) |
3105 (use-local-map Info-mode-map) | |
3106 (setq major-mode 'Info-mode) | |
3107 (setq mode-name "Info") | |
3108 (Info-set-mode-line) | |
3109 (setq buffer-read-only t) | |
3110 ;; Make mode line update. | |
3111 (set-buffer-modified-p (buffer-modified-p)) | |
3112 (and (marker-position Info-tag-table-marker) | |
3113 (buffer-modified-p) | |
3114 (message "Tags may have changed. Use Info-tagify if necessary"))) | |
3115 | |
3116 (defun Info-find-emacs-command-nodes (command) | |
3117 "Return a list of locations documenting COMMAND in the XEmacs Info manual. | |
3118 The locations are of the format used in Info-history, i.e. | |
3119 \(FILENAME NODENAME BUFFERPOS\)." | |
3120 (let ((where '()) | |
3121 (cmd-desc (concat "^\\* " (regexp-quote (symbol-name command)) | |
3625 | 3122 ":\\s *\\(.*\\)\\."))) |
428 | 3123 (save-excursion |
3124 (Info-find-node "XEmacs" "Command Index") | |
3125 ;; Take the index node off the Info history. | |
3126 ;; ??? says this isn't safe someplace else... hmmm. | |
3127 (setq Info-history (cdr Info-history)) | |
3128 (goto-char (point-max)) | |
3129 (while (re-search-backward cmd-desc nil t) | |
3130 (setq where (cons (list Info-current-file | |
3131 (buffer-substring | |
3132 (match-beginning 1) | |
3133 (match-end 1)) | |
3134 0) | |
3135 where))) | |
3136 where))) | |
3137 | |
3138 ;;; fontification and mousability for info | |
3139 | |
3140 (defun Info-highlight-region (start end face) | |
3141 (let ((extent nil) | |
3142 (splitp (string-match "\n[ \t]+" (buffer-substring start end)))) | |
3143 (if splitp | |
3144 (save-excursion | |
3145 (setq extent (make-extent start (progn (goto-char start) | |
3146 (end-of-line) | |
3147 (point)))) | |
3148 (set-extent-face extent face) | |
3149 (set-extent-property extent 'info t) | |
3150 (set-extent-property extent 'highlight t) | |
3151 (skip-chars-forward "\n\t ") | |
3152 (setq extent (make-extent (point) end))) | |
3153 (setq extent (make-extent start end))) | |
3154 (set-extent-face extent face) | |
3155 (set-extent-property extent 'info t) | |
3156 (set-extent-property extent 'highlight t))) | |
3157 | |
3158 (defun Info-fontify-node () | |
3159 (save-excursion | |
3160 (let ((case-fold-search t) | |
3161 (xref-regexp (concat "\\*" | |
3162 (regexp-quote Info-footnote-tag) | |
3163 "[ \n\t]*\\([^:]*\\):"))) | |
3164 ;; Clear the old extents | |
3165 (map-extents #'(lambda (x y) (delete-extent x)) | |
3166 (current-buffer) (point-min) (point-max) nil) | |
3167 ;; Break the top line iff it is > 79 characters. Some info nodes | |
3168 ;; have top lines that span 3 lines because of long node titles. | |
3169 ;; eg: (Info-find-node "lispref.info" "Window-Level Event Position Info") | |
3170 (toggle-read-only -1) | |
3171 (let ((extent nil) | |
3172 (len 0) | |
3173 (done nil) | |
3174 (p (point-min))) | |
3175 (goto-char (point-min)) | |
3176 (re-search-forward "Node: *[^,]+, " nil t) | |
3177 (setq len (- (point) (point-min)) | |
3178 extent (make-extent (point-min) (point))) | |
3179 (set-extent-property extent 'invisible t) | |
3180 (while (not done) | |
3181 (goto-char p) | |
3182 (end-of-line) | |
3183 (if (< (current-column) (+ 78 len)) | |
3184 (setq done t) | |
3185 (goto-char p) | |
3186 (forward-char (+ 79 len)) | |
3187 (re-search-backward "," nil t) | |
3188 (forward-char 1) | |
3189 (insert "\n") | |
3190 (just-one-space) | |
446 | 3191 (delete-backward-char 1) |
428 | 3192 (setq p (point) |
3193 len 0)))) | |
3194 (toggle-read-only 1) | |
3195 ;; Highlight xrefs in the top few lines of the node | |
3196 (goto-char (point-min)) | |
3197 (if (looking-at "^File: [^,: \t]+,?[ \t]+") | |
3198 (progn | |
3199 (goto-char (match-end 0)) | |
3200 (while | |
3201 (looking-at "[ \t]*[^:, \t\n]+:[ \t]+\\([^:,\t\n]+\\),?\n?") | |
3202 (goto-char (match-end 0)) | |
444 | 3203 (Info-highlight-region (match-beginning 1) (match-end 1) |
3204 'info-xref)))) | |
428 | 3205 ;; Now get the xrefs in the body |
3206 (goto-char (point-min)) | |
3207 (while (re-search-forward xref-regexp nil t) | |
3208 (if (= (char-after (1- (match-beginning 0))) ?\") ; hack | |
3209 nil | |
444 | 3210 (Info-highlight-region (match-beginning 1) (match-end 1) |
3211 'info-xref))) | |
428 | 3212 ;; then highlight the nodes in the menu. |
3213 (goto-char (point-min)) | |
3214 (if (and (search-forward "\n* menu:" nil t)) | |
3215 (while (re-search-forward | |
3216 "^\\* \\([^:\t\n]*\\):?:[ \t\n]" nil t) | |
444 | 3217 (Info-highlight-region (match-beginning 1) (match-end 1) |
3218 'info-node))) | |
428 | 3219 (set-buffer-modified-p nil)))) |
3220 | |
3221 (defun Info-construct-menu (&optional event) | |
3222 "Construct a menu of Info commands. | |
3223 Adds an entry for the node at EVENT, or under point if EVENT is omitted. | |
3224 Used to construct the menubar submenu and popup menu." | |
3225 (or event (setq event (point))) | |
3226 (let ((case-fold-search t) | |
442 | 3227 (xref-regexp (concat "\\*" |
428 | 3228 (regexp-quote Info-footnote-tag) |
3229 "[ \n\t]*\\([^:]*\\):")) | |
3230 up-p prev-p next-p menu xrefs subnodes in) | |
3231 (save-excursion | |
3232 ;; `one-space' fixes "Notes:" xrefs that are split across lines. | |
5567
3bc58dc9d688
Replace #'flet by #'labels where appropriate, core code.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5474
diff
changeset
|
3233 (labels |
428 | 3234 ((one-space (text) |
5567
3bc58dc9d688
Replace #'flet by #'labels where appropriate, core code.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5474
diff
changeset
|
3235 (let (i) |
3bc58dc9d688
Replace #'flet by #'labels where appropriate, core code.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5474
diff
changeset
|
3236 (while (setq i (string-match "[ \n\t]+" text i)) |
3bc58dc9d688
Replace #'flet by #'labels where appropriate, core code.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5474
diff
changeset
|
3237 (setq text (concat (substring text 0 i) " " |
3bc58dc9d688
Replace #'flet by #'labels where appropriate, core code.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5474
diff
changeset
|
3238 (substring text (match-end 0)))) |
3bc58dc9d688
Replace #'flet by #'labels where appropriate, core code.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5474
diff
changeset
|
3239 (setq i (1+ i))) |
3bc58dc9d688
Replace #'flet by #'labels where appropriate, core code.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5474
diff
changeset
|
3240 text))) |
428 | 3241 (goto-char (point-min)) |
3242 (if (looking-at ".*\\bNext:") (setq next-p t)) | |
3243 (if (looking-at ".*\\bPrev:") (setq prev-p t)) | |
3244 (if (looking-at ".*Up:") (setq up-p t)) | |
3245 (setq menu (nconc | |
3246 (if (setq in (Info-indicated-node event)) | |
3247 (list (vector (one-space (cadr in)) in t) | |
3248 "--:shadowEtchedIn")) | |
3249 (list | |
3250 ["Goto Info Top-level" Info-directory] | |
3251 (vector "Next Node" 'Info-next :active next-p) | |
3252 (vector "Previous Node" 'Info-prev :active prev-p) | |
3253 (vector "Parent Node (Up)" 'Info-up :active up-p) | |
3254 ["Goto Node..." Info-goto-node] | |
3255 ["Goto Last Visited Node " Info-last]))) | |
3256 ;; Find the xrefs and make a list | |
3257 (while (re-search-forward xref-regexp nil t) | |
3258 (setq xrefs (cons (one-space (buffer-substring (match-beginning 1) | |
3259 (match-end 1))) | |
3260 xrefs)))) | |
3261 (setq xrefs (nreverse xrefs)) | |
3262 (if (> (length xrefs) 21) (setcdr (nthcdr 20 xrefs) '(more))) | |
3263 ;; Find the subnodes and make a list | |
3264 (goto-char (point-min)) | |
3265 (if (search-forward "\n* menu:" nil t) | |
3266 (while (re-search-forward "^\\* \\([^:\t\n]*\\):" nil t) | |
3267 (setq subnodes (cons (buffer-substring (match-beginning 1) | |
3268 (match-end 1)) | |
3269 subnodes)))) | |
3270 (setq subnodes (nreverse subnodes)) | |
3271 (if (> (length subnodes) 21) (setcdr (nthcdr 20 subnodes) '(more)))) | |
3272 (if xrefs | |
3273 (nconc menu (list "--:shadowDoubleEtchedIn" | |
3274 " Cross-References" | |
3275 "--:singleLine") | |
3276 (mapcar #'(lambda (xref) | |
3277 (if (eq xref 'more) | |
3278 "...more..." | |
3279 (vector xref | |
3280 (list 'Info-follow-reference xref)))) | |
3281 xrefs))) | |
3282 (if subnodes | |
3283 (nconc menu (list "--:shadowDoubleEtchedIn" | |
3284 " Sub-Nodes" | |
3285 "--:singleLine") | |
3286 (mapcar #'(lambda (node) | |
3287 (if (eq node 'more) | |
3288 "...more..." | |
3289 (vector node (list 'Info-menu node)))) | |
3290 subnodes))) | |
3291 menu)) | |
3292 | |
3293 (defun Info-menu-filter (menu) | |
3294 "This is the menu filter for the \"Info\" submenu." | |
3295 (Info-construct-menu)) | |
3296 | |
3297 (defun Info-select-node-menu (event) | |
3298 "Pops up a menu of applicable Info commands." | |
3299 (interactive "e") | |
3300 (select-window (event-window event)) | |
3301 (let ((menu (Info-construct-menu event))) | |
3302 (setq menu (nconc (list "Info" ; title: not displayed | |
3303 " Info Commands" | |
3304 "--:shadowDoubleEtchedOut") | |
3305 menu)) | |
3306 (let ((popup-menu-titles nil)) | |
3307 (popup-menu menu)))) | |
3308 | |
3309 ;;; Info toolbar support | |
3310 | |
3311 ;; exit icon taken from GNUS | |
3312 (defvar info::toolbar-exit-icon | |
3313 (if (featurep 'toolbar) | |
3314 (toolbar-make-button-list | |
3315 (expand-file-name (if (featurep 'xpm) "info-exit.xpm" "info-exit.xbm") | |
3316 toolbar-icon-directory))) | |
3317 "Exit Info icon") | |
3318 | |
3319 (defvar info::toolbar-up-icon | |
3320 (if (featurep 'toolbar) | |
3321 (toolbar-make-button-list | |
3322 (expand-file-name (if (featurep 'xpm) "info-up.xpm" "info-up.xbm") | |
3323 toolbar-icon-directory))) | |
3324 "Up icon") | |
3325 | |
3326 (defvar info::toolbar-next-icon | |
3327 (if (featurep 'toolbar) | |
3328 (toolbar-make-button-list | |
3329 (expand-file-name (if (featurep 'xpm) "info-next.xpm" "info-next.xbm") | |
3330 toolbar-icon-directory))) | |
3331 "Next icon") | |
3332 | |
3333 (defvar info::toolbar-prev-icon | |
3334 (if (featurep 'toolbar) | |
3335 (toolbar-make-button-list | |
3336 (expand-file-name (if (featurep 'xpm) "info-prev.xpm" "info-prev.xbm") | |
3337 toolbar-icon-directory))) | |
3338 "Prev icon") | |
3339 | |
3340 (defvar info::toolbar | |
3341 (if (featurep 'toolbar) | |
3342 ; disabled until we get the next/prev-win icons working again. | |
3343 ; (cons (first initial-toolbar-spec) | |
3344 ; (cons (second initial-toolbar-spec) | |
3345 '([info::toolbar-exit-icon | |
3346 Info-exit | |
3347 t | |
3348 "Exit info"] | |
3349 [info::toolbar-next-icon | |
3350 Info-next | |
3351 t | |
3352 "Next entry in same section"] | |
3353 [info::toolbar-prev-icon | |
3354 Info-prev | |
3355 t | |
3356 "Prev entry in same section"] | |
3357 [info::toolbar-up-icon | |
3358 Info-up | |
3359 t | |
3360 "Up entry to enclosing section"] | |
3361 ))) | |
3362 ;)) | |
3363 | |
3364 (provide 'info) | |
3365 | |
3366 (run-hooks 'Info-load-hook) | |
3367 | |
3368 ;;; info.el ends here |