diff options
| author | Richard M. Stallman | 1993-06-30 22:37:30 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-06-30 22:37:30 +0000 |
| commit | ac2a7a9197e98909c978d1ffe4d044326bd74135 (patch) | |
| tree | ca78918ef08a3b041b82e015b2a678c3cb178ca3 | |
| parent | 51501e543e37dd23c74321569ccf7ba9cc7c6de8 (diff) | |
| download | emacs-ac2a7a9197e98909c978d1ffe4d044326bd74135.tar.gz emacs-ac2a7a9197e98909c978d1ffe4d044326bd74135.zip | |
Add e-mail address and version info.
Adjust commentary and doc strings.
(forms-mode): Add ###autoload.
(forms-find-file): Add ###autoload.
(forms-find-file-other-window): Add ###autoload.
| -rw-r--r-- | lisp/forms.el | 138 |
1 files changed, 66 insertions, 72 deletions
diff --git a/lisp/forms.el b/lisp/forms.el index 2da889b4769..559c60db07c 100644 --- a/lisp/forms.el +++ b/lisp/forms.el | |||
| @@ -1,7 +1,8 @@ | |||
| 1 | ;;; forms.el -- Forms mode: edit a file as a form to fill in. | 1 | ;;; forms.el -- Forms mode: edit a file as a form to fill in. |
| 2 | ;;; Copyright (C) 1991, 1993 Free Software Foundation, Inc. | 2 | ;;; Copyright (C) 1991, 1993 Free Software Foundation, Inc. |
| 3 | 3 | ||
| 4 | ;;; Author: Johan Vromans | 4 | ;; Author: Johan Vromans <jv@mh.nl> |
| 5 | ;; Version: 1.2.13 | ||
| 5 | 6 | ||
| 6 | ;; This file is part of GNU Emacs. | 7 | ;; This file is part of GNU Emacs. |
| 7 | 8 | ||
| @@ -41,15 +42,15 @@ | |||
| 41 | ;;; separated by a newline, the fields are separated by a user-defined | 42 | ;;; separated by a newline, the fields are separated by a user-defined |
| 42 | ;;; field separater (default: TAB). | 43 | ;;; field separater (default: TAB). |
| 43 | ;;; When shown, a record is transferred to an emacs buffer and | 44 | ;;; When shown, a record is transferred to an emacs buffer and |
| 44 | ;;; presented using a user-defined form. One record is shown at a | 45 | ;;; presented using a user-defined form. One record is shown at a |
| 45 | ;;; time. | 46 | ;;; time. |
| 46 | ;;; | 47 | ;;; |
| 47 | ;;; Forms mode is a composite mode. It involves two files, and two | 48 | ;;; Forms mode is a composite mode. It involves two files, and two |
| 48 | ;;; buffers. | 49 | ;;; buffers. |
| 49 | ;;; The first file, called the control file, defines the name of the | 50 | ;;; The first file, called the control file, defines the name of the |
| 50 | ;;; data file and the forms format. This file buffer will be used to | 51 | ;;; data file and the forms format. This file buffer will be used to |
| 51 | ;;; present the forms. | 52 | ;;; present the forms. |
| 52 | ;;; The second file holds the actual data. The buffer of this file | 53 | ;;; The second file holds the actual data. The buffer of this file |
| 53 | ;;; will be buried, for it is never accessed directly. | 54 | ;;; will be buried, for it is never accessed directly. |
| 54 | ;;; | 55 | ;;; |
| 55 | ;;; Forms mode is invoked using "forms-find-file control-file". | 56 | ;;; Forms mode is invoked using "forms-find-file control-file". |
| @@ -76,12 +77,12 @@ | |||
| 76 | ;;; | 77 | ;;; |
| 77 | ;;; - a string, e.g. "hello" (which is inserted \"as is\"), | 78 | ;;; - a string, e.g. "hello" (which is inserted \"as is\"), |
| 78 | ;;; | 79 | ;;; |
| 79 | ;;; - an integer, denoting a field number. The contents of the field | 80 | ;;; - an integer, denoting a field number. The contents of the field |
| 80 | ;;; are inserted at this point. | 81 | ;;; are inserted at this point. |
| 81 | ;;; The first field has number one. | 82 | ;;; The first field has number one. |
| 82 | ;;; | 83 | ;;; |
| 83 | ;;; - a function call, e.g. (insert "text"). This function call is | 84 | ;;; - a function call, e.g. (insert "text"). This function call is |
| 84 | ;;; dynamically evaluated and should return a string. It should *NOT* | 85 | ;;; dynamically evaluated and should return a string. It should *NOT* |
| 85 | ;;; have side-effects on the forms being constructed. | 86 | ;;; have side-effects on the forms being constructed. |
| 86 | ;;; The current fields are available to the function in the variable | 87 | ;;; The current fields are available to the function in the variable |
| 87 | ;;; forms-fields, they should *NOT* be modified. | 88 | ;;; forms-fields, they should *NOT* be modified. |
| @@ -92,7 +93,7 @@ | |||
| 92 | ;;; | 93 | ;;; |
| 93 | ;;; forms-field-sep [string, default TAB] | 94 | ;;; forms-field-sep [string, default TAB] |
| 94 | ;;; The field separator used to separate the | 95 | ;;; The field separator used to separate the |
| 95 | ;;; fields in the data file. It may be a string. | 96 | ;;; fields in the data file. It may be a string. |
| 96 | ;;; | 97 | ;;; |
| 97 | ;;; forms-read-only [bool, default nil] | 98 | ;;; forms-read-only [bool, default nil] |
| 98 | ;;; 't' means that the data file is visited read-only. | 99 | ;;; 't' means that the data file is visited read-only. |
| @@ -104,9 +105,9 @@ | |||
| 104 | ;;; contain fields which span multiple lines in | 105 | ;;; contain fields which span multiple lines in |
| 105 | ;;; the form. | 106 | ;;; the form. |
| 106 | ;;; This variable denoted the separator character | 107 | ;;; This variable denoted the separator character |
| 107 | ;;; to be used for this purpose. Upon display, all | 108 | ;;; to be used for this purpose. Upon display, all |
| 108 | ;;; occurrencies of this character are translated | 109 | ;;; occurrencies of this character are translated |
| 109 | ;;; to newlines. Upon storage they are translated | 110 | ;;; to newlines. Upon storage they are translated |
| 110 | ;;; back to the separator. | 111 | ;;; back to the separator. |
| 111 | ;;; | 112 | ;;; |
| 112 | ;;; forms-forms-scroll [bool, default t] | 113 | ;;; forms-forms-scroll [bool, default t] |
| @@ -121,7 +122,7 @@ | |||
| 121 | ;;; forms-new-record-filter [symbol, no default] | 122 | ;;; forms-new-record-filter [symbol, no default] |
| 122 | ;;; If defined: this should be the name of a | 123 | ;;; If defined: this should be the name of a |
| 123 | ;;; function that is called when a new | 124 | ;;; function that is called when a new |
| 124 | ;;; record is created. It can be used to fill in | 125 | ;;; record is created. It can be used to fill in |
| 125 | ;;; the new record with default fields, for example. | 126 | ;;; the new record with default fields, for example. |
| 126 | ;;; Instead of the name of the function, it may | 127 | ;;; Instead of the name of the function, it may |
| 127 | ;;; be the function itself. | 128 | ;;; be the function itself. |
| @@ -129,8 +130,8 @@ | |||
| 129 | ;;; forms-modified-record-filter [symbol, no default] | 130 | ;;; forms-modified-record-filter [symbol, no default] |
| 130 | ;;; If defined: this should be the name of a | 131 | ;;; If defined: this should be the name of a |
| 131 | ;;; function that is called when a record has | 132 | ;;; function that is called when a record has |
| 132 | ;;; been modified. It is called after the fields | 133 | ;;; been modified. It is called after the fields |
| 133 | ;;; are parsed. It can be used to register | 134 | ;;; are parsed. It can be used to register |
| 134 | ;;; modification dates, for example. | 135 | ;;; modification dates, for example. |
| 135 | ;;; Instead of the name of the function, it may | 136 | ;;; Instead of the name of the function, it may |
| 136 | ;;; be the function itself. | 137 | ;;; be the function itself. |
| @@ -149,8 +150,8 @@ | |||
| 149 | ;;; the records. | 150 | ;;; the records. |
| 150 | ;;; | 151 | ;;; |
| 151 | ;;; When a form is changed the record is updated as soon as this form | 152 | ;;; When a form is changed the record is updated as soon as this form |
| 152 | ;;; is left. The contents of the form are parsed using forms-format-list, | 153 | ;;; is left. The contents of the form are parsed using forms-format-list, |
| 153 | ;;; and the fields which are deduced from the form are modified. So, | 154 | ;;; and the fields which are deduced from the form are modified. So, |
| 154 | ;;; fields not shown on the forms retain their origional values. | 155 | ;;; fields not shown on the forms retain their origional values. |
| 155 | ;;; The newly formed record and replaces the contents of the | 156 | ;;; The newly formed record and replaces the contents of the |
| 156 | ;;; old record in forms--file-buffer. | 157 | ;;; old record in forms--file-buffer. |
| @@ -158,7 +159,7 @@ | |||
| 158 | ;;; the records. | 159 | ;;; the records. |
| 159 | ;;; | 160 | ;;; |
| 160 | ;;; Two exit functions exist: forms-exit (which saves) and forms-exit-no-save | 161 | ;;; Two exit functions exist: forms-exit (which saves) and forms-exit-no-save |
| 161 | ;;; (which doesn't). However, if forms-exit-no-save is executed and the file | 162 | ;;; (which doesn't). However, if forms-exit-no-save is executed and the file |
| 162 | ;;; buffer has been modified, emacs will ask questions. | 163 | ;;; buffer has been modified, emacs will ask questions. |
| 163 | ;;; | 164 | ;;; |
| 164 | ;;; Other functions are: | 165 | ;;; Other functions are: |
| @@ -204,7 +205,7 @@ | |||
| 204 | ;;; The bindings of standard functions scroll-up, scroll-down, | 205 | ;;; The bindings of standard functions scroll-up, scroll-down, |
| 205 | ;;; beginning-of-buffer and end-of-buffer are locally replaced with | 206 | ;;; beginning-of-buffer and end-of-buffer are locally replaced with |
| 206 | ;;; forms mode functions next/prev record and first/last | 207 | ;;; forms mode functions next/prev record and first/last |
| 207 | ;;; record. Buffer-local variables forms-forms-scroll and | 208 | ;;; record. Buffer-local variables forms-forms-scroll and |
| 208 | ;;; forms-forms-jump (default: t) may be set to nil to inhibit | 209 | ;;; forms-forms-jump (default: t) may be set to nil to inhibit |
| 209 | ;;; rebinding. | 210 | ;;; rebinding. |
| 210 | ;;; | 211 | ;;; |
| @@ -222,7 +223,7 @@ | |||
| 222 | (provide 'forms) ;;; official | 223 | (provide 'forms) ;;; official |
| 223 | (provide 'forms-mode) ;;; for compatibility | 224 | (provide 'forms-mode) ;;; for compatibility |
| 224 | 225 | ||
| 225 | (defconst forms-version "1.2.11" | 226 | (defconst forms-version "1.2.13" |
| 226 | "Version of forms-mode implementation.") | 227 | "Version of forms-mode implementation.") |
| 227 | 228 | ||
| 228 | (defvar forms-mode-hooks nil | 229 | (defvar forms-mode-hooks nil |
| @@ -238,7 +239,6 @@ | |||
| 238 | 239 | ||
| 239 | (defvar forms-number-of-fields nil | 240 | (defvar forms-number-of-fields nil |
| 240 | "Number of fields per record.") | 241 | "Number of fields per record.") |
| 241 | |||
| 242 | 242 | ||
| 243 | ;;; Optional variables with default values | 243 | ;;; Optional variables with default values |
| 244 | 244 | ||
| @@ -249,7 +249,7 @@ | |||
| 249 | "Read-only mode (defaults to the write access on the data file).") | 249 | "Read-only mode (defaults to the write access on the data file).") |
| 250 | 250 | ||
| 251 | (defvar forms-multi-line "\C-k" | 251 | (defvar forms-multi-line "\C-k" |
| 252 | "Character to separate multi-line fields (default C-k)") | 252 | "Character to separate multi-line fields (default C-k).") |
| 253 | 253 | ||
| 254 | (defvar forms-forms-scroll t | 254 | (defvar forms-forms-scroll t |
| 255 | "*Non-nil means replace scroll-up/down commands in Forms mode. | 255 | "*Non-nil means replace scroll-up/down commands in Forms mode. |
| @@ -305,7 +305,7 @@ The replacement commands performs forms-first/last-record.") | |||
| 305 | "Internal - holds dynamic text to insert between fields.") | 305 | "Internal - holds dynamic text to insert between fields.") |
| 306 | 306 | ||
| 307 | (defvar forms-fields nil | 307 | (defvar forms-fields nil |
| 308 | "List with fields of the current forms. First field has number 1.") | 308 | "List with fields of the current forms. First field has number 1.") |
| 309 | 309 | ||
| 310 | (defvar forms-new-record-filter | 310 | (defvar forms-new-record-filter |
| 311 | "The name of a function that is called when a new record is created.") | 311 | "The name of a function that is called when a new record is created.") |
| @@ -315,9 +315,9 @@ The replacement commands performs forms-first/last-record.") | |||
| 315 | 315 | ||
| 316 | ;;; forms-mode | 316 | ;;; forms-mode |
| 317 | ;;; | 317 | ;;; |
| 318 | ;;; This is not a simple major mode, as usual. Therefore, forms-mode | 318 | ;;; This is not a simple major mode, as usual. Therefore, forms-mode |
| 319 | ;;; takes an optional argument 'primary' which is used for the initial | 319 | ;;; takes an optional argument 'primary' which is used for the initial |
| 320 | ;;; set-up. Normal use would leave 'primary' to nil. | 320 | ;;; set-up. Normal use would leave 'primary' to nil. |
| 321 | ;;; | 321 | ;;; |
| 322 | ;;; A global buffer-local variable 'forms--mode-setup' has the same effect | 322 | ;;; A global buffer-local variable 'forms--mode-setup' has the same effect |
| 323 | ;;; but makes it possible to auto-invoke forms-mode using find-file. | 323 | ;;; but makes it possible to auto-invoke forms-mode using find-file. |
| @@ -325,12 +325,13 @@ The replacement commands performs forms-first/last-record.") | |||
| 325 | ;;; Note: although it seems logical to have (make-local-variable) executed | 325 | ;;; Note: although it seems logical to have (make-local-variable) executed |
| 326 | ;;; where the variable is first needed, I deliberately placed all calls | 326 | ;;; where the variable is first needed, I deliberately placed all calls |
| 327 | ;;; in the forms-mode function. | 327 | ;;; in the forms-mode function. |
| 328 | 328 | ||
| 329 | ;;;###autoload | ||
| 329 | (defun forms-mode (&optional primary) | 330 | (defun forms-mode (&optional primary) |
| 330 | "Major mode to visit files in a field-structured manner using a form. | 331 | "Major mode to visit files in a field-structured manner using a form. |
| 331 | 332 | ||
| 332 | Commands (prefix with C-c if not in read-only mode): | 333 | Commands (prefix with C-c if not in read-only mode): |
| 333 | \\{forms-mode-map}" | 334 | \\{forms-mode-map}" |
| 334 | 335 | ||
| 335 | (interactive) ; no - 'primary' is not prefix arg | 336 | (interactive) ; no - 'primary' is not prefix arg |
| 336 | 337 | ||
| @@ -417,7 +418,7 @@ The replacement commands performs forms-first/last-record.") | |||
| 417 | ;; and clean it | 418 | ;; and clean it |
| 418 | (erase-buffer))) | 419 | (erase-buffer))) |
| 419 | 420 | ||
| 420 | ;; Make more local variables | 421 | ;; Make more local variables. |
| 421 | (make-local-variable 'forms--file-buffer) | 422 | (make-local-variable 'forms--file-buffer) |
| 422 | (make-local-variable 'forms--total-records) | 423 | (make-local-variable 'forms--total-records) |
| 423 | (make-local-variable 'forms--current-record) | 424 | (make-local-variable 'forms--current-record) |
| @@ -475,12 +476,10 @@ The replacement commands performs forms-first/last-record.") | |||
| 475 | 476 | ||
| 476 | ;; initialization done | 477 | ;; initialization done |
| 477 | (setq forms--mode-setup t)) | 478 | (setq forms--mode-setup t)) |
| 478 | |||
| 479 | 479 | ||
| 480 | ;;; forms-process-format-list | 480 | ;;; forms-process-format-list |
| 481 | ;;; | 481 | ;;; |
| 482 | ;;; Validates forms-format-list. | 482 | ;;; Validates forms-format-list. |
| 483 | ;;; | ||
| 484 | ;;; Sets forms--number-of-markers and forms--markers. | 483 | ;;; Sets forms--number-of-markers and forms--markers. |
| 485 | 484 | ||
| 486 | (defun forms--process-format-list () | 485 | (defun forms--process-format-list () |
| @@ -560,8 +559,6 @@ The replacement commands performs forms-first/last-record.") | |||
| 560 | 'forms--number-of-markers) | 559 | 'forms--number-of-markers) |
| 561 | 560 | ||
| 562 | (setq forms--markers (make-vector forms--number-of-markers nil))) | 561 | (setq forms--markers (make-vector forms--number-of-markers nil))) |
| 563 | |||
| 564 | |||
| 565 | 562 | ||
| 566 | ;;; Build the format routine from forms-format-list. | 563 | ;;; Build the format routine from forms-format-list. |
| 567 | ;;; | 564 | ;;; |
| @@ -589,12 +586,12 @@ The replacement commands performs forms-first/last-record.") | |||
| 589 | ;;; | 586 | ;;; |
| 590 | 587 | ||
| 591 | (defun forms--make-format () | 588 | (defun forms--make-format () |
| 592 | "Generate format function for forms" | 589 | "Generate format function for forms." |
| 593 | (setq forms--format (forms--format-maker forms-format-list)) | 590 | (setq forms--format (forms--format-maker forms-format-list)) |
| 594 | (forms--debug 'forms--format)) | 591 | (forms--debug 'forms--format)) |
| 595 | 592 | ||
| 596 | (defun forms--format-maker (the-format-list) | 593 | (defun forms--format-maker (the-format-list) |
| 597 | "Returns the parser function for forms" | 594 | "Returns the parser function for forms." |
| 598 | (let ((the-marker 0)) | 595 | (let ((the-marker 0)) |
| 599 | (` (lambda (arg) | 596 | (` (lambda (arg) |
| 600 | (setq forms--dynamic-text nil) | 597 | (setq forms--dynamic-text nil) |
| @@ -619,7 +616,7 @@ The replacement commands performs forms-first/last-record.") | |||
| 619 | ))))) | 616 | ))))) |
| 620 | 617 | ||
| 621 | (defun forms--concat-adjacent (the-list) | 618 | (defun forms--concat-adjacent (the-list) |
| 622 | "Concatenate adjacent strings in the-list and return the resulting list" | 619 | "Concatenate adjacent strings in the-list and return the resulting list." |
| 623 | (if (consp the-list) | 620 | (if (consp the-list) |
| 624 | (let ((the-rest (forms--concat-adjacent (cdr the-list)))) | 621 | (let ((the-rest (forms--concat-adjacent (cdr the-list)))) |
| 625 | (if (and (stringp (car the-list)) (stringp (car the-rest))) | 622 | (if (and (stringp (car the-list)) (stringp (car the-rest))) |
| @@ -663,12 +660,12 @@ The replacement commands performs forms-first/last-record.") | |||
| 663 | ;;; | 660 | ;;; |
| 664 | 661 | ||
| 665 | (defun forms--make-parser () | 662 | (defun forms--make-parser () |
| 666 | "Generate parser function for forms" | 663 | "Generate parser function for forms." |
| 667 | (setq forms--parser (forms--parser-maker forms-format-list)) | 664 | (setq forms--parser (forms--parser-maker forms-format-list)) |
| 668 | (forms--debug 'forms--parser)) | 665 | (forms--debug 'forms--parser)) |
| 669 | 666 | ||
| 670 | (defun forms--parser-maker (the-format-list) | 667 | (defun forms--parser-maker (the-format-list) |
| 671 | "Returns the parser function for forms" | 668 | "Returns the parser function for forms." |
| 672 | (let ((the-field nil) | 669 | (let ((the-field nil) |
| 673 | (seen-text nil) | 670 | (seen-text nil) |
| 674 | the--format-list) | 671 | the--format-list) |
| @@ -726,7 +723,6 @@ The replacement commands performs forms-first/last-record.") | |||
| 726 | (setq the-field nil))) | 723 | (setq the-field nil))) |
| 727 | )) | 724 | )) |
| 728 | 725 | ||
| 729 | |||
| 730 | (defun forms--set-minor-mode () | 726 | (defun forms--set-minor-mode () |
| 731 | (setq minor-mode-alist | 727 | (setq minor-mode-alist |
| 732 | (if forms-read-only | 728 | (if forms-read-only |
| @@ -743,7 +739,7 @@ The replacement commands performs forms-first/last-record.") | |||
| 743 | (define-key (current-local-map) "\t" 'forms-next-field))) | 739 | (define-key (current-local-map) "\t" 'forms-next-field))) |
| 744 | 740 | ||
| 745 | (defun forms--mode-commands (map) | 741 | (defun forms--mode-commands (map) |
| 746 | "Fill map with all commands." | 742 | "Fill map with all Forms mode commands." |
| 747 | (define-key map "\t" 'forms-next-field) | 743 | (define-key map "\t" 'forms-next-field) |
| 748 | (define-key map " " 'forms-next-record) | 744 | (define-key map " " 'forms-next-record) |
| 749 | (define-key map "d" 'forms-delete-record) | 745 | (define-key map "d" 'forms-delete-record) |
| @@ -768,13 +764,9 @@ The replacement commands performs forms-first/last-record.") | |||
| 768 | ) | 764 | ) |
| 769 | 765 | ||
| 770 | ;;; Changed functions | 766 | ;;; Changed functions |
| 771 | ;;; | ||
| 772 | ;;; Emacs (as of 18.55) lacks the functionality of buffer-local | ||
| 773 | ;;; funtions. Therefore we save the original meaning of some handy | ||
| 774 | ;;; functions, and replace them with a wrapper. | ||
| 775 | 767 | ||
| 776 | (defun forms--change-commands () | 768 | (defun forms--change-commands () |
| 777 | "Localize some commands." | 769 | "Localize some commands for Forms mode." |
| 778 | ;; | 770 | ;; |
| 779 | ;; scroll-down -> forms-prev-record | 771 | ;; scroll-down -> forms-prev-record |
| 780 | ;; scroll-up -> forms-next-record | 772 | ;; scroll-up -> forms-next-record |
| @@ -809,7 +801,7 @@ The replacement commands performs forms-first/last-record.") | |||
| 809 | t)))) | 801 | t)))) |
| 810 | 802 | ||
| 811 | (defun forms--help () | 803 | (defun forms--help () |
| 812 | "Initial help." | 804 | "Initial help for Forms mode." |
| 813 | ;; We should use | 805 | ;; We should use |
| 814 | ;;(message (substitute-command-keys (concat | 806 | ;;(message (substitute-command-keys (concat |
| 815 | ;;"\\[forms-next-record]:next" | 807 | ;;"\\[forms-next-record]:next" |
| @@ -824,7 +816,7 @@ The replacement commands performs forms-first/last-record.") | |||
| 824 | (message "C-c n:next C-c p:prev C-c <:first C-c >:last C-c ?:help C-c q:exit"))) | 816 | (message "C-c n:next C-c p:prev C-c <:first C-c >:last C-c ?:help C-c q:exit"))) |
| 825 | 817 | ||
| 826 | (defun forms--trans (subj arg rep) | 818 | (defun forms--trans (subj arg rep) |
| 827 | "Translate in SUBJ all chars ARG into char REP. ARG and REP should | 819 | "Translate in SUBJ all chars ARG into char REP. ARG and REP should |
| 828 | be single-char strings." | 820 | be single-char strings." |
| 829 | (let ((i 0) | 821 | (let ((i 0) |
| 830 | (x (length subj)) | 822 | (x (length subj)) |
| @@ -868,8 +860,7 @@ The replacement commands performs forms-first/last-record.") | |||
| 868 | (goto-char here)))) | 860 | (goto-char here)))) |
| 869 | 861 | ||
| 870 | (defun forms--show-record (the-record) | 862 | (defun forms--show-record (the-record) |
| 871 | "Format THE-RECORD according to forms-format-list, | 863 | "Format THE-RECORD and display it in the current buffer." |
| 872 | and display it in the current buffer." | ||
| 873 | 864 | ||
| 874 | ;; split the-record | 865 | ;; split the-record |
| 875 | (let (the-result | 866 | (let (the-result |
| @@ -920,7 +911,7 @@ The replacement commands performs forms-first/last-record.") | |||
| 920 | ;; The contents of the form are parsed, and a new list of strings | 911 | ;; The contents of the form are parsed, and a new list of strings |
| 921 | ;; is constructed. | 912 | ;; is constructed. |
| 922 | ;; A vector with the strings from the original record is | 913 | ;; A vector with the strings from the original record is |
| 923 | ;; constructed, which is updated with the new contents. Therefore | 914 | ;; constructed, which is updated with the new contents. Therefore |
| 924 | ;; fields which were not in the form are not modified. | 915 | ;; fields which were not in the form are not modified. |
| 925 | ;; Finally, the vector is transformed into a list for further processing. | 916 | ;; Finally, the vector is transformed into a list for further processing. |
| 926 | 917 | ||
| @@ -944,8 +935,9 @@ The replacement commands performs forms-first/last-record.") | |||
| 944 | (append the-recordv nil)))) | 935 | (append the-recordv nil)))) |
| 945 | 936 | ||
| 946 | (defun forms--update () | 937 | (defun forms--update () |
| 947 | "Update current record with contents of form. As a side effect: sets | 938 | "Update current record with contents of form. |
| 948 | forms--the-record-list ." | 939 | As a side effect: sets forms--the-record-list ." |
| 940 | |||
| 949 | (if forms-read-only | 941 | (if forms-read-only |
| 950 | (progn | 942 | (progn |
| 951 | (message "Read-only buffer!") | 943 | (message "Read-only buffer!") |
| @@ -969,8 +961,8 @@ forms--the-record-list ." | |||
| 969 | 961 | ||
| 970 | (save-excursion | 962 | (save-excursion |
| 971 | (set-buffer forms--file-buffer) | 963 | (set-buffer forms--file-buffer) |
| 972 | ;; Insert something before kill-line is called. See kill-line | 964 | ;; Insert something before kill-line is called. See kill-line |
| 973 | ;; doc. Bugfix provided by Ignatios Souvatzis. | 965 | ;; doc. Bugfix provided by Ignatios Souvatzis. |
| 974 | (insert "*") | 966 | (insert "*") |
| 975 | (beginning-of-line) | 967 | (beginning-of-line) |
| 976 | (kill-line nil) | 968 | (kill-line nil) |
| @@ -984,32 +976,33 @@ forms--the-record-list ." | |||
| 984 | (forms--update) | 976 | (forms--update) |
| 985 | (set-buffer-modified-p nil) | 977 | (set-buffer-modified-p nil) |
| 986 | (goto-char here)))) | 978 | (goto-char here)))) |
| 987 | |||
| 988 | 979 | ||
| 989 | ;;; Start and exit | 980 | ;;; Start and exit |
| 981 | |||
| 982 | ;;;###autoload | ||
| 990 | (defun forms-find-file (fn) | 983 | (defun forms-find-file (fn) |
| 991 | "Visit file FN in forms mode" | 984 | "Visit a file in Forms mode." |
| 992 | (interactive "fForms file: ") | 985 | (interactive "fForms file: ") |
| 993 | (find-file-read-only fn) | 986 | (find-file-read-only fn) |
| 994 | (or forms--mode-setup (forms-mode t))) | 987 | (or forms--mode-setup (forms-mode t))) |
| 995 | 988 | ||
| 989 | ;;;###autoload | ||
| 996 | (defun forms-find-file-other-window (fn) | 990 | (defun forms-find-file-other-window (fn) |
| 997 | "Visit file FN in form mode in other window" | 991 | "Visit a file in Forms mode in other window." |
| 998 | (interactive "fFbrowse file in other window: ") | 992 | (interactive "fFbrowse file in other window: ") |
| 999 | (find-file-other-window fn) | 993 | (find-file-other-window fn) |
| 1000 | (eval-current-buffer) | 994 | (eval-current-buffer) |
| 1001 | (or forms--mode-setup (forms-mode t))) | 995 | (or forms--mode-setup (forms-mode t))) |
| 1002 | 996 | ||
| 1003 | (defun forms-exit (query) | 997 | (defun forms-exit (query) |
| 1004 | "Normal exit. Modified buffers are saved." | 998 | "Normal exit from Forms mode. Modified buffers are saved." |
| 1005 | (interactive "P") | 999 | (interactive "P") |
| 1006 | (forms--exit query t)) | 1000 | (forms--exit query t)) |
| 1007 | 1001 | ||
| 1008 | (defun forms-exit-no-save (query) | 1002 | (defun forms-exit-no-save (query) |
| 1009 | "Exit without saving buffers." | 1003 | "Exit from Forms mode without saving buffers." |
| 1010 | (interactive "P") | 1004 | (interactive "P") |
| 1011 | (forms--exit query nil)) | 1005 | (forms--exit query nil)) |
| 1012 | |||
| 1013 | 1006 | ||
| 1014 | ;;; Navigating commands | 1007 | ;;; Navigating commands |
| 1015 | 1008 | ||
| @@ -1076,8 +1069,8 @@ forms--the-record-list ." | |||
| 1076 | (forms-jump-record 1)) | 1069 | (forms-jump-record 1)) |
| 1077 | 1070 | ||
| 1078 | (defun forms-last-record () | 1071 | (defun forms-last-record () |
| 1079 | "Jump to last record. As a side effect: re-calculates the number | 1072 | "Jump to last record. |
| 1080 | of records in the data file." | 1073 | As a side effect: re-calculates the number of records in the data file." |
| 1081 | (interactive) | 1074 | (interactive) |
| 1082 | (let | 1075 | (let |
| 1083 | ((numrec | 1076 | ((numrec |
| @@ -1090,9 +1083,9 @@ forms--the-record-list ." | |||
| 1090 | (setq forms--total-records numrec) | 1083 | (setq forms--total-records numrec) |
| 1091 | (message "Number of records reset to %d." forms--total-records))) | 1084 | (message "Number of records reset to %d." forms--total-records))) |
| 1092 | (forms-jump-record forms--total-records)) | 1085 | (forms-jump-record forms--total-records)) |
| 1093 | |||
| 1094 | 1086 | ||
| 1095 | ;;; Other commands | 1087 | ;;; Other commands |
| 1088 | |||
| 1096 | (defun forms-view-mode () | 1089 | (defun forms-view-mode () |
| 1097 | "Visit buffer read-only." | 1090 | "Visit buffer read-only." |
| 1098 | (interactive) | 1091 | (interactive) |
| @@ -1127,11 +1120,11 @@ forms--the-record-list ." | |||
| 1127 | ;; (setq forms-new-record-filter 'my-new-record-filter) | 1120 | ;; (setq forms-new-record-filter 'my-new-record-filter) |
| 1128 | 1121 | ||
| 1129 | (defun forms-insert-record (arg) | 1122 | (defun forms-insert-record (arg) |
| 1130 | "Create a new record before the current one. With ARG: store the | 1123 | "Create a new record before the current one. |
| 1131 | record after the current one. | 1124 | With ARG: store the record after the current one. |
| 1132 | If a function forms-new-record-filter is defined, or forms-new-record-filter | 1125 | If a function forms-new-record-filter is defined, or |
| 1133 | contains the name of a function, it is called to | 1126 | forms-new-record-filter contains the name of a function, |
| 1134 | fill (some of) the fields with default values." | 1127 | it is called to fill (some of) the fields with default values." |
| 1135 | ; The above doc is not true, but for documentary purposes only | 1128 | ; The above doc is not true, but for documentary purposes only |
| 1136 | 1129 | ||
| 1137 | (interactive "P") | 1130 | (interactive "P") |
| @@ -1167,7 +1160,7 @@ forms--the-record-list ." | |||
| 1167 | (forms-jump-record forms--current-record)) | 1160 | (forms-jump-record forms--current-record)) |
| 1168 | 1161 | ||
| 1169 | (defun forms-delete-record (arg) | 1162 | (defun forms-delete-record (arg) |
| 1170 | "Deletes a record. With ARG: don't ask." | 1163 | "Deletes a record. With a prefix argument: don't ask." |
| 1171 | (interactive "P") | 1164 | (interactive "P") |
| 1172 | (forms--checkmod) | 1165 | (forms--checkmod) |
| 1173 | (if (or arg | 1166 | (if (or arg |
| @@ -1254,8 +1247,9 @@ forms--the-record-list ." | |||
| 1254 | ;;; Special service | 1247 | ;;; Special service |
| 1255 | ;;; | 1248 | ;;; |
| 1256 | (defun forms-enumerate (the-fields) | 1249 | (defun forms-enumerate (the-fields) |
| 1257 | "Take a quoted list of symbols, and set their values to the numbers | 1250 | "Take a quoted list of symbols, and set their values to sequential numbers. |
| 1258 | 1, 2 and so on. Returns the higest number. | 1251 | The first symbol gets number 1, the second 2 and so on. |
| 1252 | It returns the higest number. | ||
| 1259 | 1253 | ||
| 1260 | Usage: (setq forms-number-of-fields | 1254 | Usage: (setq forms-number-of-fields |
| 1261 | (forms-enumerate | 1255 | (forms-enumerate |
| @@ -1270,12 +1264,12 @@ Usage: (setq forms-number-of-fields | |||
| 1270 | the-index)) | 1264 | the-index)) |
| 1271 | 1265 | ||
| 1272 | ;;; Debugging | 1266 | ;;; Debugging |
| 1273 | ;;; | 1267 | |
| 1274 | (defvar forms--debug nil | 1268 | (defvar forms--debug nil |
| 1275 | "*Enables forms-mode debugging if not nil.") | 1269 | "*Enables forms-mode debugging if not nil.") |
| 1276 | 1270 | ||
| 1277 | (defun forms--debug (&rest args) | 1271 | (defun forms--debug (&rest args) |
| 1278 | "Internal - debugging routine" | 1272 | "Internal debugging routine." |
| 1279 | (if forms--debug | 1273 | (if forms--debug |
| 1280 | (let ((ret nil)) | 1274 | (let ((ret nil)) |
| 1281 | (while args | 1275 | (while args |