Mercurial > emacs
annotate man/forms.texi @ 70234:4282b2a1849b
(construct_mouse_wheel): Handle negative coordinates.
author | Jason Rumney <jasonr@gnu.org> |
---|---|
date | Wed, 26 Apr 2006 18:18:08 +0000 |
parents | 11b616eddda4 |
children | c7e4f78b81a6 e6bf73e43cf4 |
rev | line source |
---|---|
25829 | 1 \input texinfo @c -*-texinfo-*- |
2 @c documentation for forms-mode | |
3 @c Written by Johan Vromans, and edited by Richard Stallman | |
4 | |
5 @comment %**start of header (This is for running Texinfo on a region.) | |
6 @setfilename ../info/forms | |
7 @settitle Forms Mode User's Manual | |
8 @syncodeindex vr cp | |
9 @syncodeindex fn cp | |
10 @syncodeindex ky cp | |
11 @iftex | |
12 @finalout | |
13 @setchapternewpage odd | |
14 @end iftex | |
15 @c @smallbook | |
16 @comment %**end of header (This is for running Texinfo on a region.) | |
17 | |
47737
0a70200bde27
use @copying instead of @ifinfo.
Karl Berry <karl@gnu.org>
parents:
46918
diff
changeset
|
18 @copying |
25829 | 19 This file documents Forms mode, a form-editing major mode for GNU Emacs. |
20 | |
69681
11b616eddda4
@copyright{}, no indentation in @copying{}
Karl Berry <karl@gnu.org>
parents:
68639
diff
changeset
|
21 Copyright @copyright{} 1989, 1997, 2001, 2002, 2003, 2004, |
11b616eddda4
@copyright{}, no indentation in @copying{}
Karl Berry <karl@gnu.org>
parents:
68639
diff
changeset
|
22 2005, 2006 Free Software Foundation, Inc. |
25829 | 23 |
47737
0a70200bde27
use @copying instead of @ifinfo.
Karl Berry <karl@gnu.org>
parents:
46918
diff
changeset
|
24 @quotation |
37404
730f77edf073
Use GNU Free Documentation License.
Gerd Moellmann <gerd@gnu.org>
parents:
30009
diff
changeset
|
25 Permission is granted to copy, distribute and/or modify this document |
65555
69b3598a61c5
Update all manuals to specify GFDL version 1.2.
Romain Francoise <romain@orebokech.com>
parents:
64890
diff
changeset
|
26 under the terms of the GNU Free Documentation License, Version 1.2 or |
37404
730f77edf073
Use GNU Free Documentation License.
Gerd Moellmann <gerd@gnu.org>
parents:
30009
diff
changeset
|
27 any later version published by the Free Software Foundation; with no |
730f77edf073
Use GNU Free Documentation License.
Gerd Moellmann <gerd@gnu.org>
parents:
30009
diff
changeset
|
28 Invariant Sections, with the Front-Cover texts being ``A GNU |
730f77edf073
Use GNU Free Documentation License.
Gerd Moellmann <gerd@gnu.org>
parents:
30009
diff
changeset
|
29 Manual'', and with the Back-Cover Texts as in (a) below. A copy of the |
730f77edf073
Use GNU Free Documentation License.
Gerd Moellmann <gerd@gnu.org>
parents:
30009
diff
changeset
|
30 license is included in the section entitled ``GNU Free Documentation |
730f77edf073
Use GNU Free Documentation License.
Gerd Moellmann <gerd@gnu.org>
parents:
30009
diff
changeset
|
31 License'' in the Emacs manual. |
25829 | 32 |
37404
730f77edf073
Use GNU Free Documentation License.
Gerd Moellmann <gerd@gnu.org>
parents:
30009
diff
changeset
|
33 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify |
730f77edf073
Use GNU Free Documentation License.
Gerd Moellmann <gerd@gnu.org>
parents:
30009
diff
changeset
|
34 this GNU Manual, like GNU software. Copies published by the Free |
730f77edf073
Use GNU Free Documentation License.
Gerd Moellmann <gerd@gnu.org>
parents:
30009
diff
changeset
|
35 Software Foundation raise funds for GNU development.'' |
730f77edf073
Use GNU Free Documentation License.
Gerd Moellmann <gerd@gnu.org>
parents:
30009
diff
changeset
|
36 |
730f77edf073
Use GNU Free Documentation License.
Gerd Moellmann <gerd@gnu.org>
parents:
30009
diff
changeset
|
37 This document is part of a collection distributed under the GNU Free |
730f77edf073
Use GNU Free Documentation License.
Gerd Moellmann <gerd@gnu.org>
parents:
30009
diff
changeset
|
38 Documentation License. If you want to distribute this document |
730f77edf073
Use GNU Free Documentation License.
Gerd Moellmann <gerd@gnu.org>
parents:
30009
diff
changeset
|
39 separately from the collection, you can do so by adding a copy of the |
730f77edf073
Use GNU Free Documentation License.
Gerd Moellmann <gerd@gnu.org>
parents:
30009
diff
changeset
|
40 license to the document, as described in section 6 of the license. |
47737
0a70200bde27
use @copying instead of @ifinfo.
Karl Berry <karl@gnu.org>
parents:
46918
diff
changeset
|
41 @end quotation |
0a70200bde27
use @copying instead of @ifinfo.
Karl Berry <karl@gnu.org>
parents:
46918
diff
changeset
|
42 @end copying |
25829 | 43 |
47737
0a70200bde27
use @copying instead of @ifinfo.
Karl Berry <karl@gnu.org>
parents:
46918
diff
changeset
|
44 @dircategory Emacs |
0a70200bde27
use @copying instead of @ifinfo.
Karl Berry <karl@gnu.org>
parents:
46918
diff
changeset
|
45 @direntry |
0a70200bde27
use @copying instead of @ifinfo.
Karl Berry <karl@gnu.org>
parents:
46918
diff
changeset
|
46 * Forms: (forms). Emacs package for editing data bases |
0a70200bde27
use @copying instead of @ifinfo.
Karl Berry <karl@gnu.org>
parents:
46918
diff
changeset
|
47 by filling in forms. |
0a70200bde27
use @copying instead of @ifinfo.
Karl Berry <karl@gnu.org>
parents:
46918
diff
changeset
|
48 @end direntry |
0a70200bde27
use @copying instead of @ifinfo.
Karl Berry <karl@gnu.org>
parents:
46918
diff
changeset
|
49 |
25829 | 50 @titlepage |
51 @sp 6 | |
52 @center @titlefont{Forms Mode User's Manual} | |
53 @sp 4 | |
54 @center Forms-Mode version 2 | |
55 @sp 1 | |
56 @center for GNU Emacs 20.1 | |
57 @sp 1 | |
58 @center June 1997 | |
59 @sp 5 | |
60 @center Johan Vromans | |
61 @center @i{jvromans@@squirrel.nl} | |
62 @page | |
63 @vskip 0pt plus 1filll | |
47737
0a70200bde27
use @copying instead of @ifinfo.
Karl Berry <karl@gnu.org>
parents:
46918
diff
changeset
|
64 @insertcopying |
0a70200bde27
use @copying instead of @ifinfo.
Karl Berry <karl@gnu.org>
parents:
46918
diff
changeset
|
65 @end titlepage |
37404
730f77edf073
Use GNU Free Documentation License.
Gerd Moellmann <gerd@gnu.org>
parents:
30009
diff
changeset
|
66 |
47737
0a70200bde27
use @copying instead of @ifinfo.
Karl Berry <karl@gnu.org>
parents:
46918
diff
changeset
|
67 @ifnottex |
25829 | 68 @node Top |
69 @top Forms Mode | |
70 | |
71 Forms mode is an Emacs major mode for working with simple textual data | |
72 bases in a forms-oriented manner. In Forms mode, the information in | |
73 these files is presented in an Emacs window in a user-defined format, | |
74 one record at a time. The user can view records or modify their | |
75 contents. | |
76 | |
77 Forms mode is not a simple major mode, but requires two files to do its | |
78 job: a control file and a data file. The data file holds the | |
79 actual data to be presented. The control file describes | |
80 how to present it. | |
81 | |
82 @menu | |
83 * Forms Example:: An example: editing the password data base. | |
84 * Entering and Exiting Forms Mode:: | |
85 How to visit a file in Forms mode. | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47737
diff
changeset
|
86 * Forms Commands:: Special commands to use while in Forms mode. |
25829 | 87 * Data File Format:: How to format the data file. |
88 * Control File Format:: How to control forms mode. | |
89 * Format Description:: How to define the forms layout. | |
90 * Modifying Forms Contents:: How to modify. | |
91 * Miscellaneous:: Forms mode messages and other remarks. | |
92 * Error Messages:: List of error messages forms mode can produce. | |
93 * Long Example:: A more complex control file example. | |
94 * Credits:: Thanks everyone. | |
95 * Index:: Index to this manual. | |
96 @end menu | |
47737
0a70200bde27
use @copying instead of @ifinfo.
Karl Berry <karl@gnu.org>
parents:
46918
diff
changeset
|
97 @end ifnottex |
25829 | 98 |
99 @node Forms Example | |
100 @chapter Forms Example | |
101 | |
102 Let's illustrate Forms mode with an example. Suppose you are looking at | |
103 the @file{/etc/passwd} file, and the screen looks like this: | |
104 | |
105 @example | |
106 ====== /etc/passwd ====== | |
107 | |
108 User : root Uid: 0 Gid: 1 | |
109 | |
110 Name : Super User | |
111 | |
112 Home : / | |
113 | |
114 Shell: /bin/sh | |
115 @end example | |
116 | |
117 As you can see, the familiar fields from the entry for the super user | |
118 are all there, but instead of being colon-separated on one single line, | |
119 they make up a forms. | |
120 | |
121 The contents of the forms consist of the contents of the fields of the | |
122 record (e.g. @samp{root}, @samp{0}, @samp{1}, @samp{Super User}) | |
123 interspersed with normal text (e.g @samp{User : }, @samp{Uid: }). | |
124 | |
125 If you modify the contents of the fields, Forms mode will analyze your | |
126 changes and update the file appropriately. You cannot modify the | |
127 interspersed explanatory text (unless you go to some trouble about it), | |
128 because that is marked read-only (@pxref{Text Properties,,, elisp, The | |
129 Emacs Lisp Reference Manual}). | |
130 | |
131 The Forms mode control file specifies the relationship between the | |
132 format of @file{/etc/passwd} and what appears on the screen in Forms | |
133 mode. @xref{Control File Format}. | |
134 | |
135 @node Entering and Exiting Forms Mode | |
136 @chapter Entering and Exiting Forms Mode | |
137 | |
138 @table @kbd | |
139 @findex forms-find-file | |
140 @item M-x forms-find-file @key{RET} @var{control-file} @key{RET} | |
141 Visit a database using Forms mode. Specify the name of the | |
142 @strong{control file}, not the data file! | |
143 | |
144 @findex forms-find-file-other-window | |
145 @item M-x forms-find-file-other-window @key{RET} @var{control-file} @key{RET} | |
146 Similar, but displays the file in another window. | |
147 @end table | |
148 | |
149 The command @code{forms-find-file} evaluates the file | |
150 @var{control-file}, and also visits it in Forms mode. What you see in | |
151 its buffer is not the contents of this file, but rather a single record | |
152 of the corresponding data file that is visited in its own buffer. So | |
153 there are two buffers involved in Forms mode: the @dfn{forms buffer} | |
154 that is initially used to visit the control file and that shows the | |
155 records being browsed, and the @dfn{data buffer} that holds the data | |
156 file being visited. The latter buffer is normally not visible. | |
157 | |
158 Initially, the first record is displayed in the forms buffer. | |
159 The mode line displays the major mode name @samp{Forms}, followed by the | |
160 minor mode @samp{View} if the data base is read-only. The number of the | |
161 current record (@var{n}) and the total number of records in the | |
162 file(@var{t}) are shown in the mode line as @samp{@var{n}/@var{t}}. For | |
163 example: | |
164 | |
165 @example | |
166 --%%-Emacs: passwd-demo (Forms View 1/54)----All------- | |
167 @end example | |
168 | |
169 If the buffer is not read-only, you may change the buffer to modify the | |
170 fields in the record. When you move to a different record, the contents | |
171 of the buffer are parsed using the specifications in | |
172 @code{forms-format-list}, and the data file is updated. If the record | |
173 has fields that aren't included in the display, they are not changed. | |
174 | |
175 @vindex forms-mode-hooks | |
176 Entering Forms mode runs the normal hook @code{forms-mode-hooks} to | |
177 perform user-defined customization. | |
178 | |
179 To save any modified data, you can use @kbd{C-x C-s} | |
180 (@code{forms-save-buffer}). This does not save the forms buffer (which would | |
181 be rather useless), but instead saves the buffer visiting the data file. | |
182 | |
183 To terminate Forms mode, you can use @kbd{C-x C-s} (@code{forms-save-buffer}) | |
184 and then kill the forms buffer. However, the data buffer will still | |
185 remain. If this is not desired, you have to kill this buffer too. | |
186 | |
187 @node Forms Commands | |
188 @chapter Forms Commands | |
189 | |
190 The commands of Forms mode belong to the @kbd{C-c} prefix, with one | |
191 exception: @key{TAB}, which moves to the next field. Forms mode uses | |
192 different key maps for normal mode and read-only mode. In read-only | |
193 Forms mode, you can access most of the commands without the @kbd{C-c} | |
194 prefix, but you must type ordinary letters instead of control | |
195 characters; for example, type @kbd{n} instead of @kbd{C-c C-n}. | |
196 | |
197 If your Emacs has been built with X-toolkit support, Forms mode will | |
198 provide its own menu with a number of Forms mode commands. | |
199 | |
200 @table @kbd | |
201 @findex forms-next-record | |
202 @kindex C-c C-n | |
203 @item C-c C-n | |
204 Show the next record (@code{forms-next-record}). With a numeric | |
205 argument @var{n}, show the @var{n}th next record. | |
206 | |
207 @findex forms-prev-record | |
208 @kindex C-c C-p | |
209 @item C-c C-p | |
210 Show the previous record (@code{forms-prev-record}). With a numeric | |
211 argument @var{n}, show the @var{n}th previous record. | |
212 | |
213 @findex forms-jump-record | |
214 @kindex C-c C-l | |
215 @item C-c C-l | |
216 Jump to a record by number (@code{forms-jump-record}). Specify | |
217 the record number with a numeric argument. | |
218 | |
219 @findex forms-first-record | |
220 @kindex C-c < | |
221 @item C-c < | |
222 Jump to the first record (@code{forms-first-record}). | |
223 | |
224 @findex forms-last-record | |
225 @kindex C-c > | |
226 @item C-c > | |
227 Jump to the last record (@code{forms-last-record}). This command also | |
228 recalculates the number of records in the data file. | |
229 | |
230 @findex forms-next-field | |
231 @kindex TAB | |
232 @item @key{TAB} | |
233 @kindex C-c TAB | |
234 @itemx C-c @key{TAB} | |
235 Jump to the next field in the current record (@code{forms-next-field}). | |
236 With a numeric argument @var{n}, jump forward @var{n} fields. If this command | |
237 would move past the last field, it wraps around to the first field. | |
238 | |
239 @findex forms-toggle-read-only | |
240 @kindex C-c C-q | |
241 @item C-c C-q | |
242 Toggles read-only mode (@code{forms-toggle-read-only}). In read-only | |
243 Forms mode, you cannot edit the fields; most Forms mode commands can be | |
244 accessed without the prefix @kbd{C-c} if you use the normal letter | |
245 instead (for example, type @kbd{n} instead of @kbd{C-c C-n}). In edit | |
246 mode, you can edit the fields and thus change the contents of the data | |
247 base; you must begin Forms mode commands with @code{C-c}. Switching | |
248 to edit mode is allowed only if you have write access to the data file. | |
249 | |
250 @findex forms-insert-record | |
251 @kindex C-c C-o | |
252 @item C-c C-o | |
253 Create a new record and insert it before the current record | |
254 (@code{forms-insert-record}). It starts out with empty (or default) | |
255 contents for its fields; you can then edit the fields. With a numeric | |
256 argument, the new record is created @emph{after} the current one. | |
257 See also @code{forms-modified-record-filter} in @ref{Modifying Forms | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47737
diff
changeset
|
258 Contents}. |
25829 | 259 |
260 @findex forms-delete-record | |
261 @kindex C-c C-k | |
262 @item C-c C-k | |
263 Delete the current record (@code{forms-delete-record}). You are | |
264 prompted for confirmation before the record is deleted unless a numeric | |
265 argument has been provided. | |
266 | |
267 @findex forms-search-forward | |
268 @kindex C-c C-s @var{regexp} @key{RET} | |
269 @item C-c C-s @var{regexp} @key{RET} | |
270 Search forward for @var{regexp} in all records following this one | |
271 (@code{forms-search-forward}). If found, this record is shown. | |
272 If you give an empty argument, the previous regexp is used again. | |
273 | |
274 @findex forms-search-backward | |
275 @kindex C-c C-r @var{regexp} @key{RET} | |
276 @item C-c C-r @var{regexp} @key{RET} | |
277 Search backward for @var{regexp} in all records following this one | |
278 (@code{forms-search-backward}). If found, this record is shown. | |
279 If you give an empty argument, the previous regexp is used again. | |
280 | |
281 @ignore | |
282 @findex forms-exit | |
283 @kindex C-c C-x | |
284 @item C-c C-x | |
285 Terminate Forms mode processing (@code{forms-exit}). The data file is | |
286 saved if it has been modified. | |
287 | |
288 @findex forms-exit-no-save | |
289 @item M-x forms-exit-no-save | |
290 Terminates forms mode processing without saving modified data first. | |
291 @end ignore | |
292 | |
293 @findex forms-prev-field | |
294 @item M-x forms-prev-field | |
295 Similar to @code{forms-next-field} but moves backwards. | |
296 | |
297 @findex forms-save-buffer | |
298 @item M-x forms-save-buffer | |
299 @kindex C-x C-s | |
300 @itemx C-x C-s | |
301 Forms mode replacement for @code{save-buffer}. When executed in the | |
302 forms buffer it will save the contents of the (modified) data buffer | |
303 instead. In Forms mode this function will be bound to @kbd{C-x C-s}. | |
304 | |
305 @findex forms-print | |
306 @item M-x forms-print | |
307 This command can be used to make a formatted print | |
308 of the contents of the data file. | |
309 | |
310 @end table | |
311 | |
312 In addition the command @kbd{M-x revert-buffer} is useful in Forms mode | |
313 just as in other modes. | |
314 | |
315 @ignore | |
316 @vindex forms-forms-scroll | |
317 @findex scroll-up | |
318 @findex scroll-down | |
319 If the variable @code{forms-forms-scrolls} is set to a value other | |
320 than @code{nil} (which it is, by default), the Emacs functions | |
321 @code{scroll-up} and @code{scroll-down} will perform a | |
322 @code{forms-next-record} and @code{forms-prev-record} when in forms | |
46918
82d113655734
Minor spelling and grammar corrections.
Paul Eggert <eggert@twinsun.com>
parents:
37404
diff
changeset
|
323 mode. So you can use your favorite page commands to page through the |
25829 | 324 data file. |
325 | |
326 @vindex forms-forms-jump | |
327 @findex beginning-of-buffer | |
328 @findex end-of-buffer | |
329 Likewise, if the variable @code{forms-forms-jump} is not @code{nil} | |
330 (which it is, by default), Emacs functions @code{beginning-of-buffer} | |
331 and @code{end-of-buffer} will perform @code{forms-first-record} and | |
332 @code{forms-last-record} when in forms mode. | |
333 @end ignore | |
334 | |
335 The following function key definitions are set up in Forms mode | |
336 (whether read-only or not): | |
337 | |
338 @table @kbd | |
339 @kindex next | |
340 @item next | |
341 forms-next-record | |
342 | |
343 @kindex prior | |
344 @item prior | |
345 forms-prev-record | |
346 | |
347 @kindex begin | |
348 @item begin | |
349 forms-first-record | |
350 | |
351 @kindex end | |
352 @item end | |
353 forms-last-record | |
354 | |
355 @kindex S-Tab | |
356 @findex forms-prev-field | |
357 @item S-Tab | |
358 forms-prev-field | |
359 @end table | |
360 | |
361 @node Data File Format | |
362 @chapter Data File Format | |
363 | |
364 @cindex record | |
365 @cindex field | |
366 @vindex forms-field-sep | |
367 Files for use with Forms mode are very simple---each @dfn{record} | |
368 (usually one line) forms the contents of one form. Each record consists | |
369 of a number of @dfn{fields}, which are separated by the value of the | |
370 string @code{forms-field-sep}, which is @code{"\t"} (a Tab) by default. | |
371 | |
372 @vindex forms-read-file-filter | |
373 @vindex forms-write-file-filter | |
374 If the format of the data file is not suitable enough you can define the | |
375 filter functions @code{forms-read-file-filter} and | |
376 @code{forms-write-file-filter}. @code{forms-read-file-filter} is called | |
377 when the data file is read from disk into the data buffer. It operates | |
378 on the data buffer, ignoring read-only protections. When the data file | |
379 is saved to disk @code{forms-write-file-filter} is called to cancel the | |
380 effects of @code{forms-read-file-filter}. After being saved, | |
381 @code{forms-read-file-filter} is called again to prepare the data buffer | |
382 for further processing. | |
383 | |
384 @cindex pseudo-newline | |
385 @vindex forms-multi-line | |
386 Fields may contain text which shows up in the forms in multiple lines. | |
387 These lines are separated in the field using a ``pseudo-newline'' | |
388 character which is defined by the value of the string | |
389 @code{forms-multi-line}. Its default value is @code{"\^k"} (a Control-K | |
390 character). If it is | |
391 set to @code{nil}, multiple line fields are prohibited. | |
392 | |
393 If the data file does not exist, it is automatically created. | |
394 | |
395 @node Control File Format | |
396 @chapter Control File Format | |
397 | |
398 @cindex control file | |
399 The Forms mode @dfn{control file} serves two purposes. First, it names | |
400 the data file to use, and defines its format and properties. Second, | |
401 the Emacs buffer it occupies is used by Forms mode to display the forms. | |
402 | |
403 The contents of the control file are evaluated as a Lisp program. It | |
404 should set the following Lisp variables to suitable values: | |
405 | |
406 @table @code | |
407 @vindex forms-file | |
408 @item forms-file | |
409 This variable specifies the name of the data file. Example: | |
410 | |
411 @example | |
412 (setq forms-file "my/data-file") | |
413 @end example | |
414 | |
415 If the control file doesn't set @code{forms-file}, Forms mode | |
416 reports an error. | |
417 | |
418 @vindex forms-format-list | |
419 @item forms-format-list | |
420 This variable describes the way the fields of the record are formatted on | |
421 the screen. For details, see @ref{Format Description}. | |
422 | |
423 @vindex forms-number-of-fields | |
424 @item forms-number-of-fields | |
425 This variable holds the number of fields in each record of the data | |
426 file. Example: | |
427 | |
428 @example | |
429 (setq forms-number-of-fields 10) | |
430 @end example | |
431 @end table | |
432 | |
433 If the control file does not set @code{forms-format-list} a default | |
434 format is used. In this situation, Forms mode will deduce the number of | |
435 fields from the data file providing this file exists and | |
436 @code{forms-number-of-records} has not been set in the control file. | |
437 | |
438 The control file can optionally set the following additional Forms mode | |
439 variables. Most of them have default values that are good for most | |
440 applications. | |
441 | |
442 @table @code | |
443 @vindex forms-field-sep | |
444 @item forms-field-sep | |
445 This variable may be used to designate the string which separates the | |
446 fields in the records of the data file. If not set, it defaults to the | |
447 string @code{"\t"} (a Tab character). Example: | |
448 | |
449 @example | |
450 (setq forms-field-sep "\t") | |
451 @end example | |
452 | |
453 @vindex forms-read-only | |
454 @item forms-read-only | |
455 If the value is non-@code{nil}, the data file is treated read-only. (Forms | |
456 mode also treats the data file as read-only if you don't have access to | |
457 write it.) Example: | |
458 | |
459 @example | |
460 (set forms-read-only t) | |
461 @end example | |
462 | |
463 @vindex forms-multi-line | |
464 @item forms-multi-line | |
465 This variable specifies the @dfn{pseudo newline} separator that allows | |
466 multi-line fields. This separator goes between the ``lines'' within a | |
467 field---thus, the field doesn't really contain multiple lines, but it | |
468 appears that way when displayed in Forms mode. If the value is | |
469 @code{nil}, multi-line text fields are prohibited. The pseudo newline | |
470 must not be a character contained in @code{forms-field-sep}. | |
471 | |
472 The default value is @code{"\^k"}, the character Control-K. Example: | |
473 | |
474 @example | |
475 (setq forms-multi-line "\^k") | |
476 @end example | |
477 | |
478 @ignore | |
479 @vindex forms-forms-scroll | |
480 @item forms-forms-scroll | |
481 @xref{Forms Mode Commands}, for details. | |
482 | |
483 @vindex forms-forms-jump | |
484 @item forms-forms-jump | |
485 @xref{Forms Mode Commands}, for details. | |
486 @end ignore | |
487 | |
488 @findex forms-read-file-filter | |
489 @item forms-read-file-filter | |
490 This variable holds the name of a function to be called after the data | |
491 file has been read in. This can be used to transform the contents of the | |
492 data file into a format more suitable for forms processing. | |
493 If it is @code{nil}, no function is called. For example, to maintain a | |
494 gzipped database: | |
495 | |
496 @example | |
497 (defun gzip-read-file-filter () | |
498 (shell-command-on-region (point-min) (point-max) | |
499 "gzip -d" t t)) | |
500 (setq forms-read-file-filter 'gzip-read-file-filter) | |
501 @end example | |
502 | |
503 @findex forms-write-file-filter | |
504 @item forms-write-file-filter | |
505 This variable holds the name of a function to be called before writing | |
506 out the contents of the data file. | |
507 This can be used to undo the effects of @code{forms-read-file-filter}. | |
508 If it is @code{nil}, no function is called. Example: | |
509 | |
510 @example | |
511 (defun gzip-write-file-filter () | |
512 (make-variable-buffer-local 'require-final-newline) | |
513 (setq require-final-newline nil) | |
514 (shell-command-on-region (point-min) (point-max) | |
515 "gzip" t t)) | |
516 (setq forms-write-file-filter 'gzip-write-file-filter) | |
517 @end example | |
518 | |
519 @findex forms-new-record-filter | |
520 @item forms-new-record-filter | |
521 This variable holds a function to be called whenever a new record is created | |
522 to supply default values for fields. If it is @code{nil}, no function is | |
523 called. | |
524 @xref{Modifying Forms Contents}, for details. | |
525 | |
526 @findex forms-modified-record-filter | |
527 @item forms-modified-record-filter | |
528 This variable holds a function to be called whenever a record is | |
529 modified, just before updating the Forms data file. If it is | |
530 @code{nil}, no function is called. | |
531 @xref{Modifying Forms Contents}, for details. | |
532 | |
533 @findex forms-insert-after | |
534 @item forms-insert-after | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47737
diff
changeset
|
535 If this variable is not @code{nil}, new records are created @emph{after} the |
25829 | 536 current record. Also, upon visiting a file, the initial position will be |
537 at the last record instead of the first one. | |
538 | |
539 @findex forms-check-number-of-fields | |
540 @item forms-check-number-of-fields | |
541 Normally each record is checked to contain the correct number of fields. | |
542 Under certain circumstances, this can be undesirable. | |
543 If this variable is set to @code{nil}, these checks will be bypassed. | |
544 @end table | |
545 | |
546 @node Format Description | |
547 @chapter The Format Description | |
548 | |
549 @vindex forms-format-list | |
550 The variable @code{forms-format-list} specifies the format of the data | |
551 in the data file, and how to convert the data for display in Forms mode. | |
552 Its value must be a list of Forms mode @dfn{formatting elements}, each | |
553 of which can be a string, a number, a Lisp list, or a Lisp symbol that | |
554 evaluates to one of those. The formatting elements are processed in the | |
555 order they appear in the list. | |
556 | |
557 @table @var | |
558 @item string | |
559 A string formatting element is inserted in the forms ``as is,'' as text | |
560 that the user cannot alter. | |
561 | |
562 @item number | |
563 A number element selects a field of the record. The contents of this | |
564 field are inserted in the display at this point. Field numbers count | |
565 starting from 1 (one). | |
566 | |
567 @item list | |
568 A formatting element that is a list specifies a function call. This | |
569 function is called every time a record is displayed, and its result, | |
570 which must be a string, is inserted in the display text. The function | |
571 should do nothing but returning a string. | |
572 | |
573 @vindex forms-fields | |
574 The function you call can access the fields of the record as a list in | |
575 the variable | |
576 @code{forms-fields}. | |
577 | |
578 @item symbol | |
579 A symbol used as a formatting element should evaluate to a string, number, | |
580 or list; the value is interpreted as a formatting element, as described | |
581 above. | |
582 @end table | |
583 | |
584 If a record does not contain the number of fields as specified in | |
585 @code{forms-number-of-fields}, a warning message will be printed. Excess | |
586 fields are ignored, missing fields are set to empty. | |
587 | |
588 The control file which displays @file{/etc/passwd} file as demonstrated | |
589 in the beginning of this manual might look as follows: | |
590 | |
591 @example | |
592 ;; @r{This demo visits @file{/etc/passwd}.} | |
593 | |
594 (setq forms-file "/etc/passwd") | |
595 (setq forms-number-of-fields 7) | |
596 (setq forms-read-only t) ; @r{to make sure} | |
597 (setq forms-field-sep ":") | |
598 ;; @r{Don't allow multi-line fields.} | |
599 (setq forms-multi-line nil) | |
600 | |
601 (setq forms-format-list | |
602 (list | |
603 "====== /etc/passwd ======\n\n" | |
604 "User : " 1 | |
605 " Uid: " 3 | |
606 " Gid: " 4 | |
607 "\n\n" | |
608 "Name : " 5 | |
609 "\n\n" | |
610 "Home : " 6 | |
611 "\n\n" | |
612 "Shell: " 7 | |
613 "\n")) | |
614 @end example | |
615 | |
616 When you construct the value of @code{forms-format-list}, you should | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47737
diff
changeset
|
617 usually either quote the whole value, like this, |
25829 | 618 |
619 @example | |
620 (setq forms-format-list | |
621 '( | |
622 "====== " forms-file " ======\n\n" | |
623 "User : " 1 | |
624 (make-string 20 ?-) | |
625 @dots{} | |
626 )) | |
627 @end example | |
628 | |
629 @noindent | |
630 or quote the elements which are lists, like this: | |
631 | |
632 @example | |
633 (setq forms-format-list | |
634 (list | |
635 "====== " forms-file " ======\n\n" | |
636 "User : " 1 | |
637 '(make-string 20 ?-) | |
638 @dots{} | |
639 )) | |
640 @end example | |
641 | |
642 Forms mode validates the contents of @code{forms-format-list} when you | |
643 visit a database. If there are errors, processing is aborted with an | |
644 error message which includes a descriptive text. @xref{Error Messages}, | |
645 for a detailed list of error messages. | |
646 | |
647 If no @code{forms-format-list} is specified, Forms mode will supply a | |
648 default format list. This list contains the name of the file being | |
649 visited, and a simple label for each field indicating the field number. | |
650 | |
651 @node Modifying Forms Contents | |
652 @chapter Modifying The Forms Contents | |
653 | |
654 If @code{forms-read-only} is @code{nil}, the user can modify the fields | |
655 and records of the database. | |
656 | |
657 All normal editing commands are available for editing the contents of the | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47737
diff
changeset
|
658 displayed record. You cannot delete or modify the fixed, explanatory |
25829 | 659 text that comes from string formatting elements, but you can modify the |
660 actual field contents. | |
661 | |
662 @ignore | |
663 @c This is for the Emacs 18 version only. | |
664 If the contents of the forms cannot be recognized properly, this is | |
665 signaled using a descriptive text. @xref{Error Messages}, for more info. | |
666 The cursor will indicate the last part of the forms which was | |
667 successfully parsed. It's important to avoid entering field contents | |
668 that would cause confusion with the field-separating fixed text. | |
669 @end ignore | |
670 | |
671 If the variable @code{forms-modified-record-filter} is non-@code{nil}, | |
672 it is called as a function before the new data is written to the data | |
673 file. The function receives one argument, a vector that contains the | |
674 contents of the fields of the record. | |
675 | |
676 The function can refer to fields with @code{aref} and modify them with | |
677 @code{aset}. The first field has number 1 (one); thus, element 0 of the | |
678 vector is not used. The function should return the same vector it was | |
679 passed; the (possibly modified) contents of the vector determine what is | |
680 actually written in the file. Here is an example: | |
681 | |
682 @example | |
683 (defun my-modified-record-filter (record) | |
684 ;; @r{Modify second field.} | |
685 (aset record 2 (current-time-string)) | |
686 ;; @r{Return the field vector.} | |
687 record) | |
688 | |
689 (setq forms-modified-record-filter 'my-modified-record-filter) | |
690 @end example | |
691 | |
692 If the variable @code{forms-new-record-filter} is non-@code{nil}, its | |
693 value is a function to be called to fill in default values for the | |
694 fields of a new record. The function is passed a vector of empty | |
695 strings, one for each field; it should return the same vector, with | |
696 the desired field values stored in it. Fields are numbered starting | |
697 from 1 (one). Example: | |
698 | |
699 @example | |
700 (defun my-new-record-filter (fields) | |
701 (aset fields 5 (login-name)) | |
702 (aset fields 1 (current-time-string)) | |
703 fields) | |
704 | |
705 (setq forms-new-record-filter 'my-new-record-filter) | |
706 @end example | |
707 | |
708 @node Miscellaneous | |
709 @chapter Miscellaneous | |
710 | |
711 @vindex forms-version | |
712 The global variable @code{forms-version} holds the version information | |
713 of the Forms mode software. | |
714 | |
715 @findex forms-enumerate | |
716 It is very convenient to use symbolic names for the fields in a record. | |
717 The function @code{forms-enumerate} provides an elegant means to define | |
718 a series of variables whose values are consecutive integers. The | |
719 function returns the highest number used, so it can be used to set | |
720 @code{forms-number-of-fields} also. For example: | |
721 | |
722 @example | |
723 (setq forms-number-of-fields | |
724 (forms-enumerate | |
725 '(field1 field2 field3 @dots{}))) | |
726 @end example | |
727 | |
728 This sets @code{field1} to 1, @code{field2} to 2, and so on. | |
729 | |
730 Care has been taken to keep the Forms mode variables buffer-local, so it | |
731 is possible to visit multiple files in Forms mode simultaneously, even | |
732 if they have different properties. | |
733 | |
734 @findex forms-mode | |
735 If you have visited the control file in normal fashion with | |
736 @code{find-file} or a like command, you can switch to Forms mode with | |
737 the command @code{M-x forms-mode}. If you put @samp{-*- forms -*-} in | |
738 the first line of the control file, then visiting it enables Forms mode | |
739 automatically. But this makes it hard to edit the control file itself, | |
740 so you'd better think twice before using this. | |
741 | |
742 The default format for the data file, using @code{"\t"} to separate | |
743 fields and @code{"\^k"} to separate lines within a field, matches the | |
744 file format of some popular database programs, e.g. FileMaker. So | |
745 @code{forms-mode} can decrease the need to use proprietary software. | |
746 | |
747 @node Error Messages | |
748 @chapter Error Messages | |
749 | |
750 This section describes all error messages which can be generated by | |
751 forms mode. Error messages that result from parsing the control file | |
752 all start with the text @samp{Forms control file error}. Messages | |
753 generated while analyzing the definition of @code{forms-format-list} | |
754 start with @samp{Forms format error}. | |
755 | |
756 @table @code | |
757 @item Forms control file error: `forms-file' has not been set | |
758 The variable @code{forms-file} was not set by the control file. | |
759 | |
760 @item Forms control file error: `forms-number-of-fields' has not been set | |
761 The variable @code{forms-number-of-fields} was not set by the control | |
762 file. | |
763 | |
764 @item Forms control file error: `forms-number-of-fields' must be a number > 0 | |
765 The variable @code{forms-number-of-fields} did not contain a positive | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47737
diff
changeset
|
766 number. |
25829 | 767 |
768 @item Forms control file error: `forms-field-sep' is not a string | |
769 @itemx Forms control file error: `forms-multi-line' must be nil or a one-character string | |
770 The variable @code{forms-multi-line} was set to something other than | |
771 @code{nil} or a single-character string. | |
772 | |
773 @item Forms control file error: `forms-multi-line' is equal to 'forms-field-sep' | |
774 The variable @code{forms-multi-line} may not be equal to | |
775 @code{forms-field-sep} for this would make it impossible to distinguish | |
776 fields and the lines in the fields. | |
777 | |
778 @item Forms control file error: `forms-new-record-filter' is not a function | |
779 @itemx Forms control file error: `forms-modified-record-filter' is not a function | |
780 The variable has been set to something else than a function. | |
781 | |
782 @item Forms control file error: `forms-format-list' is not a list | |
783 The variable @code{forms-format-list} was not set to a Lisp list | |
784 by the control file. | |
785 | |
786 @item Forms format error: field number @var{xx} out of range 1..@var{nn} | |
787 A field number was supplied in @code{forms-format-list} with a value of | |
788 @var{xx}, which was not greater than zero and smaller than or equal to | |
789 the number of fields in the forms, @var{nn}. | |
790 | |
791 @item Forms format error: @var{fun} is not a function | |
792 The first element of a list which is an element of | |
793 @code{forms-format-list} was not a valid Lisp function. | |
794 | |
795 @item Forms format error: invalid element @var{xx} | |
796 A list element was supplied in @code{forms-format-list} which was not a | |
797 string, number or list. | |
798 | |
799 @ignore | |
800 @c This applies to Emacs 18 only. | |
801 @c Error messages generated while a modified form is being analyzed. | |
802 | |
803 @item Parse error: not looking at `...' | |
804 When re-parsing the contents of a forms, the text shown could not | |
805 be found. | |
806 | |
807 @item Parse error: cannot find `...' | |
808 When re-parsing the contents of a forms, the text shown, which | |
809 separates two fields, could not be found. | |
810 | |
811 @item Parse error: cannot parse adjacent fields @var{xx} and @var{yy} | |
812 Fields @var{xx} and @var{yy} were not separated by text, so could not be | |
813 parsed again. | |
814 @end ignore | |
815 | |
816 @item Warning: this record has @var{xx} fields instead of @var{yy} | |
817 The number of fields in this record in the data file did not match | |
818 @code{forms-number-of-fields}. Missing fields will be made empty. | |
819 | |
820 @item Multi-line fields in this record - update refused! | |
821 The current record contains newline characters, hence can not be written | |
822 back to the data file, for it would corrupt it. Probably you inserted a | |
823 newline in a field, while @code{forms-multi-line} was @code{nil}. | |
824 | |
825 @item Field separator occurs in record - update refused! | |
826 The current record contains the field separator string inside one of the | |
827 fields. It can not be written back to the data file, for it would | |
828 corrupt it. Probably you inserted the field separator string in a field. | |
829 | |
830 @item Record number @var{xx} out of range 1..@var{yy} | |
831 A jump was made to non-existing record @var{xx}. @var{yy} denotes the | |
832 number of records in the file. | |
833 | |
834 @item Stuck at record @var{xx} | |
835 An internal error prevented a specific record from being retrieved. | |
836 | |
837 @item No write access to @code{"}@var{file}@code{"} | |
838 An attempt was made to enable edit mode on a file that has been write | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47737
diff
changeset
|
839 protected. |
25829 | 840 |
841 @item Search failed: @var{regexp} | |
842 The @var{regexp} could not be found in the data file. Forward searching | |
843 is done from the current location until the end of the file, then | |
844 retrying from the beginning of the file until the current location. | |
845 Backward searching is done from the current location until the beginning | |
846 of the file, then retrying from the end of the file until the current | |
847 location. | |
848 | |
849 @item Wrapped | |
850 A search completed successfully after wrapping around. | |
851 | |
852 @item Warning: number of records changed to @var{nn} | |
853 Forms mode's idea of the number of records has been adjusted to the | |
854 number of records actually present in the data file. | |
855 | |
856 @item Problem saving buffers? | |
857 An error occurred while saving the data file buffer. Most likely, Emacs | |
858 did ask to confirm deleting the buffer because it had been modified, and | |
859 you said `no'. | |
860 @end table | |
861 | |
862 @node Long Example | |
863 @chapter Long Example | |
864 | |
865 The following example exploits most of the features of Forms mode. | |
866 This example is included in the distribution as file @file{forms-d2.el}. | |
867 | |
868 @example | |
869 ;; demo2 -- demo forms-mode -*- emacs-lisp -*- | |
870 | |
871 ;; @r{This sample forms exploit most of the features of forms mode.} | |
872 | |
873 ;; @r{Set the name of the data file.} | |
874 (setq forms-file "forms-d2.dat") | |
875 | |
876 ;; @r{Use @code{forms-enumerate} to set field names and number thereof.} | |
877 (setq forms-number-of-fields | |
878 (forms-enumerate | |
879 '(arch-newsgroup ; 1 | |
880 arch-volume ; 2 | |
881 arch-issue ; and ... | |
882 arch-article ; ... so | |
883 arch-shortname ; ... ... on | |
884 arch-parts | |
885 arch-from | |
886 arch-longname | |
887 arch-keywords | |
888 arch-date | |
889 arch-remarks))) | |
890 | |
891 ;; @r{The following functions are used by this form for layout purposes.} | |
892 ;; | |
893 (defun arch-tocol (target &optional fill) | |
894 "Produces a string to skip to column TARGET. | |
895 Prepends newline if needed. | |
896 The optional FILL should be a character, used to fill to the column." | |
897 (if (null fill) | |
898 (setq fill ? )) | |
899 (if (< target (current-column)) | |
900 (concat "\n" (make-string target fill)) | |
901 (make-string (- target (current-column)) fill))) | |
902 ;; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
47737
diff
changeset
|
903 (defun arch-rj (target field &optional fill) |
25829 | 904 "Produces a string to skip to column TARGET\ |
905 minus the width of field FIELD. | |
906 Prepends newline if needed. | |
907 The optional FILL should be a character, | |
908 used to fill to the column." | |
909 (arch-tocol (- target (length (nth field forms-fields))) fill)) | |
910 | |
911 ;; @r{Record filters.} | |
912 ;; | |
913 (defun new-record-filter (the-record) | |
914 "Form a new record with some defaults." | |
915 (aset the-record arch-from (user-full-name)) | |
916 (aset the-record arch-date (current-time-string)) | |
917 the-record) ; return it | |
918 (setq forms-new-record-filter 'new-record-filter) | |
919 | |
920 ;; @r{The format list.} | |
921 (setq forms-format-list | |
922 (list | |
923 "====== Public Domain Software Archive ======\n\n" | |
924 arch-shortname | |
925 " - " arch-longname | |
926 "\n\n" | |
927 "Article: " arch-newsgroup | |
928 "/" arch-article | |
929 " " | |
930 '(arch-tocol 40) | |
931 "Issue: " arch-issue | |
932 " " | |
933 '(arch-rj 73 10) | |
934 "Date: " arch-date | |
935 "\n\n" | |
936 "Submitted by: " arch-from | |
937 "\n" | |
938 '(arch-tocol 79 ?-) | |
939 "\n" | |
940 "Keywords: " arch-keywords | |
941 "\n\n" | |
942 "Parts: " arch-parts | |
943 "\n\n====== Remarks ======\n\n" | |
944 arch-remarks | |
945 )) | |
946 | |
947 ;; @r{That's all, folks!} | |
948 @end example | |
949 | |
950 @node Credits | |
951 @chapter Credits | |
952 | |
953 Bug fixes and other useful suggestions were supplied by | |
954 Harald Hanche-Olsen (@code{hanche@@imf.unit.no}), | |
955 @code{cwitty@@portia.stanford.edu}, | |
956 Jonathan I. Kamens, | |
957 Per Cederqvist (@code{ceder@@signum.se}), | |
958 Michael Lipka (@code{lipka@@lip.hanse.de}), | |
959 Andy Piper (@code{ajp@@eng.cam.ac.uk}), | |
960 Frederic Pierresteguy (@code{F.Pierresteguy@@frcl.bull.fr}), | |
961 Ignatios Souvatzis | |
962 and Richard Stallman (@code{rms@@gnu.org}). | |
963 | |
964 This documentation was slightly inspired by the documentation of ``rolo | |
965 mode'' by Paul Davis at Schlumberger Cambridge Research | |
966 (@code{davis%scrsu1%sdr.slb.com@@relay.cs.net}). | |
967 | |
968 None of this would have been possible without GNU Emacs of the Free | |
969 Software Foundation. Thanks, Richard! | |
970 | |
971 @node Index | |
972 @unnumbered Index | |
973 @printindex cp | |
974 | |
975 @contents | |
976 @bye | |
52401 | 977 |
978 @ignore | |
979 arch-tag: 2ac9810b-aa49-4ea6-8030-d7f1ecd467ed | |
980 @end ignore |