diff options
| author | Juanma Barranquero | 2003-02-04 11:26:42 +0000 |
|---|---|---|
| committer | Juanma Barranquero | 2003-02-04 11:26:42 +0000 |
| commit | 71296446d3cec5bb2a27bc5ad6da574df38d0ec8 (patch) | |
| tree | 0204c3c252547a44e2404959409034406f7680cd /lisp/forms.el | |
| parent | 693ff6134cb2ec65c7d188696f012662edadfbf0 (diff) | |
| download | emacs-71296446d3cec5bb2a27bc5ad6da574df38d0ec8.tar.gz emacs-71296446d3cec5bb2a27bc5ad6da574df38d0ec8.zip | |
Trailing whitespace deleted.
Diffstat (limited to 'lisp/forms.el')
| -rw-r--r-- | lisp/forms.el | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/lisp/forms.el b/lisp/forms.el index 975b030ad56..c3cffa3d4e3 100644 --- a/lisp/forms.el +++ b/lisp/forms.el | |||
| @@ -31,9 +31,9 @@ | |||
| 31 | ;; Names which start with 'forms--' are intended for internal use, and | 31 | ;; Names which start with 'forms--' are intended for internal use, and |
| 32 | ;; should *NOT* be used from the outside. | 32 | ;; should *NOT* be used from the outside. |
| 33 | ;; | 33 | ;; |
| 34 | ;; All variables are buffer-local, to enable multiple forms visits | 34 | ;; All variables are buffer-local, to enable multiple forms visits |
| 35 | ;; simultaneously. | 35 | ;; simultaneously. |
| 36 | ;; Variable `forms--mode-setup' is local to *ALL* buffers, for it | 36 | ;; Variable `forms--mode-setup' is local to *ALL* buffers, for it |
| 37 | ;; controls if forms-mode has been enabled in a buffer. | 37 | ;; controls if forms-mode has been enabled in a buffer. |
| 38 | ;; | 38 | ;; |
| 39 | ;; === How it works === | 39 | ;; === How it works === |
| @@ -60,9 +60,9 @@ | |||
| 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. |
| 65 | ;; | 65 | ;; |
| 66 | ;; The control file is visited, evaluated using `eval-current-buffer', | 66 | ;; The control file is visited, evaluated using `eval-current-buffer', |
| 67 | ;; and should set at least the following variables: | 67 | ;; and should set at least the following variables: |
| 68 | ;; | 68 | ;; |
| @@ -79,17 +79,17 @@ | |||
| 79 | ;; | 79 | ;; |
| 80 | ;; - a string, e.g. "hello". The string is inserted in the forms | 80 | ;; - a string, e.g. "hello". The string is inserted in the forms |
| 81 | ;; "as is". | 81 | ;; "as is". |
| 82 | ;; | 82 | ;; |
| 83 | ;; - an integer, denoting a field number. | 83 | ;; - an integer, denoting a field number. |
| 84 | ;; The contents of this field are inserted at this point. | 84 | ;; The contents of this field are inserted at this point. |
| 85 | ;; Fields are numbered starting with number one. | 85 | ;; Fields are numbered starting with number one. |
| 86 | ;; | 86 | ;; |
| 87 | ;; - a function call, e.g. (insert "text"). | 87 | ;; - a function call, e.g. (insert "text"). |
| 88 | ;; This function call is dynamically evaluated and should return a | 88 | ;; This function call is dynamically evaluated and should return a |
| 89 | ;; string. It should *NOT* have side-effects on the forms being | 89 | ;; string. It should *NOT* have side-effects on the forms being |
| 90 | ;; constructed. The current fields are available to the function | 90 | ;; constructed. The current fields are available to the function |
| 91 | ;; in the variable `forms-fields', they should *NOT* be modified. | 91 | ;; in the variable `forms-fields', they should *NOT* be modified. |
| 92 | ;; | 92 | ;; |
| 93 | ;; - a lisp symbol, that must evaluate to one of the above. | 93 | ;; - a lisp symbol, that must evaluate to one of the above. |
| 94 | ;; | 94 | ;; |
| 95 | ;; Optional variables which may be set in the control file: | 95 | ;; Optional variables which may be set in the control file: |
| @@ -102,7 +102,7 @@ | |||
| 102 | ;; Non-nil means that the data file is visited | 102 | ;; Non-nil means that the data file is visited |
| 103 | ;; read-only (view mode) as opposed to edit mode. | 103 | ;; read-only (view mode) as opposed to edit mode. |
| 104 | ;; If no write access to the data file is | 104 | ;; If no write access to the data file is |
| 105 | ;; possible, view mode is enforced. | 105 | ;; possible, view mode is enforced. |
| 106 | ;; | 106 | ;; |
| 107 | ;; forms-check-number-of-fields [bool, default t] | 107 | ;; forms-check-number-of-fields [bool, default t] |
| 108 | ;; If non-nil, a warning will be issued whenever | 108 | ;; If non-nil, a warning will be issued whenever |
| @@ -138,26 +138,26 @@ | |||
| 138 | ;; first record. | 138 | ;; first record. |
| 139 | ;; | 139 | ;; |
| 140 | ;; forms-read-file-filter [symbol, default nil] | 140 | ;; forms-read-file-filter [symbol, default nil] |
| 141 | ;; If not nil: this should be the name of a | 141 | ;; If not nil: this should be the name of a |
| 142 | ;; function that is called after the forms data file | 142 | ;; function that is called after the forms data file |
| 143 | ;; has been read. It can be used to transform | 143 | ;; has been read. It can be used to transform |
| 144 | ;; the contents of the file into a format more suitable | 144 | ;; the contents of the file into a format more suitable |
| 145 | ;; for forms-mode processing. | 145 | ;; for forms-mode processing. |
| 146 | ;; | 146 | ;; |
| 147 | ;; forms-write-file-filter [symbol, default nil] | 147 | ;; forms-write-file-filter [symbol, default nil] |
| 148 | ;; If not nil: this should be the name of a | 148 | ;; If not nil: this should be the name of a |
| 149 | ;; function that is called before the forms data file | 149 | ;; function that is called before the forms data file |
| 150 | ;; is written (saved) to disk. It can be used to undo | 150 | ;; is written (saved) to disk. It can be used to undo |
| 151 | ;; the effects of `forms-read-file-filter', if any. | 151 | ;; the effects of `forms-read-file-filter', if any. |
| 152 | ;; | 152 | ;; |
| 153 | ;; forms-new-record-filter [symbol, default nil] | 153 | ;; forms-new-record-filter [symbol, default nil] |
| 154 | ;; If not nil: this should be the name of a | 154 | ;; If not nil: this should be the name of a |
| 155 | ;; function that is called when a new | 155 | ;; function that is called when a new |
| 156 | ;; record is created. It can be used to fill in | 156 | ;; record is created. It can be used to fill in |
| 157 | ;; the new record with default fields, for example. | 157 | ;; the new record with default fields, for example. |
| 158 | ;; | 158 | ;; |
| 159 | ;; forms-modified-record-filter [symbol, default nil] | 159 | ;; forms-modified-record-filter [symbol, default nil] |
| 160 | ;; If not nil: this should be the name of a | 160 | ;; If not nil: this should be the name of a |
| 161 | ;; function that is called when a record has | 161 | ;; function that is called when a record has |
| 162 | ;; been modified. It is called after the fields | 162 | ;; been modified. It is called after the fields |
| 163 | ;; are parsed. It can be used to register | 163 | ;; are parsed. It can be used to register |
| @@ -199,7 +199,7 @@ | |||
| 199 | ;; Normal operation is to transfer one line (record) from the data file, | 199 | ;; Normal operation is to transfer one line (record) from the data file, |
| 200 | ;; split it into fields (into `forms--the-record-list'), and display it | 200 | ;; split it into fields (into `forms--the-record-list'), and display it |
| 201 | ;; using the specs in `forms-format-list'. | 201 | ;; using the specs in `forms-format-list'. |
| 202 | ;; A format routine `forms--format' is built upon startup to format | 202 | ;; A format routine `forms--format' is built upon startup to format |
| 203 | ;; the records according to `forms-format-list'. | 203 | ;; the records according to `forms-format-list'. |
| 204 | ;; | 204 | ;; |
| 205 | ;; When a form is changed the record is updated as soon as this form | 205 | ;; When a form is changed the record is updated as soon as this form |
| @@ -236,7 +236,7 @@ | |||
| 236 | ;; contents of the buffer. | 236 | ;; contents of the buffer. |
| 237 | ;; | 237 | ;; |
| 238 | ;; Edit mode commands: | 238 | ;; Edit mode commands: |
| 239 | ;; | 239 | ;; |
| 240 | ;; TAB forms-next-field | 240 | ;; TAB forms-next-field |
| 241 | ;; \C-c TAB forms-next-field | 241 | ;; \C-c TAB forms-next-field |
| 242 | ;; \C-c < forms-first-record | 242 | ;; \C-c < forms-first-record |
| @@ -251,9 +251,9 @@ | |||
| 251 | ;; \C-c \C-r forms-search-backward | 251 | ;; \C-c \C-r forms-search-backward |
| 252 | ;; \C-c \C-s forms-search-forward | 252 | ;; \C-c \C-s forms-search-forward |
| 253 | ;; \C-c \C-x forms-exit | 253 | ;; \C-c \C-x forms-exit |
| 254 | ;; | 254 | ;; |
| 255 | ;; Read-only mode commands: | 255 | ;; Read-only mode commands: |
| 256 | ;; | 256 | ;; |
| 257 | ;; SPC forms-next-record | 257 | ;; SPC forms-next-record |
| 258 | ;; DEL forms-prev-record | 258 | ;; DEL forms-prev-record |
| 259 | ;; ? describe-mode | 259 | ;; ? describe-mode |
| @@ -264,12 +264,12 @@ | |||
| 264 | ;; r forms-search-backward | 264 | ;; r forms-search-backward |
| 265 | ;; s forms-search-forward | 265 | ;; s forms-search-forward |
| 266 | ;; x forms-exit | 266 | ;; x forms-exit |
| 267 | ;; | 267 | ;; |
| 268 | ;; Of course, it is also possible to use the \C-c prefix to obtain the | 268 | ;; Of course, it is also possible to use the \C-c prefix to obtain the |
| 269 | ;; same command keys as in edit mode. | 269 | ;; same command keys as in edit mode. |
| 270 | ;; | 270 | ;; |
| 271 | ;; The following bindings are available, independent of the mode: | 271 | ;; The following bindings are available, independent of the mode: |
| 272 | ;; | 272 | ;; |
| 273 | ;; [next] forms-next-record | 273 | ;; [next] forms-next-record |
| 274 | ;; [prior] forms-prev-record | 274 | ;; [prior] forms-prev-record |
| 275 | ;; [begin] forms-first-record | 275 | ;; [begin] forms-first-record |
| @@ -301,10 +301,10 @@ | |||
| 301 | (provide 'forms) ;;; official | 301 | (provide 'forms) ;;; official |
| 302 | (provide 'forms-mode) ;;; for compatibility | 302 | (provide 'forms-mode) ;;; for compatibility |
| 303 | 303 | ||
| 304 | (defconst forms-version (substring "$Revision: 2.43 $" 11 -2) | 304 | (defconst forms-version (substring "$Revision: 2.44 $" 11 -2) |
| 305 | "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: |
| 306 | 306 | ||
| 307 | $Id: forms.el,v 2.43 2002/05/18 08:04:49 pj Exp $") | 307 | $Id: forms.el,v 2.44 2003/01/12 20:47:48 schwab Exp $") |
| 308 | 308 | ||
| 309 | (defcustom forms-mode-hooks nil | 309 | (defcustom forms-mode-hooks nil |
| 310 | "Hook run upon entering Forms mode." | 310 | "Hook run upon entering Forms mode." |
| @@ -368,7 +368,7 @@ This can be used to undo the effects of `form-read-file-hook'.") | |||
| 368 | 368 | ||
| 369 | (defvar forms-fields nil | 369 | (defvar forms-fields nil |
| 370 | "List with fields of the current forms. First field has number 1. | 370 | "List with fields of the current forms. First field has number 1. |
| 371 | This variable is for use by the filter routines only. | 371 | This variable is for use by the filter routines only. |
| 372 | The contents may NOT be modified.") | 372 | The contents may NOT be modified.") |
| 373 | 373 | ||
| 374 | (defcustom forms-use-text-properties t | 374 | (defcustom forms-use-text-properties t |
| @@ -417,7 +417,7 @@ Also, initial position is at last record." | |||
| 417 | (defvar forms--dyntexts nil | 417 | (defvar forms--dyntexts nil |
| 418 | "Dynamic texts (resulting from function calls) on the screen.") | 418 | "Dynamic texts (resulting from function calls) on the screen.") |
| 419 | 419 | ||
| 420 | (defvar forms--the-record-list nil | 420 | (defvar forms--the-record-list nil |
| 421 | "List of strings of the current record, as parsed from the file.") | 421 | "List of strings of the current record, as parsed from the file.") |
| 422 | 422 | ||
| 423 | (defvar forms--search-regexp nil | 423 | (defvar forms--search-regexp nil |
| @@ -445,13 +445,13 @@ Also, initial position is at last record." | |||
| 445 | (defvar forms--rw-face nil | 445 | (defvar forms--rw-face nil |
| 446 | "Face used to represent read-write data on the screen.") | 446 | "Face used to represent read-write data on the screen.") |
| 447 | 447 | ||
| 448 | ;;;###autoload | 448 | ;;;###autoload |
| 449 | (defun forms-mode (&optional primary) | 449 | (defun forms-mode (&optional primary) |
| 450 | "Major mode to visit files in a field-structured manner using a form. | 450 | "Major mode to visit files in a field-structured manner using a form. |
| 451 | 451 | ||
| 452 | Commands: Equivalent keys in read-only mode: | 452 | Commands: Equivalent keys in read-only mode: |
| 453 | TAB forms-next-field TAB | 453 | TAB forms-next-field TAB |
| 454 | C-c TAB forms-next-field | 454 | C-c TAB forms-next-field |
| 455 | C-c < forms-first-record < | 455 | C-c < forms-first-record < |
| 456 | C-c > forms-last-record > | 456 | C-c > forms-last-record > |
| 457 | C-c ? describe-mode ? | 457 | C-c ? describe-mode ? |
| @@ -510,7 +510,7 @@ Commands: Equivalent keys in read-only mode: | |||
| 510 | (setq forms-new-record-filter nil) | 510 | (setq forms-new-record-filter nil) |
| 511 | (setq forms-modified-record-filter nil) | 511 | (setq forms-modified-record-filter nil) |
| 512 | 512 | ||
| 513 | ;; If running Emacs 19 under X, setup faces to show read-only and | 513 | ;; If running Emacs 19 under X, setup faces to show read-only and |
| 514 | ;; read-write fields. | 514 | ;; read-write fields. |
| 515 | (if (fboundp 'make-face) | 515 | (if (fboundp 'make-face) |
| 516 | (progn | 516 | (progn |
| @@ -521,7 +521,7 @@ Commands: Equivalent keys in read-only mode: | |||
| 521 | ;;(message "forms: processing control file...") | 521 | ;;(message "forms: processing control file...") |
| 522 | ;; If enable-local-eval is not set to t the user is asked first. | 522 | ;; If enable-local-eval is not set to t the user is asked first. |
| 523 | (if (or (eq enable-local-eval t) | 523 | (if (or (eq enable-local-eval t) |
| 524 | (yes-or-no-p | 524 | (yes-or-no-p |
| 525 | (concat "Evaluate lisp code in buffer " | 525 | (concat "Evaluate lisp code in buffer " |
| 526 | (buffer-name) " to display forms "))) | 526 | (buffer-name) " to display forms "))) |
| 527 | (eval-current-buffer) | 527 | (eval-current-buffer) |
| @@ -529,7 +529,7 @@ Commands: Equivalent keys in read-only mode: | |||
| 529 | 529 | ||
| 530 | ;; Check if the mandatory variables make sense. | 530 | ;; Check if the mandatory variables make sense. |
| 531 | (or forms-file | 531 | (or forms-file |
| 532 | (error (concat "Forms control file error: " | 532 | (error (concat "Forms control file error: " |
| 533 | "`forms-file' has not been set"))) | 533 | "`forms-file' has not been set"))) |
| 534 | 534 | ||
| 535 | ;; Check forms-field-sep first, since it can be needed to | 535 | ;; Check forms-field-sep first, since it can be needed to |
| @@ -554,13 +554,13 @@ Commands: Equivalent keys in read-only mode: | |||
| 554 | (if (and (stringp forms-multi-line) | 554 | (if (and (stringp forms-multi-line) |
| 555 | (eq (length forms-multi-line) 1)) | 555 | (eq (length forms-multi-line) 1)) |
| 556 | (if (string= forms-multi-line forms-field-sep) | 556 | (if (string= forms-multi-line forms-field-sep) |
| 557 | (error (concat "Forms control file error: " | 557 | (error (concat "Forms control file error: " |
| 558 | "`forms-multi-line' is equal to 'forms-field-sep'"))) | 558 | "`forms-multi-line' is equal to 'forms-field-sep'"))) |
| 559 | (error (concat "Forms control file error: " | 559 | (error (concat "Forms control file error: " |
| 560 | "`forms-multi-line' must be nil or a one-character string")))) | 560 | "`forms-multi-line' must be nil or a one-character string")))) |
| 561 | (or (fboundp 'set-text-properties) | 561 | (or (fboundp 'set-text-properties) |
| 562 | (setq forms-use-text-properties nil)) | 562 | (setq forms-use-text-properties nil)) |
| 563 | 563 | ||
| 564 | ;; Validate and process forms-format-list. | 564 | ;; Validate and process forms-format-list. |
| 565 | ;;(message "forms: pre-processing format list...") | 565 | ;;(message "forms: pre-processing format list...") |
| 566 | (make-local-variable 'forms--elements) | 566 | (make-local-variable 'forms--elements) |
| @@ -699,7 +699,7 @@ Commands: Equivalent keys in read-only mode: | |||
| 699 | (if (= forms--total-records 0) | 699 | (if (= forms--total-records 0) |
| 700 | ;;(message "forms: proceeding setup (new file)...") | 700 | ;;(message "forms: proceeding setup (new file)...") |
| 701 | (progn | 701 | (progn |
| 702 | (insert | 702 | (insert |
| 703 | "GNU Emacs Forms Mode version " forms-version "\n\n" | 703 | "GNU Emacs Forms Mode version " forms-version "\n\n" |
| 704 | (if (file-exists-p forms-file) | 704 | (if (file-exists-p forms-file) |
| 705 | (concat "No records available in file `" forms-file "'\n\n") | 705 | (concat "No records available in file `" forms-file "'\n\n") |
| @@ -736,7 +736,7 @@ Commands: Equivalent keys in read-only mode: | |||
| 736 | ;; Symbols in the list are evaluated, and consecutive strings are | 736 | ;; Symbols in the list are evaluated, and consecutive strings are |
| 737 | ;; concatenated. | 737 | ;; concatenated. |
| 738 | ;; Array `forms--elements' is constructed that contains the order | 738 | ;; Array `forms--elements' is constructed that contains the order |
| 739 | ;; of the fields on the display. This array is used by | 739 | ;; of the fields on the display. This array is used by |
| 740 | ;; `forms--parser-using-text-properties' to extract the fields data | 740 | ;; `forms--parser-using-text-properties' to extract the fields data |
| 741 | ;; from the form on the screen. | 741 | ;; from the form on the screen. |
| 742 | ;; Upon completion, `forms-format-list' is guaranteed correct, so | 742 | ;; Upon completion, `forms-format-list' is guaranteed correct, so |
| @@ -759,7 +759,7 @@ Commands: Equivalent keys in read-only mode: | |||
| 759 | (let ((the-list forms-format-list) ; the list of format elements | 759 | (let ((the-list forms-format-list) ; the list of format elements |
| 760 | (this-item 0) ; element in list | 760 | (this-item 0) ; element in list |
| 761 | (prev-item nil) | 761 | (prev-item nil) |
| 762 | (field-num 0)) ; highest field number | 762 | (field-num 0)) ; highest field number |
| 763 | 763 | ||
| 764 | (setq forms-format-list nil) ; gonna rebuild | 764 | (setq forms-format-list nil) ; gonna rebuild |
| 765 | 765 | ||
| @@ -785,7 +785,7 @@ Commands: Equivalent keys in read-only mode: | |||
| 785 | (setq prev-item el))) | 785 | (setq prev-item el))) |
| 786 | 786 | ||
| 787 | ;; Try numeric ... | 787 | ;; Try numeric ... |
| 788 | ((numberp el) | 788 | ((numberp el) |
| 789 | 789 | ||
| 790 | ;; Validate range. | 790 | ;; Validate range. |
| 791 | (if (or (<= el 0) | 791 | (if (or (<= el 0) |
| @@ -862,8 +862,8 @@ Commands: Equivalent keys in read-only mode: | |||
| 862 | (defun forms--iif-hook (begin end) | 862 | (defun forms--iif-hook (begin end) |
| 863 | "`insert-in-front-hooks' function for read-only segments." | 863 | "`insert-in-front-hooks' function for read-only segments." |
| 864 | 864 | ||
| 865 | ;; Note start location. By making it a marker that points one | 865 | ;; Note start location. By making it a marker that points one |
| 866 | ;; character beyond the actual location, it is guaranteed to move | 866 | ;; character beyond the actual location, it is guaranteed to move |
| 867 | ;; correctly if text is inserted. | 867 | ;; correctly if text is inserted. |
| 868 | (or forms--iif-start | 868 | (or forms--iif-start |
| 869 | (setq forms--iif-start (copy-marker (1+ (point))))) | 869 | (setq forms--iif-start (copy-marker (1+ (point))))) |
| @@ -874,12 +874,12 @@ Commands: Equivalent keys in read-only mode: | |||
| 874 | 'read-only)) | 874 | 'read-only)) |
| 875 | (progn | 875 | (progn |
| 876 | ;; Fetch current properties. | 876 | ;; Fetch current properties. |
| 877 | (setq forms--iif-properties | 877 | (setq forms--iif-properties |
| 878 | (text-properties-at (1- forms--iif-start))) | 878 | (text-properties-at (1- forms--iif-start))) |
| 879 | 879 | ||
| 880 | ;; Replace them. | 880 | ;; Replace them. |
| 881 | (let ((inhibit-read-only t)) | 881 | (let ((inhibit-read-only t)) |
| 882 | (set-text-properties | 882 | (set-text-properties |
| 883 | (1- forms--iif-start) forms--iif-start | 883 | (1- forms--iif-start) forms--iif-start |
| 884 | (list 'face forms--rw-face 'front-sticky '(face)))) | 884 | (list 'face forms--rw-face 'front-sticky '(face)))) |
| 885 | 885 | ||
| @@ -900,7 +900,7 @@ Commands: Equivalent keys in read-only mode: | |||
| 900 | ;; Restore properties. | 900 | ;; Restore properties. |
| 901 | (if forms--iif-start | 901 | (if forms--iif-start |
| 902 | (let ((inhibit-read-only t)) | 902 | (let ((inhibit-read-only t)) |
| 903 | (set-text-properties | 903 | (set-text-properties |
| 904 | (1- forms--iif-start) forms--iif-start | 904 | (1- forms--iif-start) forms--iif-start |
| 905 | forms--iif-properties))) | 905 | forms--iif-properties))) |
| 906 | 906 | ||
| @@ -920,9 +920,9 @@ Commands: Equivalent keys in read-only mode: | |||
| 920 | 920 | ||
| 921 | (let ((forms--marker 0) | 921 | (let ((forms--marker 0) |
| 922 | (forms--dyntext 0)) | 922 | (forms--dyntext 0)) |
| 923 | (setq | 923 | (setq |
| 924 | forms--format | 924 | forms--format |
| 925 | (if forms-use-text-properties | 925 | (if forms-use-text-properties |
| 926 | `(lambda (arg) | 926 | `(lambda (arg) |
| 927 | (let ((inhibit-read-only t)) | 927 | (let ((inhibit-read-only t)) |
| 928 | ,@(apply 'append | 928 | ,@(apply 'append |
| @@ -957,9 +957,9 @@ Commands: Equivalent keys in read-only mode: | |||
| 957 | ;; (let ((inhibit-read-only t)) | 957 | ;; (let ((inhibit-read-only t)) |
| 958 | ;; | 958 | ;; |
| 959 | ;; ;; A string, e.g. "text: ". | 959 | ;; ;; A string, e.g. "text: ". |
| 960 | ;; (set-text-properties | 960 | ;; (set-text-properties |
| 961 | ;; (point) | 961 | ;; (point) |
| 962 | ;; (progn (insert "text: ") (point)) | 962 | ;; (progn (insert "text: ") (point)) |
| 963 | ;; (list 'face forms--ro-face | 963 | ;; (list 'face forms--ro-face |
| 964 | ;; 'read-only 1 | 964 | ;; 'read-only 1 |
| 965 | ;; 'insert-in-front-hooks 'forms--iif-hook | 965 | ;; 'insert-in-front-hooks 'forms--iif-hook |
| @@ -970,7 +970,7 @@ Commands: Equivalent keys in read-only mode: | |||
| 970 | ;; (aset forms--markers 0 (point-marker)) | 970 | ;; (aset forms--markers 0 (point-marker)) |
| 971 | ;; (insert (elt arg 5)) | 971 | ;; (insert (elt arg 5)) |
| 972 | ;; (or (= (point) here) | 972 | ;; (or (= (point) here) |
| 973 | ;; (set-text-properties | 973 | ;; (set-text-properties |
| 974 | ;; here (point) | 974 | ;; here (point) |
| 975 | ;; (list 'face forms--rw-face | 975 | ;; (list 'face forms--rw-face |
| 976 | ;; 'front-sticky '(face)))) | 976 | ;; 'front-sticky '(face)))) |
| @@ -1008,8 +1008,8 @@ Commands: Equivalent keys in read-only mode: | |||
| 1008 | 1008 | ||
| 1009 | (cond | 1009 | (cond |
| 1010 | ((stringp el) | 1010 | ((stringp el) |
| 1011 | 1011 | ||
| 1012 | `((set-text-properties | 1012 | `((set-text-properties |
| 1013 | (point) ; start at point | 1013 | (point) ; start at point |
| 1014 | (progn ; until after insertion | 1014 | (progn ; until after insertion |
| 1015 | (insert ,el) | 1015 | (insert ,el) |
| @@ -1020,16 +1020,16 @@ Commands: Equivalent keys in read-only mode: | |||
| 1020 | 'insert-in-front-hooks '(forms--iif-hook) | 1020 | 'insert-in-front-hooks '(forms--iif-hook) |
| 1021 | 'rear-nonsticky '(face read-only insert-in-front-hooks | 1021 | 'rear-nonsticky '(face read-only insert-in-front-hooks |
| 1022 | intangible))))) | 1022 | intangible))))) |
| 1023 | 1023 | ||
| 1024 | ((numberp el) | 1024 | ((numberp el) |
| 1025 | `((let ((here (point))) | 1025 | `((let ((here (point))) |
| 1026 | (aset forms--markers | 1026 | (aset forms--markers |
| 1027 | ,(prog1 forms--marker | 1027 | ,(prog1 forms--marker |
| 1028 | (setq forms--marker (1+ forms--marker))) | 1028 | (setq forms--marker (1+ forms--marker))) |
| 1029 | (point-marker)) | 1029 | (point-marker)) |
| 1030 | (insert (elt arg ,(1- el))) | 1030 | (insert (elt arg ,(1- el))) |
| 1031 | (or (= (point) here) | 1031 | (or (= (point) here) |
| 1032 | (set-text-properties | 1032 | (set-text-properties |
| 1033 | here (point) | 1033 | here (point) |
| 1034 | (list 'face forms--rw-face | 1034 | (list 'face forms--rw-face |
| 1035 | 'front-sticky '(face))))))) | 1035 | 'front-sticky '(face))))))) |
| @@ -1038,7 +1038,7 @@ Commands: Equivalent keys in read-only mode: | |||
| 1038 | `((set-text-properties | 1038 | `((set-text-properties |
| 1039 | (point) | 1039 | (point) |
| 1040 | (progn | 1040 | (progn |
| 1041 | (insert (aset forms--dyntexts | 1041 | (insert (aset forms--dyntexts |
| 1042 | ,(prog1 forms--dyntext | 1042 | ,(prog1 forms--dyntext |
| 1043 | (setq forms--dyntext (1+ forms--dyntext))) | 1043 | (setq forms--dyntext (1+ forms--dyntext))) |
| 1044 | ,el)) | 1044 | ,el)) |
| @@ -1071,7 +1071,7 @@ Commands: Equivalent keys in read-only mode: | |||
| 1071 | ;; (insert (aset forms--dyntexts 0 (tocol 40))) | 1071 | ;; (insert (aset forms--dyntexts 0 (tocol 40))) |
| 1072 | ;; ... ) | 1072 | ;; ... ) |
| 1073 | 1073 | ||
| 1074 | (cond | 1074 | (cond |
| 1075 | ((stringp el) | 1075 | ((stringp el) |
| 1076 | `((insert ,el))) | 1076 | `((insert ,el))) |
| 1077 | ((numberp el) | 1077 | ((numberp el) |
| @@ -1110,8 +1110,8 @@ Commands: Equivalent keys in read-only mode: | |||
| 1110 | (let (here) | 1110 | (let (here) |
| 1111 | (goto-char (point-min)) | 1111 | (goto-char (point-min)) |
| 1112 | ,@(apply 'append | 1112 | ,@(apply 'append |
| 1113 | (mapcar | 1113 | (mapcar |
| 1114 | 'forms--make-parser-elt | 1114 | 'forms--make-parser-elt |
| 1115 | (append forms-format-list (list nil))))))))) | 1115 | (append forms-format-list (list nil))))))))) |
| 1116 | 1116 | ||
| 1117 | (forms--debug 'forms--parser)) | 1117 | (forms--debug 'forms--parser)) |
| @@ -1128,7 +1128,7 @@ Commands: Equivalent keys in read-only mode: | |||
| 1128 | (goto-char (setq here (aref forms--markers i))) | 1128 | (goto-char (setq here (aref forms--markers i))) |
| 1129 | (if (get-text-property here 'read-only) | 1129 | (if (get-text-property here 'read-only) |
| 1130 | (aset forms--recordv (aref forms--elements i) nil) | 1130 | (aset forms--recordv (aref forms--elements i) nil) |
| 1131 | (if (setq there | 1131 | (if (setq there |
| 1132 | (next-single-property-change here 'read-only)) | 1132 | (next-single-property-change here 'read-only)) |
| 1133 | (aset forms--recordv (aref forms--elements i) | 1133 | (aset forms--recordv (aref forms--elements i) |
| 1134 | (buffer-substring-no-properties here there)) | 1134 | (buffer-substring-no-properties here there)) |
| @@ -1144,12 +1144,12 @@ Commands: Equivalent keys in read-only mode: | |||
| 1144 | ;; (lambda nil | 1144 | ;; (lambda nil |
| 1145 | ;; (let (here) | 1145 | ;; (let (here) |
| 1146 | ;; (goto-char (point-min)) | 1146 | ;; (goto-char (point-min)) |
| 1147 | ;; | 1147 | ;; |
| 1148 | ;; ;; "text: " | 1148 | ;; ;; "text: " |
| 1149 | ;; (if (not (looking-at "text: ")) | 1149 | ;; (if (not (looking-at "text: ")) |
| 1150 | ;; (error "Parse error: cannot find \"text: \"")) | 1150 | ;; (error "Parse error: cannot find \"text: \"")) |
| 1151 | ;; (forward-char 6) ; past "text: " | 1151 | ;; (forward-char 6) ; past "text: " |
| 1152 | ;; | 1152 | ;; |
| 1153 | ;; ;; 6 | 1153 | ;; ;; 6 |
| 1154 | ;; ;; "\nmore text: " | 1154 | ;; ;; "\nmore text: " |
| 1155 | ;; (setq here (point)) | 1155 | ;; (setq here (point)) |
| @@ -1163,7 +1163,7 @@ Commands: Equivalent keys in read-only mode: | |||
| 1163 | ;; (error "Parse error: not looking at \"%s\"" forms--dyntext)) | 1163 | ;; (error "Parse error: not looking at \"%s\"" forms--dyntext)) |
| 1164 | ;; (forward-char (length forms--dyntext)) | 1164 | ;; (forward-char (length forms--dyntext)) |
| 1165 | ;; (setq forms--dynamic-text (cdr-safe forms--dynamic-text))) | 1165 | ;; (setq forms--dynamic-text (cdr-safe forms--dynamic-text))) |
| 1166 | ;; ... | 1166 | ;; ... |
| 1167 | ;; ;; final flush (due to terminator sentinel, see below) | 1167 | ;; ;; final flush (due to terminator sentinel, see below) |
| 1168 | ;; (aset forms--recordv 7 (buffer-substring-no-properties (point) (point-max))) | 1168 | ;; (aset forms--recordv 7 (buffer-substring-no-properties (point) (point-max))) |
| 1169 | 1169 | ||
| @@ -1233,7 +1233,7 @@ Commands: Equivalent keys in read-only mode: | |||
| 1233 | (goto-char (point-min)) | 1233 | (goto-char (point-min)) |
| 1234 | (forms--get-record))) | 1234 | (forms--get-record))) |
| 1235 | 1235 | ||
| 1236 | ;; This may be overkill, but try to avoid interference with | 1236 | ;; This may be overkill, but try to avoid interference with |
| 1237 | ;; the normal processing. | 1237 | ;; the normal processing. |
| 1238 | (kill-buffer forms--file-buffer) | 1238 | (kill-buffer forms--file-buffer) |
| 1239 | 1239 | ||
| @@ -1260,8 +1260,8 @@ Commands: Equivalent keys in read-only mode: | |||
| 1260 | (defun forms--set-keymaps () | 1260 | (defun forms--set-keymaps () |
| 1261 | "Set the keymaps used in this mode." | 1261 | "Set the keymaps used in this mode." |
| 1262 | 1262 | ||
| 1263 | (use-local-map (if forms-read-only | 1263 | (use-local-map (if forms-read-only |
| 1264 | forms-mode-ro-map | 1264 | forms-mode-ro-map |
| 1265 | forms-mode-edit-map))) | 1265 | forms-mode-edit-map))) |
| 1266 | 1266 | ||
| 1267 | (defun forms--mode-commands () | 1267 | (defun forms--mode-commands () |
| @@ -1403,7 +1403,7 @@ Commands: Equivalent keys in read-only mode: | |||
| 1403 | (put 'forms-delete-record 'menu-enable '(not forms-read-only)) | 1403 | (put 'forms-delete-record 'menu-enable '(not forms-read-only)) |
| 1404 | ) | 1404 | ) |
| 1405 | 1405 | ||
| 1406 | (defun forms--mode-commands1 (map) | 1406 | (defun forms--mode-commands1 (map) |
| 1407 | "Helper routine to define keys." | 1407 | "Helper routine to define keys." |
| 1408 | (define-key map [TAB] 'forms-next-field) | 1408 | (define-key map [TAB] 'forms-next-field) |
| 1409 | (define-key map [S-tab] 'forms-prev-field) | 1409 | (define-key map [S-tab] 'forms-prev-field) |
| @@ -1526,10 +1526,10 @@ Commands: Equivalent keys in read-only mode: | |||
| 1526 | (message "Warning: this record has %d fields instead of %d" | 1526 | (message "Warning: this record has %d fields instead of %d" |
| 1527 | (length forms--the-record-list) forms-number-of-fields)) | 1527 | (length forms--the-record-list) forms-number-of-fields)) |
| 1528 | (if (< (length forms--the-record-list) forms-number-of-fields) | 1528 | (if (< (length forms--the-record-list) forms-number-of-fields) |
| 1529 | (setq forms--the-record-list | 1529 | (setq forms--the-record-list |
| 1530 | (append forms--the-record-list | 1530 | (append forms--the-record-list |
| 1531 | (make-list | 1531 | (make-list |
| 1532 | (- forms-number-of-fields | 1532 | (- forms-number-of-fields |
| 1533 | (length forms--the-record-list)) | 1533 | (length forms--the-record-list)) |
| 1534 | ""))))) | 1534 | ""))))) |
| 1535 | 1535 | ||
| @@ -1549,7 +1549,7 @@ Commands: Equivalent keys in read-only mode: | |||
| 1549 | "Parse contents of form into list of strings." | 1549 | "Parse contents of form into list of strings." |
| 1550 | ;; The contents of the form are parsed, and a new list of strings | 1550 | ;; The contents of the form are parsed, and a new list of strings |
| 1551 | ;; is constructed. | 1551 | ;; is constructed. |
| 1552 | ;; A vector with the strings from the original record is | 1552 | ;; A vector with the strings from the original record is |
| 1553 | ;; constructed, which is updated with the new contents. Therefore | 1553 | ;; constructed, which is updated with the new contents. Therefore |
| 1554 | ;; fields which were not in the form are not modified. | 1554 | ;; fields which were not in the form are not modified. |
| 1555 | ;; Finally, the vector is transformed into a list for further processing. | 1555 | ;; Finally, the vector is transformed into a list for further processing. |
| @@ -1585,11 +1585,11 @@ As a side effect: sets `forms--the-record-list'." | |||
| 1585 | (setq forms--the-record-list (forms--parse-form)) | 1585 | (setq forms--the-record-list (forms--parse-form)) |
| 1586 | (setq the-record | 1586 | (setq the-record |
| 1587 | (mapconcat 'identity forms--the-record-list forms-field-sep)) | 1587 | (mapconcat 'identity forms--the-record-list forms-field-sep)) |
| 1588 | 1588 | ||
| 1589 | (if (string-match (regexp-quote forms-field-sep) | 1589 | (if (string-match (regexp-quote forms-field-sep) |
| 1590 | (mapconcat 'identity forms--the-record-list "")) | 1590 | (mapconcat 'identity forms--the-record-list "")) |
| 1591 | (error "Field separator occurs in record - update refused")) | 1591 | (error "Field separator occurs in record - update refused")) |
| 1592 | 1592 | ||
| 1593 | ;; Handle multi-line fields, if allowed. | 1593 | ;; Handle multi-line fields, if allowed. |
| 1594 | (if forms-multi-line | 1594 | (if forms-multi-line |
| 1595 | (forms--trans the-record "\n" forms-multi-line)) | 1595 | (forms--trans the-record "\n" forms-multi-line)) |
| @@ -1713,7 +1713,7 @@ As a side effect: sets `forms--the-record-list'." | |||
| 1713 | As a side effect: re-calculates the number of records in the data file." | 1713 | As a side effect: re-calculates the number of records in the data file." |
| 1714 | (interactive) | 1714 | (interactive) |
| 1715 | (let | 1715 | (let |
| 1716 | ((numrec | 1716 | ((numrec |
| 1717 | (save-excursion | 1717 | (save-excursion |
| 1718 | (set-buffer forms--file-buffer) | 1718 | (set-buffer forms--file-buffer) |
| 1719 | (count-lines (point-min) (point-max))))) | 1719 | (count-lines (point-min) (point-max))))) |
| @@ -1769,7 +1769,7 @@ Otherwise enables edit mode if the visited file is writable." | |||
| 1769 | (defun forms-insert-record (arg) | 1769 | (defun forms-insert-record (arg) |
| 1770 | "Create a new record before the current one. | 1770 | "Create a new record before the current one. |
| 1771 | With ARG: store the record after the current one. | 1771 | With ARG: store the record after the current one. |
| 1772 | If `forms-new-record-filter' contains the name of a function, | 1772 | If `forms-new-record-filter' contains the name of a function, |
| 1773 | it is called to fill (some of) the fields with default values. | 1773 | it is called to fill (some of) the fields with default values. |
| 1774 | If `forms-insert-after is non-nil, the default behavior is to insert | 1774 | If `forms-insert-after is non-nil, the default behavior is to insert |
| 1775 | after the current record." | 1775 | after the current record." |
| @@ -1808,7 +1808,7 @@ after the current record." | |||
| 1808 | (open-line 1) | 1808 | (open-line 1) |
| 1809 | (insert the-record) | 1809 | (insert the-record) |
| 1810 | (beginning-of-line)) | 1810 | (beginning-of-line)) |
| 1811 | 1811 | ||
| 1812 | (setq forms--current-record ln)) | 1812 | (setq forms--current-record ln)) |
| 1813 | 1813 | ||
| 1814 | (setq forms--total-records (1+ forms--total-records)) | 1814 | (setq forms--total-records (1+ forms--total-records)) |
| @@ -1841,8 +1841,8 @@ after the current record." | |||
| 1841 | 1841 | ||
| 1842 | (defun forms-search-forward (regexp) | 1842 | (defun forms-search-forward (regexp) |
| 1843 | "Search forward for record containing REGEXP." | 1843 | "Search forward for record containing REGEXP." |
| 1844 | (interactive | 1844 | (interactive |
| 1845 | (list (read-string (concat "Search forward for" | 1845 | (list (read-string (concat "Search forward for" |
| 1846 | (if forms--search-regexp | 1846 | (if forms--search-regexp |
| 1847 | (concat " (" | 1847 | (concat " (" |
| 1848 | forms--search-regexp | 1848 | forms--search-regexp |
| @@ -1877,8 +1877,8 @@ after the current record." | |||
| 1877 | 1877 | ||
| 1878 | (defun forms-search-backward (regexp) | 1878 | (defun forms-search-backward (regexp) |
| 1879 | "Search backward for record containing REGEXP." | 1879 | "Search backward for record containing REGEXP." |
| 1880 | (interactive | 1880 | (interactive |
| 1881 | (list (read-string (concat "Search backward for" | 1881 | (list (read-string (concat "Search backward for" |
| 1882 | (if forms--search-regexp | 1882 | (if forms--search-regexp |
| 1883 | (concat " (" | 1883 | (concat " (" |
| 1884 | forms--search-regexp | 1884 | forms--search-regexp |
| @@ -1925,8 +1925,8 @@ after writing out the data." | |||
| 1925 | (set-buffer forms--file-buffer) | 1925 | (set-buffer forms--file-buffer) |
| 1926 | (let ((inhibit-read-only t)) | 1926 | (let ((inhibit-read-only t)) |
| 1927 | ;; Write file hooks are run via local-write-file-hooks. | 1927 | ;; Write file hooks are run via local-write-file-hooks. |
| 1928 | ;; (if write-file-filter | 1928 | ;; (if write-file-filter |
| 1929 | ;; (save-excursion | 1929 | ;; (save-excursion |
| 1930 | ;; (run-hooks 'write-file-filter))) | 1930 | ;; (run-hooks 'write-file-filter))) |
| 1931 | 1931 | ||
| 1932 | ;; If they have a write-file-filter, force the buffer to be | 1932 | ;; If they have a write-file-filter, force the buffer to be |
| @@ -2076,7 +2076,7 @@ Usage: (setq forms-number-of-fields | |||
| 2076 | (setq ret (concat ret (prin1-to-string vel) "\n"))) | 2076 | (setq ret (concat ret (prin1-to-string vel) "\n"))) |
| 2077 | (setq ret (concat ret "<unbound>" "\n"))) | 2077 | (setq ret (concat ret "<unbound>" "\n"))) |
| 2078 | (if (fboundp el) | 2078 | (if (fboundp el) |
| 2079 | (setq ret (concat ret (prin1-to-string (symbol-function el)) | 2079 | (setq ret (concat ret (prin1-to-string (symbol-function el)) |
| 2080 | "\n")))))) | 2080 | "\n")))))) |
| 2081 | (save-excursion | 2081 | (save-excursion |
| 2082 | (set-buffer (get-buffer-create "*forms-mode debug*")) | 2082 | (set-buffer (get-buffer-create "*forms-mode debug*")) |