;;; forms.el --- Forms mode: edit a file as a form to fill in
-;; Copyright (C) 1991, 1994, 1995, 1996, 1997, 2003 Free Software Foundation, Inc.
+;; Copyright (C) 1991, 1994-1997, 2001-2012 Free Software Foundation, Inc.
;; Author: Johan Vromans <jvromans@squirrel.nl>
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
-;; Visit a file using a form.
+;; Visit a file using a form. See etc/forms for examples.
;;
;; === Naming conventions
;;
;;; Optional variables with default values.
(defcustom forms-check-number-of-fields t
- "*If non-nil, warn about records with wrong number of fields."
+ "If non-nil, warn about records with wrong number of fields."
:group 'forms
:type 'boolean)
If not nil: use this character to separate multi-line fields (default C-k).")
(defcustom forms-forms-scroll nil
- "*Non-nil means replace scroll-up/down commands in Forms mode.
+ "Non-nil means replace scroll-up/down commands in Forms mode.
The replacement commands performs forms-next/prev-record."
:group 'forms
:type 'boolean)
(defcustom forms-forms-jump nil
- "*Non-nil means redefine beginning/end-of-buffer in Forms mode.
+ "Non-nil means redefine beginning/end-of-buffer in Forms mode.
The replacement commands performs forms-first/last-record."
:group 'forms
:type 'boolean)
The contents may NOT be modified.")
(defcustom forms-use-text-properties t
- "*Non-nil means: use text properties.
+ "Non-nil means: use text properties.
Defaults to t if this Emacs is capable of handling text properties."
:group 'forms
:type 'boolean)
(defcustom forms-insert-after nil
- "*Non-nil means: inserts of new records go after current record.
+ "Non-nil means: inserts of new records go after current record.
Also, initial position is at last record."
:group 'forms
:type 'boolean)
(if (or (eq enable-local-eval t)
(yes-or-no-p
(concat "Evaluate lisp code in buffer "
- (buffer-name) " to display forms ")))
+ (buffer-name) " to display forms? ")))
(eval-buffer)
(error "`enable-local-eval' inhibits buffer evaluation"))
(eq (length forms-multi-line) 1))
(if (string= forms-multi-line forms-field-sep)
(error (concat "Forms control file error: "
- "`forms-multi-line' is equal to 'forms-field-sep'")))
+ "`forms-multi-line' is equal to `forms-field-sep'")))
(error (concat "Forms control file error: "
"`forms-multi-line' must be nil or a one-character string"))))
(or (fboundp 'set-text-properties)
(error (concat "Forms control file error: "
"`forms-modified-record-filter' is not a function")))
- ;; The filters acces the contents of the forms using `forms-fields'.
+ ;; The filters access the contents of the forms using `forms-fields'.
(make-local-variable 'forms-fields)
;; Dynamic text support.
(forms-first-record))
)
- ;; user customising
+ ;; user customizing
;;(message "forms: proceeding setup (user hooks)...")
- (run-hooks 'forms-mode-hook 'forms-mode-hooks)
+ (run-mode-hooks 'forms-mode-hook 'forms-mode-hooks)
;;(message "forms: setting up... done.")
;; be helpful
(defvar forms--iif-properties nil
"Original properties of the character being overridden.")
-(defun forms--iif-hook (begin end)
+(defun forms--iif-hook (_begin _end)
"`insert-in-front-hooks' function for read-only segments."
;; Note start location. By making it a marker that points one
(setq forms--field nil)))
))
\f
+(defvar read-file-filter) ; bound in forms--intuit-from-file
+
(defun forms--intuit-from-file ()
"Get number of fields and a default form using the data file."
;; Need a file to do this.
(if (not (file-exists-p forms-file))
- (error "Need existing file or explicit 'forms-number-of-records'")
+ (error "Need existing file or explicit `forms-number-of-fields'")
;; Visit the file and extract the first record.
(setq forms--file-buffer (find-file-noselect forms-file))
)
(defun forms--mode-menu-ro (map)
-;;; Menu initialisation
+;;; Menu initialization
; (define-key map [menu-bar] (make-sparse-keymap))
(define-key map [menu-bar forms]
(cons "Forms" (make-sparse-keymap "Forms")))
(put 'forms-delete-record 'menu-enable '(not forms-read-only))
)
(defun forms--mode-menu-edit (map)
-;;; Menu initialisation
+;;; Menu initialization
; (define-key map [menu-bar] (make-sparse-keymap))
(define-key map [menu-bar forms]
(cons "Forms" (make-sparse-keymap "Forms")))
(if forms-forms-scroll
(progn
(local-set-key [remap scroll-up] 'forms-next-record)
- (local-set-key [remap scroll-down] 'forms-prev-record)))
+ (local-set-key [remap scroll-down] 'forms-prev-record)
+ (local-set-key [remap scroll-up-command] 'forms-next-record)
+ (local-set-key [remap scroll-down-command] 'forms-prev-record)))
;;
;; beginning-of-buffer -> forms-first-record
;; end-of-buffer -> forms-end-record
(forms-jump-record cur))
t)
-(defun forms--revert-buffer (&optional arg noconfirm)
+(defun forms--revert-buffer (&optional _arg noconfirm)
"Reverts current form to un-modified."
(interactive "P")
(if (or noconfirm
(goto-char (aref forms--markers (1- (length forms--markers)))))))
(defun forms-print ()
- "Send the records to the printer with 'print-buffer', one record per page."
+ "Send the records to the printer with `print-buffer', one record per page."
(interactive)
(let ((inhibit-read-only t)
(save-record forms--current-record)
\f
;;; Debugging
-(defvar forms--debug nil
- "*Enables forms-mode debugging if not nil.")
+(defcustom forms--debug nil
+ "If non-nil, enable Forms mode debugging."
+ :type 'boolean
+ :group 'forms)
(defun forms--debug (&rest args)
"Internal debugging routine."
(goto-char (point-max))
(insert ret)))))
-;;; arch-tag: 4a6695c7-d47a-4a21-809b-5cec7f8ec7a1
;;; forms.el ends here