]> code.delx.au - gnu-emacs/blobdiff - lisp/forms.el
(vc-annotate-display): Delete old overlays. Fix check for major-mode.
[gnu-emacs] / lisp / forms.el
index 3abb15c8c20dc4567a99a6330d7d8dc9f0603d98..df683ae13639aa936ea8aedee5c27ed60b9bb0be 100644 (file)
 \f
 ;;; Code:
 
+(defgroup forms nil
+  "Edit a file as a form to fill in."
+  :group 'data)
+
 ;;; Global variables and constants:
 
 (provide 'forms)                       ;;; official
 (provide 'forms-mode)                  ;;; for compatibility
 
-(defconst forms-version (substring "$Revision: 2.30 $" 11 -2)
+(defconst forms-version (substring "$Revision: 2.36 $" 11 -2)
   "The version number of forms-mode (as string).  The complete RCS id is:
 
-  $Id: forms.el,v 2.30 1997/06/10 18:32:33 kwzh Exp rms $")
+  $Id: forms.el,v 2.36 1998/10/06 23:19:46 kwzh Exp rms $")
 
-(defvar forms-mode-hooks nil
-  "Hook functions to be run upon entering Forms mode.")
+(defcustom forms-mode-hooks nil
+  "Hook functions to be run upon entering Forms mode."
+  :group 'forms
+  :type 'function)
 \f
 ;;; Mandatory variables - must be set by evaluating the control file.
 
 \f
 ;;; Optional variables with default values.
 
-(defvar forms-check-number-of-fields t
-  "*If non-nil, warn about records with wrong number of fields.")
+(defcustom forms-check-number-of-fields t
+  "*If non-nil, warn about records with wrong number of fields."
+  :group 'forms
+  :type 'boolean)
 
 (defvar forms-field-sep "\t"
   "Field separator character (default TAB).")
 
 (defvar forms-read-only nil
   "Non-nil means: visit the file in view (read-only) mode.
-\(Defaults to the write access on the data file).")
+This is set automatically if the file permissions don't let you write it.")
 
-(defvar forms-multi-line "\C-k"
-  "If not nil: use this character to separate multi-line fields (default C-k).")
+(defvar forms-multi-line "\C-k" "\
+If not nil: use this character to separate multi-line fields (default C-k).")
 
-(defvar forms-forms-scroll nil
+(defcustom forms-forms-scroll nil
   "*Non-nil means replace scroll-up/down commands in Forms mode.
-The replacement commands performs forms-next/prev-record.")
+The replacement commands performs forms-next/prev-record."
+  :group 'forms
+  :type 'boolean)
 
-(defvar forms-forms-jump nil
+(defcustom forms-forms-jump nil
   "*Non-nil means redefine beginning/end-of-buffer in Forms mode.
-The replacement commands performs forms-first/last-record.")
+The replacement commands performs forms-first/last-record."
+  :group 'forms
+  :type 'boolean)
 
 (defvar forms-read-file-filter nil
   "The name of a function that is called after reading the data file.
@@ -341,7 +353,7 @@ suitable for forms processing.")
 
 (defvar forms-write-file-filter nil
   "The name of a function that is called before writing the data file.
-This can be used to undo the effects of form-read-file-hook.")
+This can be used to undo the effects of `form-read-file-hook'.")
 
 (defvar forms-new-record-filter nil
   "The name of a function that is called when a new record is created.")
@@ -354,19 +366,27 @@ This can be used to undo the effects of form-read-file-hook.")
 This variable is for use by the filter routines only. 
 The contents may NOT be modified.")
 
-(defvar forms-use-text-properties (fboundp 'set-text-properties)
-  "*Non-nil means: use emacs-19 text properties.
-Defaults to t if this emacs is capable of handling text properties.")
+(defcustom forms-use-text-properties t
+  "*Non-nil means: use text properties.
+Defaults to t if this Emacs is capable of handling text properties."
+  :group 'forms
+  :type 'boolean)
 
-(defvar forms-insert-after nil
+(defcustom forms-insert-after nil
   "*Non-nil means: inserts of new records go after current record.
-Also, initial position is at last record.")
-
-(defvar forms-ro-face 'default
-  "The face (a symbol) that is used to display read-only text on the screen.")
-
-(defvar forms-rw-face 'region
-  "The face (a symbol) that is used to display read-write text on the screen.")
+Also, initial position is at last record."
+  :group 'forms
+  :type 'boolean)
+
+(defcustom forms-ro-face 'default
+  "The face (a symbol) that is used to display read-only text on the screen."
+  :group 'forms
+  :type 'face)
+
+(defcustom forms-rw-face 'region
+  "The face (a symbol) that is used to display read-write text on the screen."
+  :group 'forms
+  :type 'face)
 \f
 ;;; Internal variables.
 
@@ -426,19 +446,19 @@ Also, initial position is at last record.")
 
 Commands:                        Equivalent keys in read-only mode:
  TAB            forms-next-field          TAB
\\C-c TAB       forms-next-field          
\\C-c <         forms-first-record         <
\\C-c >         forms-last-record          >
\\C-c ?         describe-mode              ?
\\C-c \\C-k      forms-delete-record
\\C-c \\C-q      forms-toggle-read-only     q
\\C-c \\C-o      forms-insert-record
\\C-c \\C-l      forms-jump-record          l
\\C-c \\C-n      forms-next-record          n
\\C-c \\C-p      forms-prev-record          p
\\C-c \\C-r      forms-search-reverse       r
\\C-c \\C-s      forms-search-forward       s
\\C-c \\C-x      forms-exit                 x
C-c TAB        forms-next-field          
C-c <          forms-first-record         <
C-c >          forms-last-record          >
C-c ?          describe-mode              ?
C-c C-k        forms-delete-record
C-c C-q        forms-toggle-read-only     q
C-c C-o        forms-insert-record
C-c C-l        forms-jump-record          l
C-c C-n        forms-next-record          n
C-c C-p        forms-prev-record          p
C-c C-r        forms-search-reverse       r
C-c C-s        forms-search-forward       s
C-c C-x        forms-exit                 x
 "
   (interactive)
 
@@ -569,7 +589,7 @@ Commands:                        Equivalent keys in read-only mode:
        ;; Dynamic text support.
        (make-local-variable 'forms--dynamic-text)
 
-       ;; Prevent accidental overwrite of the control file and autosave.
+       ;; Prevent accidental overwrite of the control file and auto-save.
        (set-visited-file-name nil)
 
        ;; Prepare this buffer for further processing.
@@ -1525,7 +1545,8 @@ Commands:                        Equivalent keys in read-only mode:
   (set-buffer-modified-p nil)
   (setq buffer-read-only forms-read-only)
   (setq mode-line-process
-       (concat " " forms--current-record "/" forms--total-records)))
+       (concat " " (int-to-string forms--current-record)
+               "/" (int-to-string forms--total-records))))
 
 (defun forms--parse-form ()
   "Parse contents of form into list of strings."
@@ -1981,6 +2002,7 @@ after writing out the data."
   (interactive)
   (let ((inhibit-read-only t)
        (save-record forms--current-record)
+       (total-nb-records forms--total-records)
        (nb-record 1)
        (record nil))
     (while (<= nb-record forms--total-records)
@@ -1991,7 +2013,7 @@ after writing out the data."
        (goto-char (buffer-end 1))
        (insert record)
        (setq buffer-read-only nil)
-       (if (< nb-record forms--total-records)
+       (if (< nb-record total-nb-records)
            (insert "\n\f\n")))
       (setq nb-record (1+ nb-record)))
     (save-excursion