annotate lisp/forms.el @ 3364:3dd9b89c6a17

(inhibit-local-variables-regexps): New variable. (set-auto-mode): Handle inhibit-local-variables-regexps.
author Richard M. Stallman <rms@gnu.org>
date Mon, 31 May 1993 21:50:52 +0000
parents 7fede845e304
children 994bb6dc9249
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1 ;;; forms.el -- Forms Mode - A GNU Emacs Major Mode
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
2 ;;; SCCS Status : @(#)@ forms 1.2.7
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
3 ;;; Author : Johan Vromans
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
4 ;;; Created On : 1989
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
5 ;;; Last Modified By: Johan Vromans
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
6 ;;; Last Modified On: Mon Jul 1 14:13:20 1991
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
7 ;;; Update Count : 15
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
8 ;;; Status : OK
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
9
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
10 ;;; This file is part of GNU Emacs.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
11 ;;; GNU Emacs is distributed in the hope that it will be useful,
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
12 ;;; but WITHOUT ANY WARRANTY. No author or distributor
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
13 ;;; accepts responsibility to anyone for the consequences of using it
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
14 ;;; or for whether it serves any particular purpose or works at all,
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
15 ;;; unless he says so in writing. Refer to the GNU Emacs General Public
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
16 ;;; License for full details.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
17
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
18 ;;; Everyone is granted permission to copy, modify and redistribute
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
19 ;;; GNU Emacs, but only under the conditions described in the
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
20 ;;; GNU Emacs General Public License. A copy of this license is
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
21 ;;; supposed to have been given to you along with GNU Emacs so you
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
22 ;;; can know your rights and responsibilities.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
23 ;;; If you don't have this copy, write to the Free Software
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
24 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
25 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
26
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
27 ;;; HISTORY
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
28 ;;; 1-Jul-1991 Johan Vromans
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
29 ;;; Normalized error messages.
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
30 ;;; 30-Jun-1991 Johan Vromans
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
31 ;;; Add support for forms-modified-record-filter.
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
32 ;;; Allow the filter functions to be the name of a function.
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
33 ;;; Fix: parse--format used forms--dynamic-text destructively.
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
34 ;;; Internally optimized the forms-format-list.
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
35 ;;; Added support for debugging.
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
36 ;;; Stripped duplicate documentation.
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
37 ;;;
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
38 ;;; 29-Jun-1991 Johan Vromans
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
39 ;;; Add support for functions and lisp symbols in forms-format-list.
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
40 ;;; Add function forms-enumerate.
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
41
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
42 (provide 'forms-mode)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
43
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
44 ;;; Visit a file using a form.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
45 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
46 ;;; === Naming conventions
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
47 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
48 ;;; The names of all variables and functions start with 'form-'.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
49 ;;; Names which start with 'form--' are intended for internal use, and
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
50 ;;; should *NOT* be used from the outside.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
51 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
52 ;;; All variables are buffer-local, to enable multiple forms visits
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
53 ;;; simultaneously.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
54 ;;; Variable 'forms--mode-setup' is local to *ALL* buffers, for it
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
55 ;;; controls if forms-mode has been enabled in a buffer.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
56 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
57 ;;; === How it works ===
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
58 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
59 ;;; Forms mode means visiting a data file which is supposed to consist
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
60 ;;; of records each containing a number of fields. The records are
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
61 ;;; separated by a newline, the fields are separated by a user-defined
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
62 ;;; field separater (default: TAB).
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
63 ;;; When shown, a record is transferred to an emacs buffer and
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
64 ;;; presented using a user-defined form. One record is shown at a
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
65 ;;; time.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
66 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
67 ;;; Forms mode is a composite mode. It involves two files, and two
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
68 ;;; buffers.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
69 ;;; The first file, called the control file, defines the name of the
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
70 ;;; data file and the forms format. This file buffer will be used to
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
71 ;;; present the forms.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
72 ;;; The second file holds the actual data. The buffer of this file
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
73 ;;; will be buried, for it is never accessed directly.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
74 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
75 ;;; Forms mode is invoked using "forms-find-file control-file".
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
76 ;;; Alternativily forms-find-file-other-window can be used.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
77 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
78 ;;; You may also visit the control file, and switch to forms mode by hand
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
79 ;;; with M-x forms-mode .
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
80 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
81 ;;; Automatic mode switching is supported, so you may use "find-file"
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
82 ;;; if you specify "-*- forms -*-" in the first line of the control file.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
83 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
84 ;;; The control file is visited, evaluated using
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
85 ;;; eval-current-buffer, and should set at least the following
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
86 ;;; variables:
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
87 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
88 ;;; forms-file [string] the name of the data file.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
89 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
90 ;;; forms-number-of-fields [integer]
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
91 ;;; The number of fields in each record.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
92 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
93 ;;; forms-format-list [list] formatting instructions.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
94 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
95 ;;; The forms-format-list should be a list, each element containing
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
96 ;;;
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
97 ;;; - a string, e.g. "hello" (which is inserted \"as is\"),
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
98 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
99 ;;; - an integer, denoting a field number. The contents of the field
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
100 ;;; are inserted at this point.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
101 ;;; The first field has number one.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
102 ;;;
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
103 ;;; - a function call, e.g. (insert "text"). This function call is
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
104 ;;; dynamically evaluated and should return a string. It should *NOT*
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
105 ;;; have side-effects on the forms being constructed.
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
106 ;;; The current fields are available to the function in the variable
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
107 ;;; forms-fields, they should *NOT* be modified.
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
108 ;;;
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
109 ;;; - a lisp symbol, that must evaluate to one of the above.
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
110 ;;;
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
111 ;;; Optional variables which may be set in the control file:
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
112 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
113 ;;; forms-field-sep [string, default TAB]
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
114 ;;; The field separator used to separate the
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
115 ;;; fields in the data file. It may be a string.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
116 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
117 ;;; forms-read-only [bool, default nil]
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
118 ;;; 't' means that the data file is visited read-only.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
119 ;;; If no write access to the data file is
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
120 ;;; possible, read-only mode is enforced.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
121 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
122 ;;; forms-multi-line [string, default "^K"]
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
123 ;;; If non-null the records of the data file may
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
124 ;;; contain fields which span multiple lines in
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
125 ;;; the form.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
126 ;;; This variable denoted the separator character
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
127 ;;; to be used for this purpose. Upon display, all
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
128 ;;; occurrencies of this character are translated
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
129 ;;; to newlines. Upon storage they are translated
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
130 ;;; back to the separator.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
131 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
132 ;;; forms-forms-scroll [bool, default t]
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
133 ;;; If non-nil: redefine scroll-up/down to perform
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
134 ;;; forms-next/prev-field if in forms mode.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
135 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
136 ;;; forms-forms-jump [bool, default t]
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
137 ;;; If non-nil: redefine beginning/end-of-buffer
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
138 ;;; to performs forms-first/last-field if in
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
139 ;;; forms mode.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
140 ;;;
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
141 ;;; forms-new-record-filter [symbol, no default]
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
142 ;;; If defined: this should be the name of a
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
143 ;;; function that is called when a new
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
144 ;;; record is created. It can be used to fill in
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
145 ;;; the new record with default fields, for example.
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
146 ;;; Instead of the name of the function, it may
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
147 ;;; be the function itself.
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
148 ;;;
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
149 ;;; forms-modified-record-filter [symbol, no default]
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
150 ;;; If defined: this should be the name of a
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
151 ;;; function that is called when a record has
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
152 ;;; been modified. It is called after the fields
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
153 ;;; are parsed. It can be used to register
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
154 ;;; modification dates, for example.
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
155 ;;; Instead of the name of the function, it may
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
156 ;;; be the function itself.
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
157 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
158 ;;; After evaluating the control file, its buffer is cleared and used
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
159 ;;; for further processing.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
160 ;;; The data file (as designated by "forms-file") is visited in a buffer
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
161 ;;; (forms--file-buffer) which will not normally be shown.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
162 ;;; Great malfunctioning may be expected if this file/buffer is modified
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
163 ;;; outside of this package while it's being visited!
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
164 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
165 ;;; A record from the data file is transferred from the data file,
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
166 ;;; split into fields (into forms--the-record-list), and displayed using
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
167 ;;; the specs in forms-format-list.
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
168 ;;; A format routine 'forms--format' is built upon startup to format
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
169 ;;; the records.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
170 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
171 ;;; When a form is changed the record is updated as soon as this form
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
172 ;;; is left. The contents of the form are parsed using forms-format-list,
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
173 ;;; and the fields which are deduced from the form are modified. So,
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
174 ;;; fields not shown on the forms retain their origional values.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
175 ;;; The newly formed record and replaces the contents of the
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
176 ;;; old record in forms--file-buffer.
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
177 ;;; A parse routine 'forms--parser' is built upon startup to parse
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
178 ;;; the records.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
179 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
180 ;;; Two exit functions exist: forms-exit (which saves) and forms-exit-no-save
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
181 ;;; (which doesn't). However, if forms-exit-no-save is executed and the file
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
182 ;;; buffer has been modified, emacs will ask questions.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
183 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
184 ;;; Other functions are:
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
185 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
186 ;;; paging (forward, backward) by record
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
187 ;;; jumping (first, last, random number)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
188 ;;; searching
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
189 ;;; creating and deleting records
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
190 ;;; reverting the form (NOT the file buffer)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
191 ;;; switching edit <-> view mode v.v.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
192 ;;; jumping from field to field
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
193 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
194 ;;; As an documented side-effect: jumping to the last record in the
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
195 ;;; file (using forms-last-record) will adjust forms--total-records if
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
196 ;;; needed.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
197 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
198 ;;; Commands and keymaps:
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
199 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
200 ;;; A local keymap 'forms-mode-map' is used in the forms buffer.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
201 ;;; As conventional, this map can be accessed with C-c prefix.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
202 ;;; In read-only mode, the C-c prefix must be omitted.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
203 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
204 ;;; Default bindings:
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
205 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
206 ;;; \C-c forms-mode-map
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
207 ;;; TAB forms-next-field
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
208 ;;; SPC forms-next-record
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
209 ;;; < forms-first-record
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
210 ;;; > forms-last-record
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
211 ;;; ? describe-mode
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
212 ;;; d forms-delete-record
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
213 ;;; e forms-edit-mode
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
214 ;;; i forms-insert-record
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
215 ;;; j forms-jump-record
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
216 ;;; n forms-next-record
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
217 ;;; p forms-prev-record
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
218 ;;; q forms-exit
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
219 ;;; s forms-search
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
220 ;;; v forms-view-mode
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
221 ;;; x forms-exit-no-save
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
222 ;;; DEL forms-prev-record
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
223 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
224 ;;; Standard functions scroll-up, scroll-down, beginning-of-buffer and
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
225 ;;; end-of-buffer are wrapped with re-definitions, which map them to
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
226 ;;; next/prev record and first/last record.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
227 ;;; Buffer-local variables forms-forms-scroll and forms-forms-jump
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
228 ;;; may be used to control these redefinitions.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
229 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
230 ;;; Function save-buffer is also wrapped to perform a sensible action.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
231 ;;; A revert-file-hook is defined to revert a forms to original.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
232 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
233 ;;; For convenience, TAB is always bound to forms-next-field, so you
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
234 ;;; don't need the C-c prefix for this command.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
235 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
236 ;;; Global variables and constants
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
237
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
238 (defconst forms-version "1.2.7"
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
239 "Version of forms-mode implementation")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
240
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
241 (defvar forms-forms-scrolls t
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
242 "If non-null: redefine scroll-up/down to be used with forms-mode.")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
243
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
244 (defvar forms-forms-jumps t
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
245 "If non-null: redefine beginning/end-of-buffer to be used with forms-mode.")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
246
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
247 (defvar forms-mode-hooks nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
248 "Hook functions to be run upon entering forms mode.")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
249 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
250 ;;; Mandatory variables - must be set by evaluating the control file
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
251
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
252 (defvar forms-file nil
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
253 "Name of the file holding the data.")
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
254
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
255 (defvar forms-format-list nil
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
256 "List of formatting specifications.")
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
257
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
258 (defvar forms-number-of-fields nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
259 "Number of fields per record.")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
260
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
261 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
262 ;;; Optional variables with default values
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
263
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
264 (defvar forms-field-sep "\t"
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
265 "Field separator character (default TAB)")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
266
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
267 (defvar forms-read-only nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
268 "Read-only mode (defaults to the write access on the data file).")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
269
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
270 (defvar forms-multi-line "\C-k"
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
271 "Character to separate multi-line fields (default ^K)")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
272
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
273 (defvar forms-forms-scroll t
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
274 "Redefine scroll-up/down to perform forms-next/prev-record when in
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
275 forms mode.")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
277 (defvar forms-forms-jump t
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
278 "Redefine beginning/end-of-buffer to perform forms-first/last-record
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
279 when in forms mode.")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
280
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
281 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
282 ;;; Internal variables.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
283
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
284 (defvar forms--file-buffer nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
285 "Buffer which holds the file data")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
286
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
287 (defvar forms--total-records 0
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
288 "Total number of records in the data file.")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
289
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
290 (defvar forms--current-record 0
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
291 "Number of the record currently on the screen.")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
292
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
293 (defvar forms-mode-map nil ; yes - this one is global
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
294 "Keymap for form buffer.")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
295
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
296 (defvar forms--markers nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
297 "Field markers in the screen.")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
298
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
299 (defvar forms--number-of-markers 0
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
300 "Number of fields on screen.")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
301
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
302 (defvar forms--the-record-list nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
303 "List of strings of the current record, as parsed from the file.")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
304
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
305 (defvar forms--search-regexp nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
306 "Last regexp used by forms-search.")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
307
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
308 (defvar forms--format nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
309 "Formatting routine.")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
310
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
311 (defvar forms--parser nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
312 "Forms parser routine.")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
313
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
314 (defvar forms--mode-setup nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
315 "Internal - keeps track of forms-mode being set-up.")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
316 (make-variable-buffer-local 'forms--mode-setup)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
317
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
318 (defvar forms--new-record-filter nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
319 "Internal - set if a new record filter has been defined.")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
320
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
321 (defvar forms--modified-record-filter nil
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
322 "Internal - set if a modified record filter has been defined.")
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
323
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
324 (defvar forms--dynamic-text nil
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
325 "Internal - holds dynamic text to insert between fields.")
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
326
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
327 (defvar forms-fields nil
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
328 "List with fields of the current forms. First field has number 1.")
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
329
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
330 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
331 ;;; forms-mode
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
332 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
333 ;;; This is not a simple major mode, as usual. Therefore, forms-mode
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
334 ;;; takes an optional argument 'primary' which is used for the initial
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
335 ;;; set-up. Normal use would leave 'primary' to nil.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
336 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
337 ;;; A global buffer-local variable 'forms--mode-setup' has the same effect
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
338 ;;; but makes it possible to auto-invoke forms-mode using find-file.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
339 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
340 ;;; Note: although it seems logical to have (make-local-variable) executed
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
341 ;;; where the variable is first needed, I deliberately placed all calls
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
342 ;;; in the forms-mode function.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
343
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
344 (defun forms-mode (&optional primary)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
345 "Major mode to visit files in a field-structured manner using a form.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
346
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
347 Commands (prefix with C-c if not in read-only mode):
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
348 \\{forms-mode-map}"
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
349
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
350 (interactive) ; no - 'primary' is not prefix arg
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
351
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
352 ;; Primary set-up: evaluate buffer and check if the mandatory
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
353 ;; variables have been set.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
354 (if (or primary (not forms--mode-setup))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
355 (progn
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
356 (kill-all-local-variables)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
357
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
358 ;; make mandatory variables
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
359 (make-local-variable 'forms-file)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
360 (make-local-variable 'forms-number-of-fields)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
361 (make-local-variable 'forms-format-list)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
362
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
363 ;; make optional variables
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
364 (make-local-variable 'forms-field-sep)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
365 (make-local-variable 'forms-read-only)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
366 (make-local-variable 'forms-multi-line)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
367 (make-local-variable 'forms-forms-scroll)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
368 (make-local-variable 'forms-forms-jump)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
369 (fmakunbound 'forms-new-record-filter)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
370
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
371 ;; eval the buffer, should set variables
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
372 (eval-current-buffer)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
373
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
374 ;; check if the mandatory variables make sense.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
375 (or forms-file
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
376 (error "'forms-file' has not been set"))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
377 (or forms-number-of-fields
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
378 (error "'forms-number-of-fields' has not been set"))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
379 (or (> forms-number-of-fields 0)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
380 (error "'forms-number-of-fields' must be > 0")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
381 (or (stringp forms-field-sep))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
382 (error "'forms-field-sep' is not a string"))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
383 (if forms-multi-line
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
384 (if (and (stringp forms-multi-line)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
385 (eq (length forms-multi-line) 1))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
386 (if (string= forms-multi-line forms-field-sep)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
387 (error "'forms-multi-line' is equal to 'forms-field-sep'"))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
388 (error "'forms-multi-line' must be nil or a one-character string")))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
389
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
390 ;; validate and process forms-format-list
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
391 (make-local-variable 'forms--number-of-markers)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
392 (make-local-variable 'forms--markers)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
393 (forms--process-format-list)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
394
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
395 ;; build the formatter and parser
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
396 (make-local-variable 'forms--format)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
397 (forms--make-format)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
398 (make-local-variable 'forms--parser)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
399 (forms--make-parser)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
400
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
401 ;; check if record filters are defined
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
402 (make-local-variable 'forms--new-record-filter)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
403 (setq forms--new-record-filter
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
404 (cond
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
405 ((fboundp 'forms-new-record-filter)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
406 (symbol-function 'forms-new-record-filter))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
407 ((and (boundp 'forms-new-record-filter)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
408 (fboundp forms-new-record-filter))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
409 forms-new-record-filter)))
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
410 (fmakunbound 'forms-new-record-filter)
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
411 (make-local-variable 'forms--modified-record-filter)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
412 (setq forms--modified-record-filter
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
413 (cond
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
414 ((fboundp 'forms-modified-record-filter)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
415 (symbol-function 'forms-modified-record-filter))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
416 ((and (boundp 'forms-modified-record-filter)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
417 (fboundp forms-modified-record-filter))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
418 forms-modified-record-filter)))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
419 (fmakunbound 'forms-modified-record-filter)
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
420
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
421 ;; dynamic text support
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
422 (make-local-variable 'forms--dynamic-text)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
423 (make-local-variable 'forms-fields)
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
424
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
425 ;; prepare this buffer for further processing
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
426 (setq buffer-read-only nil)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
427
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
428 ;; prevent accidental overwrite of the control file and autosave
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
429 (setq buffer-file-name nil)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
430 (auto-save-mode nil)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
431
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
432 ;; and clean it
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
433 (erase-buffer)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
434
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
435 ;; make local variables
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
436 (make-local-variable 'forms--file-buffer)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
437 (make-local-variable 'forms--total-records)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
438 (make-local-variable 'forms--current-record)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
439 (make-local-variable 'forms--the-record-list)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
440 (make-local-variable 'forms--search-rexexp)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
441
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
442 ;; A bug in the current Emacs release prevents a keymap
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
443 ;; which is buffer-local from being used by 'describe-mode'.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
444 ;; Hence we'll leave it global.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
445 ;;(make-local-variable 'forms-mode-map)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
446 (if forms-mode-map ; already defined
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
447 nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
448 (setq forms-mode-map (make-keymap))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
449 (forms--mode-commands forms-mode-map)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
450 (forms--change-commands))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
451
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
452 ;; find the data file
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
453 (setq forms--file-buffer (find-file-noselect forms-file))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
454
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
455 ;; count the number of records, and set see if it may be modified
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
456 (let (ro)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
457 (setq forms--total-records
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
458 (save-excursion
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
459 (set-buffer forms--file-buffer)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
460 (bury-buffer (current-buffer))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
461 (setq ro buffer-read-only)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
462 (count-lines (point-min) (point-max))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
463 (if ro
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
464 (setq forms-read-only t)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
465
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
466 ;; set the major mode indicator
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
467 (setq major-mode 'forms-mode)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
468 (setq mode-name "Forms")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
469 (make-local-variable 'minor-mode-alist) ; needed?
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
470 (forms--set-minor-mode)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
471 (forms--set-keymaps)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
472
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
473 (set-buffer-modified-p nil)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
474
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
475 ;; We have our own revert function - use it
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
476 (make-local-variable 'revert-buffer-function)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
477 (setq revert-buffer-function 'forms-revert-buffer)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
478
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
479 ;; setup the first (or current) record to show
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
480 (if (< forms--current-record 1)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
481 (setq forms--current-record 1))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
482 (forms-jump-record forms--current-record)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
483
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
484 ;; user customising
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
485 (run-hooks 'forms-mode-hooks)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
486
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
487 ;; be helpful
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
488 (forms--help)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
489
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
490 ;; initialization done
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
491 (setq forms--mode-setup t))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
492
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
493 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
494 ;;; forms-process-format-list
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
495 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
496 ;;; Validates forms-format-list.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
497 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
498 ;;; Sets forms--number-of-markers and forms--markers.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
499
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
500 (defun forms--process-format-list ()
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
501 "Validate forms-format-list and set some global variables."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
502
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
503 (forms--debug "forms-forms-list before 1st pass:\n"
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
504 'forms-format-list)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
505
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
506 ;; it must be non-nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
507 (or forms-format-list
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
508 (error "'forms-format-list' has not been set"))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
509 ;; it must be a list ...
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
510 (or (listp forms-format-list)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
511 (error "'forms-format-list' is not a list"))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
512
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
513 (setq forms--number-of-markers 0)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
514
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
515 (let ((the-list forms-format-list) ; the list of format elements
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
516 (this-item 0) ; element in list
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
517 (field-num 0)) ; highest field number
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
518
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
519 (setq forms-format-list nil) ; gonna rebuild
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
520
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
521 (while the-list
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
522
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
523 (let ((el (car-safe the-list))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
524 (rem (cdr-safe the-list)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
525
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
526 ;; if it is a symbol, eval it first
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
527 (if (and (symbolp el)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
528 (boundp el))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
529 (setq el (eval el)))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
530
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
531 (cond
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
532
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
533 ;; try string ...
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
534 ((stringp el)) ; string is OK
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
535
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
536 ;; try numeric ...
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
537 ((numberp el)
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
538
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
539 (if (or (<= el 0)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
540 (> el forms-number-of-fields))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
541 (error
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
542 "Forms error: field number %d out of range 1..%d"
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
543 el forms-number-of-fields))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
544
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
545 (setq forms--number-of-markers (1+ forms--number-of-markers))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
546 (if (> el field-num)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
547 (setq field-num el)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
548
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
549 ;; try function
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
550 ((listp el)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
551 (or (fboundp (car-safe el))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
552 (error
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
553 "Forms error: not a function: %s"
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
554 (prin1-to-string (car-safe el)))))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
555
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
556 ;; else
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
557 (t
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
558 (error "Invalid element in 'forms-format-list': %s"
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
559 (prin1-to-string el))))
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
560
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
561 ;; advance to next element of the list
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
562 (setq the-list rem)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
563 (setq forms-format-list
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
564 (append forms-format-list (list el) nil)))))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
565
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
566 (forms--debug "forms-forms-list after 1st pass:\n"
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
567 'forms-format-list)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
568
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
569 ;; concat adjacent strings
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
570 (setq forms-format-list (forms--concat-adjacent forms-format-list))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
571
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
572 (forms--debug "forms-forms-list after 2nd pass:\n"
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
573 'forms-format-list
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
574 'forms--number-of-markers)
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
575
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
576 (setq forms--markers (make-vector forms--number-of-markers nil)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
577
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
578
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
579 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
580 ;;; Build the format routine from forms-format-list.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
581 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
582 ;;; The format routine (forms--format) will look like
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
583 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
584 ;;; (lambda (arg)
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
585 ;;; (setq forms--dynamic-text nil)
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
586 ;;; ;; "text: "
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
587 ;;; (insert "text: ")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
588 ;;; ;; 6
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
589 ;;; (aset forms--markers 0 (point-marker))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
590 ;;; (insert (elt arg 5))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
591 ;;; ;; "\nmore text: "
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
592 ;;; (insert "\nmore text: ")
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
593 ;;; ;; (tocol 40)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
594 ;;; (let ((the-dyntext (tocol 40)))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
595 ;;; (insert the-dyntext)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
596 ;;; (setq forms--dynamic-text (append forms--dynamic-text
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
597 ;;; (list the-dyntext))))
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
598 ;;; ;; 9
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
599 ;;; (aset forms--markers 1 (point-marker))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
600 ;;; (insert (elt arg 8))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
601 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
602 ;;; ... )
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
603 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
604
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
605 (defun forms--make-format ()
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
606 "Generate format function for forms"
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
607 (setq forms--format (forms--format-maker forms-format-list))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
608 (forms--debug 'forms--format))
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
609
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
610 (defun forms--format-maker (the-format-list)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
611 "Returns the parser function for forms"
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
612 (let ((the-marker 0))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
613 (` (lambda (arg)
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
614 (setq forms--dynamic-text nil)
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
615 (,@ (apply 'append
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
616 (mapcar 'forms--make-format-elt the-format-list)))))))
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
617
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
618 (defun forms--make-format-elt (el)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
619 (cond ((stringp el)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
620 (` ((insert (, el)))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
621 ((numberp el)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
622 (prog1
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
623 (` ((aset forms--markers (, the-marker) (point-marker))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
624 (insert (elt arg (, (1- el))))))
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
625 (setq the-marker (1+ the-marker))))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
626 ((listp el)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
627 (prog1
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
628 (` ((let ((the-dyntext (, el)))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
629 (insert the-dyntext)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
630 (setq forms--dynamic-text (append forms--dynamic-text
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
631 (list the-dyntext)))))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
632 )))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
633 ))
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
634
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
635
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
636 (defun forms--concat-adjacent (the-list)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
637 "Concatenate adjacent strings in the-list and return the resulting list"
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
638 (if (consp the-list)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
639 (let ((the-rest (forms--concat-adjacent (cdr the-list))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
640 (if (and (stringp (car the-list)) (stringp (car the-rest)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
641 (cons (concat (car the-list) (car the-rest))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
642 (cdr the-rest))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
643 (cons (car the-list) the-rest)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
644 the-list))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
645 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
646 ;;; forms--make-parser.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
647 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
648 ;;; Generate parse routine from forms-format-list.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
649 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
650 ;;; The parse routine (forms--parser) will look like (give or take
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
651 ;;; a few " " .
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
652 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
653 ;;; (lambda nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
654 ;;; (let (here)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
655 ;;; (goto-char (point-min))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
656 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
657 ;;; ;; "text: "
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
658 ;;; (if (not (looking-at "text: "))
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
659 ;;; (error "Parse error: cannot find \"text: \""))
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
660 ;;; (forward-char 6) ; past "text: "
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
661 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
662 ;;; ;; 6
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
663 ;;; ;; "\nmore text: "
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
664 ;;; (setq here (point))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
665 ;;; (if (not (search-forward "\nmore text: " nil t nil))
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
666 ;;; (error "Parse error: cannot find \"\\nmore text: \""))
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
667 ;;; (aset the-recordv 5 (buffer-substring here (- (point) 12)))
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
668 ;;;
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
669 ;;; ;; (tocol 40)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
670 ;;; (let ((the-dyntext (car-safe forms--dynamic-text)))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
671 ;;; (if (not (looking-at (regexp-quote the-dyntext)))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
672 ;;; (error "Parse error: not looking at \"%s\"" the-dyntext))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
673 ;;; (forward-char (length the-dyntext))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
674 ;;; (setq forms--dynamic-text (cdr-safe forms--dynamic-text)))
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
675 ;;; ...
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
676 ;;; ;; final flush (due to terminator sentinel, see below)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
677 ;;; (aset the-recordv 7 (buffer-substring (point) (point-max)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
678 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
679
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
680 (defun forms--make-parser ()
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
681 "Generate parser function for forms"
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
682 (setq forms--parser (forms--parser-maker forms-format-list))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
683 (forms--debug 'forms--parser))
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
684
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
685 (defun forms--parser-maker (the-format-list)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
686 "Returns the parser function for forms"
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
687 (let ((the-field nil)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
688 (seen-text nil)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
689 the--format-list)
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
690 ;; add a terminator sentinel
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
691 (setq the--format-list (append the-format-list (list nil)))
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
692 (` (lambda nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
693 (let (here)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
694 (goto-char (point-min))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
695 (,@ (apply 'append
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
696 (mapcar 'forms--make-parser-elt the--format-list))))))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
697
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
698 (defun forms--make-parser-elt (el)
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
699 (cond
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
700 ((stringp el)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
701 (prog1
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
702 (if the-field
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
703 (` ((setq here (point))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
704 (if (not (search-forward (, el) nil t nil))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
705 (error "Parse error: cannot find \"%s\"" (, el)))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
706 (aset the-recordv (, (1- the-field))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
707 (buffer-substring here
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
708 (- (point) (, (length el)))))))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
709 (` ((if (not (looking-at (, (regexp-quote el))))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
710 (error "Parse error: not looking at \"%s\"" (, el)))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
711 (forward-char (, (length el))))))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
712 (setq seen-text t)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
713 (setq the-field nil)))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
714 ((numberp el)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
715 (if the-field
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
716 (error "Cannot parse adjacent fields %d and %d"
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
717 the-field el)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
718 (setq the-field el)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
719 nil))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
720 ((null el)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
721 (if the-field
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
722 (` ((aset the-recordv (, (1- the-field))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
723 (buffer-substring (point) (point-max)))))))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
724 ((listp el)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
725 (prog1
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
726 (if the-field
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
727 (` ((let ((here (point))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
728 (the-dyntext (car-safe forms--dynamic-text)))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
729 (if (not (search-forward the-dyntext nil t nil))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
730 (error "Parse error: cannot find \"%s\"" the-dyntext))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
731 (aset the-recordv (, (1- the-field))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
732 (buffer-substring here
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
733 (- (point) (length the-dyntext))))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
734 (setq forms--dynamic-text (cdr-safe forms--dynamic-text)))))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
735 (` ((let ((the-dyntext (car-safe forms--dynamic-text)))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
736 (if (not (looking-at (regexp-quote the-dyntext)))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
737 (error "Parse error: not looking at \"%s\"" the-dyntext))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
738 (forward-char (length the-dyntext))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
739 (setq forms--dynamic-text (cdr-safe forms--dynamic-text))))))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
740 (setq seen-text t)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
741 (setq the-field nil)))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
742 ))
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
743 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
744
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
745 (defun forms--set-minor-mode ()
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
746 (setq minor-mode-alist
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
747 (if forms-read-only
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
748 " View"
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
749 nil)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
750
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
751 (defun forms--set-keymaps ()
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
752 "Set the keymaps used in this mode."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
753
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
754 (if forms-read-only
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
755 (use-local-map forms-mode-map)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
756 (use-local-map (make-sparse-keymap))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
757 (define-key (current-local-map) "\C-c" forms-mode-map)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
758 (define-key (current-local-map) "\t" 'forms-next-field)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
759
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
760 (defun forms--mode-commands (map)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
761 "Fill map with all commands."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
762 (define-key map "\t" 'forms-next-field)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
763 (define-key map " " 'forms-next-record)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
764 (define-key map "d" 'forms-delete-record)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
765 (define-key map "e" 'forms-edit-mode)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
766 (define-key map "i" 'forms-insert-record)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
767 (define-key map "j" 'forms-jump-record)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
768 (define-key map "n" 'forms-next-record)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
769 (define-key map "p" 'forms-prev-record)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
770 (define-key map "q" 'forms-exit)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
771 (define-key map "s" 'forms-search)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
772 (define-key map "v" 'forms-view-mode)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
773 (define-key map "x" 'forms-exit-no-save)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
774 (define-key map "<" 'forms-first-record)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
775 (define-key map ">" 'forms-last-record)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
776 (define-key map "?" 'describe-mode)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
777 (define-key map "\177" 'forms-prev-record)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
778 ; (define-key map "\C-c" map)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
779 (define-key map "\e" 'ESC-prefix)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
780 (define-key map "\C-x" ctl-x-map)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
781 (define-key map "\C-u" 'universal-argument)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
782 (define-key map "\C-h" help-map)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
783 )
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
784 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
785 ;;; Changed functions
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
786 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
787 ;;; Emacs (as of 18.55) lacks the functionality of buffer-local
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
788 ;;; funtions. Therefore we save the original meaning of some handy
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
789 ;;; functions, and replace them with a wrapper.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
790
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
791 (defun forms--change-commands ()
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
792 "Localize some commands."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
793 ;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
794 ;; scroll-down -> forms-prev-record
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
795 ;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
796 (if (fboundp 'forms--scroll-down)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
797 nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
798 (fset 'forms--scroll-down (symbol-function 'scroll-down))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
799 (fset 'scroll-down
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
800 '(lambda (&optional arg)
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
801 (interactive "P")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
802 (if (and forms--mode-setup
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
803 forms-forms-scroll)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
804 (forms-prev-record arg)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
805 (forms--scroll-down arg)))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
806 ;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
807 ;; scroll-up -> forms-next-record
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
808 ;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
809 (if (fboundp 'forms--scroll-up)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
810 nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
811 (fset 'forms--scroll-up (symbol-function 'scroll-up))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
812 (fset 'scroll-up
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
813 '(lambda (&optional arg)
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
814 (interactive "P")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
815 (if (and forms--mode-setup
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
816 forms-forms-scroll)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
817 (forms-next-record arg)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
818 (forms--scroll-up arg)))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
819 ;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
820 ;; beginning-of-buffer -> forms-first-record
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
821 ;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
822 (if (fboundp 'forms--beginning-of-buffer)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
823 nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
824 (fset 'forms--beginning-of-buffer (symbol-function 'beginning-of-buffer))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
825 (fset 'beginning-of-buffer
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
826 '(lambda ()
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
827 (interactive)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
828 (if (and forms--mode-setup
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
829 forms-forms-jump)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
830 (forms-first-record)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
831 (forms--beginning-of-buffer)))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
832 ;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
833 ;; end-of-buffer -> forms-end-record
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
834 ;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
835 (if (fboundp 'forms--end-of-buffer)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
836 nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
837 (fset 'forms--end-of-buffer (symbol-function 'end-of-buffer))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
838 (fset 'end-of-buffer
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
839 '(lambda ()
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
840 (interactive)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
841 (if (and forms--mode-setup
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
842 forms-forms-jump)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
843 (forms-last-record)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
844 (forms--end-of-buffer)))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
845 ;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
846 ;; save-buffer -> forms--save-buffer
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
847 ;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
848 (if (fboundp 'forms--save-buffer)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
849 nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
850 (fset 'forms--save-buffer (symbol-function 'save-buffer))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
851 (fset 'save-buffer
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
852 '(lambda (&optional arg)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
853 (interactive "p")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
854 (if forms--mode-setup
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
855 (progn
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
856 (forms--checkmod)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
857 (save-excursion
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
858 (set-buffer forms--file-buffer)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
859 (forms--save-buffer arg)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
860 (forms--save-buffer arg)))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
861 ;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
862 )
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
863
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
864 (defun forms--help ()
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
865 "Initial help."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
866 ;; We should use
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
867 ;;(message (substitute-command-keys (concat
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
868 ;;"\\[forms-next-record]:next"
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
869 ;;" \\[forms-prev-record]:prev"
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
870 ;;" \\[forms-first-record]:first"
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
871 ;;" \\[forms-last-record]:last"
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
872 ;;" \\[describe-mode]:help"
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
873 ;;" \\[forms-exit]:exit")))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
874 ;; but it's too slow ....
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
875 (if forms-read-only
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
876 (message "SPC:next DEL:prev <:first >:last ?:help q:exit")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
877 (message "C-c n:next C-c p:prev C-c <:first C-c >:last C-c ?:help C-c q:exit")))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
878
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
879 (defun forms--trans (subj arg rep)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
880 "Translate in SUBJ all chars ARG into char REP. ARG and REP should
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
881 be single-char strings."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
882 (let ((i 0)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
883 (x (length subj))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
884 (re (regexp-quote arg))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
885 (k (string-to-char rep)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
886 (while (setq i (string-match re subj i))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
887 (aset subj i k)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
888 (setq i (1+ i)))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
889
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
890 (defun forms--exit (query &optional save)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
891 (let ((buf (buffer-name forms--file-buffer)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
892 (forms--checkmod)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
893 (if (and save
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
894 (buffer-modified-p forms--file-buffer))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
895 (save-excursion
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
896 (set-buffer forms--file-buffer)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
897 (save-buffer)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
898 (save-excursion
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
899 (set-buffer forms--file-buffer)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
900 (delete-auto-save-file-if-necessary)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
901 (kill-buffer (current-buffer)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
902 (if (get-buffer buf) ; not killed???
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
903 (if save
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
904 (progn
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
905 (beep)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
906 (message "Problem saving buffers?")))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
907 (delete-auto-save-file-if-necessary)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
908 (kill-buffer (current-buffer)))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
909
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
910 (defun forms--get-record ()
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
911 "Fetch the current record from the file buffer."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
912 ;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
913 ;; This function is executed in the context of the forms--file-buffer.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
914 ;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
915 (or (bolp)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
916 (beginning-of-line nil))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
917 (let ((here (point)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
918 (prog2
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
919 (end-of-line)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
920 (buffer-substring here (point))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
921 (goto-char here))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
922
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
923 (defun forms--show-record (the-record)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
924 "Format THE-RECORD according to forms-format-list,
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
925 and display it in the current buffer."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
926
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
927 ;; split the-record
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
928 (let (the-result
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
929 (start-pos 0)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
930 found-pos
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
931 (field-sep-length (length forms-field-sep)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
932 (if forms-multi-line
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
933 (forms--trans the-record forms-multi-line "\n"))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
934 ;; add an extra separator (makes splitting easy)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
935 (setq the-record (concat the-record forms-field-sep))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
936 (while (setq found-pos (string-match forms-field-sep the-record start-pos))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
937 (let ((ent (substring the-record start-pos found-pos)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
938 (setq the-result
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
939 (append the-result (list ent)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
940 (setq start-pos (+ field-sep-length found-pos))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
941 (setq forms--the-record-list the-result))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
942
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
943 (setq buffer-read-only nil)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
944 (erase-buffer)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
945
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
946 ;; verify the number of fields, extend forms--the-record-list if needed
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
947 (if (= (length forms--the-record-list) forms-number-of-fields)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
948 nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
949 (beep)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
950 (message "Record has %d fields instead of %d."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
951 (length forms--the-record-list) forms-number-of-fields)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
952 (if (< (length forms--the-record-list) forms-number-of-fields)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
953 (setq forms--the-record-list
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
954 (append forms--the-record-list
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
955 (make-list
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
956 (- forms-number-of-fields
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
957 (length forms--the-record-list))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
958 "")))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
959
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
960 ;; call the formatter function
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
961 (setq forms-fields (append (list nil) forms--the-record-list nil))
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
962 (funcall forms--format forms--the-record-list)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
963
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
964 ;; prepare
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
965 (goto-char (point-min))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
966 (set-buffer-modified-p nil)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
967 (setq buffer-read-only forms-read-only)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
968 (setq mode-line-process
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
969 (concat " " forms--current-record "/" forms--total-records)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
970
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
971 (defun forms--parse-form ()
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
972 "Parse contents of form into list of strings."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
973 ;; The contents of the form are parsed, and a new list of strings
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
974 ;; is constructed.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
975 ;; A vector with the strings from the original record is
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
976 ;; constructed, which is updated with the new contents. Therefore
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
977 ;; fields which were not in the form are not modified.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
978 ;; Finally, the vector is transformed into a list for further processing.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
979
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
980 (let (the-recordv)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
981
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
982 ;; build the vector
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
983 (setq the-recordv (vconcat forms--the-record-list))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
984
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
985 ;; parse the form and update the vector
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
986 (let ((forms--dynamic-text forms--dynamic-text))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
987 (funcall forms--parser))
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
988
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
989 (if forms--modified-record-filter
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
990 ;; As a service to the user, we add a zeroth element so she
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
991 ;; can use the same indices as in the forms definition.
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
992 (let ((the-fields (vconcat [nil] the-recordv)))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
993 (setq the-fields (funcall forms--modified-record-filter the-fields))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
994 (cdr (append the-fields nil)))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
995
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
996 ;; transform to a list and return
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
997 (append the-recordv nil))))
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
998
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
999 (defun forms--update ()
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1000 "Update current record with contents of form. As a side effect: sets
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1001 forms--the-record-list ."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1002 (if forms-read-only
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1003 (progn
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1004 (message "Read-only buffer!")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1005 (beep))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1006
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1007 (let (the-record)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1008 ;; build new record
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1009 (setq forms--the-record-list (forms--parse-form))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1010 (setq the-record
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1011 (mapconcat 'identity forms--the-record-list forms-field-sep))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1012
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1013 ;; handle multi-line fields, if allowed
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1014 (if forms-multi-line
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1015 (forms--trans the-record "\n" forms-multi-line))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1016
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1017 ;; a final sanity check before updating
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1018 (if (string-match "\n" the-record)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1019 (progn
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1020 (message "Multi-line fields in this record - update refused!")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1021 (beep))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1022
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1023 (save-excursion
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1024 (set-buffer forms--file-buffer)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1025 ;; Insert something before kill-line is called. See kill-line
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1026 ;; doc. Bugfix provided by Ignatios Souvatzis.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1027 (insert "*")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1028 (beginning-of-line)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1029 (kill-line nil)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1030 (insert the-record)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1031 (beginning-of-line))))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1032
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1033 (defun forms--checkmod ()
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1034 "Check if this form has been modified, and call forms--update if so."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1035 (if (buffer-modified-p nil)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1036 (let ((here (point)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1037 (forms--update)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1038 (set-buffer-modified-p nil)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1039 (goto-char here))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1040
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1041 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1042 ;;; Start and exit
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1043 (defun forms-find-file (fn)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1044 "Visit file FN in forms mode"
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1045 (interactive "fForms file: ")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1046 (find-file-read-only fn)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1047 (or forms--mode-setup (forms-mode t)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1048
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1049 (defun forms-find-file-other-window (fn)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1050 "Visit file FN in form mode in other window"
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1051 (interactive "fFbrowse file in other window: ")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1052 (find-file-other-window fn)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1053 (eval-current-buffer)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1054 (or forms--mode-setup (forms-mode t)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1055
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1056 (defun forms-exit (query)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1057 "Normal exit. Modified buffers are saved."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1058 (interactive "P")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1059 (forms--exit query t))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1060
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1061 (defun forms-exit-no-save (query)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1062 "Exit without saving buffers."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1063 (interactive "P")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1064 (forms--exit query nil))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1065
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1066 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1067 ;;; Navigating commands
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1068
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1069 (defun forms-next-record (arg)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1070 "Advance to the ARGth following record."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1071 (interactive "P")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1072 (forms-jump-record (+ forms--current-record (prefix-numeric-value arg)) t))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1073
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1074 (defun forms-prev-record (arg)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1075 "Advance to the ARGth previous record."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1076 (interactive "P")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1077 (forms-jump-record (- forms--current-record (prefix-numeric-value arg)) t))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1078
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1079 (defun forms-jump-record (arg &optional relative)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1080 "Jump to a random record."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1081 (interactive "NRecord number: ")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1082
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1083 ;; verify that the record number is within range
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1084 (if (or (> arg forms--total-records)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1085 (<= arg 0))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1086 (progn
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1087 (beep)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1088 ;; don't give the message if just paging
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1089 (if (not relative)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1090 (message "Record number %d out of range 1..%d"
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1091 arg forms--total-records))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1092 )
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1093
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1094 ;; flush
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1095 (forms--checkmod)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1096
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1097 ;; calculate displacement
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1098 (let ((disp (- arg forms--current-record))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1099 (cur forms--current-record))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1100
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1101 ;; forms--show-record needs it now
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1102 (setq forms--current-record arg)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1103
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1104 ;; get the record and show it
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1105 (forms--show-record
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1106 (save-excursion
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1107 (set-buffer forms--file-buffer)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1108 (beginning-of-line)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1109
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1110 ;; move, and adjust the amount if needed (shouldn't happen)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1111 (if relative
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1112 (if (zerop disp)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1113 nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1114 (setq cur (+ cur disp (- (forward-line disp)))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1115 (setq cur (+ cur disp (- (goto-line arg)))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1116
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1117 (forms--get-record)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1118
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1119 ;; this shouldn't happen
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1120 (if (/= forms--current-record cur)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1121 (progn
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1122 (setq forms--current-record cur)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1123 (beep)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1124 (message "Stuck at record %d." cur))))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1125
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1126 (defun forms-first-record ()
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1127 "Jump to first record."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1128 (interactive)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1129 (forms-jump-record 1))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1130
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1131 (defun forms-last-record ()
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1132 "Jump to last record. As a side effect: re-calculates the number
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1133 of records in the data file."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1134 (interactive)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1135 (let
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1136 ((numrec
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1137 (save-excursion
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1138 (set-buffer forms--file-buffer)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1139 (count-lines (point-min) (point-max)))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1140 (if (= numrec forms--total-records)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1141 nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1142 (beep)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1143 (setq forms--total-records numrec)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1144 (message "Number of records reset to %d." forms--total-records)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1145 (forms-jump-record forms--total-records))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1146
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1147 ;;;
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1148 ;;; Other commands
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1149 (defun forms-view-mode ()
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1150 "Visit buffer read-only."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1151 (interactive)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1152 (if forms-read-only
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1153 nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1154 (forms--checkmod) ; sync
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1155 (setq forms-read-only t)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1156 (forms-mode)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1157
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1158 (defun forms-edit-mode ()
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1159 "Make form suitable for editing, if possible."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1160 (interactive)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1161 (let ((ro forms-read-only))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1162 (if (save-excursion
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1163 (set-buffer forms--file-buffer)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1164 buffer-read-only)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1165 (progn
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1166 (setq forms-read-only t)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1167 (message "No write access to \"%s\"" forms-file)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1168 (beep))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1169 (setq forms-read-only nil))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1170 (if (equal ro forms-read-only)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1171 nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1172 (forms-mode))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1173
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1174 ;; Sample:
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1175 ;; (defun my-new-record-filter (the-fields)
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1176 ;; ;; numbers are relative to 1
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1177 ;; (aset the-fields 4 (current-time-string))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1178 ;; (aset the-fields 6 (user-login-name))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1179 ;; the-list)
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1180 ;; (setq forms-new-record-filter 'my-new-record-filter)
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1181
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1182 (defun forms-insert-record (arg)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1183 "Create a new record before the current one. With ARG: store the
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1184 record after the current one.
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1185 If a function forms-new-record-filter is defined, or forms-new-record-filter
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1186 contains the name of a function, it is called to
276
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1187 fill (some of) the fields with default values."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1188 ; The above doc is not true, but for documentary purposes only
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1189
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1190 (interactive "P")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1191
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1192 (let ((ln (if arg (1+ forms--current-record) forms--current-record))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1193 the-list the-record)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1194
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1195 (forms--checkmod)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1196 (if forms--new-record-filter
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1197 ;; As a service to the user, we add a zeroth element so she
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1198 ;; can use the same indices as in the forms definition.
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1199 (let ((the-fields (make-vector (1+ forms-number-of-fields) "")))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1200 (setq the-fields (funcall forms--new-record-filter the-fields))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1201 (setq the-list (cdr (append the-fields nil))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1202 (setq the-list (make-list forms-number-of-fields "")))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1203
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1204 (setq the-record
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1205 (mapconcat
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1206 'identity
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1207 the-list
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1208 forms-field-sep))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1209
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1210 (save-excursion
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1211 (set-buffer forms--file-buffer)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1212 (goto-line ln)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1213 (open-line 1)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1214 (insert the-record)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1215 (beginning-of-line))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1216
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1217 (setq forms--current-record ln))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1218
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1219 (setq forms--total-records (1+ forms--total-records))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1220 (forms-jump-record forms--current-record))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1221
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1222 (defun forms-delete-record (arg)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1223 "Deletes a record. With ARG: don't ask."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1224 (interactive "P")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1225 (forms--checkmod)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1226 (if (or arg
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1227 (y-or-n-p "Really delete this record? "))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1228 (let ((ln forms--current-record))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1229 (save-excursion
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1230 (set-buffer forms--file-buffer)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1231 (goto-line ln)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1232 (kill-line 1))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1233 (setq forms--total-records (1- forms--total-records))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1234 (if (> forms--current-record forms--total-records)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1235 (setq forms--current-record forms--total-records))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1236 (forms-jump-record forms--current-record)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1237 (message ""))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1238
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1239 (defun forms-search (regexp)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1240 "Search REGEXP in file buffer."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1241 (interactive
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1242 (list (read-string (concat "Search for"
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1243 (if forms--search-regexp
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1244 (concat " ("
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1245 forms--search-regexp
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1246 ")"))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1247 ": "))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1248 (if (equal "" regexp)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1249 (setq regexp forms--search-regexp))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1250 (forms--checkmod)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1251
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1252 (let (the-line the-record here
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1253 (fld-sep forms-field-sep))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1254 (if (save-excursion
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1255 (set-buffer forms--file-buffer)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1256 (setq here (point))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1257 (end-of-line)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1258 (if (null (re-search-forward regexp nil t))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1259 (progn
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1260 (goto-char here)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1261 (message (concat "\"" regexp "\" not found."))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1262 nil)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1263 (setq the-record (forms--get-record))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1264 (setq the-line (1+ (count-lines (point-min) (point))))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1265 (progn
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1266 (setq forms--current-record the-line)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1267 (forms--show-record the-record)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1268 (re-search-forward regexp nil t))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1269 (setq forms--search-regexp regexp))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1270
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1271 (defun forms-revert-buffer (&optional arg noconfirm)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1272 "Reverts current form to un-modified."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1273 (interactive "P")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1274 (if (or noconfirm
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1275 (yes-or-no-p "Revert form to unmodified? "))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1276 (progn
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1277 (set-buffer-modified-p nil)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1278 (forms-jump-record forms--current-record))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1279
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1280 (defun forms-next-field (arg)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1281 "Jump to ARG-th next field."
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1282 (interactive "p")
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1283
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1284 (let ((i 0)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1285 (here (point))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1286 there
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1287 (cnt 0))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1288
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1289 (if (zerop arg)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1290 (setq cnt 1)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1291 (setq cnt (+ cnt arg)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1292
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1293 (if (catch 'done
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1294 (while (< i forms--number-of-markers)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1295 (if (or (null (setq there (aref forms--markers i)))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1296 (<= there here))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1297 nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1298 (if (<= (setq cnt (1- cnt)) 0)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1299 (progn
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1300 (goto-char there)
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1301 (throw 'done t))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1302 (setq i (1+ i))))
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1303 nil
e7eb71cbf478 Initial revision
Brian Preble <rassilon@gnu.org>
parents:
diff changeset
1304 (goto-char (aref forms--markers 0)))))
307
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1305
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1306 ;;;
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1307 ;;; Special service
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1308 ;;;
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1309 (defun forms-enumerate (the-fields)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1310 "Take a quoted list of symbols, and set their values to the numbers
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1311 1, 2 and so on. Returns the higest number.
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1312
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1313 Usage: (setq forms-number-of-fields
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1314 (forms-enumerate
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1315 '(field1 field2 field2 ...)))"
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1316
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1317 (let ((the-index 0))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1318 (while the-fields
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1319 (setq the-index (1+ the-index))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1320 (let ((el (car-safe the-fields)))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1321 (setq the-fields (cdr-safe the-fields))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1322 (set el the-index)))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1323 the-index))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1324
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1325 ;;;
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1326 ;;; Debugging
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1327 ;;;
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1328 (defvar forms--debug nil
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1329 "*Enables forms-mode debugging if not nil.")
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1330
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1331 (defun forms--debug (&rest args)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1332 "Internal - debugging routine"
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1333 (if forms--debug
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1334 (let ((ret nil))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1335 (while args
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1336 (let ((el (car-safe args)))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1337 (setq args (cdr-safe args))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1338 (if (stringp el)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1339 (setq ret (concat ret el))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1340 (setq ret (concat ret (prin1-to-string el) " = "))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1341 (if (boundp el)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1342 (let ((vel (eval el)))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1343 (setq ret (concat ret (prin1-to-string vel) "\n")))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1344 (setq ret (concat ret "<unbound>" "\n")))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1345 (if (fboundp el)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1346 (setq ret (concat ret (prin1-to-string (symbol-function el))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1347 "\n"))))))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1348 (save-excursion
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1349 (set-buffer (get-buffer-create "*forms-mode debug*"))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1350 (goto-char (point-max))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1351 (insert ret)))))
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1352
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1353 ;;; Local Variables:
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1354 ;;; eval: (headers)
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1355 ;;; eval: (setq comment-start ";;; ")
7fede845e304 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 276
diff changeset
1356 ;;; End: