aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1999-05-01 01:11:12 +0000
committerKarl Heuer1999-05-01 01:11:12 +0000
commit4e0a3e27236f937896764a8d060ee7f443ac6166 (patch)
treee1fb61fdaae61eff0d2609545141bf04af637fc8
parentf6ad5a4bc83a0b1739d5db6e3eaff5ccb9083e37 (diff)
downloademacs-4e0a3e27236f937896764a8d060ee7f443ac6166.tar.gz
emacs-4e0a3e27236f937896764a8d060ee7f443ac6166.zip
(forms-mode): Don't call forms-first-record or
forms-last-record if the data file has zero records.
-rw-r--r--lisp/forms.el61
1 files changed, 33 insertions, 28 deletions
diff --git a/lisp/forms.el b/lisp/forms.el
index df683ae1363..a251c306c05 100644
--- a/lisp/forms.el
+++ b/lisp/forms.el
@@ -54,11 +54,11 @@
54;; The second file holds the actual data. The buffer of this file 54;; The second file holds the actual data. The buffer of this file
55;; will be buried, for it is never accessed directly. 55;; will be buried, for it is never accessed directly.
56;; 56;;
57;; Forms mode is invoked using M-x forms-find-file control-file . 57;; Forms mode is invoked using M-x `forms-find-file' control-file.
58;; Alternatively `forms-find-file-other-window' can be used. 58;; Alternatively `forms-find-file-other-window' can be used.
59;; 59;;
60;; You may also visit the control file, and switch to forms mode by hand 60;; You may also visit the control file, and switch to forms mode by hand
61;; with M-x forms-mode . 61;; with M-x `forms-mode'.
62;; 62;;
63;; Automatic mode switching is supported if you specify 63;; Automatic mode switching is supported if you specify
64;; "-*- forms -*-" in the first line of the control file. 64;; "-*- forms -*-" in the first line of the control file.
@@ -110,14 +110,14 @@
110;; of fields specified by `forms-number-of-fields'. 110;; of fields specified by `forms-number-of-fields'.
111;; 111;;
112;; forms-multi-line [string, default "^K"] 112;; forms-multi-line [string, default "^K"]
113;; If non-null the records of the data file may 113;; If non-null, the records of the data file may
114;; contain fields that can span multiple lines in 114;; contain fields that can span multiple lines in
115;; the form. 115;; the form.
116;; This variable denotes the separator character 116;; This variable denotes the separator string
117;; to be used for this purpose. Upon display, all 117;; to be used for this purpose. Upon display, all
118;; occurrences of this character are translated 118;; occurrences of this string are translated
119;; to newlines. Upon storage they are translated 119;; to newlines. Upon storage they are translated
120;; back to the separator character. 120;; back to the separator string.
121;; 121;;
122;; forms-forms-scroll [bool, default nil] 122;; forms-forms-scroll [bool, default nil]
123;; Non-nil means: rebind locally the commands that 123;; Non-nil means: rebind locally the commands that
@@ -125,12 +125,17 @@
125;; `forms-next-field' resp. `forms-prev-field'. 125;; `forms-next-field' resp. `forms-prev-field'.
126;; 126;;
127;; forms-forms-jump [bool, default nil] 127;; forms-forms-jump [bool, default nil]
128;; Non-nil means: rebind locally the commands that 128;; Non-nil means: rebind locally the commands
129;; `beginning-of-buffer' and `end-of-buffer' to
130;; perform, respectively, `forms-first-record' and
131;; `forms-last-record' instead.
129;; 132;;
130;; forms-insert-after [bool, default nil] 133;; forms-insert-after [bool, default nil]
131;; Non-nil means: inserts of new records go after 134;; Non-nil means: insertions of new records go after
132;; current record, also initial position is at last 135;; current record, also initial position is at the
133;; record. 136;; last record. The default is to insert before the
137;; current record and the initial position is at the
138;; first record.
134;; 139;;
135;; forms-read-file-filter [symbol, default nil] 140;; forms-read-file-filter [symbol, default nil]
136;; If not nil: this should be the name of a 141;; If not nil: this should be the name of a
@@ -166,14 +171,14 @@
166;; distinct face, if possible. 171;; distinct face, if possible.
167;; As of emacs 19.29, the `intangible' text property 172;; As of emacs 19.29, the `intangible' text property
168;; is used to prevent moving into read-only fields. 173;; is used to prevent moving into read-only fields.
169;; This variable defaults to t if running Emacs 19 174;; This variable defaults to t if running Emacs 19 or
170;; with text properties. 175;; later with text properties.
171;; The default face to show read-write fields is 176;; The default face to show read-write fields is
172;; copied from face `region'. 177;; copied from face `region'.
173;; 178;;
174;; forms-ro-face [symbol, default 'default] 179;; forms-ro-face [symbol, default 'default]
175;; This is the face that is used to show 180;; This is the face that is used to show
176;; read-only text on the screen.If used, this 181;; read-only text on the screen. If used, this
177;; variable should be set to a symbol that is a 182;; variable should be set to a symbol that is a
178;; valid face. 183;; valid face.
179;; E.g. 184;; E.g.
@@ -187,7 +192,7 @@
187;; After evaluating the control file, its buffer is cleared and used 192;; After evaluating the control file, its buffer is cleared and used
188;; for further processing. 193;; for further processing.
189;; The data file (as designated by `forms-file') is visited in a buffer 194;; The data file (as designated by `forms-file') is visited in a buffer
190;; `forms--file-buffer' which will not normally be shown. 195;; `forms--file-buffer' which normally will not be shown.
191;; Great malfunctioning may be expected if this file/buffer is modified 196;; Great malfunctioning may be expected if this file/buffer is modified
192;; outside of this package while it is being visited! 197;; outside of this package while it is being visited!
193;; 198;;
@@ -208,7 +213,7 @@
208;; 213;;
209;; Two exit functions exist: `forms-exit' and `forms-exit-no-save'. 214;; Two exit functions exist: `forms-exit' and `forms-exit-no-save'.
210;; `forms-exit' saves the data to the file, if modified. 215;; `forms-exit' saves the data to the file, if modified.
211;; `forms-exit-no-save` does not. However, if `forms-exit-no-save' 216;; `forms-exit-no-save' does not. However, if `forms-exit-no-save'
212;; is executed and the file buffer has been modified, Emacs will ask 217;; is executed and the file buffer has been modified, Emacs will ask
213;; questions anyway. 218;; questions anyway.
214;; 219;;
@@ -222,12 +227,12 @@
222;; switching edit <-> view mode v.v. 227;; switching edit <-> view mode v.v.
223;; jumping from field to field 228;; jumping from field to field
224;; 229;;
225;; As an documented side-effect: jumping to the last record in the 230;; As a documented side-effect: jumping to the last record in the
226;; file (using forms-last-record) will adjust forms--total-records if 231;; file (using forms-last-record) will adjust forms--total-records if
227;; needed. 232;; needed.
228;; 233;;
229;; The forms buffer can be in on eof two modes: edit mode or view 234;; The forms buffer can be in one of two modes: edit mode or view
230;; mode. View mode is a read-only mode, you cannot modify the 235;; mode. View mode is a read-only mode, whereby you cannot modify the
231;; contents of the buffer. 236;; contents of the buffer.
232;; 237;;
233;; Edit mode commands: 238;; Edit mode commands:
@@ -252,7 +257,7 @@
252;; SPC forms-next-record 257;; SPC forms-next-record
253;; DEL forms-prev-record 258;; DEL forms-prev-record
254;; ? describe-mode 259;; ? describe-mode
255;; \C-q forms-toggle-read-only 260;; \C-q forms-toggle-read-only
256;; l forms-jump-record 261;; l forms-jump-record
257;; n forms-next-record 262;; n forms-next-record
258;; p forms-prev-record 263;; p forms-prev-record
@@ -270,18 +275,18 @@
270;; [begin] forms-first-record 275;; [begin] forms-first-record
271;; [end] forms-last-record 276;; [end] forms-last-record
272;; [S-TAB] forms-prev-field 277;; [S-TAB] forms-prev-field
273;; [backtab] forms-prev-field 278;; [backtab] forms-prev-field
274;; 279;;
275;; For convenience, TAB is always bound to `forms-next-field', so you 280;; For convenience, TAB is always bound to `forms-next-field', so you
276;; don't need the C-c prefix for this command. 281;; don't need the C-c prefix for this command.
277;; 282;;
278;; As mentioned above (see `forms-forms-scroll' and `forms-forms-jump') 283;; As mentioned above (see `forms-forms-scroll' and `forms-forms-jump'),
279;; the bindings of standard functions `scroll-up', `scroll-down', 284;; the bindings of standard functions `scroll-up', `scroll-down',
280;; `beginning-of-buffer' and `end-of-buffer' can be locally replaced with 285;; `beginning-of-buffer' and `end-of-buffer' can be locally replaced with
281;; forms mode functions next/prev record and first/last 286;; forms mode functions next/prev record and first/last
282;; record. 287;; record.
283;; 288;;
284;; `local-write-file hook' is defined to save the actual data file 289;; `local-write-file-hooks' is defined to save the actual data file
285;; instead of the buffer data, `revert-file-hook' is defined to 290;; instead of the buffer data, `revert-file-hook' is defined to
286;; revert a forms to original. 291;; revert a forms to original.
287 292
@@ -296,10 +301,10 @@
296(provide 'forms) ;;; official 301(provide 'forms) ;;; official
297(provide 'forms-mode) ;;; for compatibility 302(provide 'forms-mode) ;;; for compatibility
298 303
299(defconst forms-version (substring "$Revision: 2.36 $" 11 -2) 304(defconst forms-version (substring "$Revision: 2.37 $" 11 -2)
300 "The version number of forms-mode (as string). The complete RCS id is: 305 "The version number of forms-mode (as string). The complete RCS id is:
301 306
302 $Id: forms.el,v 2.36 1998/10/06 23:19:46 kwzh Exp rms $") 307 $Id: forms.el,v 2.37 1999/01/15 16:19:53 rms Exp kwzh $")
303 308
304(defcustom forms-mode-hooks nil 309(defcustom forms-mode-hooks nil
305 "Hook functions to be run upon entering Forms mode." 310 "Hook functions to be run upon entering Forms mode."
@@ -711,11 +716,11 @@ Commands: Equivalent keys in read-only mode:
711 (if (< forms--current-record 1) 716 (if (< forms--current-record 1)
712 (setq forms--current-record 1)) 717 (setq forms--current-record 1))
713 (forms-jump-record forms--current-record) 718 (forms-jump-record forms--current-record)
714 )
715 719
716 (if forms-insert-after 720 (if forms-insert-after
717 (forms-last-record) 721 (forms-last-record)
718 (forms-first-record)) 722 (forms-first-record))
723 )
719 724
720 ;; user customising 725 ;; user customising
721 ;;(message "forms: proceeding setup (user hooks)...") 726 ;;(message "forms: proceeding setup (user hooks)...")