Mercurial > hg > xemacs-beta
annotate lisp/info.el @ 5567:3bc58dc9d688
Replace #'flet by #'labels where appropriate, core code.
lisp/ChangeLog addition:
2011-09-07 Aidan Kehoe <kehoea@parhasard.net>
* simple.el (transpose-subr):
* specifier.el (let-specifier):
* specifier.el (derive-device-type-from-tag-set):
* test-harness.el (batch-test-emacs):
* x-compose.el (alias-colon-to-doublequote):
* mule/chinese.el (make-chinese-cns11643-charset):
* mule/mule-cmds.el (set-locale-for-language-environment):
* mule/mule-cmds.el (set-language-environment-coding-systems):
* mule/mule-x-init.el (x-use-halfwidth-roman-font):
* about.el (about-xemacs):
* about.el (about-hackers):
* diagnose.el (show-memory-usage):
* diagnose.el (show-object-memory-usage-stats):
* diagnose.el (show-mc-alloc-memory-usage):
* diagnose.el (show-gc-stats):
* dialog.el (make-dialog-box):
* faces.el:
* faces.el (Face-frob-property):
* faces.el (set-face-stipple):
* glyphs.el:
* glyphs.el (init-glyphs): Removed.
* help-macro.el (make-help-screen):
* info.el (Info-construct-menu):
* keymap.el (key-sequence-list-description):
* lisp-mode.el (construct-lisp-mode-menu):
* loadhist.el (unload-feature):
* minibuf.el (get-user-response):
* mouse.el (default-mouse-track-check-for-activation):
* mouse.el (mouse-track-insert-1):
Follow my own advice from the last commit and use #'labels instead
of #'flet in core code.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Wed, 07 Sep 2011 21:21:36 +0100 |
parents | 4dee0387b9de |
children | cc6f0266bc36 |
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) | |
801 (let ((bufs (delq nil (mapcar 'get-file-buffer | |
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 | |
916 (if (string-match "localdir" file) | |
917 "localdir" | |
918 "info dir")))) | |
442 | 919 (if (not buf) |
428 | 920 (insert-file-contents file)) |
921 (if (string-match "localdir" (buffer-name)) | |
922 (setq lbuffers (cons (current-buffer) lbuffers)) | |
923 (setq buffers (cons (current-buffer) buffers))) | |
924 (if attrs | |
925 (setq Info-dir-file-attributes | |
926 (cons (cons file attrs) | |
927 Info-dir-file-attributes))))))) | |
928 (or (cdr dirs) (setq Info-dir-contents-directory (car dirs))) | |
929 (setq dirs (cdr dirs)))) | |
442 | 930 |
428 | 931 ;; ensure that the localdir files are inserted last, and reverse |
932 ;; the list of them so that when they get pushed in, they appear | |
933 ;; in the same order they got specified in the path, from top to | |
934 ;; bottom. | |
935 (nconc buffers (reverse lbuffers)) | |
442 | 936 |
428 | 937 (or buffers |
938 (error "Can't find the Info directory node")) | |
939 ;; Distinguish the dir file that comes with Emacs from all the | |
940 ;; others. Yes, that is really what this is supposed to do. | |
941 ;; If it doesn't work, fix it. | |
942 (setq buffer (car buffers) | |
943 ;; reverse it since they are pushed down from the top. the | |
944 ;; `Info-directory-list can be specified in natural order | |
945 ;; this way. | |
946 others (reverse (cdr buffers))) | |
947 | |
948 ;; Insert the entire original dir file as a start; note that we've | |
949 ;; already saved its default directory to use as the default | |
950 ;; directory for the whole concatenation. | |
951 (insert-buffer buffer) | |
952 | |
953 ;; Look at each of the other buffers one by one. | |
954 (while others | |
955 (let ((other (car others)) | |
956 (info-buffer (current-buffer))) | |
957 (if (string-match "localdir" (buffer-name other)) | |
958 (save-excursion | |
959 (set-buffer info-buffer) | |
960 (goto-char (point-max)) | |
961 (cond | |
962 ((re-search-backward "^ *\\* *Locals *: *$" nil t) | |
963 (delete-region (match-beginning 0) (match-end 0))) | |
964 ;; look for a line like |Local XEmacs packages: | |
965 ;; or mismatch on some text ... | |
966 ((re-search-backward Info-localdir-heading-regexp nil t) | |
967 ;; This is for people who underline topic headings with | |
968 ;; equal signs or dashes. | |
969 (when (save-excursion | |
970 (forward-line 1) | |
971 (beginning-of-line) | |
972 (looking-at "^[ \t]*[-=*]+")) | |
973 (forward-line 1)) | |
974 (forward-line 1) | |
975 (beginning-of-line)) | |
976 (t (search-backward "\^L" nil t))) | |
977 ;; Insert menu part of the file | |
978 (let* ((pt (point)) | |
979 (len (length (buffer-string nil nil other)))) | |
980 (insert (buffer-string nil nil other)) | |
981 (goto-char (+ pt len)) | |
982 (save-excursion | |
983 (goto-char pt) | |
984 (if (search-forward "* Menu:" (+ pt len) t) | |
985 (progn | |
986 (forward-line 1) | |
987 (delete-region pt (point))))))) | |
988 ;; In each, find all the menus. | |
989 (save-excursion | |
990 (set-buffer other) | |
991 (goto-char (point-min)) | |
992 ;; Find each menu, and add an elt to NODES for it. | |
993 (while (re-search-forward "^\\* Menu:" nil t) | |
994 (let (beg nodename end) | |
995 (forward-line 1) | |
996 (setq beg (point)) | |
997 (search-backward "\n\^_") | |
998 (search-forward "Node: ") | |
999 (setq nodename (Info-following-node-name)) | |
1000 (search-forward "\n\^_" nil 'move) | |
1001 (beginning-of-line) | |
1002 (setq end (point)) | |
1003 (setq nodes (cons (list nodename other beg end) nodes)))))) | |
1004 (setq others (cdr others)))) | |
442 | 1005 |
428 | 1006 ;; Add to the main menu a menu item for each other node. |
1007 (re-search-forward "^\\* Menu:" nil t) | |
1008 (forward-line 1) | |
1009 (let ((menu-items '("top")) | |
1010 (nodes nodes) | |
1011 (case-fold-search t) | |
1012 (end (save-excursion (search-forward "\^_" nil t) (point)))) | |
1013 (while nodes | |
1014 (let ((nodename (car (car nodes)))) | |
1015 (save-excursion | |
1016 (or (member (downcase nodename) menu-items) | |
1017 (re-search-forward (concat "^\\* " | |
1018 (regexp-quote nodename) | |
1019 "::") | |
1020 end t) | |
1021 (progn | |
1022 (insert "* " nodename "::" "\n") | |
1023 (setq menu-items (cons nodename menu-items)))))) | |
1024 (setq nodes (cdr nodes)))) | |
1025 ;; Now take each node of each of the other buffers | |
1026 ;; and merge it into the main buffer. | |
1027 (while nodes | |
1028 (let ((nodename (car (car nodes)))) | |
1029 (goto-char (point-min)) | |
1030 ;; Find the like-named node in the main buffer. | |
1031 (if (re-search-forward (concat "\n\^_.*\n.*Node: " | |
1032 (regexp-quote nodename) | |
1033 "[,\n\t]") | |
1034 nil t) | |
1035 (progn | |
1036 (search-forward "\n\^_" nil 'move) | |
1037 (beginning-of-line) | |
1038 (insert "\n")) | |
1039 ;; If none exists, add one. | |
1040 (goto-char (point-max)) | |
1041 (insert "\^_\nFile: dir\tNode: " nodename "\n\n* Menu:\n\n")) | |
1042 ;; Merge the text from the other buffer's menu | |
1043 ;; into the menu in the like-named node in the main buffer. | |
1044 (apply 'insert-buffer-substring (cdr (car nodes)))) | |
1045 (setq nodes (cdr nodes))) | |
1046 ;; Kill all the buffers we just made. | |
1047 (while buffers | |
1048 (kill-buffer (car buffers)) | |
1049 (setq buffers (cdr buffers))) | |
1050 (while lbuffers | |
1051 (kill-buffer (car lbuffers)) | |
1052 (setq lbuffers (cdr lbuffers))) | |
1053 (message "Composing main Info directory...done")) | |
1054 (setq Info-dir-contents (buffer-string))) | |
1232 | 1055 (setq default-directory (file-name-as-directory Info-dir-contents-directory)) |
3693 | 1056 (setq buffer-file-name (caar Info-dir-file-attributes) |
1057 buffer-file-truename (file-truename buffer-file-name))) | |
428 | 1058 |
444 | 1059 (defmacro Info-directory-files (dir-file &optional all full nosort files-only) |
1060 "Return a list of Info files living in the same directory as DIR-FILE. | |
1061 This list actually contains the files living in this directory, except for | |
1062 the dir file itself and the secondary info files (foo-1 foo-2 etc). | |
1063 | |
1064 If the optional argument ALL is non nil, the secondary info files are also | |
1065 included in the list. | |
1066 | |
1067 Please refer to the function `directory-files' for the meaning of the other | |
1068 optional arguments." | |
1069 `(let* ((dir (file-name-directory ,dir-file)) | |
1070 (all-files (remove ,dir-file (directory-files dir ',full nil ',nosort | |
1071 ',files-only)))) | |
1072 (setq all-files | |
1073 (if ,full | |
1074 (remove (concat dir ".") | |
1075 (remove (concat dir "..") all-files)) | |
1076 (remove "." | |
1077 (remove ".." all-files)))) | |
1078 (if ,all | |
1079 all-files | |
1080 (let ((suff-match | |
1081 (concat "-[0-9]+\\(" | |
1082 ;; Extract all known compression suffixes from | |
1083 ;; Info-suffix-list. These suffixes can typically be | |
1084 ;; found in entries of the form `.info.something'. | |
1085 (let ((suff-list Info-suffix-list) | |
1086 suff regexp) | |
1087 (while (setq suff (pop suff-list)) | |
1088 (and (string-match "^\\.info" (car suff)) | |
1089 (setq regexp (concat regexp | |
1090 (regexp-quote | |
1091 (substring | |
1092 (car suff) 5)) | |
1093 (and suff-list "\\|"))))) | |
1094 regexp) | |
1095 "\\)?$")) | |
1096 info-files file) | |
1097 (while (setq file (pop all-files)) | |
1098 (or (string-match suff-match file) | |
1099 (push file info-files))) | |
1100 (reverse info-files) | |
1101 )) | |
1102 )) | |
1103 | |
428 | 1104 (defun Info-maybe-update-dir (file) |
1105 "Rebuild dir or localdir according to `Info-auto-generate-directory'." | |
1106 (unless (or (not (file-exists-p (file-name-directory file))) | |
444 | 1107 (null (Info-directory-files file 'all))) |
428 | 1108 (if (not (find-buffer-visiting file)) |
1109 (if (not (file-exists-p file)) | |
747 | 1110 (if (or (memq Info-auto-generate-directory |
1111 '(always if-missing if-outdated))) | |
428 | 1112 (Info-build-dir-anew (file-name-directory file))) |
1113 (if (or (eq Info-auto-generate-directory 'always) | |
1114 (and (eq Info-auto-generate-directory 'if-outdated) | |
1115 (Info-dir-outdated-p file))) | |
1116 (Info-rebuild-dir file)))))) | |
1117 | |
1118 ;; Record which *.info files are newer than the dir file | |
1119 (defvar Info-dir-newer-info-files nil) | |
1120 | |
1121 (defun Info-dir-outdated-p (file) | |
1122 "Return non-nil if dir or localdir is outdated. | |
1123 dir or localdir are outdated when an info file in the same | |
1124 directory has been modified more recently." | |
1125 (let ((dir-mod-time (nth 5 (file-attributes file))) | |
444 | 1126 f-mod-time newer) |
428 | 1127 (setq Info-dir-newer-info-files nil) |
5369
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1128 (mapc |
428 | 1129 #'(lambda (f) |
1130 (prog2 | |
1131 (setq f-mod-time (nth 5 (file-attributes f))) | |
1132 (setq newer (or (> (car f-mod-time) (car dir-mod-time)) | |
1133 (and (= (car f-mod-time) (car dir-mod-time)) | |
444 | 1134 (> (car (cdr f-mod-time)) |
1135 (car (cdr dir-mod-time)))))) | |
1136 (if (and (file-readable-p f) newer) | |
442 | 1137 (setq Info-dir-newer-info-files |
428 | 1138 (cons f Info-dir-newer-info-files))))) |
444 | 1139 (Info-directory-files file nil 'fullname 'nosort t)) |
428 | 1140 Info-dir-newer-info-files)) |
1141 | |
1142 (defun Info-extract-dir-entry-from (file) | |
1143 "Extract the dir entry from the info FILE. | |
1144 The dir entry is delimited by the markers `START-INFO-DIR-ENTRY' | |
444 | 1145 and `END-INFO-DIR-ENTRY'." |
428 | 1146 (save-excursion |
1147 (set-buffer (get-buffer-create " *Info-tmp*")) | |
1148 (when (file-readable-p file) | |
1149 (insert-file-contents file nil nil nil t) | |
1150 (goto-char (point-min)) | |
1151 (let (beg) | |
1152 (unless (null (re-search-forward "^START-INFO-DIR-ENTRY" nil t)) | |
1153 (forward-line 1) | |
1154 (setq beg (point)) | |
1155 (unless (null (re-search-forward "^END-INFO-DIR-ENTRY" nil t)) | |
1156 (goto-char (match-beginning 0)) | |
1157 (car (Info-parse-dir-entries beg (point))))))))) | |
1158 | |
444 | 1159 ;; Parse dir entries contained between START and END into a list of the form |
428 | 1160 ;; (filename topic node (description-line-1 description-line-2 ...)) |
444 | 1161 (defun Info-parse-dir-entries (start end) |
428 | 1162 (let (entry entries) |
1163 (save-excursion | |
1164 (save-restriction | |
444 | 1165 (narrow-to-region start end) |
1166 (goto-char start) | |
1167 (while (re-search-forward | |
1168 "^\\* \\([^:]+\\):\\([ \t]*(\\([^)]*\\))\\w*\\.\\|:\\)" nil t) | |
428 | 1169 (setq entry (list (match-string 2) |
1170 (match-string 1) | |
1171 (downcase (or (match-string 3) | |
1172 (match-string 1))))) | |
442 | 1173 (setq entry |
1174 (cons (nreverse | |
1175 (cdr | |
1176 (nreverse | |
1177 (split-string | |
1178 (buffer-substring | |
428 | 1179 (re-search-forward "[ \t]*" nil t) |
1180 (or (and (re-search-forward "^[^ \t]" nil t) | |
1181 (goto-char (match-beginning 0))) | |
1182 (point-max))) | |
1183 "[ \t]*\n[ \t]*")))) | |
1184 entry)) | |
1185 (setq entries (cons (nreverse entry) entries))))) | |
1186 (nreverse entries))) | |
1187 | |
1188 (defun Info-dump-dir-entries (entries) | |
1189 (let ((tab-width 8) | |
1190 (description-col 0) | |
1191 len) | |
5369
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1192 (mapc #'(lambda (e) |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1193 (setq e (cdr e)) ; Drop filename |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1194 (setq len (length (concat (car e) |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1195 (car (cdr e))))) |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1196 (if (> len description-col) |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1197 (setq description-col len))) |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1198 entries) |
442 | 1199 (setq description-col (+ 5 description-col)) |
5369
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1200 (mapc #'(lambda (e) |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1201 (setq e (cdr e)) ; Drop filename |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1202 (insert "* " (car e) ":" (car (cdr e))) |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1203 (setq e (car (cdr (cdr e)))) |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1204 (while e |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1205 (indent-to-column description-col) |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1206 (insert (car e) "\n") |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1207 (setq e (cdr e)))) |
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1208 entries) |
428 | 1209 (insert "\n"))) |
1210 | |
1211 | |
1212 (defun Info-build-dir-anew (directory) | |
1213 "Build info directory information for DIRECTORY. | |
442 | 1214 The generated directory listing may be saved to a `dir' according |
444 | 1215 to the value of `Info-save-auto-generated-dir'." |
428 | 1216 (save-excursion |
1217 (let* ((dirfile (expand-file-name "dir" directory)) | |
1218 (to-temp (or (null Info-save-auto-generated-dir) | |
1219 (eq Info-save-auto-generated-dir 'never) | |
1220 (and (not (file-writable-p dirfile)) | |
444 | 1221 (message "File not writable %s. Using temporary." |
1222 dirfile)))) | |
1223 (info-files (Info-directory-files dirfile nil 'fullname nil t))) | |
428 | 1224 (if to-temp |
1225 (message "Creating temporary dir in %s..." directory) | |
1226 (message "Creating %s..." dirfile)) | |
1227 (set-buffer (find-file-noselect dirfile t)) | |
1228 (setq buffer-read-only nil) | |
1229 (erase-buffer) | |
444 | 1230 (insert Info-dir-prologue "Info files in " directory ":\n\n") |
442 | 1231 (Info-dump-dir-entries |
1232 (mapcar | |
428 | 1233 #'(lambda (f) |
1234 (or (Info-extract-dir-entry-from f) | |
1235 (list 'dummy | |
444 | 1236 (progn (string-match "\\([^.]*\\)\\(\\..*\\)?$" |
1237 (file-name-nondirectory f)) | |
1238 (capitalize | |
1239 (match-string 1 (file-name-nondirectory f)))) | |
428 | 1240 ":" |
1241 (list Info-no-description-string)))) | |
1242 info-files)) | |
1243 (if to-temp | |
1244 (set-buffer-modified-p nil) | |
1245 (save-buffer)) | |
1246 (if to-temp | |
1247 (message "Creating temporary dir in %s...done" directory) | |
1248 (message "Creating %s...done" dirfile))))) | |
1249 | |
1250 | |
1251 (defun Info-rebuild-dir (file) | |
1252 "Build info directory information in the directory of dir FILE. | |
442 | 1253 Description of info files are merged from the info files in the |
428 | 1254 directory and the contents of FILE with the description in info files |
442 | 1255 taking precedence over descriptions in FILE. |
1256 The generated directory listing may be saved to a `dir' according to | |
444 | 1257 the value of `Info-save-auto-generated-dir'." |
428 | 1258 (save-excursion |
1259 (save-restriction | |
1260 (let (dir-section-contents dir-full-contents | |
1261 dir-entry | |
1262 file-dir-entry | |
1263 mark next-section | |
1264 not-first-section | |
442 | 1265 (to-temp |
428 | 1266 (or (null Info-save-auto-generated-dir) |
1267 (eq Info-save-auto-generated-dir 'never) | |
1268 (and (eq Info-save-auto-generated-dir 'always) | |
1269 (not (file-writable-p file)) | |
1270 (message "File not writable %s. Using temporary." file)) | |
1271 (and (eq Info-save-auto-generated-dir 'conservative) | |
1272 (or (and (not (file-writable-p file)) | |
444 | 1273 (message |
1274 "File not writable %s. Using temporary." file)) | |
442 | 1275 (not (y-or-n-p |
1276 (message "%s is outdated. Overwrite ? " | |
428 | 1277 file)))))))) |
1278 (set-buffer (find-file-noselect file t)) | |
1279 (setq buffer-read-only nil) | |
1280 (if to-temp | |
1281 (message "Rebuilding temporary %s..." file) | |
1282 (message "Rebuilding %s..." file)) | |
1283 (catch 'done | |
1284 (setq buffer-read-only nil) | |
1285 (goto-char (point-min)) | |
1286 (unless (and (search-forward "\^_") | |
1287 (re-search-forward "^\\* Menu:.*$" nil t) | |
1288 (setq mark (and (re-search-forward "^\\* " nil t) | |
1289 (match-beginning 0)))) | |
1290 (throw 'done nil)) | |
1291 (setq dir-full-contents (Info-parse-dir-entries mark (point-max))) | |
444 | 1292 (setq next-section (or (and (re-search-forward "^[^* \t].*:[ \t]*$" |
1293 nil t) | |
428 | 1294 (match-beginning 0)) |
1295 (point-max))) | |
1296 (while next-section | |
1297 (narrow-to-region mark next-section) | |
444 | 1298 (setq dir-section-contents (nreverse (Info-parse-dir-entries |
1299 (point-min) (point-max)))) | |
5369
4141aeddc55b
Eliminate byte-compile warnings, core Lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5366
diff
changeset
|
1300 (mapc |
428 | 1301 #'(lambda (file) |
1302 (setq dir-entry (assoc (downcase | |
1303 (file-name-sans-extension | |
1304 (file-name-nondirectory file))) | |
1305 dir-section-contents) | |
1306 file-dir-entry (Info-extract-dir-entry-from file)) | |
1307 (if dir-entry | |
1308 (if file-dir-entry | |
444 | 1309 ;; A dir entry in the info file takes precedence over |
1310 ;; an existing entry in the dir file | |
428 | 1311 (setcdr dir-entry (cdr file-dir-entry))) |
1312 (unless (or not-first-section | |
1313 (assoc (downcase | |
1314 (file-name-sans-extension | |
1315 (file-name-nondirectory file))) | |
1316 dir-full-contents)) | |
1317 (if file-dir-entry | |
444 | 1318 (setq dir-section-contents |
1319 (cons file-dir-entry dir-section-contents)) | |
442 | 1320 (setq dir-section-contents |
428 | 1321 (cons (list 'dummy |
1322 (capitalize (file-name-sans-extension | |
444 | 1323 (file-name-nondirectory |
1324 file))) | |
428 | 1325 ":" |
442 | 1326 (list Info-no-description-string)) |
428 | 1327 dir-section-contents)))))) |
1328 Info-dir-newer-info-files) | |
1329 (delete-region (point-min) (point-max)) | |
1330 (Info-dump-dir-entries (nreverse dir-section-contents)) | |
1331 (widen) | |
1332 (if (= next-section (point-max)) | |
1333 (setq next-section nil) | |
1334 (or (setq mark (and (re-search-forward "^\\* " nil t) | |
1335 (match-beginning 0))) | |
1336 (throw 'done nil)) | |
444 | 1337 (setq next-section (or (and (re-search-forward |
1338 "^[^* \t].*:[ \t]*$" nil t) | |
428 | 1339 (match-beginning 0)) |
1340 (point-max)))) | |
1341 (setq not-first-section t))) | |
1342 (if to-temp | |
1343 (progn | |
1344 (set-buffer-modified-p nil) | |
1345 (message "Rebuilding temporary %s...done" file)) | |
1346 (save-buffer) | |
1347 (message "Rebuilding %s...done" file)))))) | |
1348 | |
442 | 1349 ;;;###autoload |
428 | 1350 (defun Info-batch-rebuild-dir () |
444 | 1351 "(Re)build `dir' files in the directories remaining on the command line. |
1352 Use this from the command line, with `-batch', it won't work in an | |
1353 interactive XEmacs. | |
1354 | |
1355 Each file is processed even if an error occurred previously. For example, | |
1356 invoke \"xemacs -batch -f Info-batch-rebuild-dir /usr/local/info\"." | |
428 | 1357 ;; command-line-args-left is what is left of the command line (from |
1358 ;; startup.el) | |
1359 (defvar command-line-args-left) ; Avoid 'free variable' warning | |
1360 (if (not noninteractive) | |
1361 (error "`Info-batch-rebuild-dir' is to be used only with -batch")) | |
1362 (let ((Info-save-auto-generated-dir 'always) | |
1363 dir localdir) | |
1364 (while command-line-args-left | |
1365 (if (not (file-directory-p (car command-line-args-left))) | |
1366 (message "Warning: Skipped %s. Not a directory." | |
1367 (car command-line-args-left)) | |
1368 (setq dir (expand-file-name "dir" (car command-line-args-left))) | |
444 | 1369 (setq localdir (expand-file-name "localdir" |
1370 (car command-line-args-left))) | |
442 | 1371 (cond |
428 | 1372 ((file-exists-p dir) |
1373 (Info-rebuild-dir dir)) | |
1374 ((file-exists-p localdir) | |
1375 (Info-rebuild-dir localdir)) | |
1376 (t | |
1377 (Info-build-dir-anew (car command-line-args-left))))) | |
1378 (setq command-line-args-left (cdr command-line-args-left))) | |
1379 (message "Done") | |
1380 (kill-emacs 0))) | |
1381 | |
1382 (defun Info-history-add (file node point) | |
1383 (if Info-keeping-history | |
1384 (let* ((name (format "(%s)%s" (Info-file-name-only file) node)) | |
1385 (found (assoc name Info-history))) | |
1386 (if found | |
1387 (setq Info-history (delq found Info-history))) | |
1388 (setq Info-history (cons (list name (- point (point-min)) | |
1389 (and (eq (window-buffer) | |
1390 (current-buffer)) | |
1391 (- (window-start) (point-min)))) | |
1392 Info-history))))) | |
1393 | |
1394 (defun Info-file-name-only (file) | |
1395 (let ((dir (file-name-directory file)) | |
1396 (p Info-directory-list)) | |
1397 (while (and p (not (equal (car p) dir))) | |
1398 (setq p (cdr p))) | |
1399 (if p (file-name-nondirectory file) file))) | |
1400 | |
1401 (defun Info-read-subfile (nodepos) | |
1402 (let (lastfilepos | |
1403 lastfilename) | |
442 | 1404 (save-excursion |
1405 (set-buffer (marker-buffer Info-tag-table-marker)) | |
1406 (goto-char (point-min)) | |
1407 (search-forward "\n\^_") | |
1408 (forward-line 2) | |
1409 (catch 'foo | |
1410 (while (not (looking-at "\^_")) | |
1411 (if (not (eolp)) | |
444 | 1412 (let ((start (point)) |
442 | 1413 thisfilepos thisfilename) |
1414 (search-forward ": ") | |
444 | 1415 (setq thisfilename (buffer-substring start (- (point) 2))) |
442 | 1416 (setq thisfilepos (read (current-buffer))) |
1417 ;; read in version 19 stops at the end of number. | |
1418 ;; Advance to the next line. | |
1419 (if (eolp) | |
1420 (forward-line 1)) | |
1421 (if (> thisfilepos nodepos) | |
1422 (throw 'foo t)) | |
1423 (setq lastfilename thisfilename) | |
1424 (setq lastfilepos thisfilepos)) | |
1425 (throw 'foo t))))) | |
428 | 1426 (or (equal Info-current-subfile lastfilename) |
1427 (let ((buffer-read-only nil)) | |
3693 | 1428 (setq buffer-file-name nil |
1429 buffer-file-truename nil) | |
428 | 1430 (widen) |
1431 (erase-buffer) | |
1432 (Info-insert-file-contents (Info-suffixed-file | |
1433 (expand-file-name lastfilename | |
1434 (file-name-directory | |
444 | 1435 Info-current-file)) |
1436 'exact) | |
428 | 1437 t) |
1438 (set-buffer-modified-p nil) | |
1439 (setq Info-current-subfile lastfilename))) | |
1440 (goto-char (point-min)) | |
1441 (search-forward "\n\^_") | |
1442 (+ (- nodepos lastfilepos) (point)))) | |
1443 | |
444 | 1444 (defun Info-all-case-regexp (str) |
1445 (let ((regexp "") | |
1446 (len (length str)) | |
1447 (i 0) | |
1448 c) | |
1449 (while (< i len) | |
1450 (setq c (aref str i)) | |
1451 (cond ((or (and (>= c ?A) (<= c ?Z)) | |
1452 (and (>= c ?a) (<= c ?z))) | |
1453 (setq regexp (concat regexp | |
1454 "[" | |
1455 (char-to-string (downcase c)) | |
1456 "\\|" | |
1457 (char-to-string (upcase c)) | |
1458 "]"))) | |
1459 (t | |
1460 (setq regexp (concat regexp (char-to-string c))))) | |
1461 (setq i (1+ i))) | |
1462 regexp)) | |
1463 | |
1464 (defun Info-suffixed-file (name &optional exact) | |
1465 "Look for an info file named NAME. This function tries to be smart in | |
1466 finding the file corresponding to NAME: if it doesn't exist, several | |
1467 variants are looked for, notably by appending suffixes from | |
1468 `Info-suffix-list' and by trying to change the characters case in NAME. | |
1469 | |
1470 The optional argument EXACT prevents this function from trying different case | |
1471 versions of NAME. Only the suffixes are tried." | |
1472 (catch 'found | |
1473 ;; First, try NAME alone: | |
1474 (and (file-regular-p name) (throw 'found name)) | |
1475 ;; Then, try different variants | |
1476 (let ((suff-match (concat "\\(" | |
1477 (let ((suff-list Info-suffix-list) | |
1478 suff regexp) | |
1479 (while (setq suff (pop suff-list)) | |
1480 (setq regexp | |
1481 (concat regexp | |
1482 (regexp-quote (car suff)) | |
1483 (and suff-list "\\|")))) | |
1484 regexp) | |
1485 "\\)?$")) | |
1486 (dir (file-name-directory name)) | |
1487 file files) | |
1488 (setq name (file-name-nondirectory name)) | |
1489 (setq files | |
793 | 1490 (with-trapping-errors ;; protect against invalid directory |
1491 :operation (format "directory `%s'" dir) | |
1492 :class 'info | |
1493 :error-form nil | |
1494 :no-backtrace t | |
1495 ;; First, try NAME[.<suffix>] | |
1496 (append | |
1497 (directory-files dir 'fullname | |
1498 (concat "^" (regexp-quote name) suff-match) | |
1499 nil t) | |
1500 (if exact | |
1501 nil | |
5384
3889ef128488
Fix misspelled words, and some grammar, across the entire source tree.
Jerry James <james@xemacs.org>
parents:
5369
diff
changeset
|
1502 ;; Then, try to match the name independently of the |
793 | 1503 ;; characters case. |
444 | 1504 (directory-files dir 'fullname |
793 | 1505 (Info-all-case-regexp |
1506 (concat "^" | |
1507 (regexp-quote name) | |
1508 suff-match)) | |
1509 nil t))))) | |
444 | 1510 (while (setq file (pop files)) |
1511 (and (file-regular-p file) | |
1512 (throw 'found file))) | |
1513 ))) | |
428 | 1514 |
1515 (defun Info-insert-file-contents (file &optional visit) | |
1516 (setq file (expand-file-name file default-directory)) | |
444 | 1517 (let ((suff Info-suffix-list) |
1518 len) | |
1519 (while (and suff | |
1520 (setq len (length (car (car suff)))) | |
1521 (or (<= (length file) len) | |
1522 (not (or | |
1523 (equal (substring file (- len)) | |
1524 (car (car suff))) | |
1525 (equal (substring file (- len)) | |
1526 (upcase (car (car suff))))) | |
1527 ))) | |
428 | 1528 (setq suff (cdr suff))) |
1529 (if (stringp (cdr (car suff))) | |
1530 (let ((command (if (string-match "%s" (cdr (car suff))) | |
1531 (format (cdr (car suff)) file) | |
1532 (concat (cdr (car suff)) " < " file)))) | |
1533 (message "%s..." command) | |
1870 | 1534 (call-process shell-file-name nil t nil shell-command-switch command) |
428 | 1535 (message "") |
1536 (when visit | |
3693 | 1537 (setq buffer-file-name file |
1538 buffer-file-truename (file-truename buffer-file-name)) | |
428 | 1539 (set-buffer-modified-p nil) |
1540 (clear-visited-file-modtime))) | |
1541 (insert-file-contents file visit)))) | |
1542 | |
1543 (defun Info-select-node () | |
1544 "Select the node that point is in, after using `g *' to select whole file." | |
1545 (interactive) | |
1546 (widen) | |
1547 (save-excursion | |
1548 ;; Find beginning of node. | |
1549 (search-backward "\n\^_") | |
1550 (forward-line 2) | |
1551 ;; Get nodename spelled as it is in the node. | |
1552 (re-search-forward "Node:[ \t]*") | |
1553 (setq Info-current-node | |
1554 (buffer-substring (point) | |
1555 (progn | |
1556 (skip-chars-forward "^,\t\n") | |
1557 (point)))) | |
1558 (Info-set-mode-line) | |
1559 ;; Find the end of it, and narrow. | |
1560 (beginning-of-line) | |
1561 (let (active-expression) | |
1562 (narrow-to-region (point) | |
1563 (if (re-search-forward "\n[\^_\f]" nil t) | |
1564 (prog1 | |
1565 (1- (point)) | |
1566 (if (looking-at "[\n\^_\f]*execute: ") | |
1567 (progn | |
1568 (goto-char (match-end 0)) | |
1569 (setq active-expression | |
1570 (read (current-buffer)))))) | |
1571 (point-max))) | |
1572 (or (equal Info-footnote-tag "Note") | |
1573 (progn | |
1574 (goto-char (point-min)) | |
1575 (let ((buffer-read-only nil) | |
1576 (bufmod (buffer-modified-p)) | |
1577 (case-fold-search t)) | |
1578 (while (re-search-forward "\\*[Nn]ote\\([ \n]\\)" nil t) | |
1579 (replace-match (concat "*" Info-footnote-tag "\ "))) | |
1580 (set-buffer-modified-p bufmod)))) | |
1581 (Info-reannotate-node) | |
1582 ;; XEmacs: remove v19 test | |
1583 (and Info-fontify | |
1584 (Info-fontify-node)) | |
1585 (run-hooks 'Info-select-hook) | |
1586 (if Info-enable-active-nodes (eval active-expression))))) | |
1587 | |
1588 (defun Info-set-mode-line () | |
1589 (setq modeline-buffer-identification | |
1590 (list (cons modeline-buffer-id-left-extent "Info: ") | |
1591 (cons modeline-buffer-id-right-extent | |
1592 (concat | |
1593 "(" | |
1594 (if Info-current-file | |
444 | 1595 (let ((name (file-name-nondirectory |
1596 Info-current-file))) | |
1597 (if (string-match "^\\([^.]*\\)\\..*$" name) | |
1598 (match-string 1 name) | |
428 | 1599 name)) |
1600 "") | |
1601 ")" | |
1602 (or Info-current-node "")))))) | |
771 | 1603 |
428 | 1604 |
1605 ;; Go to an info node specified with a filename-and-nodename string | |
1606 ;; of the sort that is found in pointers in nodes. | |
1607 | |
1608 ;;;###autoload | |
1609 (defun Info-goto-node (nodename &optional no-going-back tryfile) | |
1610 "Go to info node named NAME. Give just NODENAME or (FILENAME)NODENAME. | |
1611 Actually, the following interpretations of NAME are tried in order: | |
1612 (FILENAME)NODENAME | |
1613 (FILENAME) (using Top node) | |
1614 NODENAME (in current file) | |
1615 TAGNAME (see below) | |
1616 FILENAME (using Top node) | |
1617 where TAGNAME is a string that appears in quotes: \"TAGNAME\", in an | |
1618 annotation for any node of any file. (See `a' and `x' commands.)" | |
1619 (interactive (list (Info-read-node-name "Goto node, file or tag: ") | |
1620 nil t)) | |
1621 (let (filename) | |
1622 (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)" | |
1623 nodename) | |
1624 (setq filename (if (= (match-beginning 1) (match-end 1)) | |
1625 "" | |
1626 (substring nodename (match-beginning 2) (match-end 2))) | |
1627 nodename (substring nodename (match-beginning 3) (match-end 3))) | |
1628 (let ((trim (string-match "\\s *\\'" filename))) | |
1629 (if trim (setq filename (substring filename 0 trim)))) | |
1630 (let ((trim (string-match "\\s *\\'" nodename))) | |
1631 (if trim (setq nodename (substring nodename 0 trim)))) | |
1632 (Info-find-node (if (equal filename "") nil filename) | |
1633 (if (equal nodename "") "Top" nodename) | |
1634 no-going-back (and tryfile (equal filename ""))))) | |
1635 | |
1636 (defun Info-goto-bookmark () | |
1637 (interactive) | |
1638 (let ((completion-ignore-case nil) | |
1639 (tag (completing-read "Goto tag: " | |
1640 (Info-build-annotation-completions) | |
1641 nil t nil | |
1642 'Info-minibuffer-history))) | |
1643 (or (equal tag "") (Info-find-node nil (format "<<%s>>" tag))))) | |
1644 | |
1645 ;;;###autoload | |
438 | 1646 (defun Info-visit-file (file) |
428 | 1647 "Directly visit an info file." |
438 | 1648 (interactive "fVisit Info file: ") |
1649 (Info-find-node (expand-file-name file) "Top")) | |
428 | 1650 |
1651 (defun Info-restore-point (&optional always) | |
1652 "Restore point to same location it had last time we were in this node." | |
1653 (interactive "p") | |
1654 (if (or Info-restoring-point always) | |
1655 (let* ((name (format "(%s)%s" | |
1656 (Info-file-name-only Info-current-file) | |
1657 Info-current-node)) | |
1658 (p (assoc name Info-history))) | |
1659 (if p (Info-restore-history-entry p))))) | |
1660 | |
1661 (defun Info-restore-history-entry (entry) | |
1662 (goto-char (+ (nth 1 entry) (point-min))) | |
1663 (and (nth 2 entry) | |
1664 (get-buffer-window (current-buffer)) | |
1665 (set-window-start (get-buffer-window (current-buffer)) | |
1666 (+ (nth 2 entry) (point-min))))) | |
1667 | |
438 | 1668 (defvar Info-read-node-completion-table) |
1669 | |
1670 ;; This function is used as the "completion table" while reading a node name. | |
1671 ;; It does completion using the alist in Info-read-node-completion-table | |
1672 ;; unless STRING starts with an open-paren. | |
1673 (defun Info-read-node-name-1 (string predicate code) | |
1674 (let ((no-completion (and (> (length string) 0) (eq (aref string 0) ?\()))) | |
1675 (cond ((eq code nil) | |
1676 (if no-completion | |
1677 string | |
444 | 1678 (try-completion string Info-read-node-completion-table |
1679 predicate))) | |
438 | 1680 ((eq code t) |
1681 (if no-completion | |
1682 nil | |
444 | 1683 (all-completions string Info-read-node-completion-table |
1684 predicate))) | |
438 | 1685 ((eq code 'lambda) |
1686 (if no-completion | |
1687 t | |
1688 (assoc string Info-read-node-completion-table)))))) | |
1689 | |
428 | 1690 (defun Info-read-node-name (prompt &optional default) |
1691 (Info-setup-initial) | |
1692 (let* ((completion-ignore-case t) | |
438 | 1693 (Info-read-node-completion-table (Info-build-node-completions)) |
1694 (nodename (completing-read prompt 'Info-read-node-name-1 | |
1695 nil t nil 'Info-minibuffer-history | |
1696 default))) | |
428 | 1697 (if (equal nodename "") |
1698 (or default | |
1699 (Info-read-node-name prompt)) | |
1700 nodename))) | |
1701 | |
1702 (defun Info-build-annotation-completions () | |
1703 (or Info-current-annotation-completions | |
1704 (save-excursion | |
1705 (let ((bufs (delq nil (mapcar 'get-file-buffer | |
1706 Info-annotations-path))) | |
1707 (compl nil)) | |
1708 (while bufs | |
1709 (set-buffer (car bufs)) | |
1710 (goto-char (point-min)) | |
1711 (while (re-search-forward "<<\\(.*\\)>>" nil t) | |
1712 (setq compl (cons (list (buffer-substring (match-beginning 1) | |
1713 (match-end 1))) | |
1714 compl))) | |
1715 (setq bufs (cdr bufs))) | |
1716 (setq Info-current-annotation-completions compl))))) | |
1717 | |
1718 (defun Info-build-node-completions () | |
1719 (or Info-current-file-completions | |
442 | 1720 (let ((m Info-tag-table-marker) |
1721 (compl (Info-build-annotation-completions))) | |
428 | 1722 (save-excursion |
1723 (save-restriction | |
1724 (widen) | |
1725 (if (marker-buffer Info-tag-table-marker) | |
1726 (progn | |
1727 (set-buffer (marker-buffer Info-tag-table-marker)) | |
442 | 1728 (goto-char m) |
428 | 1729 (while (re-search-forward "\nNode: \\(.*\\)\177" nil t) |
1730 (setq compl | |
1731 (cons (list (buffer-substring (match-beginning 1) | |
1732 (match-end 1))) | |
1733 compl)))) | |
1734 (goto-char (point-min)) | |
1735 (while (search-forward "\n\^_" nil t) | |
1736 (forward-line 1) | |
444 | 1737 (let ((start (point))) |
428 | 1738 (forward-line 1) |
1739 (if (re-search-backward "Node: *\\([^,\n]*\\) *[,\n\t]" | |
444 | 1740 start t) |
442 | 1741 (setq compl |
428 | 1742 (cons (list (buffer-substring (match-beginning 1) |
1743 (match-end 1))) | |
1744 compl)))))))) | |
1745 (setq Info-current-file-completions compl)))) | |
1746 | |
1747 (defvar Info-last-search nil | |
1748 "Default regexp for \\<Info-mode-map>\\[Info-search] command to search for.") | |
1749 | |
1750 | |
1751 ;;;###autoload | |
1752 (defun Info-search (regexp) | |
1753 "Search for REGEXP, starting from point, and select node it's found in." | |
438 | 1754 (interactive (list |
1755 (read-from-minibuffer | |
1756 (if Info-last-search | |
1757 (format "Search (regexp, default %s): " | |
1758 Info-last-search) | |
1759 "Search (regexp): ") | |
1760 nil nil nil nil nil Info-last-search))) | |
1761 (setq Info-last-search regexp) | |
428 | 1762 (with-search-caps-disable-folding regexp t |
1763 (let ((found ()) | |
1764 (onode Info-current-node) | |
1765 (ofile Info-current-file) | |
1766 (opoint (point)) | |
1767 (osubfile Info-current-subfile)) | |
1768 (save-excursion | |
1769 (save-restriction | |
1770 (widen) | |
1771 (if (null Info-current-subfile) | |
1772 (progn (re-search-forward regexp) (setq found (point))) | |
1773 (condition-case nil | |
1774 (progn (re-search-forward regexp) (setq found (point))) | |
1775 (search-failed nil))))) | |
444 | 1776 (if (not found) |
1777 ;; can only happen in subfile case -- else would have erred | |
428 | 1778 (unwind-protect |
1779 (let ((list ())) | |
442 | 1780 (save-excursion |
1781 (set-buffer (marker-buffer Info-tag-table-marker)) | |
1782 (goto-char (point-min)) | |
1783 (search-forward "\n\^_\nIndirect:") | |
1784 (save-restriction | |
1785 (narrow-to-region (point) | |
1786 (progn (search-forward "\n\^_") | |
1787 (1- (point)))) | |
1788 (goto-char (point-min)) | |
1789 (search-forward (concat "\n" osubfile ": ")) | |
1790 (beginning-of-line) | |
1791 (while (not (eobp)) | |
1792 (re-search-forward "\\(^.*\\): [0-9]+$") | |
1793 (goto-char (+ (match-end 1) 2)) | |
1794 (setq list (cons (cons (read (current-buffer)) | |
444 | 1795 (buffer-substring |
1796 (match-beginning 1) | |
1797 (match-end 1))) | |
442 | 1798 list)) |
1799 (goto-char (1+ (match-end 0)))) | |
1800 (setq list (nreverse list) | |
1801 list (cdr list)))) | |
428 | 1802 (while list |
1803 (message "Searching subfile %s..." (cdr (car list))) | |
1804 (Info-read-subfile (car (car list))) | |
1805 (setq list (cdr list)) | |
1806 (goto-char (point-min)) | |
1807 (if (re-search-forward regexp nil t) | |
1808 (setq found (point) list ()))) | |
1809 (if found | |
1810 (message "") | |
1811 (signal 'search-failed (list regexp)))) | |
1812 (if (not found) | |
1813 (progn (Info-read-subfile opoint) | |
1814 (goto-char opoint) | |
1815 (Info-select-node))))) | |
1816 (widen) | |
1817 (goto-char found) | |
1818 (Info-select-node) | |
1819 (or (and (equal onode Info-current-node) | |
1820 (equal ofile Info-current-file)) | |
502 | 1821 (Info-history-add ofile onode opoint)))) |
1822 (message "Found \"%s\" in %s. Press `z' to continue search." | |
1823 regexp Info-current-node) | |
1824 ) | |
1825 | |
1826 (defun Info-search-next () | |
1827 "Repeat search starting from point with last regexp used in `Info-search'." | |
1828 (interactive) | |
1829 (Info-search Info-last-search)) | |
1830 | |
428 | 1831 |
1832 ;; Extract the value of the node-pointer named NAME. | |
442 | 1833 ;; If there is none, use ERRORNAME in the error message; |
428 | 1834 ;; if ERRORNAME is nil, just return nil. |
1835 (defun Info-extract-pointer (name &optional errorname) | |
1836 (save-excursion | |
1837 (goto-char (point-min)) | |
1838 (forward-line 4) | |
1839 (let ((case-fold-search t)) | |
1840 (if (re-search-backward (concat name ":") nil t) | |
1841 (progn | |
1842 (goto-char (match-end 0)) | |
1843 (Info-following-node-name)) | |
1844 (if (eq errorname t) | |
1845 nil | |
1846 (error (concat "Node has no " (capitalize (or errorname name))))))))) | |
1847 | |
1848 ;; Return the node name in the buffer following point. | |
1849 ;; ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp | |
440 | 1850 ;; saying which chars may appear in the node name. |
428 | 1851 (defun Info-following-node-name (&optional allowedchars) |
1852 (skip-chars-forward " \t") | |
1853 (buffer-substring | |
1854 (point) | |
1855 (progn | |
1856 (while (looking-at (concat "[" (or allowedchars "^,\t\n") "]")) | |
1857 (skip-chars-forward (concat (or allowedchars "^,\t\n") "(")) | |
1858 (if (looking-at "(") | |
1859 (skip-chars-forward "^)"))) | |
438 | 1860 (skip-chars-backward " .") |
428 | 1861 (point)))) |
1862 | |
1863 (defun Info-next (&optional n) | |
1864 "Go to the next node of this node. | |
1865 A positive or negative prefix argument moves by multiple nodes." | |
1866 (interactive "p") | |
1867 (or n (setq n 1)) | |
1868 (if (< n 0) | |
1869 (Info-prev (- n)) | |
1870 (while (>= (setq n (1- n)) 0) | |
1871 (Info-goto-node (Info-extract-pointer "next"))))) | |
1872 | |
1873 (defun Info-prev (&optional n) | |
1874 "Go to the previous node of this node. | |
1875 A positive or negative prefix argument moves by multiple nodes." | |
1876 (interactive "p") | |
1877 (or n (setq n 1)) | |
1878 (if (< n 0) | |
1879 (Info-next (- n)) | |
1880 (while (>= (setq n (1- n)) 0) | |
1881 (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous"))))) | |
1882 | |
1883 (defun Info-up (&optional n) | |
1884 "Go to the superior node of this node. | |
1885 A positive prefix argument moves up several times." | |
1886 (interactive "p") | |
1887 (or n (setq n 1)) | |
1888 (while (>= (setq n (1- n)) 0) | |
1889 (Info-goto-node (Info-extract-pointer "up"))) | |
1890 (if (interactive-p) (Info-restore-point))) | |
1891 | |
1892 (defun Info-last (&optional n) | |
1893 "Go back to the last node visited. | |
1894 With a prefix argument, go to Nth most recently visited node. History is | |
1895 circular; after oldest node, history comes back around to most recent one. | |
1896 Argument can be negative to go through the circle in the other direction. | |
1897 \(In other words, `l' is like \"undo\" and `C-u - l' is like \"redo\".)" | |
1898 (interactive "p") | |
1899 (or n (setq n 1)) | |
1900 (or Info-history | |
1901 (error "This is the first Info node you looked at")) | |
1902 (let ((len (1+ (length Info-history)))) | |
1903 (setq n (% (+ n (* len 100)) len))) | |
1904 (if (> n 0) | |
1905 (let ((entry (nth (1- n) Info-history))) | |
1906 (Info-history-add Info-current-file Info-current-node (point)) | |
1907 (while (>= (setq n (1- n)) 0) | |
1908 (setq Info-history (nconc (cdr Info-history) | |
1909 (list (car Info-history))))) | |
1910 (setq Info-history (cdr Info-history)) | |
1911 (let ((Info-keeping-history nil)) | |
1912 (Info-goto-node (car entry))) | |
1913 (Info-restore-history-entry entry)))) | |
1914 | |
1915 (defun Info-directory () | |
1916 "Go to the Info directory node." | |
1917 (interactive) | |
1918 (Info-find-node "dir" "top")) | |
1919 | |
1920 (defun Info-follow-reference (footnotename) | |
1921 "Follow cross reference named NAME to the node it refers to. | |
1922 NAME may be an abbreviation of the reference name." | |
1923 (interactive | |
1924 (let ((completion-ignore-case t) | |
1925 completions default (start-point (point)) str i) | |
1926 (save-excursion | |
1927 (goto-char (point-min)) | |
1928 (while (re-search-forward (format "\\*%s[ \n\t]*\\([^:]*\\):" | |
1929 Info-footnote-tag) | |
1930 nil t) | |
1931 (setq str (buffer-substring | |
1932 (match-beginning 1) | |
1933 (1- (point)))) | |
1934 ;; See if this one should be the default. | |
1935 (and (null default) | |
1936 (< (match-beginning 0) start-point) | |
1937 (<= start-point (point)) | |
1938 (setq default t)) | |
1939 (setq i 0) | |
1940 (while (setq i (string-match "[ \n\t]+" str i)) | |
1941 (setq str (concat (substring str 0 i) " " | |
1942 (substring str (match-end 0)))) | |
1943 (setq i (1+ i))) | |
1944 ;; Record as a completion and perhaps as default. | |
1945 (if (eq default t) (setq default str)) | |
1946 (setq completions | |
1947 (cons (cons str nil) | |
1948 completions)))) | |
1949 (if completions | |
1950 (let ((item (completing-read (if default | |
1951 (concat "Follow reference named: (" | |
1952 default ") ") | |
1953 "Follow reference named: ") | |
1954 completions nil t nil | |
438 | 1955 'Info-minibuffer-history |
1956 default))) | |
428 | 1957 (if (and (string= item "") default) |
1958 (list default) | |
1959 (list item))) | |
1960 (error "No cross-references in this node")))) | |
1961 (let (target i (str (concat "\\*" Info-footnote-tag " " | |
1962 (regexp-quote footnotename)))) | |
1963 (while (setq i (string-match " " str i)) | |
1964 (setq str (concat (substring str 0 i) "\\([ \t\n]+\\)" | |
1965 (substring str (1+ i)))) | |
1966 (setq i (+ i 10))) | |
1967 (save-excursion | |
1968 (goto-char (point-min)) | |
1969 (or (re-search-forward str nil t) | |
1970 (error "No cross-reference named %s" footnotename)) | |
1971 (goto-char (match-end 1)) | |
1972 (setq target | |
1973 (Info-extract-menu-node-name "Bad format cross reference" t))) | |
1974 (while (setq i (string-match "[ \t\n]+" target i)) | |
1975 (setq target (concat (substring target 0 i) " " | |
1976 (substring target (match-end 0)))) | |
1977 (setq i (+ i 1))) | |
1978 (Info-goto-node target) | |
1979 (setq Info-in-cross-reference t))) | |
1980 | |
1981 (defun Info-next-reference (n) | |
1982 (interactive "p") | |
1983 (let ((pat (format "\\*%s[ \n\t]*\\([^:]*\\):\\|^\\* .*:\\|<<.*>>" | |
1984 Info-footnote-tag)) | |
1985 (old-pt (point)) | |
1986 wrapped found-nomenu) | |
1987 (while (< n 0) | |
1988 (unless (re-search-backward pat nil t) | |
1989 ;; Don't wrap more than once in a buffer where only the | |
1990 ;; menu references are found. | |
1991 (when (and wrapped (not found-nomenu)) | |
1992 (goto-char old-pt) | |
1993 (error "No cross references in this node")) | |
1994 (setq wrapped t) | |
1995 (goto-char (point-max)) | |
1996 (unless (re-search-backward pat nil t) | |
1997 (goto-char old-pt) | |
1998 (error "No cross references in this node"))) | |
1999 (unless (save-excursion | |
2000 (goto-char (match-beginning 0)) | |
2001 (when (looking-at "\\* Menu:") | |
2002 (decf n))) | |
2003 (setq found-nomenu t)) | |
2004 (incf n)) | |
2005 (while (> n 0) | |
2006 (or (eobp) (forward-char 1)) | |
2007 (unless (re-search-forward pat nil t) | |
2008 (when (and wrapped (not found-nomenu)) | |
2009 (goto-char old-pt) | |
2010 (error "No cross references in this node")) | |
2011 (setq wrapped t) | |
2012 (goto-char (point-min)) | |
2013 (unless (re-search-forward pat nil t) | |
2014 (goto-char old-pt) | |
2015 (error "No cross references in this node"))) | |
2016 (unless (save-excursion | |
2017 (goto-char (match-beginning 0)) | |
2018 (when (looking-at "\\* Menu:") | |
2019 (incf n))) | |
2020 (setq found-nomenu t)) | |
2021 (decf n)) | |
2022 (when (looking-at "\\* Menu:") | |
2023 (error "No cross references in this node")) | |
2024 (goto-char (match-beginning 0)))) | |
2025 | |
2026 (defun Info-prev-reference (n) | |
2027 (interactive "p") | |
2028 (Info-next-reference (- n))) | |
2029 | |
2030 (defun Info-extract-menu-node-name (&optional errmessage multi-line) | |
2031 (skip-chars-forward " \t\n") | |
444 | 2032 (let ((start (point)) |
428 | 2033 str i) |
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))) | |
428 | 2053 (while (setq i (string-match "\n" str i)) |
2054 (aset str i ?\ )) | |
2055 str)) | |
2056 | |
2057 (defun Info-menu (menu-item) | |
2058 "Go to node for menu item named (or abbreviated) NAME. | |
2059 Completion is allowed, and the menu item point is on is the default." | |
2060 (interactive | |
2061 (let ((completions '()) | |
2062 ;; If point is within a menu item, use that item as the default | |
2063 (default nil) | |
2064 (p (point)) | |
2065 (last nil)) | |
2066 (save-excursion | |
2067 (goto-char (point-min)) | |
2068 (let ((case-fold-search t)) | |
2069 (if (not (search-forward "\n* menu:" nil t)) | |
2070 (error "No menu in this node"))) | |
2071 (while (re-search-forward | |
2072 "\n\\* \\([^:\t\n]*\\):" nil t) | |
2073 (if (and (null default) | |
2074 (prog1 (if last (< last p) nil) | |
2075 (setq last (match-beginning 0))) | |
2076 (<= p last)) | |
2077 (setq default (car (car completions)))) | |
2078 (setq completions (cons (cons (buffer-substring | |
2079 (match-beginning 1) | |
2080 (match-end 1)) | |
2081 (match-beginning 1)) | |
2082 completions))) | |
2083 (if (and (null default) last | |
2084 (< last p) | |
2085 (<= p (progn (end-of-line) (point)))) | |
2086 (setq default (car (car completions))))) | |
2087 (let ((item nil)) | |
2088 (while (null item) | |
2089 (setq item (let ((completion-ignore-case t)) | |
2090 (completing-read (if default | |
2091 (format "Menu item (default %s): " | |
2092 default) | |
2093 "Menu item: ") | |
2094 completions nil t nil | |
438 | 2095 'Info-minibuffer-history |
2096 default))) | |
428 | 2097 ;; we rely on the fact that completing-read accepts an input |
2098 ;; of "" even when the require-match argument is true and "" | |
2099 ;; is not a valid possibility | |
2100 (if (string= item "") | |
2101 (if default | |
2102 (setq item default) | |
2103 ;; ask again | |
2104 (setq item nil)))) | |
2105 (list item)))) | |
2106 ;; there is a problem here in that if several menu items have the same | |
2107 ;; name you can only go to the node of the first with this command. | |
2108 (Info-goto-node (Info-extract-menu-item menu-item) nil t)) | |
442 | 2109 |
428 | 2110 (defun Info-extract-menu-item (menu-item &optional noerror) |
2111 (save-excursion | |
2112 (goto-char (point-min)) | |
2113 (if (let ((case-fold-search t)) | |
2114 (search-forward "\n* menu:" nil t)) | |
2115 (if (or (search-forward (concat "\n* " menu-item ":") nil t) | |
2116 (search-forward (concat "\n* " menu-item) nil t)) | |
2117 (progn | |
2118 (beginning-of-line) | |
2119 (forward-char 2) | |
2120 (Info-extract-menu-node-name)) | |
2121 (and (not noerror) (error "No such item in menu"))) | |
2122 (and (not noerror) (error "No menu in this node"))))) | |
2123 | |
2124 ;; If COUNT is nil, use the last item in the menu. | |
2125 (defun Info-extract-menu-counting (count &optional noerror noindex) | |
2126 (save-excursion | |
2127 (goto-char (point-min)) | |
2128 (if (let ((case-fold-search t)) | |
2129 (and (search-forward "\n* menu:" nil t) | |
2130 (or (not noindex) | |
2131 (not (string-match "\\<Index\\>" Info-current-node))))) | |
2132 (if (search-forward "\n* " nil t count) | |
2133 (progn | |
2134 (or count | |
2135 (while (search-forward "\n* " nil t))) | |
2136 (Info-extract-menu-node-name)) | |
2137 (and (not noerror) (error "Too few items in menu"))) | |
2138 (and (not noerror) (error "No menu in this node"))))) | |
2139 | |
2140 (defun Info-nth-menu-item (n) | |
2141 "Go to the node of the Nth menu item." | |
2142 (interactive "P") | |
2143 (or n (setq n (- last-command-char ?0))) | |
2144 (if (< n 1) (error "Index must be at least 1")) | |
2145 (Info-goto-node (Info-extract-menu-counting n) nil t)) | |
2146 | |
2147 (defun Info-last-menu-item () | |
2148 "Go to the node of the tenth menu item." | |
2149 (interactive) | |
2150 (Info-goto-node (Info-extract-menu-counting nil) nil t)) | |
2151 | |
2152 (defun Info-top () | |
2153 "Go to the Top node of this file." | |
2154 (interactive) | |
2155 (Info-goto-node "Top")) | |
2156 | |
2157 (defun Info-end () | |
2158 "Go to the final node in this file." | |
2159 (interactive) | |
2160 (Info-top) | |
2161 (let ((Info-keeping-history nil) | |
2162 node) | |
2163 (Info-last-menu-item) | |
2164 (while (setq node (or (Info-extract-pointer "next" t) | |
2165 (Info-extract-menu-counting nil t t))) | |
2166 (Info-goto-node node)) | |
2167 (or (equal (Info-extract-pointer "up" t) "Top") | |
2168 (let ((executing-kbd-macro "")) ; suppress messages | |
2169 (condition-case nil | |
2170 (Info-global-next 10000) | |
2171 (error nil)))))) | |
2172 | |
2173 (defun Info-global-next (&optional n) | |
2174 "Go to the next node in this file, traversing node structure as necessary. | |
2175 This works only if the Info file is structured as a hierarchy of nodes. | |
2176 A positive or negative prefix argument moves by multiple nodes." | |
2177 (interactive "p") | |
2178 (or n (setq n 1)) | |
2179 (if (< n 0) | |
2180 (Info-global-prev (- n)) | |
2181 (while (>= (setq n (1- n)) 0) | |
2182 (let (node) | |
2183 (cond ((and (string-match "^Top$" Info-current-node) | |
2184 (setq node (Info-extract-pointer "next" t)) | |
2185 (Info-extract-menu-item node t)) | |
2186 (Info-goto-node node)) | |
2187 ((setq node (Info-extract-menu-counting 1 t t)) | |
2188 (message "Going down...") | |
2189 (Info-goto-node node)) | |
2190 (t | |
2191 (let ((Info-keeping-history Info-keeping-history) | |
2192 (orignode Info-current-node) | |
2193 (ups "")) | |
2194 (while (not (Info-extract-pointer "next" t)) | |
2195 (if (and (setq node (Info-extract-pointer "up" t)) | |
2196 (not (equal node "Top"))) | |
2197 (progn | |
2198 (message "Going%s..." (setq ups (concat ups " up"))) | |
2199 (Info-goto-node node) | |
2200 (setq Info-keeping-history nil)) | |
2201 (if orignode | |
2202 (let ((Info-keeping-history nil)) | |
2203 (Info-goto-node orignode))) | |
2204 (error "Last node in file"))) | |
2205 (Info-next)))))))) | |
2206 | |
2207 (defun Info-page-next (&optional n) | |
2208 "Scroll forward one screenful, or go to next global node. | |
2209 A positive or negative prefix argument moves by multiple screenfuls." | |
2210 (interactive "p") | |
2211 (or n (setq n 1)) | |
2212 (if (< n 0) | |
2213 (Info-page-prev (- n)) | |
2214 (while (>= (setq n (1- n)) 0) | |
2215 (if (pos-visible-in-window-p (point-max)) | |
2216 (progn | |
2217 (Info-global-next) | |
2218 (message "Node: %s" Info-current-node)) | |
2219 (scroll-up))))) | |
2220 | |
2221 (defun Info-scroll-next (arg) | |
2222 (interactive "P") | |
2223 (if Info-auto-advance | |
2224 (if (and (pos-visible-in-window-p (point-max)) | |
2225 (not (eq Info-auto-advance t)) | |
2226 (not (eq last-command this-command))) | |
2227 (message "Hit %s again to go to next node" | |
2228 (if (= last-command-char 0) | |
2229 "mouse button" | |
2230 (key-description (char-to-string last-command-char)))) | |
2231 (Info-page-next) | |
2232 (setq this-command 'Info)) | |
2233 (scroll-up arg))) | |
2234 | |
2235 (defun Info-global-prev (&optional n) | |
2236 "Go to the previous node in this file, traversing structure as necessary. | |
2237 This works only if the Info file is structured as a hierarchy of nodes. | |
2238 A positive or negative prefix argument moves by multiple nodes." | |
2239 (interactive "p") | |
2240 (or n (setq n 1)) | |
2241 (if (< n 0) | |
2242 (Info-global-next (- n)) | |
2243 (while (>= (setq n (1- n)) 0) | |
2244 (let ((upnode (Info-extract-pointer "up" t)) | |
2245 (prevnode (Info-extract-pointer "prev[ious]*" t))) | |
2246 (if (or (not prevnode) | |
2247 (equal prevnode upnode)) | |
2248 (if (string-match "^Top$" Info-current-node) | |
2249 (error "First node in file") | |
2250 (message "Going up...") | |
2251 (Info-up)) | |
2252 (Info-goto-node prevnode) | |
2253 (let ((downs "") | |
2254 (Info-keeping-history nil) | |
2255 node) | |
2256 (while (setq node (Info-extract-menu-counting nil t t)) | |
2257 (message "Going%s..." (setq downs (concat downs " down"))) | |
2258 (Info-goto-node node)))))))) | |
2259 | |
2260 (defun Info-page-prev (&optional n) | |
2261 "Scroll backward one screenful, or go to previous global node. | |
2262 A positive or negative prefix argument moves by multiple screenfuls." | |
2263 (interactive "p") | |
2264 (or n (setq n 1)) | |
2265 (if (< n 0) | |
2266 (Info-page-next (- n)) | |
2267 (while (>= (setq n (1- n)) 0) | |
2268 (if (pos-visible-in-window-p (point-min)) | |
2269 (progn | |
2270 (Info-global-prev) | |
2271 (message "Node: %s" Info-current-node) | |
2272 (goto-char (point-max)) | |
2273 (recenter -1) | |
2274 (move-to-window-line 0)) | |
2275 (scroll-down))))) | |
2276 | |
2277 (defun Info-scroll-prev (arg) | |
2278 (interactive "P") | |
2279 (if Info-auto-advance | |
2280 (if (and (pos-visible-in-window-p (point-min)) | |
2281 (not (eq Info-auto-advance t)) | |
2282 (not (eq last-command this-command))) | |
2283 (message "Hit %s again to go to previous node" | |
2284 (if (mouse-event-p last-command-event) | |
2285 "mouse button" | |
2286 (key-description (event-key last-command-event)))) | |
2287 (Info-page-prev) | |
2288 (setq this-command 'Info)) | |
2289 (scroll-down arg))) | |
502 | 2290 |
428 | 2291 |
502 | 2292 (defun Info-find-index-alternatives (topic) |
428 | 2293 (let ((pattern (format "\n\\* \\([^\n:]*%s[^\n:]*\\):[ \t]*%s" |
2294 (regexp-quote topic) | |
830 | 2295 "\\(.*\\)\\.[ \t]*\\([0-9]*\\)$")) |
428 | 2296 node) |
2297 (message "Searching index for `%s'..." topic) | |
2298 (Info-goto-node "Top") | |
2299 (let ((case-fold-search t)) | |
2300 (or (search-forward "\n* menu:" nil t) | |
2301 (error "No index")) | |
2302 (or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t) | |
2303 (error "No index"))) | |
2304 (goto-char (match-beginning 1)) | |
2305 (let ((Info-keeping-history nil) | |
2306 (Info-fontify (and Info-fontify (equal topic "")))) | |
2307 (Info-goto-node (Info-extract-menu-node-name))) | |
2308 (or (equal topic "") | |
2309 (let ((matches nil) | |
502 | 2310 (Info-keeping-history nil)) |
428 | 2311 (while |
2312 (progn | |
2313 (goto-char (point-min)) | |
2314 (while (re-search-forward pattern nil t) | |
2315 (setq matches | |
2316 (cons (list (buffer-substring (match-beginning 1) | |
2317 (match-end 1)) | |
771 | 2318 (format "(%s)%s" Info-current-file |
2319 (buffer-substring | |
2320 (match-beginning 2) | |
2321 (match-end 2))) | |
428 | 2322 Info-current-node |
2323 (string-to-int (concat "0" | |
2324 (buffer-substring | |
2325 (match-beginning 3) | |
2326 (match-end 3))))) | |
2327 matches))) | |
2328 (and (setq node (Info-extract-pointer "next" t)) | |
2329 (string-match "\\<Index\\>" node))) | |
2330 (let ((Info-fontify nil)) | |
2331 (Info-goto-node node))) | |
502 | 2332 (nreverse matches))))) |
2333 | |
2334 (defun Info-index (topic &optional starting-nodes) | |
2335 "Look up a string in the index for this file. | |
2336 The index is defined as the first node in the top-level menu whose | |
2337 name contains the word \"Index\", plus any immediately following | |
2338 nodes whose names also contain the word \"Index\". | |
2339 If there are no exact matches to the specified topic, this chooses | |
2340 the first match which is a case-insensitive substring of a topic. | |
2341 Use the `,' command to see the other matches. | |
2342 Give a blank topic name to go to the Index node itself. | |
2343 | |
2344 If STARTING-NODES is given, it should be a list of nodes specifying | |
2345 files in which the indices will be searched. The results will be | |
2346 combined together." | |
2347 (interactive "sIndex topic: ") | |
2348 (let ((matches (if starting-nodes | |
2349 (mapcan #'(lambda (node) | |
2350 (Info-goto-node node) | |
2351 (Info-find-index-alternatives topic)) | |
2352 starting-nodes) | |
2353 (Info-find-index-alternatives topic))) | |
2354 exact found) | |
2355 (or matches | |
2356 (progn | |
2357 (if (or (not starting-nodes) (< (length starting-nodes) 2)) | |
2358 (Info-last)) | |
2359 (error "No \"%s\" in index" topic))) | |
2360 ;; Here it is a feature that assoc is case-sensitive. | |
2361 (while (setq found (assoc topic matches)) | |
2362 (setq exact (cons found exact) | |
2363 matches (delq found matches))) | |
2364 (setq Info-index-alternatives (nconc exact matches) | |
2365 Info-index-first-alternative (car Info-index-alternatives)) | |
2366 (Info-index-next 0))) | |
428 | 2367 |
2368 (defun Info-index-next (num) | |
2369 "Go to the next matching index item from the last `i' command." | |
2370 (interactive "p") | |
2371 (or Info-index-alternatives | |
2372 (error "No previous `i' command in this file")) | |
2373 (while (< num 0) | |
2374 (setq num (+ num (length Info-index-alternatives)))) | |
2375 (while (> num 0) | |
2376 (setq Info-index-alternatives | |
2377 (nconc (cdr Info-index-alternatives) | |
2378 (list (car Info-index-alternatives))) | |
2379 num (1- num))) | |
2380 (Info-goto-node (nth 1 (car Info-index-alternatives))) | |
2381 (if (> (nth 3 (car Info-index-alternatives)) 0) | |
2382 (forward-line (nth 3 (car Info-index-alternatives))) | |
2383 (forward-line 3) ; don't search in headers | |
2384 (let ((name (car (car Info-index-alternatives)))) | |
2385 (if (or (re-search-forward (format | |
2386 "\\(Function\\|Command\\): %s\\( \\|$\\)" | |
2387 (regexp-quote name)) nil t) | |
2388 (re-search-forward (format "^`%s[ ']" (regexp-quote name)) nil t) | |
2389 (search-forward (format "`%s'" name) nil t) | |
2390 (and (string-match "\\`.*\\( (.*)\\)\\'" name) | |
2391 (search-forward | |
2392 (format "`%s'" (substring name 0 (match-beginning 1))) | |
2393 nil t)) | |
2394 (search-forward name nil t)) | |
2395 (beginning-of-line) | |
2396 (goto-char (point-min))))) | |
2397 (message "Found \"%s\" in %s. %s" | |
2398 (car (car Info-index-alternatives)) | |
2399 (nth 2 (car Info-index-alternatives)) | |
2400 (if (cdr Info-index-alternatives) | |
2401 (if (eq (car (cdr Info-index-alternatives)) | |
2402 Info-index-first-alternative) | |
2403 "(Press `,' to repeat)" | |
2404 (format "(Press `,' for %d more)" | |
2405 (- (1- (length Info-index-alternatives)) | |
2406 (length (memq Info-index-first-alternative | |
2407 (cdr Info-index-alternatives)))))) | |
2408 "(Only match)"))) | |
2409 | |
2410 | |
2411 ;;;###autoload | |
2412 (defun Info-emacs-command (command) | |
2413 "Look up an Emacs command in the Emacs manual in the Info system. | |
2414 This command is designed to be used whether you are already in Info or not." | |
2415 (interactive "CLook up command in Emacs manual: ") | |
2416 (save-window-excursion | |
2417 (info) | |
2418 (Info-find-node Info-emacs-info-file-name "Top") | |
2419 (Info-index (symbol-name command))) | |
2420 (pop-to-buffer "*info*")) | |
2421 | |
2422 | |
2423 ;;;###autoload | |
2424 (defun Info-goto-emacs-command-node (key) | |
2425 "Look up an Emacs command in the Emacs manual in the Info system. | |
2426 This command is designed to be used whether you are already in Info or not." | |
2427 (interactive "CLook up command in Emacs manual: ") | |
2428 (Info-emacs-command key)) | |
2429 | |
2430 ;;;###autoload | |
2431 (defun Info-goto-emacs-key-command-node (key) | |
2432 "Look up an Emacs key sequence in the Emacs manual in the Info system. | |
2433 This command is designed to be used whether you are already in Info or not." | |
2434 (interactive "kLook up key in Emacs manual: ") | |
2435 (let ((command (key-binding key))) | |
2436 (cond ((eq command 'keyboard-quit) | |
2437 (keyboard-quit)) | |
2438 ((null command) | |
2439 (error "%s is undefined" (key-description key))) | |
2440 ((and (interactive-p) (eq command 'execute-extended-command)) | |
2441 (call-interactively 'Info-goto-emacs-command-node)) | |
2442 (t | |
2443 (Info-goto-emacs-command-node command))))) | |
2444 | |
2445 ;;;###autoload | |
2446 (defun Info-emacs-key (key) | |
2447 "Look up an Emacs key sequence in the Emacs manual in the Info system. | |
2448 This command is designed to be used whether you are already in Info or not." | |
2449 (interactive "kLook up key in Emacs manual: ") | |
2450 (cond ((eq (key-binding key) 'keyboard-quit) | |
2451 (keyboard-quit)) | |
2452 ((and (interactive-p) (eq (key-binding key) 'execute-extended-command)) | |
2453 (call-interactively 'Info-goto-emacs-command-node)) | |
2454 (t | |
2455 (save-window-excursion | |
2456 (info) | |
2457 (Info-find-node Info-emacs-info-file-name "Top") | |
2458 (setq key (key-description key)) | |
2459 (let (p) | |
2460 (if (setq p (string-match "[@{}]" key)) | |
2461 (setq key (concat (substring key 0 p) "@" (substring key p)))) | |
2462 (if (string-match "^ESC " key) | |
2463 (setq key (concat "M-" (substring key 4)))) | |
2464 (if (string-match "^M-C-" key) | |
2465 (setq key (concat "C-M-" (substring key 4))))) | |
2466 (Info-index key)) | |
2467 (pop-to-buffer "*info*")))) | |
2468 | |
2469 ;;;###autoload | |
2470 (defun Info-elisp-ref (func) | |
2471 "Look up an Emacs Lisp function in the Elisp manual in the Info system. | |
2472 This command is designed to be used whether you are already in Info or not." | |
2473 (interactive (let ((fn (function-at-point)) | |
442 | 2474 (enable-recursive-minibuffers t) |
428 | 2475 val) |
2476 (setq val (completing-read | |
2477 (format "Look up Emacs Lisp function%s: " | |
2478 (if fn | |
2479 (format " (default %s)" fn) | |
2480 "")) | |
456 | 2481 obarray 'fboundp t |
2482 nil nil (and fn (symbol-name fn)))) | |
428 | 2483 (list (if (equal val "") |
2484 fn (intern val))))) | |
2485 (save-window-excursion | |
2486 (info) | |
2487 (condition-case nil | |
2488 (Info-find-node "lispref" "Top") | |
2489 (error (Info-find-node "elisp" "Top"))) | |
2490 (Info-index (symbol-name func))) | |
2491 (pop-to-buffer "*info*")) | |
502 | 2492 |
2493 (defun Info-read-search-text-regexp () | |
2494 (read-from-minibuffer | |
2495 (if (and (boundp 'Info-last-search) Info-last-search) | |
2496 (format "Search (regexp, default %s): " | |
2497 Info-last-search) | |
2498 "Search (regexp): ") | |
2499 nil nil nil nil nil (and (boundp 'Info-last-search) Info-last-search))) | |
2500 | |
2501 ;;;###autoload | |
2502 (defun Info-search-text-in-lispref (regexp) | |
2503 "Search for REGEXP in Lispref text and select node it's found in." | |
2504 (interactive (list (Info-read-search-text-regexp))) | |
2505 (Info-goto-node "(Lispref)") | |
2506 (Info-search regexp)) | |
2507 | |
2508 ;;;###autoload | |
2509 (defun Info-search-text-in-xemacs (regexp) | |
2510 "Search for REGEXP in User's Manual text and select node it's found in." | |
2511 (interactive (list (Info-read-search-text-regexp))) | |
2512 (Info-goto-node "(XEmacs)") | |
2513 (Info-search regexp)) | |
2514 | |
2515 ;;;###autoload | |
2516 (defun Info-search-index-in-lispref (regexp) | |
2517 "Search for REGEXP in Lispref index and select node it's found in." | |
2518 (interactive "sIndex topic: ") | |
2519 (Info-goto-node "(Lispref)") | |
2520 (Info-index regexp)) | |
2521 | |
2522 ;;;###autoload | |
2523 (defun Info-search-index-in-xemacs-and-lispref (regexp) | |
2524 "Search for REGEXP in both User's Manual and Lispref indices. | |
2525 Select node it's found in." | |
2526 (interactive "sIndex topic: ") | |
2527 (Info-index regexp '("(XEmacs)" "(Lispref)"))) | |
2528 | |
428 | 2529 |
2530 (defun Info-reannotate-node () | |
2531 (let ((bufs (delq nil (mapcar 'get-file-buffer Info-annotations-path)))) | |
2532 (if bufs | |
2533 (let ((ibuf (current-buffer)) | |
2534 (file (concat "\\(" (regexp-quote | |
2535 (file-name-nondirectory Info-current-file)) | |
2536 "\\|" (regexp-quote Info-current-file) "\\)")) | |
2537 (node (regexp-quote Info-current-node)) | |
2538 (savept (point))) | |
2539 (goto-char (point-min)) | |
2540 (if (search-forward "\n------ NOTE:\n" nil t) | |
2541 (let ((buffer-read-only nil) | |
2542 (bufmod (buffer-modified-p)) | |
2543 top) | |
2544 (setq savept (copy-marker savept)) | |
2545 (goto-char (point-min)) | |
2546 (while (search-forward "\n------ NOTE:" nil t) | |
2547 (setq top (1+ (match-beginning 0))) | |
2548 (if (search-forward "\n------\n" nil t) | |
2549 (delete-region top (point))) | |
2550 (backward-char 1)) | |
2551 (set-buffer-modified-p bufmod))) | |
2552 (save-excursion | |
2553 (while bufs | |
2554 (set-buffer (car bufs)) | |
2555 (goto-char (point-min)) | |
2556 (while (re-search-forward | |
2557 (format | |
2558 "------ *File: *%s *Node: *%s *Line: *\\([0-9]+\\) *\n" | |
2559 file node) | |
2560 nil t) | |
2561 (let ((line (string-to-int | |
2562 (buffer-substring (match-beginning 2) | |
2563 (match-end 2)))) | |
2564 (top (point)) | |
2565 bot) | |
2566 (search-forward "\n------\n" nil t) | |
2567 (setq bot (point)) | |
2568 (save-excursion | |
2569 (set-buffer ibuf) | |
2570 (if (integerp savept) (setq savept (copy-marker savept))) | |
2571 (if (= line 0) | |
2572 (goto-char (point-max)) | |
2573 (goto-char (point-min)) | |
2574 (forward-line line)) | |
2575 (let ((buffer-read-only nil) | |
2576 (bufmod (buffer-modified-p))) | |
2577 (insert "------ NOTE:\n") | |
2578 (insert-buffer-substring (car bufs) top bot) | |
2579 (set-buffer-modified-p bufmod))))) | |
2580 (setq bufs (cdr bufs)))) | |
2581 (goto-char savept))))) | |
2582 | |
2583 (defvar Info-annotate-map nil | |
2584 "Local keymap used within `a' command of Info.") | |
444 | 2585 |
428 | 2586 (if Info-annotate-map |
2587 nil | |
2588 ;; (setq Info-annotate-map (nconc (make-sparse-keymap) text-mode-map)) | |
2589 (setq Info-annotate-map (copy-keymap text-mode-map)) | |
2590 (define-key Info-annotate-map "\C-c\C-c" 'Info-cease-annotate)) | |
2591 | |
2592 (defun Info-annotate-mode () | |
2593 "Major mode for adding an annotation to an Info node. | |
2594 Like text mode with the addition of Info-cease-annotate | |
2595 which returns to Info mode for browsing. | |
2596 \\{Info-annotate-map}") | |
2597 | |
2598 (defun Info-annotate (arg) | |
2599 "Add a personal annotation to the current Info node. | |
2600 Only you will be able to see this annotation. Annotations are stored | |
2601 in the file \"~/.xemacs/info.notes\" by default. If point is inside | |
2602 an existing annotation, edit that annotation. A prefix argument | |
2603 specifies which annotations file (from `Info-annotations-path') is to | |
2604 be edited; default is 1." | |
2605 (interactive "p") | |
2606 (setq arg (1- arg)) | |
2607 (if (or (< arg 0) (not (nth arg Info-annotations-path))) | |
2608 (if (= arg 0) | |
2609 (setq Info-annotations-path | |
2610 (list (read-file-name | |
2611 "Annotations file: " "~/" "~/.infonotes"))) | |
2612 (error "File number must be in the range from 1 to %d" | |
2613 (length Info-annotations-path)))) | |
2614 (let ((which nil) | |
2615 (file (file-name-nondirectory Info-current-file)) | |
2616 (d Info-directory-list) | |
2617 where pt) | |
2618 (while (and d (not (equal (expand-file-name file (car d)) | |
2619 Info-current-file))) | |
2620 (setq d (cdr d))) | |
2621 (or d (setq file Info-current-file)) | |
2622 (if (and (save-excursion | |
2623 (goto-char (min (point-max) (+ (point) 13))) | |
2624 (and (search-backward "------ NOTE:\n" nil t) | |
2625 (setq pt (match-end 0)) | |
2626 (search-forward "\n------\n" nil t))) | |
2627 (< (point) (match-end 0))) | |
2628 (setq which (format "File: *%s *Node: *%s *Line:.*\n%s" | |
2629 (regexp-quote file) | |
2630 (regexp-quote Info-current-node) | |
2631 (regexp-quote | |
2632 (buffer-substring pt (match-beginning 0)))) | |
2633 where (max (- (point) pt) 0))) | |
2634 (let ((node Info-current-node) | |
2635 (line (if (looking-at "[ \n]*\\'") 0 | |
2636 (count-lines (point-min) (point))))) | |
2637 (or which | |
2638 (let ((buffer-read-only nil) | |
2639 (bufmod (buffer-modified-p))) | |
2640 (beginning-of-line) | |
2641 (if (bobp) (goto-char (point-max))) | |
2642 (insert "------ NOTE:\n------\n") | |
2643 (backward-char 20) | |
2644 (set-buffer-modified-p bufmod))) | |
2645 ;; (setq Info-window-start (window-start)) | |
2646 (setq Info-window-configuration (current-window-configuration)) | |
2647 (pop-to-buffer (find-file-noselect (nth arg Info-annotations-path))) | |
2648 (use-local-map Info-annotate-map) | |
2649 (setq major-mode 'Info-annotate-mode) | |
2650 (setq mode-name "Info Annotate") | |
2651 (if which | |
2652 (if (save-excursion | |
2653 (goto-char (point-min)) | |
2654 (re-search-forward which nil t)) | |
2655 (progn | |
2656 (goto-char (match-beginning 0)) | |
2657 (forward-line 1) | |
2658 (forward-char where))) | |
2659 (let ((bufmod (buffer-modified-p))) | |
2660 (goto-char (point-max)) | |
2661 (insert (format "\n------ File: %s Node: %s Line: %d\n" | |
2662 file node line)) | |
2663 (setq pt (point)) | |
2664 (insert "\n------\n" | |
2665 "\nPress C-c C-c to save and return to Info.\n") | |
2666 (goto-char pt) | |
2667 (set-buffer-modified-p bufmod)))))) | |
2668 | |
2669 (defun Info-cease-annotate () | |
2670 (interactive) | |
2671 (let ((bufmod (buffer-modified-p))) | |
2672 (while (save-excursion | |
2673 (goto-char (point-min)) | |
2674 (re-search-forward "\n\n?Press .* to save and return to Info.\n" | |
2675 nil t)) | |
2676 (delete-region (1+ (match-beginning 0)) (match-end 0))) | |
2677 (while (save-excursion | |
2678 (goto-char (point-min)) | |
2679 (re-search-forward "\n------ File:.*Node:.*Line:.*\n+------\n" | |
2680 nil t)) | |
2681 (delete-region (match-beginning 0) (match-end 0))) | |
2682 (set-buffer-modified-p bufmod)) | |
2683 (save-buffer) | |
2684 (fundamental-mode) | |
2685 (bury-buffer) | |
2686 (or (one-window-p) (delete-window)) | |
2687 (info) | |
2688 (setq Info-current-annotation-completions nil) | |
2689 (set-window-configuration Info-window-configuration) | |
2690 (Info-reannotate-node)) | |
2691 | |
2692 (defun Info-bookmark (arg tag) | |
2693 (interactive "p\nsBookmark name: ") | |
2694 (Info-annotate arg) | |
2695 (if (or (string-match "^\"\\(.*\\)\"$" tag) | |
2696 (string-match "^<<\\(.*\\)>>$" tag)) | |
2697 (setq tag (substring tag (match-beginning 1) (match-end 1)))) | |
2698 (let ((pt (point))) | |
2699 (search-forward "\n------\n") | |
2700 (let ((end (- (point) 8))) | |
2701 (goto-char pt) | |
2702 (if (re-search-forward "<<[^>\n]*>>" nil t) | |
2703 (delete-region (match-beginning 0) (match-end 0)) | |
2704 (goto-char end)) | |
2705 (or (equal tag "") | |
2706 (insert "<<" tag ">>")))) | |
2707 (Info-cease-annotate)) | |
2708 | |
2709 (defun Info-exit () | |
2710 "Exit Info by selecting some other buffer." | |
2711 (interactive) | |
2712 (if Info-standalone | |
2713 (save-buffers-kill-emacs) | |
2714 (bury-buffer (current-buffer)) | |
2715 (if (and (featurep 'toolbar) | |
2716 (boundp 'toolbar-info-frame) | |
2717 (eq toolbar-info-frame (selected-frame))) | |
2718 (condition-case () | |
2719 (delete-frame toolbar-info-frame) | |
2720 (error (bury-buffer))) | |
2721 (switch-to-buffer (other-buffer (current-buffer)))))) | |
2722 | |
2723 (defun Info-undefined () | |
2724 "Make command be undefined in Info." | |
2725 (interactive) | |
2726 (ding)) | |
2727 | |
2728 (defun Info-help () | |
2729 "Enter the Info tutorial." | |
2730 (interactive) | |
2731 (delete-other-windows) | |
2732 (Info-find-node "info" | |
2733 (if (< (window-height) 23) | |
2734 "Help-Small-Screen" | |
2735 "Help"))) | |
2736 | |
2737 (defun Info-summary () | |
2738 "Display a brief summary of all Info commands." | |
2739 (interactive) | |
2740 (save-window-excursion | |
2741 (switch-to-buffer "*Help*") | |
2742 (erase-buffer) | |
2743 (insert (documentation 'Info-mode)) | |
2744 (goto-char (point-min)) | |
2745 (let (flag) | |
2746 (while (progn (setq flag (not (pos-visible-in-window-p (point-max)))) | |
2747 (message (if flag "Type Space to see more" | |
2748 "Type Space to return to Info")) | |
2749 (let ((e (next-command-event))) | |
2750 (if (/= ?\ (event-to-character e)) | |
2751 (progn (setq unread-command-event e) nil) | |
2752 flag))) | |
2753 (scroll-up))) | |
2754 (message "") | |
2755 (bury-buffer "*Help*"))) | |
2756 | |
2757 (defun Info-get-token (pos start all &optional errorstring) | |
2758 "Return the token around POS, | |
2759 POS must be somewhere inside the token | |
2760 START is a regular expression which will match the | |
2761 beginning of the tokens delimited string | |
2762 ALL is a regular expression with a single | |
2763 parenthized subpattern which is the token to be | |
2764 returned. E.g. '{\(.*\)}' would return any string | |
2765 enclosed in braces around POS. | |
2766 SIG optional fourth argument, controls action on no match | |
2767 nil: return nil | |
2768 t: beep | |
2769 a string: signal an error, using that string." | |
2770 (save-excursion | |
2771 (goto-char (point-min)) | |
2772 (re-search-backward "\\`") ; Bug fix due to Nicholas J. Foskett. | |
2773 (goto-char pos) | |
2774 (re-search-backward start (max (point-min) (- pos 200)) 'yes) | |
2775 (let (found) | |
2776 (while (and (re-search-forward all (min (point-max) (+ pos 200)) 'yes) | |
2777 (not (setq found (and (<= (match-beginning 0) pos) | |
2778 (> (match-end 0) pos)))))) | |
2779 (if (and found (<= (match-beginning 0) pos) | |
2780 (> (match-end 0) pos)) | |
2781 (buffer-substring (match-beginning 1) (match-end 1)) | |
2782 (cond ((null errorstring) | |
2783 nil) | |
2784 ((eq errorstring t) | |
2785 (beep) | |
2786 nil) | |
2787 (t | |
2788 (error "No %s around position %d" errorstring pos))))))) | |
2789 | |
2790 (defun Info-follow-clicked-node (event) | |
2791 "Follow a node reference near clicked point. Like M, F, N, P or U command. | |
2792 At end of the node's text, moves to the next node." | |
2793 (interactive "@e") | |
2794 (or (and (event-point event) | |
2795 (Info-follow-nearest-node | |
2796 (max (progn | |
2797 (select-window (event-window event)) | |
2798 (event-point event)) | |
2799 (1+ (point-min))))) | |
2800 (error "click on a cross-reference to follow"))) | |
2801 | |
2802 (defun Info-maybe-follow-clicked-node (event &optional click-count) | |
2803 "Follow a node reference (if any) near clicked point. | |
2804 Like M, F, N, P or U command. At end of the node's text, moves to the | |
2805 next node. No error is given if there is no node to follow." | |
2806 (interactive "@e") | |
2807 (and Info-button1-follows-hyperlink | |
2808 (event-point event) | |
2809 (Info-follow-nearest-node | |
2810 (max (progn | |
2811 (select-window (event-window event)) | |
2812 (event-point event)) | |
2813 (1+ (point-min)))))) | |
2814 | |
2815 (defun Info-find-nearest-node (point) | |
2816 (let (node) | |
2817 (cond | |
2818 ((= point (point-min)) nil) ; don't trigger on accidental RET. | |
2819 ((setq node (Info-get-token point | |
2820 (format "\\*%s[ \n]" Info-footnote-tag) | |
2821 (format "\\*%s[ \n]\\([^:]*\\):" | |
2822 Info-footnote-tag))) | |
2823 (list "Following cross-reference %s..." | |
2824 (list 'Info-follow-reference node))) | |
2825 ((setq node (Info-get-token point "\\* " "\\* \\([^:]*\\)::")) | |
2826 (list "Selecting menu item %s..." | |
2827 (list 'Info-goto-node node nil t))) | |
2828 ((setq node (Info-get-token point "\\* " "\\* \\([^:]*\\):")) | |
2829 (list "Selecting menu item %s..." | |
2830 (list 'Info-menu node))) | |
2831 ((setq node (Info-get-token point "Up: " "Up: \\([^,\n\t]*\\)")) | |
2832 (list "Going up..." | |
2833 (list 'Info-goto-node node))) | |
2834 ((setq node (Info-get-token point "Next: " "Next: \\([^,\n\t]*\\)")) | |
2835 (list "Next node..." | |
2836 (list 'Info-goto-node node))) | |
2837 ((setq node (Info-get-token point "File: " "File: \\([^,\n\t]*\\)")) | |
2838 (list "Top node..." | |
2839 (list 'Info-goto-node "Top"))) | |
2840 ((setq node (Info-get-token point "Prev[ious]*: " | |
2841 "Prev[ious]*: \\([^,\n\t]*\\)")) | |
2842 (list "Previous node..." | |
2843 (list 'Info-goto-node node))) | |
2844 ((setq node (Info-get-token point "Node: " "Node: \\([^,\n\t]*\\)")) | |
2845 (list "Reselecting %s..." | |
2846 (list 'Info-goto-node node))) | |
2847 ((save-excursion (goto-char point) (looking-at "[ \n]*\\'")) | |
2848 (if Info-in-cross-reference | |
2849 (list "Back to last node..." | |
2850 '(Info-last)) | |
2851 (list "Next node..." | |
2852 '(Info-global-next))))) | |
2853 )) | |
2854 | |
2855 (defun Info-follow-nearest-node (point) | |
2856 "Follow a node reference near point. Like M, F, N, P or U command. | |
2857 At end of the node's text, moves to the next node." | |
2858 (interactive "d") | |
2859 (let ((data (Info-find-nearest-node point))) | |
2860 (if (null data) | |
2861 nil | |
2862 (let ((msg (format (car data) (nth 1 (nth 1 data))))) | |
2863 (message "%s" msg) | |
2864 (eval (nth 1 data)) | |
2865 (message "%sdone" msg)) | |
2866 t))) | |
2867 | |
2868 (defun Info-indicated-node (event) | |
2869 (condition-case () | |
2870 (save-excursion | |
2871 (cond ((eventp event) | |
2872 (set-buffer (event-buffer event)) | |
2873 (setq event (event-point event)))) | |
2874 (let* ((data (Info-find-nearest-node event)) | |
2875 (name (nth 1 (nth 1 data)))) | |
2876 (and name (nth 1 data)))) | |
2877 (error nil))) | |
2878 | |
2879 (defun Info-mouse-track-double-click-hook (event click-count) | |
2880 "Handle double-clicks by turning pages, like the `gv' ghostscript viewer" | |
2881 (if (/= click-count 2) | |
2882 ;; Return nil so any other hooks are performed. | |
2883 nil | |
2884 (let* ((fw (face-width 'default)) | |
2885 (fh (face-height 'default)) | |
2886 (x (/ (event-x-pixel event) fw)) | |
2887 (y (/ (event-y-pixel event) fw)) | |
2888 (w (/ (window-pixel-width (event-window event)) fw)) | |
2889 (h (/ (window-pixel-height (event-window event)) fh)) | |
2890 (bx 3) | |
2891 (by 2)) | |
2892 (cond | |
2893 ((<= y by) (Info-up) t) | |
2894 ((>= y (- h by)) (Info-nth-menu-item 1) t) | |
2895 ((<= x bx) (Info-prev) t) | |
2896 ((>= x (- w bx)) (Info-next) t) | |
2897 (t nil))))) | |
2898 | |
2899 (defvar Info-mode-map nil | |
2900 "Keymap containing Info commands.") | |
444 | 2901 |
428 | 2902 (if Info-mode-map |
2903 nil | |
2904 (setq Info-mode-map (make-sparse-keymap)) | |
2905 (suppress-keymap Info-mode-map) | |
2906 (define-key Info-mode-map "." 'beginning-of-buffer) | |
2907 (define-key Info-mode-map " " 'Info-scroll-next) | |
2908 (define-key Info-mode-map "1" 'Info-nth-menu-item) | |
2909 (define-key Info-mode-map "2" 'Info-nth-menu-item) | |
2910 (define-key Info-mode-map "3" 'Info-nth-menu-item) | |
2911 (define-key Info-mode-map "4" 'Info-nth-menu-item) | |
2912 (define-key Info-mode-map "5" 'Info-nth-menu-item) | |
2913 (define-key Info-mode-map "6" 'Info-nth-menu-item) | |
2914 (define-key Info-mode-map "7" 'Info-nth-menu-item) | |
2915 (define-key Info-mode-map "8" 'Info-nth-menu-item) | |
2916 (define-key Info-mode-map "9" 'Info-nth-menu-item) | |
2917 (define-key Info-mode-map "0" 'Info-last-menu-item) | |
2918 (define-key Info-mode-map "?" 'Info-summary) | |
2919 (define-key Info-mode-map "a" 'Info-annotate) | |
2920 (define-key Info-mode-map "b" 'beginning-of-buffer) | |
2921 (define-key Info-mode-map "d" 'Info-directory) | |
2922 (define-key Info-mode-map "e" 'Info-edit) | |
2923 (define-key Info-mode-map "f" 'Info-follow-reference) | |
2924 (define-key Info-mode-map "g" 'Info-goto-node) | |
2925 (define-key Info-mode-map "h" 'Info-help) | |
2926 (define-key Info-mode-map "i" 'Info-index) | |
2927 (define-key Info-mode-map "j" 'Info-goto-bookmark) | |
2928 (define-key Info-mode-map "k" 'Info-emacs-key) | |
2929 (define-key Info-mode-map "l" 'Info-last) | |
2930 (define-key Info-mode-map "m" 'Info-menu) | |
2931 (define-key Info-mode-map "n" 'Info-next) | |
2932 (define-key Info-mode-map "p" 'Info-prev) | |
2933 (define-key Info-mode-map "q" 'Info-exit) | |
2934 (define-key Info-mode-map "r" 'Info-follow-reference) | |
2935 (define-key Info-mode-map "s" 'Info-search) | |
2936 (define-key Info-mode-map "t" 'Info-top) | |
2937 (define-key Info-mode-map "u" 'Info-up) | |
2938 (define-key Info-mode-map "v" 'Info-visit-file) | |
2939 (define-key Info-mode-map "x" 'Info-bookmark) | |
502 | 2940 (define-key Info-mode-map "z" 'Info-search-next) |
428 | 2941 (define-key Info-mode-map "<" 'Info-top) |
2942 (define-key Info-mode-map ">" 'Info-end) | |
2943 (define-key Info-mode-map "[" 'Info-global-prev) | |
2944 (define-key Info-mode-map "]" 'Info-global-next) | |
2945 (define-key Info-mode-map "{" 'Info-page-prev) | |
2946 (define-key Info-mode-map "}" 'Info-page-next) | |
2947 (define-key Info-mode-map "=" 'Info-restore-point) | |
2948 (define-key Info-mode-map "!" 'Info-select-node) | |
2949 (define-key Info-mode-map "@" 'Info-follow-nearest-node) | |
2950 (define-key Info-mode-map "," 'Info-index-next) | |
2951 (define-key Info-mode-map "*" 'Info-elisp-ref) | |
2952 (define-key Info-mode-map [tab] 'Info-next-reference) | |
2953 (define-key Info-mode-map [(meta tab)] 'Info-prev-reference) | |
2954 (define-key Info-mode-map [(shift tab)] 'Info-prev-reference) | |
2955 (define-key Info-mode-map "\r" 'Info-follow-nearest-node) | |
2956 ;; XEmacs addition | |
2957 (define-key Info-mode-map 'backspace 'Info-scroll-prev) | |
2958 (define-key Info-mode-map 'delete 'Info-scroll-prev) | |
2959 (define-key Info-mode-map 'button2 'Info-follow-clicked-node) | |
2960 (define-key Info-mode-map 'button3 'Info-select-node-menu)) | |
2961 | |
2962 | |
2963 ;; Info mode is suitable only for specially formatted data. | |
2964 (put 'info-mode 'mode-class 'special) | |
2965 | |
2966 (defun Info-mode () | |
2967 "Info mode is for browsing through the Info documentation tree. | |
2968 Documentation in Info is divided into \"nodes\", each of which | |
2969 discusses one topic and contains references to other nodes | |
2970 which discuss related topics. Info has commands to follow | |
2971 the references and show you other nodes. | |
2972 | |
2973 h Invoke the Info tutorial. | |
2974 q Quit Info: return to the previously selected file or buffer. | |
2975 | |
2976 Selecting other nodes: | |
2977 n Move to the \"next\" node of this node. | |
2978 p Move to the \"previous\" node of this node. | |
2979 m Pick menu item specified by name (or abbreviation). | |
2980 1-9, 0 Pick first..ninth, last item in node's menu. | |
2981 Menu items select nodes that are \"subsections\" of this node. | |
2982 u Move \"up\" from this node (i.e., from a subsection to a section). | |
2983 f or r Follow a cross reference by name (or abbrev). Type `l' to get back. | |
2984 RET Follow cross reference or menu item indicated by cursor. | |
2985 i Look up a topic in this file's Index and move to that node. | |
2986 , (comma) Move to the next match from a previous `i' command. | |
2987 l (letter L) Move back to the last node you were in. | |
2988 | |
2989 Moving within a node: | |
2990 Space Scroll forward a full screen. DEL Scroll backward. | |
2991 b Go to beginning of node. Meta-> Go to end of node. | |
2992 TAB Go to next cross-reference. Meta-TAB Go to previous ref. | |
2993 | |
2994 Mouse commands: | |
2995 Left Button Set point (usual text-mode functionality) | |
2996 Middle Button Click on a highlighted node reference to go to it. | |
2997 Right Button Pop up a menu of applicable Info commands. | |
2998 | |
2999 Left Button Double Click in window edges: | |
3000 Top edge: Go up to the parent node, like `u'. | |
3001 Left edge: Go to the previous node, like `p'. | |
3002 Right edge: Go to the next node, like `n'. | |
3003 Bottom edge: Follow first menu item, like `1'. | |
3004 | |
3005 Advanced commands: | |
3006 g Move to node, file, or annotation tag specified by name. | |
3007 Examples: `g Rectangles' `g (Emacs)Rectangles' `g Emacs'. | |
3008 v Move to file, with filename completion. | |
3009 k Look up a key sequence in Emacs manual (also C-h C-k at any time). | |
3010 * Look up a function name in Emacs Lisp manual (also C-h C-f). | |
3011 d Go to the main directory of Info files. | |
3012 < or t Go to Top (first) node of this file. | |
3013 > Go to last node in this file. | |
3014 \[ Go to previous node, treating file as one linear document. | |
3015 \] Go to next node, treating file as one linear document. | |
3016 { Scroll backward, or go to previous node if at top. | |
3017 } Scroll forward, or go to next node if at bottom. | |
3018 = Restore cursor position from last time in this node. | |
3019 a Add a private note (annotation) to the current node. | |
3020 x, j Add, jump to a bookmark (annotation tag). | |
3021 s Search this Info file for a node containing the specified regexp. | |
3022 e Edit the contents of the current node." | |
3023 (kill-all-local-variables) | |
3024 (setq major-mode 'Info-mode) | |
3025 (setq mode-name "Info") | |
3026 (use-local-map Info-mode-map) | |
3027 (set-syntax-table text-mode-syntax-table) | |
3028 (setq local-abbrev-table text-mode-abbrev-table) | |
3029 (setq case-fold-search t) | |
3030 (setq buffer-read-only t) | |
3031 ; (setq buffer-mouse-map Info-mode-mouse-map) | |
3032 (make-local-variable 'Info-current-file) | |
3033 (make-local-variable 'Info-current-subfile) | |
3034 (make-local-variable 'Info-current-node) | |
3035 (make-local-variable 'Info-tag-table-marker) | |
442 | 3036 (setq Info-tag-table-marker (make-marker)) |
3037 (make-local-variable 'Info-tag-table-buffer) | |
3038 (setq Info-tag-table-buffer nil) | |
428 | 3039 (make-local-variable 'Info-current-file-completions) |
3040 (make-local-variable 'Info-current-annotation-completions) | |
3041 (make-local-variable 'Info-index-alternatives) | |
3042 (make-local-variable 'Info-history) | |
3043 ;; Faces are now defined by `defface'... | |
548 | 3044 (make-local-hook 'mouse-track-click-hook) |
3045 (add-hook 'mouse-track-click-hook 'Info-maybe-follow-clicked-node t t) | |
3046 (add-hook 'mouse-track-click-hook 'Info-mouse-track-double-click-hook t t) | |
428 | 3047 ;; #### The console-on-window-system-p check is to allow this to |
3048 ;; work on tty's. The real problem here is that featurep really | |
3049 ;; needs to have some device/console domain knowledge added to it. | |
3050 (defvar info::toolbar) | |
3051 (if (and (featurep 'toolbar) | |
3052 (console-on-window-system-p) | |
3053 (not Info-inhibit-toolbar)) | |
3054 (set-specifier default-toolbar (cons (current-buffer) info::toolbar))) | |
3055 (if (featurep 'menubar) | |
3056 (progn | |
3057 ;; make a local copy of the menubar, so our modes don't | |
3058 ;; change the global menubar | |
3059 (easy-menu-add '("Info" :filter Info-menu-filter)))) | |
3060 (run-hooks 'Info-mode-hook) | |
3061 (Info-set-mode-line)) | |
3062 | |
3063 (defvar Info-edit-map nil | |
3064 "Local keymap used within `e' command of Info.") | |
444 | 3065 |
428 | 3066 (if Info-edit-map |
3067 nil | |
3068 ;; XEmacs: remove FSF stuff | |
3069 (setq Info-edit-map (make-sparse-keymap)) | |
3070 (set-keymap-name Info-edit-map 'Info-edit-map) | |
3071 (set-keymap-parents Info-edit-map (list text-mode-map)) | |
3072 (define-key Info-edit-map "\C-c\C-c" 'Info-cease-edit)) | |
3073 | |
3074 ;; Info-edit mode is suitable only for specially formatted data. | |
3075 (put 'info-edit-mode 'mode-class 'special) | |
3076 | |
3077 (defun Info-edit-mode () | |
3078 "Major mode for editing the contents of an Info node. | |
3079 Like text mode with the addition of `Info-cease-edit' | |
3080 which returns to Info mode for browsing. | |
3081 \\{Info-edit-map}" | |
3082 ) | |
3083 | |
3084 (defun Info-edit () | |
3085 "Edit the contents of this Info node. | |
3086 Allowed only if variable `Info-enable-edit' is non-nil." | |
3087 (interactive) | |
3088 (or Info-enable-edit | |
3089 (error "Editing info nodes is not enabled")) | |
3090 (use-local-map Info-edit-map) | |
3091 (setq major-mode 'Info-edit-mode) | |
3092 (setq mode-name "Info Edit") | |
3093 (kill-local-variable 'modeline-buffer-identification) | |
3094 (setq buffer-read-only nil) | |
3095 ;; Make mode line update. | |
3096 (set-buffer-modified-p (buffer-modified-p)) | |
3097 (message (substitute-command-keys | |
3098 "Editing: Type \\[Info-cease-edit] to return to info"))) | |
3099 | |
3100 (defun Info-cease-edit () | |
3101 "Finish editing Info node; switch back to Info proper." | |
3102 (interactive) | |
3103 ;; Do this first, so nothing has changed if user C-g's at query. | |
3104 (and (buffer-modified-p) | |
442 | 3105 (y-or-n-p "Save the file? ") |
428 | 3106 (save-buffer)) |
3107 (use-local-map Info-mode-map) | |
3108 (setq major-mode 'Info-mode) | |
3109 (setq mode-name "Info") | |
3110 (Info-set-mode-line) | |
3111 (setq buffer-read-only t) | |
3112 ;; Make mode line update. | |
3113 (set-buffer-modified-p (buffer-modified-p)) | |
3114 (and (marker-position Info-tag-table-marker) | |
3115 (buffer-modified-p) | |
3116 (message "Tags may have changed. Use Info-tagify if necessary"))) | |
3117 | |
3118 (defun Info-find-emacs-command-nodes (command) | |
3119 "Return a list of locations documenting COMMAND in the XEmacs Info manual. | |
3120 The locations are of the format used in Info-history, i.e. | |
3121 \(FILENAME NODENAME BUFFERPOS\)." | |
3122 (let ((where '()) | |
3123 (cmd-desc (concat "^\\* " (regexp-quote (symbol-name command)) | |
3625 | 3124 ":\\s *\\(.*\\)\\."))) |
428 | 3125 (save-excursion |
3126 (Info-find-node "XEmacs" "Command Index") | |
3127 ;; Take the index node off the Info history. | |
3128 ;; ??? says this isn't safe someplace else... hmmm. | |
3129 (setq Info-history (cdr Info-history)) | |
3130 (goto-char (point-max)) | |
3131 (while (re-search-backward cmd-desc nil t) | |
3132 (setq where (cons (list Info-current-file | |
3133 (buffer-substring | |
3134 (match-beginning 1) | |
3135 (match-end 1)) | |
3136 0) | |
3137 where))) | |
3138 where))) | |
3139 | |
3140 ;;; fontification and mousability for info | |
3141 | |
3142 (defun Info-highlight-region (start end face) | |
3143 (let ((extent nil) | |
3144 (splitp (string-match "\n[ \t]+" (buffer-substring start end)))) | |
3145 (if splitp | |
3146 (save-excursion | |
3147 (setq extent (make-extent start (progn (goto-char start) | |
3148 (end-of-line) | |
3149 (point)))) | |
3150 (set-extent-face extent face) | |
3151 (set-extent-property extent 'info t) | |
3152 (set-extent-property extent 'highlight t) | |
3153 (skip-chars-forward "\n\t ") | |
3154 (setq extent (make-extent (point) end))) | |
3155 (setq extent (make-extent start end))) | |
3156 (set-extent-face extent face) | |
3157 (set-extent-property extent 'info t) | |
3158 (set-extent-property extent 'highlight t))) | |
3159 | |
3160 (defun Info-fontify-node () | |
3161 (save-excursion | |
3162 (let ((case-fold-search t) | |
3163 (xref-regexp (concat "\\*" | |
3164 (regexp-quote Info-footnote-tag) | |
3165 "[ \n\t]*\\([^:]*\\):"))) | |
3166 ;; Clear the old extents | |
3167 (map-extents #'(lambda (x y) (delete-extent x)) | |
3168 (current-buffer) (point-min) (point-max) nil) | |
3169 ;; Break the top line iff it is > 79 characters. Some info nodes | |
3170 ;; have top lines that span 3 lines because of long node titles. | |
3171 ;; eg: (Info-find-node "lispref.info" "Window-Level Event Position Info") | |
3172 (toggle-read-only -1) | |
3173 (let ((extent nil) | |
3174 (len 0) | |
3175 (done nil) | |
3176 (p (point-min))) | |
3177 (goto-char (point-min)) | |
3178 (re-search-forward "Node: *[^,]+, " nil t) | |
3179 (setq len (- (point) (point-min)) | |
3180 extent (make-extent (point-min) (point))) | |
3181 (set-extent-property extent 'invisible t) | |
3182 (while (not done) | |
3183 (goto-char p) | |
3184 (end-of-line) | |
3185 (if (< (current-column) (+ 78 len)) | |
3186 (setq done t) | |
3187 (goto-char p) | |
3188 (forward-char (+ 79 len)) | |
3189 (re-search-backward "," nil t) | |
3190 (forward-char 1) | |
3191 (insert "\n") | |
3192 (just-one-space) | |
446 | 3193 (delete-backward-char 1) |
428 | 3194 (setq p (point) |
3195 len 0)))) | |
3196 (toggle-read-only 1) | |
3197 ;; Highlight xrefs in the top few lines of the node | |
3198 (goto-char (point-min)) | |
3199 (if (looking-at "^File: [^,: \t]+,?[ \t]+") | |
3200 (progn | |
3201 (goto-char (match-end 0)) | |
3202 (while | |
3203 (looking-at "[ \t]*[^:, \t\n]+:[ \t]+\\([^:,\t\n]+\\),?\n?") | |
3204 (goto-char (match-end 0)) | |
444 | 3205 (Info-highlight-region (match-beginning 1) (match-end 1) |
3206 'info-xref)))) | |
428 | 3207 ;; Now get the xrefs in the body |
3208 (goto-char (point-min)) | |
3209 (while (re-search-forward xref-regexp nil t) | |
3210 (if (= (char-after (1- (match-beginning 0))) ?\") ; hack | |
3211 nil | |
444 | 3212 (Info-highlight-region (match-beginning 1) (match-end 1) |
3213 'info-xref))) | |
428 | 3214 ;; then highlight the nodes in the menu. |
3215 (goto-char (point-min)) | |
3216 (if (and (search-forward "\n* menu:" nil t)) | |
3217 (while (re-search-forward | |
3218 "^\\* \\([^:\t\n]*\\):?:[ \t\n]" nil t) | |
444 | 3219 (Info-highlight-region (match-beginning 1) (match-end 1) |
3220 'info-node))) | |
428 | 3221 (set-buffer-modified-p nil)))) |
3222 | |
3223 (defun Info-construct-menu (&optional event) | |
3224 "Construct a menu of Info commands. | |
3225 Adds an entry for the node at EVENT, or under point if EVENT is omitted. | |
3226 Used to construct the menubar submenu and popup menu." | |
3227 (or event (setq event (point))) | |
3228 (let ((case-fold-search t) | |
442 | 3229 (xref-regexp (concat "\\*" |
428 | 3230 (regexp-quote Info-footnote-tag) |
3231 "[ \n\t]*\\([^:]*\\):")) | |
3232 up-p prev-p next-p menu xrefs subnodes in) | |
3233 (save-excursion | |
3234 ;; `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
|
3235 (labels |
428 | 3236 ((one-space (text) |
5567
3bc58dc9d688
Replace #'flet by #'labels where appropriate, core code.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5474
diff
changeset
|
3237 (let (i) |
3bc58dc9d688
Replace #'flet by #'labels where appropriate, core code.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5474
diff
changeset
|
3238 (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
|
3239 (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
|
3240 (substring text (match-end 0)))) |
3bc58dc9d688
Replace #'flet by #'labels where appropriate, core code.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5474
diff
changeset
|
3241 (setq i (1+ i))) |
3bc58dc9d688
Replace #'flet by #'labels where appropriate, core code.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5474
diff
changeset
|
3242 text))) |
428 | 3243 (goto-char (point-min)) |
3244 (if (looking-at ".*\\bNext:") (setq next-p t)) | |
3245 (if (looking-at ".*\\bPrev:") (setq prev-p t)) | |
3246 (if (looking-at ".*Up:") (setq up-p t)) | |
3247 (setq menu (nconc | |
3248 (if (setq in (Info-indicated-node event)) | |
3249 (list (vector (one-space (cadr in)) in t) | |
3250 "--:shadowEtchedIn")) | |
3251 (list | |
3252 ["Goto Info Top-level" Info-directory] | |
3253 (vector "Next Node" 'Info-next :active next-p) | |
3254 (vector "Previous Node" 'Info-prev :active prev-p) | |
3255 (vector "Parent Node (Up)" 'Info-up :active up-p) | |
3256 ["Goto Node..." Info-goto-node] | |
3257 ["Goto Last Visited Node " Info-last]))) | |
3258 ;; Find the xrefs and make a list | |
3259 (while (re-search-forward xref-regexp nil t) | |
3260 (setq xrefs (cons (one-space (buffer-substring (match-beginning 1) | |
3261 (match-end 1))) | |
3262 xrefs)))) | |
3263 (setq xrefs (nreverse xrefs)) | |
3264 (if (> (length xrefs) 21) (setcdr (nthcdr 20 xrefs) '(more))) | |
3265 ;; Find the subnodes and make a list | |
3266 (goto-char (point-min)) | |
3267 (if (search-forward "\n* menu:" nil t) | |
3268 (while (re-search-forward "^\\* \\([^:\t\n]*\\):" nil t) | |
3269 (setq subnodes (cons (buffer-substring (match-beginning 1) | |
3270 (match-end 1)) | |
3271 subnodes)))) | |
3272 (setq subnodes (nreverse subnodes)) | |
3273 (if (> (length subnodes) 21) (setcdr (nthcdr 20 subnodes) '(more)))) | |
3274 (if xrefs | |
3275 (nconc menu (list "--:shadowDoubleEtchedIn" | |
3276 " Cross-References" | |
3277 "--:singleLine") | |
3278 (mapcar #'(lambda (xref) | |
3279 (if (eq xref 'more) | |
3280 "...more..." | |
3281 (vector xref | |
3282 (list 'Info-follow-reference xref)))) | |
3283 xrefs))) | |
3284 (if subnodes | |
3285 (nconc menu (list "--:shadowDoubleEtchedIn" | |
3286 " Sub-Nodes" | |
3287 "--:singleLine") | |
3288 (mapcar #'(lambda (node) | |
3289 (if (eq node 'more) | |
3290 "...more..." | |
3291 (vector node (list 'Info-menu node)))) | |
3292 subnodes))) | |
3293 menu)) | |
3294 | |
3295 (defun Info-menu-filter (menu) | |
3296 "This is the menu filter for the \"Info\" submenu." | |
3297 (Info-construct-menu)) | |
3298 | |
3299 (defun Info-select-node-menu (event) | |
3300 "Pops up a menu of applicable Info commands." | |
3301 (interactive "e") | |
3302 (select-window (event-window event)) | |
3303 (let ((menu (Info-construct-menu event))) | |
3304 (setq menu (nconc (list "Info" ; title: not displayed | |
3305 " Info Commands" | |
3306 "--:shadowDoubleEtchedOut") | |
3307 menu)) | |
3308 (let ((popup-menu-titles nil)) | |
3309 (popup-menu menu)))) | |
3310 | |
3311 ;;; Info toolbar support | |
3312 | |
3313 ;; exit icon taken from GNUS | |
3314 (defvar info::toolbar-exit-icon | |
3315 (if (featurep 'toolbar) | |
3316 (toolbar-make-button-list | |
3317 (expand-file-name (if (featurep 'xpm) "info-exit.xpm" "info-exit.xbm") | |
3318 toolbar-icon-directory))) | |
3319 "Exit Info icon") | |
3320 | |
3321 (defvar info::toolbar-up-icon | |
3322 (if (featurep 'toolbar) | |
3323 (toolbar-make-button-list | |
3324 (expand-file-name (if (featurep 'xpm) "info-up.xpm" "info-up.xbm") | |
3325 toolbar-icon-directory))) | |
3326 "Up icon") | |
3327 | |
3328 (defvar info::toolbar-next-icon | |
3329 (if (featurep 'toolbar) | |
3330 (toolbar-make-button-list | |
3331 (expand-file-name (if (featurep 'xpm) "info-next.xpm" "info-next.xbm") | |
3332 toolbar-icon-directory))) | |
3333 "Next icon") | |
3334 | |
3335 (defvar info::toolbar-prev-icon | |
3336 (if (featurep 'toolbar) | |
3337 (toolbar-make-button-list | |
3338 (expand-file-name (if (featurep 'xpm) "info-prev.xpm" "info-prev.xbm") | |
3339 toolbar-icon-directory))) | |
3340 "Prev icon") | |
3341 | |
3342 (defvar info::toolbar | |
3343 (if (featurep 'toolbar) | |
3344 ; disabled until we get the next/prev-win icons working again. | |
3345 ; (cons (first initial-toolbar-spec) | |
3346 ; (cons (second initial-toolbar-spec) | |
3347 '([info::toolbar-exit-icon | |
3348 Info-exit | |
3349 t | |
3350 "Exit info"] | |
3351 [info::toolbar-next-icon | |
3352 Info-next | |
3353 t | |
3354 "Next entry in same section"] | |
3355 [info::toolbar-prev-icon | |
3356 Info-prev | |
3357 t | |
3358 "Prev entry in same section"] | |
3359 [info::toolbar-up-icon | |
3360 Info-up | |
3361 t | |
3362 "Up entry to enclosing section"] | |
3363 ))) | |
3364 ;)) | |
3365 | |
3366 (provide 'info) | |
3367 | |
3368 (run-hooks 'Info-load-hook) | |
3369 | |
3370 ;;; info.el ends here |