diff options
| author | Richard M. Stallman | 1997-06-11 21:07:22 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-06-11 21:07:22 +0000 |
| commit | a92f7abb621d3e96719fbcdf7be75d9d1ff2e928 (patch) | |
| tree | d0c2359b0f615322a7b930df8641f32db5c9ced4 | |
| parent | 946340aed2872039908657c62def32ed751673d4 (diff) | |
| download | emacs-a92f7abb621d3e96719fbcdf7be75d9d1ff2e928.tar.gz emacs-a92f7abb621d3e96719fbcdf7be75d9d1ff2e928.zip | |
(forms-mode, forms--process-format-list)
(forms--make-parser-elt, forms-search-forward, forms-search-backward):
Fix error messages.
(forms-save-buffer):
Do not run the `write-file-filter' hooks
explicitly since they are run via `local-write-file-hooks'.
(forms-search-forward, forms-search-backward):
Wrap the search. Use `error' to signal failure.
| -rw-r--r-- | lisp/forms.el | 105 |
1 files changed, 57 insertions, 48 deletions
diff --git a/lisp/forms.el b/lisp/forms.el index ccca6d396d0..3abb15c8c20 100644 --- a/lisp/forms.el +++ b/lisp/forms.el | |||
| @@ -292,10 +292,10 @@ | |||
| 292 | (provide 'forms) ;;; official | 292 | (provide 'forms) ;;; official |
| 293 | (provide 'forms-mode) ;;; for compatibility | 293 | (provide 'forms-mode) ;;; for compatibility |
| 294 | 294 | ||
| 295 | (defconst forms-version (substring "$Revision: 2.29 $" 11 -2) | 295 | (defconst forms-version (substring "$Revision: 2.30 $" 11 -2) |
| 296 | "The version number of forms-mode (as string). The complete RCS id is: | 296 | "The version number of forms-mode (as string). The complete RCS id is: |
| 297 | 297 | ||
| 298 | $Id: forms.el,v 2.29 1996/03/01 21:13:01 jvromans Exp kwzh $") | 298 | $Id: forms.el,v 2.30 1997/06/10 18:32:33 kwzh Exp rms $") |
| 299 | 299 | ||
| 300 | (defvar forms-mode-hooks nil | 300 | (defvar forms-mode-hooks nil |
| 301 | "Hook functions to be run upon entering Forms mode.") | 301 | "Hook functions to be run upon entering Forms mode.") |
| @@ -505,22 +505,22 @@ Commands: Equivalent keys in read-only mode: | |||
| 505 | ;; Check if the mandatory variables make sense. | 505 | ;; Check if the mandatory variables make sense. |
| 506 | (or forms-file | 506 | (or forms-file |
| 507 | (error (concat "Forms control file error: " | 507 | (error (concat "Forms control file error: " |
| 508 | "'forms-file' has not been set"))) | 508 | "`forms-file' has not been set"))) |
| 509 | 509 | ||
| 510 | ;; Check forms-field-sep first, since it can be needed to | 510 | ;; Check forms-field-sep first, since it can be needed to |
| 511 | ;; construct a default format list. | 511 | ;; construct a default format list. |
| 512 | (or (stringp forms-field-sep) | 512 | (or (stringp forms-field-sep) |
| 513 | (error (concat "Forms control file error: " | 513 | (error (concat "Forms control file error: " |
| 514 | "'forms-field-sep' is not a string"))) | 514 | "`forms-field-sep' is not a string"))) |
| 515 | 515 | ||
| 516 | (if forms-number-of-fields | 516 | (if forms-number-of-fields |
| 517 | (or (and (numberp forms-number-of-fields) | 517 | (or (and (numberp forms-number-of-fields) |
| 518 | (> forms-number-of-fields 0)) | 518 | (> forms-number-of-fields 0)) |
| 519 | (error (concat "Forms control file error: " | 519 | (error (concat "Forms control file error: " |
| 520 | "'forms-number-of-fields' must be a number > 0"))) | 520 | "`forms-number-of-fields' must be a number > 0"))) |
| 521 | (or (null forms-format-list) | 521 | (or (null forms-format-list) |
| 522 | (error (concat "Forms control file error: " | 522 | (error (concat "Forms control file error: " |
| 523 | "'forms-number-of-fields' has not been set")))) | 523 | "`forms-number-of-fields' has not been set")))) |
| 524 | 524 | ||
| 525 | (or forms-format-list | 525 | (or forms-format-list |
| 526 | (forms--intuit-from-file)) | 526 | (forms--intuit-from-file)) |
| @@ -530,9 +530,9 @@ Commands: Equivalent keys in read-only mode: | |||
| 530 | (eq (length forms-multi-line) 1)) | 530 | (eq (length forms-multi-line) 1)) |
| 531 | (if (string= forms-multi-line forms-field-sep) | 531 | (if (string= forms-multi-line forms-field-sep) |
| 532 | (error (concat "Forms control file error: " | 532 | (error (concat "Forms control file error: " |
| 533 | "'forms-multi-line' is equal to 'forms-field-sep'"))) | 533 | "`forms-multi-line' is equal to 'forms-field-sep'"))) |
| 534 | (error (concat "Forms control file error: " | 534 | (error (concat "Forms control file error: " |
| 535 | "'forms-multi-line' must be nil or a one-character string")))) | 535 | "`forms-multi-line' must be nil or a one-character string")))) |
| 536 | (or (fboundp 'set-text-properties) | 536 | (or (fboundp 'set-text-properties) |
| 537 | (setq forms-use-text-properties nil)) | 537 | (setq forms-use-text-properties nil)) |
| 538 | 538 | ||
| @@ -556,12 +556,12 @@ Commands: Equivalent keys in read-only mode: | |||
| 556 | (if (and forms-new-record-filter | 556 | (if (and forms-new-record-filter |
| 557 | (not (fboundp forms-new-record-filter))) | 557 | (not (fboundp forms-new-record-filter))) |
| 558 | (error (concat "Forms control file error: " | 558 | (error (concat "Forms control file error: " |
| 559 | "'forms-new-record-filter' is not a function"))) | 559 | "`forms-new-record-filter' is not a function"))) |
| 560 | 560 | ||
| 561 | (if (and forms-modified-record-filter | 561 | (if (and forms-modified-record-filter |
| 562 | (not (fboundp forms-modified-record-filter))) | 562 | (not (fboundp forms-modified-record-filter))) |
| 563 | (error (concat "Forms control file error: " | 563 | (error (concat "Forms control file error: " |
| 564 | "'forms-modified-record-filter' is not a function"))) | 564 | "`forms-modified-record-filter' is not a function"))) |
| 565 | 565 | ||
| 566 | ;; The filters acces the contents of the forms using `forms-fields'. | 566 | ;; The filters acces the contents of the forms using `forms-fields'. |
| 567 | (make-local-variable 'forms-fields) | 567 | (make-local-variable 'forms-fields) |
| @@ -721,11 +721,11 @@ Commands: Equivalent keys in read-only mode: | |||
| 721 | ;; Verify that `forms-format-list' is not nil. | 721 | ;; Verify that `forms-format-list' is not nil. |
| 722 | (or forms-format-list | 722 | (or forms-format-list |
| 723 | (error (concat "Forms control file error: " | 723 | (error (concat "Forms control file error: " |
| 724 | "'forms-format-list' has not been set"))) | 724 | "`forms-format-list' has not been set"))) |
| 725 | ;; It must be a list. | 725 | ;; It must be a list. |
| 726 | (or (listp forms-format-list) | 726 | (or (listp forms-format-list) |
| 727 | (error (concat "Forms control file error: " | 727 | (error (concat "Forms control file error: " |
| 728 | "'forms-format-list' is not a list"))) | 728 | "`forms-format-list' is not a list"))) |
| 729 | 729 | ||
| 730 | ;; Assume every field is painted once. | 730 | ;; Assume every field is painted once. |
| 731 | ;; `forms--elements' will grow if needed. | 731 | ;; `forms--elements' will grow if needed. |
| @@ -786,7 +786,7 @@ Commands: Equivalent keys in read-only mode: | |||
| 786 | ;; Validate. | 786 | ;; Validate. |
| 787 | (or (fboundp (car-safe el)) | 787 | (or (fboundp (car-safe el)) |
| 788 | (error (concat "Forms format error: " | 788 | (error (concat "Forms format error: " |
| 789 | "not a function %S") | 789 | "%S is not a function") |
| 790 | (car-safe el))) | 790 | (car-safe el))) |
| 791 | 791 | ||
| 792 | ;; Shift. | 792 | ;; Shift. |
| @@ -1148,12 +1148,12 @@ Commands: Equivalent keys in read-only mode: | |||
| 1148 | (if forms--field | 1148 | (if forms--field |
| 1149 | (` ((setq here (point)) | 1149 | (` ((setq here (point)) |
| 1150 | (if (not (search-forward (, el) nil t nil)) | 1150 | (if (not (search-forward (, el) nil t nil)) |
| 1151 | (error "Parse error: cannot find \"%s\"" (, el))) | 1151 | (error "Parse error: cannot find `%s'" (, el))) |
| 1152 | (aset forms--recordv (, (1- forms--field)) | 1152 | (aset forms--recordv (, (1- forms--field)) |
| 1153 | (buffer-substring-no-properties here | 1153 | (buffer-substring-no-properties here |
| 1154 | (- (point) (, (length el))))))) | 1154 | (- (point) (, (length el))))))) |
| 1155 | (` ((if (not (looking-at (, (regexp-quote el)))) | 1155 | (` ((if (not (looking-at (, (regexp-quote el)))) |
| 1156 | (error "Parse error: not looking at \"%s\"" (, el))) | 1156 | (error "Parse error: not looking at `%s'" (, el))) |
| 1157 | (forward-char (, (length el)))))) | 1157 | (forward-char (, (length el)))))) |
| 1158 | (setq forms--seen-text t) | 1158 | (setq forms--seen-text t) |
| 1159 | (setq forms--field nil))) | 1159 | (setq forms--field nil))) |
| @@ -1173,13 +1173,13 @@ Commands: Equivalent keys in read-only mode: | |||
| 1173 | (` ((let ((here (point)) | 1173 | (` ((let ((here (point)) |
| 1174 | (forms--dyntext (aref forms--dyntexts (, forms--dyntext)))) | 1174 | (forms--dyntext (aref forms--dyntexts (, forms--dyntext)))) |
| 1175 | (if (not (search-forward forms--dyntext nil t nil)) | 1175 | (if (not (search-forward forms--dyntext nil t nil)) |
| 1176 | (error "Parse error: cannot find \"%s\"" forms--dyntext)) | 1176 | (error "Parse error: cannot find `%s'" forms--dyntext)) |
| 1177 | (aset forms--recordv (, (1- forms--field)) | 1177 | (aset forms--recordv (, (1- forms--field)) |
| 1178 | (buffer-substring-no-properties here | 1178 | (buffer-substring-no-properties here |
| 1179 | (- (point) (length forms--dyntext))))))) | 1179 | (- (point) (length forms--dyntext))))))) |
| 1180 | (` ((let ((forms--dyntext (aref forms--dyntexts (, forms--dyntext)))) | 1180 | (` ((let ((forms--dyntext (aref forms--dyntexts (, forms--dyntext)))) |
| 1181 | (if (not (looking-at (regexp-quote forms--dyntext))) | 1181 | (if (not (looking-at (regexp-quote forms--dyntext))) |
| 1182 | (error "Parse error: not looking at \"%s\"" forms--dyntext)) | 1182 | (error "Parse error: not looking at `%s'" forms--dyntext)) |
| 1183 | (forward-char (length forms--dyntext)))))) | 1183 | (forward-char (length forms--dyntext)))))) |
| 1184 | (setq forms--dyntext (1+ forms--dyntext)) | 1184 | (setq forms--dyntext (1+ forms--dyntext)) |
| 1185 | (setq forms--seen-text t) | 1185 | (setq forms--seen-text t) |
| @@ -1833,21 +1833,25 @@ after the current record." | |||
| 1833 | 1833 | ||
| 1834 | (let (the-line the-record here | 1834 | (let (the-line the-record here |
| 1835 | (fld-sep forms-field-sep)) | 1835 | (fld-sep forms-field-sep)) |
| 1836 | (if (save-excursion | 1836 | (save-excursion |
| 1837 | (set-buffer forms--file-buffer) | 1837 | (set-buffer forms--file-buffer) |
| 1838 | (setq here (point)) | 1838 | (end-of-line) |
| 1839 | (end-of-line) | 1839 | (setq here (point)) |
| 1840 | (if (null (re-search-forward regexp nil t)) | 1840 | (if (or (re-search-forward regexp nil t) |
| 1841 | (progn | 1841 | (and (> here (point-min)) |
| 1842 | (goto-char here) | 1842 | (progn |
| 1843 | (message "\"%s\" not found" regexp) | 1843 | (goto-char (point-min)) |
| 1844 | nil) | 1844 | (re-search-forward regexp here t)))) |
| 1845 | (progn | ||
| 1845 | (setq the-record (forms--get-record)) | 1846 | (setq the-record (forms--get-record)) |
| 1846 | (setq the-line (1+ (count-lines (point-min) (point)))))) | 1847 | (setq the-line (1+ (count-lines (point-min) (point)))) |
| 1847 | (progn | 1848 | (if (< (point) here) |
| 1848 | (setq forms--current-record the-line) | 1849 | (message "Wrapped"))) |
| 1849 | (forms--show-record the-record) | 1850 | (goto-char here) |
| 1850 | (re-search-forward regexp nil t)))) | 1851 | (error "Search failed: %s" regexp))) |
| 1852 | (setq forms--current-record the-line) | ||
| 1853 | (forms--show-record the-record)) | ||
| 1854 | (re-search-forward regexp nil t) | ||
| 1851 | (setq forms--search-regexp regexp)) | 1855 | (setq forms--search-regexp regexp)) |
| 1852 | 1856 | ||
| 1853 | (defun forms-search-backward (regexp) | 1857 | (defun forms-search-backward (regexp) |
| @@ -1865,21 +1869,25 @@ after the current record." | |||
| 1865 | 1869 | ||
| 1866 | (let (the-line the-record here | 1870 | (let (the-line the-record here |
| 1867 | (fld-sep forms-field-sep)) | 1871 | (fld-sep forms-field-sep)) |
| 1868 | (if (save-excursion | 1872 | (save-excursion |
| 1869 | (set-buffer forms--file-buffer) | 1873 | (set-buffer forms--file-buffer) |
| 1870 | (setq here (point)) | 1874 | (beginning-of-line) |
| 1871 | (beginning-of-line) | 1875 | (setq here (point)) |
| 1872 | (if (null (re-search-backward regexp nil t)) | 1876 | (if (or (re-search-backward regexp nil t) |
| 1873 | (progn | 1877 | (and (< (point) (point-max)) |
| 1874 | (goto-char here) | 1878 | (progn |
| 1875 | (message "\"%s\" not found" regexp) | 1879 | (goto-char (point-max)) |
| 1876 | nil) | 1880 | (re-search-backward regexp here t)))) |
| 1881 | (progn | ||
| 1877 | (setq the-record (forms--get-record)) | 1882 | (setq the-record (forms--get-record)) |
| 1878 | (setq the-line (1+ (count-lines (point-min) (point)))))) | 1883 | (setq the-line (1+ (count-lines (point-min) (point)))) |
| 1879 | (progn | 1884 | (if (> (point) here) |
| 1880 | (setq forms--current-record the-line) | 1885 | (message "Wrapped"))) |
| 1881 | (forms--show-record the-record) | 1886 | (goto-char here) |
| 1882 | (re-search-forward regexp nil t)))) | 1887 | (error "Search failed: %s" regexp))) |
| 1888 | (setq forms--current-record the-line) | ||
| 1889 | (forms--show-record the-record)) | ||
| 1890 | (re-search-forward regexp nil t) | ||
| 1883 | (setq forms--search-regexp regexp)) | 1891 | (setq forms--search-regexp regexp)) |
| 1884 | 1892 | ||
| 1885 | (defun forms-save-buffer (&optional args) | 1893 | (defun forms-save-buffer (&optional args) |
| @@ -1894,9 +1902,10 @@ after writing out the data." | |||
| 1894 | (save-excursion | 1902 | (save-excursion |
| 1895 | (set-buffer forms--file-buffer) | 1903 | (set-buffer forms--file-buffer) |
| 1896 | (let ((inhibit-read-only t)) | 1904 | (let ((inhibit-read-only t)) |
| 1897 | (if write-file-filter | 1905 | ;; Write file hooks are run via local-write-file-hooks. |
| 1898 | (save-excursion | 1906 | ;; (if write-file-filter |
| 1899 | (run-hooks 'write-file-filter))) | 1907 | ;; (save-excursion |
| 1908 | ;; (run-hooks 'write-file-filter))) | ||
| 1900 | (save-buffer args) | 1909 | (save-buffer args) |
| 1901 | (if read-file-filter | 1910 | (if read-file-filter |
| 1902 | (save-excursion | 1911 | (save-excursion |