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