annotate lisp/utils/forms.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children b82b59fe008d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; forms.el --- Forms mode: edit a file as a form to fill in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;; Copyright (C) 1991, 1993 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: Johan Vromans <jv@nl.net>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Version: Revision: 2.10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Keywords: extensions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; hacked on by jwz for XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; along with XEmacs; see the file COPYING. If not, write to the Free
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Synched up with: FSF 19.28.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; Visit a file using a form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; === Naming conventions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;; The names of all variables and functions start with 'forms-'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; Names which start with 'forms--' are intended for internal use, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;;; should *NOT* be used from the outside.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;; All variables are buffer-local, to enable multiple forms visits
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;;; simultaneously.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;; Variable `forms--mode-setup' is local to *ALL* buffers, for it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;; controls if forms-mode has been enabled in a buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;; === How it works ===
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;; Forms mode means visiting a data file which is supposed to consist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;; of records each containing a number of fields. The records are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;; separated by a newline, the fields are separated by a user-defined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;;; field separater (default: TAB).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;; When shown, a record is transferred to an Emacs buffer and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;; presented using a user-defined form. One record is shown at a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;; time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;; Forms mode is a composite mode. It involves two files, and two
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;; buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;; The first file, called the control file, defines the name of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;; data file and the forms format. This file buffer will be used to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;;; present the forms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;; The second file holds the actual data. The buffer of this file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;; will be buried, for it is never accessed directly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;; Forms mode is invoked using M-x forms-find-file control-file .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;; Alternativily `forms-find-file-other-window' can be used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;; You may also visit the control file, and switch to forms mode by hand
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;; with M-x forms-mode .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;; Automatic mode switching is supported if you specify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;;; "-*- forms -*-" in the first line of the control file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;; The control file is visited, evaluated using `eval-current-buffer',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;;; and should set at least the following variables:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;;; forms-file [string]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;;; The name of the data file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;;; forms-number-of-fields [integer]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;;; The number of fields in each record.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;;; forms-format-list [list]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;;; Formatting instructions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;;; `forms-format-list' should be a list, each element containing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;;; - a string, e.g. "hello". The string is inserted in the forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;;; "as is".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;;; - an integer, denoting a field number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;;; The contents of this field are inserted at this point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;;; Fields are numbered starting with number one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;;; - a function call, e.g. (insert "text").
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;;; This function call is dynamically evaluated and should return a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;;; string. It should *NOT* have side-effects on the forms being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;;; constructed. The current fields are available to the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;;; in the variable `forms-fields', they should *NOT* be modified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;;; - a lisp symbol, that must evaluate to one of the above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;; Optional variables which may be set in the control file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;;; forms-field-sep [string, default TAB]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;;; The field separator used to separate the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;;; fields in the data file. It may be a string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;;; forms-read-only [bool, default nil]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;;; Non-nil means that the data file is visited
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;;; read-only (view mode) as opposed to edit mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;;; If no write access to the data file is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;;; possible, view mode is enforced.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;;; forms-multi-line [string, default "^K"]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;;; If non-null the records of the data file may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;;; contain fields that can span multiple lines in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;;; the form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;;; This variable denotes the separator character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;;; to be used for this purpose. Upon display, all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;;; occurrencies of this character are translated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;;; to newlines. Upon storage they are translated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;;; back to the separator character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;;; forms-forms-scroll [bool, default nil]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;;; Non-nil means: rebind locally the commands that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;;; perform `scroll-up' or `scroll-down' to use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;;; `forms-next-field' resp. `forms-prev-field'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;;; forms-forms-jump [bool, default nil]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;;; Non-nil means: rebind locally the commands that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;;; perform `beginning-of-buffer' or `end-of-buffer'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;;; to perform `forms-first-field' resp. `forms-last-field'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;;; forms-read-file-filter [symbol, default nil]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;;; If not nil: this should be the name of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;;; function that is called after the forms data file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;;; has been read. It can be used to transform
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;;; the contents of the file into a format more suitable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;;; for forms-mode processing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;;; forms-write-file-filter [symbol, default nil]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;;; If not nil: this should be the name of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;;; function that is called before the forms data file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;;; is written (saved) to disk. It can be used to undo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;;; the effects of `forms-read-file-filter', if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;;; forms-new-record-filter [symbol, default nil]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;;; If not nil: this should be the name of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;;; function that is called when a new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;;; record is created. It can be used to fill in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;;; the new record with default fields, for example.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;;; forms-modified-record-filter [symbol, default nil]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;;; If not nil: this should be the name of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;;; function that is called when a record has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;;; been modified. It is called after the fields
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;;; are parsed. It can be used to register
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;;; modification dates, for example.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;;; forms-use-extents [bool, see text for default]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;;; forms-use-text-properties [bool, see text for default]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;;; These variables control if forms mode should use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;;; text properties or extents to protect the form text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;;; from being modified (using text-property `read-only').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;;; Also, the read-write fields are shown using a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ;;; distinct face, if possible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;;; One of these variables defaults to t if running
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;;; FSF or Lucid Emacs 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;;; forms-ro-face [symbol, default 'default]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;;; This is the face that is used to show
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;;; read-only text on the screen.If used, this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;;; variable should be set to a symbol that is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;;; valid face.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;;; E.g.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;;; (make-face 'my-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;;; (setq forms-ro-face 'my-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;;; forms-rw-face [symbol, default 'region]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;;; This is the face that is used to show
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;;; read-write text on the screen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;;; After evaluating the control file, its buffer is cleared and used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;;; for further processing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;;; The data file (as designated by `forms-file') is visited in a buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;;; `forms--file-buffer' which will not normally be shown.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;;; Great malfunctioning may be expected if this file/buffer is modified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;;; outside of this package while it is being visited!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;;; Normal operation is to transfer one line (record) from the data file,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;;; split it into fields (into `forms--the-record-list'), and display it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;;; using the specs in `forms-format-list'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;;; A format routine `forms--format' is built upon startup to format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;;; the records according to `forms-format-list'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;;; When a form is changed the record is updated as soon as this form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;;; is left. The contents of the form are parsed using information
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;;; obtained from `forms-format-list', and the fields which are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;;; deduced from the form are modified. Fields not shown on the forms
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;;; retain their origional values. The newly formed record then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;;; replaces the contents of the old record in `forms--file-buffer'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;;; A parse routine `forms--parser' is built upon startup to parse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;;; the records.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ;;; Two exit functions exist: `forms-exit' and `forms-exit-no-save'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ;;; `forms-exit' saves the data to the file, if modified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;;; `forms-exit-no-save` does not. However, if `forms-exit-no-save'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;;; is executed and the file buffer has been modified, Emacs will ask
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;;; questions anyway.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;;; Other functions provided by forms mode are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;;; paging (forward, backward) by record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;;; jumping (first, last, random number)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 ;;; searching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 ;;; creating and deleting records
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ;;; reverting the form (NOT the file buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 ;;; switching edit <-> view mode v.v.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 ;;; jumping from field to field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ;;; As an documented side-effect: jumping to the last record in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ;;; file (using forms-last-record) will adjust forms--total-records if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ;;; needed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ;;; The forms buffer can be in on eof two modes: edit mode or view
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ;;; mode. View mode is a read-only mode, you cannot modify the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;;; contents of the buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ;;; Edit mode commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ;;; TAB forms-next-field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 ;;; \C-c TAB forms-next-field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;;; \C-c < forms-first-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;;; \C-c > forms-last-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ;;; \C-c ? describe-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ;;; \C-c \C-k forms-delete-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ;;; \C-c \C-q forms-toggle-read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 ;;; \C-c \C-o forms-insert-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 ;;; \C-c \C-l forms-jump-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 ;;; \C-c \C-n forms-next-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ;;; \C-c \C-p forms-prev-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ;;; \C-c \C-s forms-search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ;;; \C-c \C-x forms-exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 ;;; Read-only mode commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ;;; SPC forms-next-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ;;; DEL forms-prev-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ;;; ? describe-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ;;; \C-q forms-toggle-read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ;;; l forms-jump-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 ;;; n forms-next-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ;;; p forms-prev-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ;;; s forms-search
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ;;; x forms-exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ;;; Of course, it is also possible to use the \C-c prefix to obtain the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ;;; same command keys as in edit mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ;;; The following bindings are available, independent of the mode:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;;; [next] forms-next-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ;;; [prior] forms-prev-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ;;; [begin] forms-first-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 ;;; [end] forms-last-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 ;;; [S-TAB] forms-prev-field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;;; [backtab] forms-prev-field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;;; For convenience, TAB is always bound to `forms-next-field', so you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 ;;; don't need the C-c prefix for this command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ;;; As mentioned above (see `forms-forms-scroll' and `forms-forms-jump')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ;;; the bindings of standard functions `scroll-up', `scroll-down',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ;;; `beginning-of-buffer' and `end-of-buffer' can be locally replaced with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;;; forms mode functions next/prev record and first/last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ;;; record.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 ;;; `local-write-file hook' is defined to save the actual data file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 ;;; instead of the buffer data, `revert-file-hook' is defined to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ;;; revert a forms to original.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ;;; Global variables and constants:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (provide 'forms) ;;; official
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (provide 'forms-mode) ;;; for compatibility
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (defconst forms-version (substring "!Revision: 2.10 !" 11 -2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 "The version number of forms-mode (as string). The complete RCS id is:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 !Id: forms.el,v 2.10 1994/07/26 21:31:13 rms Exp !")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (defvar forms-mode-hooks nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 "Hook functions to be run upon entering Forms mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 ;;; Mandatory variables - must be set by evaluating the control file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (defvar forms-file nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 "Name of the file holding the data.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (defvar forms-format-list nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 "List of formatting specifications.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (defvar forms-number-of-fields nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 "Number of fields per record.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 ;;; Optional variables with default values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (defvar forms-field-sep "\t"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 "Field separator character (default TAB).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (defvar forms-read-only nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 "Non-nil means: visit the file in view (read-only) mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 \(Defaults to the write access on the data file).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (defvar forms-multi-line "\C-k"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 "If not nil: use this character to separate multi-line fields (default C-k).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (defvar forms-forms-scroll nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 "*Non-nil means replace scroll-up/down commands in Forms mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 The replacement commands performs forms-next/prev-record.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (defvar forms-forms-jump nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 "*Non-nil means redefine beginning/end-of-buffer in Forms mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 The replacement commands performs forms-first/last-record.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (defvar forms-read-file-filter nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 "The name of a function that is called after reading the data file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 This can be used to change the contents of the file to something more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 suitable for forms processing.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (defvar forms-write-file-filter nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 "The name of a function that is called before writing the data file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 This can be used to undo the effects of form-read-file-hook.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (defvar forms-new-record-filter nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 "The name of a function that is called when a new record is created.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (defvar forms-modified-record-filter nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 "The name of a function that is called when a record has been modified.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (defvar forms-fields nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 "List with fields of the current forms. First field has number 1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 This variable is for use by the filter routines only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 The contents may NOT be modified.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (defvar forms-use-extents (fboundp 'set-extent-property) ; XEmacs 19.9+
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 "*Non-nil means: use XEmacs/Lucid Emacs extents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 Defaults to t if this emacs is capable of handling text properties.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (defvar forms-use-text-properties (and (fboundp 'set-text-properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (not forms-use-extents))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 "*Non-nil means: use emacs-19 text properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 Defaults to t if this emacs is capable of handling text properties.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (defvar forms-ro-face (if (string-match "XEmacs" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 'forms-label-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 'default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 "The face (a symbol) that is used to display read-only text on the screen.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (defvar forms-rw-face (if (string-match "XEmacs" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 'forms-field-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 'region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 "The face (a symbol) that is used to display read-write text on the screen.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 ;;; Internal variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (defvar forms--lemacs-p (string-match "XEmacs" emacs-version))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (defvar forms--file-buffer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 "Buffer which holds the file data")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (defvar forms--total-records 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 "Total number of records in the data file.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (defvar forms--current-record 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 "Number of the record currently on the screen.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (defvar forms-mode-map nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 "Keymap for form buffer.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (defvar forms-mode-ro-map nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 "Keymap for form buffer in view mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (defvar forms-mode-edit-map nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 "Keymap for form buffer in edit mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (defvar forms--markers nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 "Field markers in the screen.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (defvar forms--dyntexts nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 "Dynamic texts (resulting from function calls) on the screen.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (defvar forms--the-record-list nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 "List of strings of the current record, as parsed from the file.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (defvar forms--search-regexp nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 "Last regexp used by forms-search.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (defvar forms--format nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 "Formatting routine.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (defvar forms--parser nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 "Forms parser routine.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (defvar forms--mode-setup nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 "To keep track of forms-mode being set-up.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (make-variable-buffer-local 'forms--mode-setup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (defvar forms--dynamic-text nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 "Array that holds dynamic texts to insert between fields.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (defvar forms--elements nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 "Array with the order in which the fields are displayed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (defvar forms--ro-face nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 "Face used to represent read-only data on the screen.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (defvar forms--rw-face nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 "Face used to represent read-write data on the screen.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (defun forms-mode (&optional primary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 "Major mode to visit files in a field-structured manner using a form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 Commands: Equivalent keys in read-only mode:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 TAB forms-next-field TAB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 C-c TAB forms-next-field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 C-c < forms-first-record <
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 C-c > forms-last-record >
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 C-c ? describe-mode ?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 C-c C-k forms-delete-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 C-c C-q forms-toggle-read-only q
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 C-c C-o forms-insert-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 C-c C-l forms-jump-record l
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 C-c C-n forms-next-record n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 C-c C-p forms-prev-record p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 C-c C-s forms-search s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 C-c C-x forms-exit x"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 ;; This is not a simple major mode, as usual. Therefore, forms-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 ;; takes an optional argument `primary' which is used for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 ;; initial set-up. Normal use would leave `primary' to nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 ;; A global buffer-local variable `forms--mode-setup' has the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 ;; effect but makes it possible to auto-invoke forms-mode using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 ;; `find-file'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 ;; Note: although it seems logical to have `make-local-variable'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 ;; executed where the variable is first needed, I have deliberately
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 ;; placed all calls in this function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 ;; Primary set-up: evaluate buffer and check if the mandatory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 ;; variables have been set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (if (or primary (not forms--mode-setup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 ;;(message "forms: setting up...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 ;; Make mandatory variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (make-local-variable 'forms-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (make-local-variable 'forms-number-of-fields)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (make-local-variable 'forms-format-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 ;; Make optional variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (make-local-variable 'forms-field-sep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (make-local-variable 'forms-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (make-local-variable 'forms-multi-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (make-local-variable 'forms-forms-scroll)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (make-local-variable 'forms-forms-jump)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 ;; (make-local-variable 'forms-use-text-properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 ;; Filter functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (make-local-variable 'forms-read-file-filter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (make-local-variable 'forms-write-file-filter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (make-local-variable 'forms-new-record-filter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (make-local-variable 'forms-modified-record-filter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 ;; Make sure no filters exist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (setq forms-read-file-filter nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (setq forms-write-file-filter nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (setq forms-new-record-filter nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (setq forms-modified-record-filter nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (if forms--lemacs-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 ;; forms-field-face defaults to bold.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 ;; forms-label-face defaults to no attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 ;; (inherit from default.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (make-face 'forms-field-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (make-face 'forms-label-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (if (face-differs-from-default-p 'forms-field-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (copy-face 'bold 'forms-field-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 ;;(set-face-underline-p 'forms-field-face t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 ;; If running Emacs 19 under X, setup faces to show read-only and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 ;; read-write fields.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (if (fboundp 'make-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (make-local-variable 'forms-ro-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (make-local-variable 'forms-rw-face)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 ;; eval the buffer, should set variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 ;;(message "forms: processing control file...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 ;; If enable-local-eval is not set to t the user is asked first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (if (or (eq enable-local-eval t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (yes-or-no-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (concat "Evaluate lisp code in buffer "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (buffer-name) " to display forms ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (eval-current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (error "`enable-local-eval' inhibits buffer evaluation"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 ;; Check if the mandatory variables make sense.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (or forms-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (error (concat "Forms control file error: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 "'forms-file' has not been set")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 ;; Check forms-field-sep first, since it can be needed to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 ;; construct a default format list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (or (stringp forms-field-sep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (error (concat "Forms control file error: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 "'forms-field-sep' is not a string")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (if forms-number-of-fields
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (or (and (numberp forms-number-of-fields)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (> forms-number-of-fields 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (error (concat "Forms control file error: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 "'forms-number-of-fields' must be a number > 0")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (or (null forms-format-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (error (concat "Forms control file error: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 "'forms-number-of-fields' has not been set"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (or forms-format-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (forms--intuit-from-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (if forms-multi-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (if (and (stringp forms-multi-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (eq (length forms-multi-line) 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (if (string= forms-multi-line forms-field-sep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (error (concat "Forms control file error: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 "'forms-multi-line' is equal to 'forms-field-sep'")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (error (concat "Forms control file error: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 "'forms-multi-line' must be nil or a one-character string"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 ;; (or (fboundp 'set-text-properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 ;; (setq forms-use-text-properties nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 ;; Validate and process forms-format-list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 ;;(message "forms: pre-processing format list...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (forms--process-format-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 ;; Build the formatter and parser.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 ;;(message "forms: building formatter...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (make-local-variable 'forms--format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (make-local-variable 'forms--markers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (make-local-variable 'forms--dyntexts)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (make-local-variable 'forms--elements)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 ;;(message "forms: building parser...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (forms--make-format)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (make-local-variable 'forms--parser)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (forms--make-parser)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 ;;(message "forms: building parser... done.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 ;; Check if record filters are defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (if (and forms-new-record-filter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (not (fboundp forms-new-record-filter)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (error (concat "Forms control file error: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 "'forms-new-record-filter' is not a function")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (if (and forms-modified-record-filter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (not (fboundp forms-modified-record-filter)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (error (concat "Forms control file error: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 "'forms-modified-record-filter' is not a function")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 ;; The filters acces the contents of the forms using `forms-fields'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (make-local-variable 'forms-fields)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 ;; Dynamic text support.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (make-local-variable 'forms--dynamic-text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 ;; Prevent accidental overwrite of the control file and autosave.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (setq buffer-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (auto-save-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 ;; Prepare this buffer for further processing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 ;;(message "forms: setting up... done.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 ;; initialization done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (setq forms--mode-setup t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 ;; Copy desired faces to the actual variables used by the forms formatter.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (if (fboundp 'make-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (make-local-variable 'forms--ro-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (make-local-variable 'forms--rw-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (if forms-read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (setq forms--ro-face forms-ro-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (setq forms--rw-face forms-ro-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (setq forms--ro-face forms-ro-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (setq forms--rw-face forms-rw-face))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 ;; Make more local variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (make-local-variable 'forms--file-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (make-local-variable 'forms--total-records)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (make-local-variable 'forms--current-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (make-local-variable 'forms--the-record-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (make-local-variable 'forms--search-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 ; The keymaps are global, so multiple forms mode buffers can share them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 ;(make-local-variable 'forms-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 ;(make-local-variable 'forms-mode-ro-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 ;(make-local-variable 'forms-mode-edit-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (if forms-mode-map ; already defined
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 ;;(message "forms: building keymap...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (forms--mode-commands)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 ;;(message "forms: building keymap... done.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 ;; find the data file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (setq forms--file-buffer (find-file-noselect forms-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 ;; Pre-transform.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (let ((read-file-filter forms-read-file-filter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (write-file-filter forms-write-file-filter))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (if read-file-filter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (set-buffer forms--file-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (let ((inhibit-read-only t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (run-hooks 'read-file-filter))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (if write-file-filter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (make-variable-buffer-local 'local-write-file-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (setq local-write-file-hooks (list write-file-filter)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (if write-file-filter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (set-buffer forms--file-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (make-variable-buffer-local 'local-write-file-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (setq local-write-file-hooks write-file-filter)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 ;; count the number of records, and set see if it may be modified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (let (ro)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (setq forms--total-records
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 ;;(message "forms: counting records...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (set-buffer forms--file-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (bury-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (setq ro buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (count-lines (point-min) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 ;;(message "forms: counting records... done.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (if ro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (setq forms-read-only t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 ;;(message "forms: proceeding setup...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 ;; set the major mode indicator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (setq major-mode 'forms-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (setq mode-name "Forms")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 ;; Since we aren't really implementing a minor mode, we hack the modeline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 ;; directly to get the text " View " into forms-read-only form buffers. For
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 ;; that reason, this variable must be buffer only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (make-local-variable 'minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (setq minor-mode-alist (list (list 'forms-read-only " View")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 ;;(message "forms: proceeding setup (keymaps)...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (forms--set-keymaps)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 ;;(message "forms: proceeding setup (commands)...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (forms--change-commands)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 ;;(message "forms: proceeding setup (buffer)...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (if (= forms--total-records 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 ;;(message "forms: proceeding setup (new file)...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 "GNU Emacs Forms Mode version " forms-version "\n\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (if (file-exists-p forms-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (concat "No records available in file \"" forms-file "\".\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (format "Creating new file \"%s\"\nwith %d field%s per record.\n\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 forms-file forms-number-of-fields
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (if (= 1 forms-number-of-fields) "" "s")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 "Use " (substitute-command-keys "\\[forms-insert-record]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 " to create new records.\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (setq forms--current-record 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (set-buffer-modified-p nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 ;; setup the first (or current) record to show
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (if (< forms--current-record 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (setq forms--current-record 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (forms-jump-record forms--current-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 ;; user customising
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 ;;(message "forms: proceeding setup (user hooks)...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (run-hooks 'forms-mode-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 ;;(message "forms: setting up... done.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 ;; be helpful
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (forms--help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (defun forms--process-format-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 ;; Validate `forms-format-list' and set some global variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 ;; Symbols in the list are evaluated, and consecutive strings are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 ;; concatenated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 ;; Array `forms--elements' is constructed that contains the order
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 ;; of the fields on the display. This array is used by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 ;; `forms--parser-using-text-properties' to extract the fields data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 ;; from the form on the screen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 ;; Upon completion, `forms-format-list' is garanteed correct, so
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 ;; `forms--make-format' and `forms--make-parser' do not need to perform
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 ;; any checks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 ;; Verify that `forms-format-list' is not nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (or forms-format-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (error (concat "Forms control file error: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 "'forms-format-list' has not been set")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 ;; It must be a list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (or (listp forms-format-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (error (concat "Forms control file error: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 "'forms-format-list' is not a list")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 ;; Assume every field is painted once.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 ;; `forms--elements' will grow if needed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (setq forms--elements (make-vector forms-number-of-fields nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (let ((the-list forms-format-list) ; the list of format elements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (this-item 0) ; element in list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (prev-item nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (field-num 0)) ; highest field number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (setq forms-format-list nil) ; gonna rebuild
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (while the-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (let ((el (car-safe the-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (rem (cdr-safe the-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 ;; If it is a symbol, eval it first.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (if (and (symbolp el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (boundp el))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (setq el (eval el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 ;; Try string ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 ((stringp el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (if (stringp prev-item) ; try to concatenate strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (setq prev-item (concat prev-item el))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (if prev-item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (setq forms-format-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (append forms-format-list (list prev-item) nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (setq prev-item el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 ;; Try numeric ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 ((numberp el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 ;; Validate range.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (if (or (<= el 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (> el forms-number-of-fields))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (error (concat "Forms format error: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 "field number %d out of range 1..%d")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 el forms-number-of-fields))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 ;; Store forms order.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (if (> field-num (length forms--elements))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (setq forms--elements (vconcat forms--elements (1- el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (aset forms--elements field-num (1- el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (setq field-num (1+ field-num))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 (if prev-item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (setq forms-format-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (append forms-format-list (list prev-item) nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (setq prev-item el))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 ;; Try function ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 ((listp el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 ;; Validate.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (or (fboundp (car-safe el))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (error (concat "Forms format error: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 "not a function "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (prin1-to-string (car-safe el)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 ;; Shift.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (if prev-item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (setq forms-format-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (append forms-format-list (list prev-item) nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (setq prev-item el))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 ;; else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (error (concat "Forms format error: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 "invalid element "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (prin1-to-string el)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 ;; Advance to next element of the list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (setq the-list rem)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 ;; Append last item.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (if prev-item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (setq forms-format-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (append forms-format-list (list prev-item) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 ;; Append a newline if the last item is a field.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 ;; This prevents parsing problems.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 ;; Also it makes it possible to insert an empty last field.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (if (numberp prev-item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (setq forms-format-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (append forms-format-list (list "\n") nil))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (forms--debug 'forms-format-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 'forms--elements))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 ;; Special treatment for read-only segments. (FSF19 only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 ;; If text is inserted between two read-only segments, it inherits the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 ;; read-only properties. This is not what we want.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 ;; To solve this, read-only segments get the `insert-in-front-hooks'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 ;; property set with a function that temporarily switches the properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 ;; of the first character of the segment to read-write, so the new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 ;; text gets the right properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 ;; The `post-command-hook' is used to restore the original properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (defvar forms--iif-start nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 "Record start of modification command.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (defvar forms--iif-properties nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 "Original properties of the character being overridden.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (defun forms--iif-hook (begin end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 "`insert-in-front-hooks' function for read-only segments."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 ;; Note start location. By making it a marker that points one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 ;; character beyond the actual location, it is guaranteed to move
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 ;; correctly if text is inserted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (or forms--iif-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (setq forms--iif-start (copy-marker (1+ (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 ;; Check if there is special treatment required.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (if (or (<= forms--iif-start 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (get-text-property (- forms--iif-start 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 'read-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 ;; Fetch current properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (setq forms--iif-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (text-properties-at (1- forms--iif-start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 ;; Replace them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (let ((inhibit-read-only t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (set-text-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (1- forms--iif-start) forms--iif-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 (list 'face forms--rw-face 'front-sticky '(face))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 ;; Enable `post-command-hook' to restore the properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (setq post-command-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (append (list 'forms--iif-post-command-hook) post-command-hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 ;; No action needed. Clear marker.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (setq forms--iif-start nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (defun forms--iif-post-command-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 "`post-command-hook' function for read-only segments."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 ;; Disable `post-command-hook'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (setq post-command-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (delq 'forms--iif-hook-post-command-hook post-command-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 ;; Restore properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (if forms--iif-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (let ((inhibit-read-only t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (set-text-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (1- forms--iif-start) forms--iif-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 forms--iif-properties)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 ;; Cleanup.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (setq forms--iif-start nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (defvar forms--marker)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (defvar forms--dyntext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (defun forms--make-format ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 "Generate `forms--format' using the information in `forms-format-list'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 ;; The real work is done using a mapcar of `forms--make-format-elt' on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 ;; `forms-format-list'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 ;; This function sets up the necessary environment, and decides
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 ;; which function to mapcar.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (let ((forms--marker 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (forms--dyntext 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 forms--format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (if forms-use-text-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (` (lambda (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (let ((inhibit-read-only t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (,@ (apply 'append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (mapcar 'forms--make-format-elt-using-text-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 forms-format-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 ;; Prevent insertion before the first text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (,@ (if (numberp (car forms-format-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 '((add-text-properties (point-min) (1+ (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 '(front-sticky (read-only))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 ;; Prevent insertion after the last text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (remove-text-properties (1- (point)) (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 '(rear-nonsticky)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (setq forms--iif-start nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 (if forms-use-extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (` (lambda (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (,@ (apply 'append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (mapcar 'forms--make-format-elt-using-extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 forms-format-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 ;; After creating all the extents, set their endpoint behavior.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 ;; We can't do this when creating the extents, because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 ;; otherwise the text we insert for the labels would be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 ;; interpreted as user input, and would alter the endpoints
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 ;; of the previous extents we created (the text-entry fields
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 ;; would be extended by the following static-text areas.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (map-extents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (lambda (extent ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 ((not (extent-property extent 'forms))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 ;; it's not one of ours; leave it alone.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 ((not (extent-property extent 'read-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 ;; text-entry fields should be [closed,closed] so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 ;; characters at either boundary go into them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (set-extent-property extent 'end-open nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 ;; Read-only fields should be (open,open) so that a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 ;; read-only error isn't signalled when characters are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 ;; inserted adjascent to them. However, the very first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 ;; label should be [closed,open) so that one can't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 ;; insert text at point-min before the first label,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 ;; and the very last should be (open,closed] for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 ;; same reason.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 ((= (point-min) (extent-start-position extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (set-extent-property extent 'start-open nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 (set-extent-property extent 'end-open t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 ((= (point-max) (extent-end-position extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (set-extent-property extent 'start-open t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (set-extent-property extent 'end-open nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (set-extent-property extent 'start-open t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (set-extent-property extent 'end-open t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 ;; return nil to continue mapping.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (current-buffer) (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (` (lambda (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (,@ (apply 'append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (mapcar 'forms--make-format-elt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 forms-format-list))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 ;; We have tallied the number of markers and dynamic texts,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 ;; so we can allocate the arrays now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (setq forms--markers (make-vector forms--marker nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (setq forms--dyntexts (make-vector forms--dyntext nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (forms--debug 'forms--format))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (defun forms--make-format-elt-using-text-properties (el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 "Helper routine to generate format function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 ;; The format routine `forms--format' will look like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 ;; ;; preamble
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 ;; (lambda (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 ;; (let ((inhibit-read-only t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 ;; ;; A string, e.g. "text: ".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 ;; (set-text-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 ;; (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 ;; (progn (insert "text: ") (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 ;; (list 'face forms--ro-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 ;; 'read-only 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 ;; 'insert-in-front-hooks 'forms--iif-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 ;; 'rear-nonsticky '(read-only face insert-in-front-hooks)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 ;; ;; A field, e.g. 6.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 ;; (let ((here (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 ;; (aset forms--markers 0 (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 ;; (insert (elt arg 5))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 ;; (or (= (point) here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 ;; (set-text-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 ;; here (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 ;; (list 'face forms--rw-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 ;; 'front-sticky '(face))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 ;; ;; Another string, e.g. "\nmore text: ".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 ;; (set-text-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 ;; (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 ;; (progn (insert "\nmore text: ") (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 ;; (list 'face forms--ro-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 ;; 'read-only 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 ;; 'insert-in-front-hooks 'forms--iif-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 ;; 'rear-nonsticky '(read-only face insert-in-front-hooks)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 ;; ;; A function, e.g. (tocol 40).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 ;; (set-text-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 ;; (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 ;; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 ;; (insert (aset forms--dyntexts 0 (tocol 40)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 ;; (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 ;; (list 'face forms--ro-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 ;; 'read-only 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 ;; 'insert-in-front-hooks 'forms--iif-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 ;; 'rear-nonsticky '(read-only face insert-in-front-hooks)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 ;; ;; Prevent insertion before the first text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 ;; (add-text-properties (point-min) (1+ (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 ;; '(front-sticky (read-only))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 ;; ;; Prevent insertion after the last text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 ;; (remove-text-properties (1- (point)) (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 ;; '(rear-nonsticky)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 ;; ;; wrap up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 ;; (setq forms--iif-start nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 ;; ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 ((stringp el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (` ((set-text-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 (point) ; start at point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 (progn ; until after insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (insert (, el))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (list 'face forms--ro-face ; read-only appearance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 'read-only (,@ (list (1+ forms--marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 'insert-in-front-hooks '(forms--iif-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 'rear-nonsticky '(face read-only insert-in-front-hooks))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 ((numberp el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 (` ((let ((here (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (aset forms--markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (, (prog1 forms--marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (setq forms--marker (1+ forms--marker))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (insert (elt arg (, (1- el))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (or (= (point) here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (set-text-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 here (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (list 'face forms--rw-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 'front-sticky '(face))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 ((listp el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (` ((set-text-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (insert (aset forms--dyntexts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (, (prog1 forms--dyntext
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (setq forms--dyntext (1+ forms--dyntext))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (, el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (list 'face forms--ro-face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 'read-only (,@ (list (1+ forms--marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 'insert-in-front-hooks '(forms--iif-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 'rear-nonsticky '(read-only face insert-in-front-hooks))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 ;; end of cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 (defun forms--make-format-elt-using-extents (el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 "Helper routine to generate format function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 ;; The format routine `forms--format' will look like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 ;; ;; preamble
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 ;; (lambda (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 ;; ;; A string, e.g. "text: ".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 ;; (let ((extent (make-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 ;; (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 ;; (progn (insert "text: ") (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 ;; (set-extent-face extent forms--ro-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 ;; (set-extent-property extent 'read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 ;; (set-extent-property extent 'forms t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 ;; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 ;; ;; A field, e.g. 6.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 ;; (let ((here (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 ;; (aset forms--markers 0 (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 ;; (insert (elt arg 5))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 ;; (if (= (point) here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 ;; nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 ;; (let ((extent (make-extent here (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 ;; (set-extent-face extent forms--rw-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 ;; (set-extent-property extent 'forms t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 ;; )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 ;; ;; A function, e.g. (tocol 40).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 ;; (let ((extent (make-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 ;; (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 ;; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 ;; (insert (aset forms--dyntexts 0 (tocol 40)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 ;; (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 ;; (set-extent-face extent forms--ro-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 ;; (set-extent-property extent 'read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 ;; (set-extent-property extent 'forms t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 ;; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 ;; ;; wrap up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 ;; (setq forms--iif-start nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 ;; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 ((stringp el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 (` ((let ((extent (make-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 (point) ; start at point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 (progn ; until after insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 (insert (, el))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 (set-extent-face extent forms--ro-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 (set-extent-property extent 'forms t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (set-extent-property extent 'read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 ((numberp el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 (` ((let ((here (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (aset forms--markers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (, (prog1 forms--marker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (setq forms--marker (1+ forms--marker))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (insert (elt arg (, (1- el))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (if (= (point) here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 (let ((extent (make-extent here (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (set-extent-face extent forms--rw-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (set-extent-property extent 'forms t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 ))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 ((listp el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (` ((let ((extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (make-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 (insert (aset forms--dyntexts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (, (prog1 forms--dyntext
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 (setq forms--dyntext
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 (1+ forms--dyntext))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 (, el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 (set-extent-face extent forms--ro-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (set-extent-property extent 'forms t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (set-extent-property extent 'read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 ;; end of cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (defun forms--make-format-elt (el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 "Helper routine to generate format function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 ;; If we're not using text properties, the format routine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 ;; `forms--format' will look like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 ;; (lambda (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 ;; ;; a string, e.g. "text: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 ;; (insert "text: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 ;; ;; a field, e.g. 6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 ;; (aset forms--markers 0 (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 ;; (insert (elt arg 5))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 ;; ;; another string, e.g. "\nmore text: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 ;; (insert "\nmore text: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 ;; ;; a function, e.g. (tocol 40)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 ;; (insert (aset forms--dyntexts 0 (tocol 40)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 ;; ... )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 ((stringp el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 (` ((insert (, el)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 ((numberp el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 (` ((aset forms--markers (, forms--marker) (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 (insert (elt arg (, (1- el))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (setq forms--marker (1+ forms--marker))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 ((listp el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 (` ((insert (aset forms--dyntexts (, forms--dyntext) (, el)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 (setq forms--dyntext (1+ forms--dyntext))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (defvar forms--field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 (defvar forms--recordv)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 (defvar forms--seen-text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (defun forms--make-parser ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 "Generate `forms--parser' from the information in `forms-format-list'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 ;; If we can use text properties, we simply set it to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 ;; `forms--parser-using-text-properties'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 ;; Otherwise, the function is constructed using a mapcar of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 ;; `forms--make-parser-elt on `forms-format-list'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (setq
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 forms--parser
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 (if forms-use-text-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 (function forms--parser-using-text-properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (let ((forms--field nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 (forms--seen-text nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 (forms--dyntext 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 ;; Note: we add a nil element to the list passed to `mapcar',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 ;; see `forms--make-parser-elt' for details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 (` (lambda nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 (let (here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 (,@ (apply 'append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 'forms--make-parser-elt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 (append forms-format-list (list nil)))))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (forms--debug 'forms--parser))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (defun forms--parser-using-text-properties ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 "Extract field info from forms when using text properties."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 ;; Using text properties, we can simply jump to the markers, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 ;; extract the information up to the following read-only segment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 (let ((i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 here there)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 (while (< i (length forms--markers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (goto-char (setq here (aref forms--markers i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (if (get-text-property here 'read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (aset forms--recordv (aref forms--elements i) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (if (setq there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (next-single-property-change here 'read-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (aset forms--recordv (aref forms--elements i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (buffer-substring here there))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 (aset forms--recordv (aref forms--elements i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (buffer-substring here (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (setq i (1+ i)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (defun forms--make-parser-elt (el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 "Helper routine to generate forms parser function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 ;; The parse routine will look like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 ;; (lambda nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 ;; (let (here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 ;; (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 ;; ;; "text: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 ;; (if (not (looking-at "text: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 ;; (error "Parse error: cannot find \"text: \""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 ;; (forward-char 6) ; past "text: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 ;; ;; 6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 ;; ;; "\nmore text: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 ;; (setq here (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 ;; (if (not (search-forward "\nmore text: " nil t nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 ;; (error "Parse error: cannot find \"\\nmore text: \""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 ;; (aset forms--recordv 5 (buffer-substring here (- (point) 12)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 ;; ;; (tocol 40)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 ;; (let ((forms--dyntext (car-safe forms--dynamic-text)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 ;; (if (not (looking-at (regexp-quote forms--dyntext)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 ;; (error "Parse error: not looking at \"%s\"" forms--dyntext))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 ;; (forward-char (length forms--dyntext))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 ;; (setq forms--dynamic-text (cdr-safe forms--dynamic-text)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 ;; ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 ;; ;; final flush (due to terminator sentinel, see below)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 ;; (aset forms--recordv 7 (buffer-substring (point) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 ((stringp el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 (if forms--field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 (` ((setq here (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 (if (not (search-forward (, el) nil t nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 (error "Parse error: cannot find \"%s\"" (, el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 (aset forms--recordv (, (1- forms--field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 (buffer-substring here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 (- (point) (, (length el)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 (` ((if (not (looking-at (, (regexp-quote el))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 (error "Parse error: not looking at \"%s\"" (, el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 (forward-char (, (length el))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 (setq forms--seen-text t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 (setq forms--field nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 ((numberp el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 (if forms--field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 (error "Cannot parse adjacent fields %d and %d"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 forms--field el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 (setq forms--field el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 ((null el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 (if forms--field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 (` ((aset forms--recordv (, (1- forms--field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 (buffer-substring (point) (point-max)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 ((listp el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 (if forms--field
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 (` ((let ((here (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 (forms--dyntext (aref forms--dyntexts (, forms--dyntext))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 (if (not (search-forward forms--dyntext nil t nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (error "Parse error: cannot find \"%s\"" forms--dyntext))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 (aset forms--recordv (, (1- forms--field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 (buffer-substring here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 (- (point) (length forms--dyntext)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 (` ((let ((forms--dyntext (aref forms--dyntexts (, forms--dyntext))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 (if (not (looking-at (regexp-quote forms--dyntext)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 (error "Parse error: not looking at \"%s\"" forms--dyntext))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 (forward-char (length forms--dyntext))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 (setq forms--dyntext (1+ forms--dyntext))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 (setq forms--seen-text t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 (setq forms--field nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 (defun forms--intuit-from-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 "Get number of fields and a default form using the data file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 ;; If `forms-number-of-fields' is not set, get it from the data file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 (if (null forms-number-of-fields)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 ;; Need a file to do this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 (if (not (file-exists-p forms-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 (error "Need existing file or explicit 'forms-number-of-records'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 ;; Visit the file and extract the first record.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 (setq forms--file-buffer (find-file-noselect forms-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 (let ((read-file-filter forms-read-file-filter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 (the-record))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 (setq the-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 (set-buffer forms--file-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337 (let ((inhibit-read-only t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 (run-hooks 'read-file-filter))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 (forms--get-record)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 ;; This may be overkill, but try to avoid interference with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 ;; the normal processing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 (kill-buffer forms--file-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 ;; Count the number of fields in `the-record'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 (let (the-result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 (start-pos 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 found-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 (field-sep-length (length forms-field-sep)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 (setq forms-number-of-fields 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 (while (setq found-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 (string-match forms-field-sep the-record start-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 (setq forms-number-of-fields (1+ forms-number-of-fields))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 (setq start-pos (+ field-sep-length found-pos))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 ;; Construct default format list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 (setq forms-format-list (list "Forms file \"" forms-file "\".\n\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 (let ((i 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 (while (<= (setq i (1+ i)) forms-number-of-fields)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (setq forms-format-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 (append forms-format-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 (list (format "%4d: " i) i "\n"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 (defun forms--set-keymaps ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 "Set the keymaps used in this mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 (use-local-map (if forms-read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 forms-mode-ro-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 forms-mode-edit-map)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 (defun forms--mode-commands ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 "Fill the Forms mode keymaps."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 ;; `forms-mode-map' is always accessible via \C-c prefix.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (setq forms-mode-map (make-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 (define-key forms-mode-map "\t" 'forms-next-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 (define-key forms-mode-map "\C-k" 'forms-delete-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 (define-key forms-mode-map "\C-q" 'forms-toggle-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 (define-key forms-mode-map "\C-o" 'forms-insert-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 (define-key forms-mode-map "\C-l" 'forms-jump-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 (define-key forms-mode-map "\C-n" 'forms-next-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 (define-key forms-mode-map "\C-p" 'forms-prev-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 (define-key forms-mode-map "\C-s" 'forms-search)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 (define-key forms-mode-map "\C-x" 'forms-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 (define-key forms-mode-map "<" 'forms-first-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 (define-key forms-mode-map ">" 'forms-last-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 (define-key forms-mode-map "?" 'describe-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 (define-key forms-mode-map "\C-?" 'forms-prev-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 ;; `forms-mode-ro-map' replaces the local map when in read-only mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 (setq forms-mode-ro-map (make-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 (suppress-keymap forms-mode-ro-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 (define-key forms-mode-ro-map "\C-c" forms-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 (define-key forms-mode-ro-map "\t" 'forms-next-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 (define-key forms-mode-ro-map "q" 'forms-toggle-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 (define-key forms-mode-ro-map "l" 'forms-jump-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 (define-key forms-mode-ro-map "n" 'forms-next-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 (define-key forms-mode-ro-map "p" 'forms-prev-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 (define-key forms-mode-ro-map "s" 'forms-search)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 (define-key forms-mode-ro-map "x" 'forms-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 (define-key forms-mode-ro-map "<" 'forms-first-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (define-key forms-mode-ro-map ">" 'forms-last-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 (define-key forms-mode-ro-map "?" 'describe-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 (define-key forms-mode-ro-map " " 'forms-next-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 (forms--mode-commands1 forms-mode-ro-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 ;; This is the normal, local map.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 (setq forms-mode-edit-map (make-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 (define-key forms-mode-edit-map "\t" 'forms-next-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 (define-key forms-mode-edit-map "\C-c" forms-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 (forms--mode-commands1 forms-mode-edit-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 (defun forms--mode-commands1 (map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 "Helper routine to define keys."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 (if forms--lemacs-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 (define-key map [tab] 'forms-next-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 (define-key map [(shift tab)] 'forms-prev-field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 (define-key map [TAB] 'forms-next-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 (define-key map [S-tab] 'forms-prev-field))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 (define-key map [next] 'forms-next-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 (define-key map [prior] 'forms-prev-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 (define-key map [begin] 'forms-first-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 (define-key map [last] 'forms-last-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (define-key map [backtab] 'forms-prev-field)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 ;;; Changed functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 (defun forms--change-commands ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 "Localize some commands for Forms mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 ;; scroll-down -> forms-prev-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 ;; scroll-up -> forms-next-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 (if forms-forms-scroll
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 (substitute-key-definition 'scroll-up 'forms-next-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 (current-local-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 ;;(current-global-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 (substitute-key-definition 'scroll-down 'forms-prev-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 (current-local-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 ;;(current-global-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 ;; beginning-of-buffer -> forms-first-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 ;; end-of-buffer -> forms-end-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 (if forms-forms-jump
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 (substitute-key-definition 'beginning-of-buffer 'forms-first-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 (current-local-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 ;;(current-global-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 (substitute-key-definition 'end-of-buffer 'forms-last-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 (current-local-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 ;;(current-global-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 ;; Save buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 (local-set-key "\C-x\C-s" 'forms-save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 ;; We have our own revert function - use it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 (make-local-variable 'revert-buffer-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 (setq revert-buffer-function 'forms--revert-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 (defun forms--help ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 "Initial help for Forms mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 (message (substitute-command-keys (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 "\\[forms-next-record]:next"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 " \\[forms-prev-record]:prev"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 " \\[forms-first-record]:first"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 " \\[forms-last-record]:last"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 " \\[describe-mode]:help"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 (defun forms--trans (subj arg rep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 "Translate in SUBJ all chars ARG into char REP. ARG and REP should
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 be single-char strings."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 (let ((i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 (x (length subj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 (re (regexp-quote arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 (k (string-to-char rep)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 (while (setq i (string-match re subj i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 (aset subj i k)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 (setq i (1+ i)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 (defun forms--exit (query &optional save)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 "Internal exit from forms mode function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 (let ((buf (buffer-name forms--file-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 (forms--checkmod)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 (if (and save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 (buffer-modified-p forms--file-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 (forms-save-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 (set-buffer forms--file-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 (delete-auto-save-file-if-necessary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 (kill-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 (if (get-buffer buf) ; not killed???
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 (if save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 (message "Problem saving buffers?")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 (delete-auto-save-file-if-necessary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 (kill-buffer (current-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 (defun forms--get-record ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 "Fetch the current record from the file buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 ;; This function is executed in the context of the `forms--file-buffer'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 (or (bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 (beginning-of-line nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 (let ((here (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 (prog2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 (buffer-substring here (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 (goto-char here))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 (defun forms--show-record (the-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 "Format THE-RECORD and display it in the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 ;; Split the-record.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 (let (the-result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 (start-pos 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 found-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 (field-sep-length (length forms-field-sep)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 (if forms-multi-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 (forms--trans the-record forms-multi-line "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 ;; Add an extra separator (makes splitting easy).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 (setq the-record (concat the-record forms-field-sep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 (while (setq found-pos (string-match forms-field-sep the-record start-pos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 (let ((ent (substring the-record start-pos found-pos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 (setq the-result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 (append the-result (list ent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 (setq start-pos (+ field-sep-length found-pos))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 (setq forms--the-record-list the-result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 (if forms-use-text-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 (let ((inhibit-read-only t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 (set-text-properties (point-min) (point-max) nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 ;; Verify the number of fields, extend forms--the-record-list if needed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 (if (= (length forms--the-record-list) forms-number-of-fields)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 (message "Warning: this record has %d fields instead of %d"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 (length forms--the-record-list) forms-number-of-fields)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 (if (< (length forms--the-record-list) forms-number-of-fields)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 (setq forms--the-record-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 (append forms--the-record-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 (make-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 (- forms-number-of-fields
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 (length forms--the-record-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 "")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 ;; Call the formatter function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 (setq forms-fields (append (list nil) forms--the-record-list nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 (funcall forms--format forms--the-record-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 ;; Prepare.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 (setq buffer-read-only forms-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 (setq mode-line-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 (format " %d/%d" forms--current-record forms--total-records)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 (defun forms--parse-form ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 "Parse contents of form into list of strings."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 ;; The contents of the form are parsed, and a new list of strings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 ;; is constructed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 ;; A vector with the strings from the original record is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 ;; constructed, which is updated with the new contents. Therefore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 ;; fields which were not in the form are not modified.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 ;; Finally, the vector is transformed into a list for further processing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 (let (forms--recordv)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 ;; Build the vector.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (setq forms--recordv (vconcat forms--the-record-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 ;; Parse the form and update the vector.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 (let ((forms--dynamic-text forms--dynamic-text))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 (funcall forms--parser))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 (if forms-modified-record-filter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 ;; As a service to the user, we add a zeroth element so she
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 ;; can use the same indices as in the forms definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 (let ((the-fields (vconcat [nil] forms--recordv)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 (setq the-fields (funcall forms-modified-record-filter the-fields))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 (cdr (append the-fields nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 ;; Transform to a list and return.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 (append forms--recordv nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 (defun forms--update ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 "Update current record with contents of form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 As a side effect: sets `forms--the-record-list'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 (if forms-read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 (message "Read-only buffer!")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 (beep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 (let (the-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 ;; Build new record.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 (setq forms--the-record-list (forms--parse-form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 (setq the-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 (mapconcat 'identity forms--the-record-list forms-field-sep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 (if (string-match (regexp-quote forms-field-sep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 (mapconcat 'identity forms--the-record-list ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 (error "Field separator occurs in record - update refused!"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 ;; Handle multi-line fields, if allowed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 (if forms-multi-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 (forms--trans the-record "\n" forms-multi-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 ;; A final sanity check before updating.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 (if (string-match "\n" the-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 (message "Multi-line fields in this record - update refused!")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 (beep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 (set-buffer forms--file-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 ;; Use delete-region instead of kill-region, to avoid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 ;; adding junk to the kill-ring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 (delete-region (save-excursion (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 (save-excursion (end-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 (insert the-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 (beginning-of-line))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 (defun forms--checkmod ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 "Check if this form has been modified, and call forms--update if so."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 (if (buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 (let ((here (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 (forms--update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 (goto-char here))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 ;;; Start and exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 (defun forms-find-file (fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 "Visit a file in Forms mode."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 (interactive "fForms file: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 (let ((enable-local-eval t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 (enable-local-variables t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 (find-file-read-only fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 (or forms--mode-setup (forms-mode t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 (defun forms-find-file-other-window (fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 "Visit a file in Forms mode in other window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 (interactive "fFbrowse file in other window: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 (let ((enable-local-eval t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 (enable-local-variables t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 (find-file-other-window fn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 (or forms--mode-setup (forms-mode t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 (defun forms-exit (query)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 "Normal exit from Forms mode. Modified buffers are saved."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 (forms--exit query t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 (defun forms-exit-no-save (query)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 "Exit from Forms mode without saving buffers."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 (forms--exit query nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 ;;; Navigating commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 (defun forms-next-record (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 "Advance to the ARGth following record."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 (forms-jump-record (+ forms--current-record (prefix-numeric-value arg)) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 (defun forms-prev-record (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 "Advance to the ARGth previous record."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 (forms-jump-record (- forms--current-record (prefix-numeric-value arg)) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 (defun forms-jump-record (arg &optional relative)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 "Jump to a random record."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 (interactive "NRecord number: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 ;; Verify that the record number is within range.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 (if (or (> arg forms--total-records)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 (<= arg 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 ;; Don't give the message if just paging.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 (if (not relative)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 (message "Record number %d out of range 1..%d"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 arg forms--total-records))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 ;; Flush.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 (forms--checkmod)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 ;; Calculate displacement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 (let ((disp (- arg forms--current-record))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 (cur forms--current-record))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 ;; `forms--show-record' needs it now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 (setq forms--current-record arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 ;; Get the record and show it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 (forms--show-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 (set-buffer forms--file-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 ;; Move, and adjust the amount if needed (shouldn't happen).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 (if relative
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 (if (zerop disp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 (setq cur (+ cur disp (- (forward-line disp)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 (setq cur (+ cur disp (- (goto-line arg)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 (forms--get-record)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 ;; This shouldn't happen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 (if (/= forms--current-record cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 (setq forms--current-record cur)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 (message "Stuck at record %d" cur))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 (defun forms-first-record ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 "Jump to first record."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 (forms-jump-record 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 (defun forms-last-record ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 "Jump to last record.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 As a side effect: re-calculates the number of records in the data file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 (let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 ((numrec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 (set-buffer forms--file-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 (count-lines (point-min) (point-max)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 (if (= numrec forms--total-records)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 (setq forms--total-records numrec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 (message "Warning: number of records changed to %d" forms--total-records)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 (forms-jump-record forms--total-records))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 ;;; Other commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 (defun forms-toggle-read-only (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 "Toggles read-only mode of a forms mode buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 With an argument, enables read-only mode if the argument is positive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 Otherwise enables edit mode if the visited file is writeable."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 (if (if arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 ;; Negative arg means switch it off.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 (<= (prefix-numeric-value arg) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 ;; No arg means toggle.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 forms-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 ;; Enable edit mode, if possible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 (let ((ro forms-read-only))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 (if (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 (set-buffer forms--file-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 (setq forms-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 (message "No write access to \"%s\"" forms-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 (beep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 (setq forms-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 (if (equal ro forms-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 (forms-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 ;; Enable view mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 (if forms-read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 (forms--checkmod) ; sync
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 (setq forms-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 (forms-mode))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 ;; Sample:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 ;; (defun my-new-record-filter (the-fields)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 ;; ;; numbers are relative to 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 ;; (aset the-fields 4 (current-time-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 ;; (aset the-fields 6 (user-login-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 ;; the-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 ;; (setq forms-new-record-filter 'my-new-record-filter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 (defun forms-insert-record (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 "Create a new record before the current one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 With ARG: store the record after the current one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 If `forms-new-record-filter' contains the name of a function,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 it is called to fill (some of) the fields with default values."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 (if forms-read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 (error ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 (let ((ln (if arg (1+ forms--current-record) forms--current-record))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 the-list the-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 (forms--checkmod)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 (if forms-new-record-filter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 ;; As a service to the user, we add a zeroth element so she
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 ;; can use the same indices as in the forms definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 (let ((the-fields (make-vector (1+ forms-number-of-fields) "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 (setq the-fields (funcall forms-new-record-filter the-fields))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 (setq the-list (cdr (append the-fields nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 (setq the-list (make-list forms-number-of-fields "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 (setq the-record
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 'identity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 the-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 forms-field-sep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 (set-buffer forms--file-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 (goto-line ln)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 (open-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 (insert the-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 (beginning-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 (setq forms--current-record ln))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 (setq forms--total-records (1+ forms--total-records))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 (forms-jump-record forms--current-record))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 (defun forms-delete-record (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 "Deletes a record. With a prefix argument: don't ask."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 (if forms-read-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 (error ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 (forms--checkmod)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 (if (or arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 (y-or-n-p "Really delete this record? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 (let ((ln forms--current-record))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 (set-buffer forms--file-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 (goto-line ln)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 ;; Use delete-region instead of kill-region, to avoid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 ;; adding junk to the kill-ring.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 (delete-region (progn (beginning-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 (progn (beginning-of-line 2) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 (setq forms--total-records (1- forms--total-records))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 (if (> forms--current-record forms--total-records)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 (setq forms--current-record forms--total-records))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 (forms-jump-record forms--current-record)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 (message ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 (defun forms-search (regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 "Search REGEXP in file buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 (list (read-string (concat "Search for"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 (if forms--search-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 (concat " ("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 forms--search-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 ")"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 ": "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 (if (equal "" regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 (setq regexp forms--search-regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 (forms--checkmod)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 (let (the-line the-record here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 (fld-sep forms-field-sep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 (if (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 (set-buffer forms--file-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 (setq here (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 (if (null (re-search-forward regexp nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 (goto-char here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 (message (concat "\"" regexp "\" not found."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 (setq the-record (forms--get-record))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 (setq the-line (1+ (count-lines (point-min) (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 (setq forms--current-record the-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 (forms--show-record the-record)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 (re-search-forward regexp nil t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 (setq forms--search-regexp regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 (defun forms-save-buffer (&optional args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 "Forms mode replacement for save-buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 It saves the data buffer instead of the forms buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 Calls `forms-write-file-filter' before writing out the data."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 (forms--checkmod)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 (let ((read-file-filter forms-read-file-filter))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 (set-buffer forms--file-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 (let ((inhibit-read-only t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 (save-buffer args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 (if read-file-filter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 (run-hooks 'read-file-filter))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 (set-buffer-modified-p nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 (defun forms--revert-buffer (&optional arg noconfirm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 "Reverts current form to un-modified."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 (if (or noconfirm
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 (yes-or-no-p "Revert form to unmodified? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 (forms-jump-record forms--current-record))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 (defun forms-next-field (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 "Jump to ARG-th next field."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 (let ((i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 (here (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 (cnt 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 (if (zerop arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 (setq cnt 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 (setq cnt (+ cnt arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 (if (catch 'done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 (while (< i (length forms--markers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 (if (or (null (setq there (aref forms--markers i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 (<= there here))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 (if (<= (setq cnt (1- cnt)) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 (goto-char there)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 (throw 'done t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 (setq i (1+ i))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 (goto-char (aref forms--markers 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 (defun forms-prev-field (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 "Jump to ARG-th previous field."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 (let ((i (length forms--markers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 (here (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 there
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 (cnt 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 (if (zerop arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 (setq cnt 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 (setq cnt (+ cnt arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 (if (catch 'done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 (while (> i 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 (setq i ( 1- i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 (if (or (null (setq there (aref forms--markers i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 (>= there here))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 (if (<= (setq cnt (1- cnt)) 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 (goto-char there)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 (throw 'done t))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 (goto-char (aref forms--markers (1- (length forms--markers)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 ;;; Special service
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 (defun forms-enumerate (the-fields)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 "Take a quoted list of symbols, and set their values to sequential numbers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 The first symbol gets number 1, the second 2 and so on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 It returns the higest number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 Usage: (setq forms-number-of-fields
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 (forms-enumerate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 '(field1 field2 field2 ...)))"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 (let ((the-index 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 (while the-fields
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 (setq the-index (1+ the-index))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 (let ((el (car-safe the-fields)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 (setq the-fields (cdr-safe the-fields))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 (set el the-index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 the-index))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 ;;; Debugging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 (defvar forms--debug nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 "*Enables forms-mode debugging if not nil.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 (defun forms--debug (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 "Internal debugging routine."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 (if forms--debug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 (let ((ret nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 (while args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 (let ((el (car-safe args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 (setq args (cdr-safe args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 (if (stringp el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 (setq ret (concat ret el))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 (setq ret (concat ret (prin1-to-string el) " = "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 (if (boundp el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 (let ((vel (eval el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 (setq ret (concat ret (prin1-to-string vel) "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 (setq ret (concat ret "<unbound>" "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 (if (fboundp el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 (setq ret (concat ret (prin1-to-string (symbol-function el))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 "\n"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 (set-buffer (get-buffer-create "*forms-mode debug*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 (if (zerop (buffer-size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 (emacs-lisp-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 (insert ret)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 ;;; forms.el ends here.