• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/emacs-93/emacs/lisp/

Lines Matching +defs:find +defs:file +defs:other +defs:window

1 ;;; forms.el --- Forms mode: edit a file as a form to fill in
8 ;; This file is part of GNU Emacs.
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
27 ;; Visit a file using a form.
42 ;; Forms mode means visiting a data file which is supposed to consist
52 ;; The first file, called the control file, defines the name of the
53 ;; data file and the forms format. This file buffer will be used to
55 ;; The second file holds the actual data. The buffer of this file
58 ;; Forms mode is invoked using M-x `forms-find-file' control-file.
59 ;; Alternatively `forms-find-file-other-window' can be used.
61 ;; You may also visit the control file, and switch to forms mode by hand
65 ;; "-*- forms -*-" in the first line of the control file.
67 ;; The control file is visited, evaluated using `eval-buffer',
70 ;; forms-file [string]
71 ;; The name of the data file.
96 ;; Optional variables which may be set in the control file:
100 ;; fields in the data file. It may be a string.
103 ;; Non-nil means that the data file is visited
105 ;; If no write access to the data file is
114 ;; If non-null, the records of the data file may
141 ;; forms-read-file-filter [symbol, default nil]
143 ;; function that is called after the forms data file
145 ;; the contents of the file into a format more suitable
148 ;; forms-write-file-filter [symbol, default nil]
150 ;; function that is called before the forms data file
152 ;; the effects of `forms-read-file-filter', if any.
193 ;; After evaluating the control file, its buffer is cleared and used
195 ;; The data file (as designated by `forms-file') is visited in a buffer
196 ;; `forms--file-buffer' which normally will not be shown.
197 ;; Great malfunctioning may be expected if this file/buffer is modified
200 ;; Normal operation is to transfer one line (record) from the data file,
211 ;; replaces the contents of the old record in `forms--file-buffer'.
216 ;; `forms-exit' saves the data to the file, if modified.
218 ;; is executed and the file buffer has been modified, Emacs will ask
227 ;; reverting the form (NOT the file buffer)
232 ;; file (using forms-last-record) will adjust forms--total-records if
290 ;; `write-file-functions' is defined to save the actual data file
291 ;; instead of the buffer data, `revert-file-hook' is defined to
298 "Edit a file as a form to fill in."
312 ;;; Mandatory variables - must be set by evaluating the control file.
314 (defvar forms-file nil
315 "Name of the file holding the data.")
335 "Non-nil means: visit the file in view (read-only) mode.
336 This is set automatically if the file permissions don't let you write it.")
353 (defvar forms-read-file-filter nil
354 "The name of a function that is called after reading the data file.
355 This can be used to change the contents of the file to something more
358 (defvar forms-write-file-filter nil
359 "The name of a function that is called before writing the data file.
360 This can be used to undo the effects of `form-read-file-hook'.")
398 (defvar forms--file-buffer nil
399 "Buffer which holds the file data")
402 "Total number of records in the data file.")
421 "List of strings of the current record, as parsed from the file.")
476 ;; `find-file'.
489 (make-local-variable 'forms-file)
503 (make-local-variable 'forms-read-file-filter)
504 (make-local-variable 'forms-write-file-filter)
509 (setq forms-read-file-filter nil)
510 (setq forms-write-file-filter nil)
522 ;;(message "forms: processing control file...")
532 (or forms-file
533 (error (concat "Forms control file error: "
534 "`forms-file' has not been set")))
539 (error (concat "Forms control file error: "
545 (error (concat "Forms control file error: "
548 (error (concat "Forms control file error: "
552 (forms--intuit-from-file))
558 (error (concat "Forms control file error: "
560 (error (concat "Forms control file error: "
584 (error (concat "Forms control file error: "
589 (error (concat "Forms control file error: "
598 ;; Prevent accidental overwrite of the control file and auto-save.
599 (set-visited-file-name nil)
624 (make-local-variable 'forms--file-buffer)
645 ;; find the data file
646 (setq forms--file-buffer (find-file-noselect forms-file))
649 (let ((read-file-filter forms-read-file-filter)
650 (write-file-filter forms-write-file-filter))
651 (if read-file-filter
652 (with-current-buffer forms--file-buffer
654 (file-modified (buffer-modified-p)))
655 (run-hooks 'read-file-filter)
656 (if (not file-modified) (set-buffer-modified-p nil)))
657 (if write-file-filter
658 (add-hook 'write-file-functions write-file-filter nil t)))
659 (if write-file-filter
660 (with-current-buffer forms--file-buffer
661 (add-hook 'write-file-functions write-file-filter nil t)))))
666 (with-current-buffer forms--file-buffer
695 ;;(message "forms: proceeding setup (new file)...")
699 (if (file-exists-p forms-file)
700 (concat "No records available in file `" forms-file "'\n\n")
701 (format "Creating new file `%s'\nwith %d field%s per record\n\n"
702 forms-file forms-number-of-fields
744 (error (concat "Forms control file error: "
748 (error (concat "Forms control file error: "
1148 ;; (error "Parse error: cannot find \"text: \""))
1155 ;; (error "Parse error: cannot find \"\\nmore text: \""))
1174 (error "Parse error: cannot find `%s'" ,el))
1199 (error "Parse error: cannot find `%s'" forms--dyntext))
1213 (defun forms--intuit-from-file ()
1214 "Get number of fields and a default form using the data file."
1216 ;; If `forms-number-of-fields' is not set, get it from the data file.
1219 ;; Need a file to do this.
1220 (if (not (file-exists-p forms-file))
1221 (error "Need existing file or explicit `forms-number-of-fields'")
1223 ;; Visit the file and extract the first record.
1224 (setq forms--file-buffer (find-file-noselect forms-file))
1225 (let ((read-file-filter forms-read-file-filter)
1228 (with-current-buffer forms--file-buffer
1230 (run-hooks 'read-file-filter))
1236 (kill-buffer forms--file-buffer)
1250 (setq forms-format-list (list "Forms file \"" forms-file "\".\n\n"))
1464 (let ((buf (buffer-name forms--file-buffer)))
1467 (buffer-modified-p forms--file-buffer))
1469 (with-current-buffer forms--file-buffer
1470 (delete-auto-save-file-if-necessary)
1475 (delete-auto-save-file-if-necessary)
1479 "Fetch the current record from the file buffer."
1481 ;; This function is executed in the context of the `forms--file-buffer'.
1596 (with-current-buffer forms--file-buffer
1615 (defun forms-find-file (fn)
1616 "Visit a file in Forms mode."
1617 (interactive "fForms file: ")
1620 (find-file-read-only fn)
1624 (defun forms-find-file-other-window (fn)
1625 "Visit a file in Forms mode in other window."
1626 (interactive "fFbrowse file in other window: ")
1629 (find-file-other-window fn)
1690 (with-current-buffer forms--file-buffer
1711 As a side effect: re-calculates the number of records in the data file."
1715 (with-current-buffer forms--file-buffer
1729 Otherwise enables edit mode if the visited file is writable."
1741 (if (with-current-buffer forms--file-buffer
1745 (message "No write access to `%s'" forms-file))
1801 (with-current-buffer forms--file-buffer
1823 (with-current-buffer forms--file-buffer
1849 (with-current-buffer forms--file-buffer
1883 (with-current-buffer forms--file-buffer
1906 Calls `forms-write-file-filter' before, and `forms-read-file-filter'
1910 (let ((write-file-filter forms-write-file-filter)
1911 (read-file-filter forms-read-file-filter)
1913 (with-current-buffer forms--file-buffer
1915 ;; Write file hooks are run via write-file-functions.
1916 ;; (if write-file-filter
1918 ;; (run-hooks 'write-file-filter)))
1920 ;; If they have a write-file-filter, force the buffer to be
1922 ;; might have changed the write-file-filter; and second, if
1923 ;; save-buffer does nothing, write-file-filter won't get run,
1924 ;; and then read-file-filter will be mightily confused.
1925 (or (null write-file-filter)
1928 (if read-file-filter
1930 (run-hooks 'read-file-filter)))
1933 ;; Since read-file-filter may perform arbitrary transformations on