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

Lines Matching +defs:the +defs:face

11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
33 ;; should *NOT* be used from the outside.
44 ;; separated by a newline, the fields are separated by a user-defined
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
54 ;; present the forms.
55 ;; The second file holds the actual data. The buffer of this file
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.
68 ;; and should set at least the following variables:
71 ;; The name of the data file.
81 ;; - a string, e.g. "hello". The string is inserted in the forms
90 ;; string. It should *NOT* have side-effects on the forms being
91 ;; constructed. The current fields are available to the function
92 ;; in the variable `forms-fields', they should *NOT* be modified.
94 ;; - a lisp symbol, that must evaluate to one of the above.
96 ;; Optional variables which may be set in the control file:
99 ;; The field separator used to separate the
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
110 ;; a record is found that does not have the number
114 ;; If non-null, the records of the data file may
116 ;; the form.
117 ;; This variable denotes the separator string
121 ;; back to the separator string.
124 ;; Non-nil means: rebind locally the commands that
129 ;; Non-nil means: rebind locally the commands
136 ;; current record, also initial position is at the
137 ;; last record. The default is to insert before the
138 ;; current record and the initial position is at the
142 ;; If not nil: this should be the name of a
143 ;; function that is called after the forms data file
145 ;; the contents of the file into a format more suitable
149 ;; If not nil: this should be the name of a
150 ;; function that is called before the forms data file
152 ;; the effects of `forms-read-file-filter', if any.
155 ;; If not nil: this should be the name of a
158 ;; the new record with default fields, for example.
161 ;; If not nil: this should be the name of a
163 ;; been modified. It is called after the fields
169 ;; text properties to protect the form text from being
171 ;; Also, the read-write fields are shown using a
172 ;; distinct face, if possible.
173 ;; As of emacs 19.29, the `intangible' text property
177 ;; The default face to show read-write fields is
178 ;; copied from face `region'.
180 ;; forms-ro-face [symbol, default 'default]
181 ;; This is the face that is used to show
182 ;; read-only text on the screen. If used, this
184 ;; valid face.
186 ;; (make-face 'my-face)
187 ;; (setq forms-ro-face 'my-face)
189 ;; forms-rw-face [symbol, default 'region]
190 ;; This is the face that is used to show
191 ;; read-write text on the screen.
193 ;; After evaluating the control file, its buffer is cleared and used
200 ;; Normal operation is to transfer one line (record) from the data file,
201 ;; split it into fields (into `forms--the-record-list'), and display it
202 ;; using the specs in `forms-format-list'.
204 ;; the records according to `forms-format-list'.
206 ;; When a form is changed the record is updated as soon as this form
207 ;; is left. The contents of the form are parsed using information
208 ;; obtained from `forms-format-list', and the fields which are
209 ;; deduced from the form are modified. Fields not shown on the forms
211 ;; replaces the contents of the old record in `forms--file-buffer'.
213 ;; the records.
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)
231 ;; As a documented side-effect: jumping to the last record in the
236 ;; mode. View mode is a read-only mode, whereby you cannot modify the
237 ;; contents of the buffer.
269 ;; Of course, it is also possible to use the \C-c prefix to obtain the
272 ;; The following bindings are available, independent of the mode:
282 ;; don't need the C-c prefix for this command.
285 ;; the bindings of standard functions `scroll-up', `scroll-down',
290 ;; `write-file-functions' is defined to save the actual data file
291 ;; instead of the buffer data, `revert-file-hook' is defined to
312 ;;; Mandatory variables - must be set by evaluating the control file.
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.")
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
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'.")
369 "List with fields of the current forms. First field has number 1.
370 This variable is for use by the filter routines only.
385 (defcustom forms-ro-face 'default
386 "The face (a symbol) that is used to display read-only text on the screen."
388 :type 'face)
390 (defcustom forms-rw-face 'region
391 "The face (a symbol) that is used to display read-write text on the screen."
393 :type 'face)
399 "Buffer which holds the file data")
402 "Total number of records in the data file.")
405 "Number of the record currently on the screen.")
415 "Field markers in the screen.")
418 "Dynamic texts (resulting from function calls) on the screen.")
420 (defvar forms--the-record-list nil
421 "List of strings of the current record, as parsed from the file.")
440 "Array with the order in which the fields are displayed.")
442 (defvar forms--ro-face nil
443 "Face used to represent read-only data on the screen.")
445 (defvar forms--rw-face nil
446 "Face used to represent read-write data on the screen.")
472 ;; takes an optional argument `primary' which is used for the
474 ;; A global buffer-local variable `forms--mode-setup' has the same
478 ;; executed where the variable is first needed, I have deliberately
481 ;; Primary set-up: evaluate buffer and check if the mandatory
516 (if (fboundp 'make-face)
518 (make-local-variable 'forms-ro-face)
519 (make-local-variable 'forms-rw-face)))
521 ;; eval the buffer, should set variables
523 ;; If enable-local-eval is not set to t the user is asked first.
531 ;; Check if the mandatory variables make sense.
570 ;; Build the formatter and parser.
592 ;; The filters acces the contents of the forms using `forms-fields'.
598 ;; Prevent accidental overwrite of the control file and auto-save.
611 ;; Copy desired faces to the actual variables used by the forms formatter.
612 (if (fboundp 'make-face)
614 (make-local-variable 'forms--ro-face)
615 (make-local-variable 'forms--rw-face)
618 (setq forms--ro-face forms-ro-face)
619 (setq forms--rw-face forms-ro-face))
620 (setq forms--ro-face forms-ro-face)
621 (setq forms--rw-face forms-rw-face))))
627 (make-local-variable 'forms--the-record-list)
641 ;; set the major mode indicator
645 ;; find the data file
663 ;; count the number of records, and set see if it may be modified
680 ;; Since we aren't really implementing a minor mode, we hack the modeline
681 ;; directly to get the text " View " into forms-read-only form buffers. For
710 ;; setup the first (or current) record to show
732 ;; Symbols in the list are evaluated, and consecutive strings are
734 ;; Array `forms--elements' is constructed that contains the order
735 ;; of the fields on the display. This array is used by
736 ;; `forms--parser-using-text-properties' to extract the fields data
737 ;; from the form on the screen.
755 (let ((the-list forms-format-list) ; the list of format elements
761 (while the-list
763 (let ((el (car-safe the-list))
764 (rem (cdr-safe the-list)))
824 ;; Advance to next element of the list.
825 (setq the-list rem)))
832 ;; Append a newline if the last item is a field.
846 ;; be no way to give the newly inserted text the RW face.
847 ;; To solve this, read-only segments get the `insert-in-front-hooks'
848 ;; property set with a function that temporarily switches the
849 ;; properties of the first character of the segment to the RW face, so
850 ;; the new text gets the right face. The `post-command-hook' is
851 ;; used to restore the original properties.
856 "Original properties of the character being overridden.")
862 ;; character beyond the actual location, it is guaranteed to move
880 (list 'face forms--rw-face 'front-sticky '(face))))
882 ;; Enable `post-command-hook' to restore the properties.
911 "Generate `forms--format' using the information in `forms-format-list'."
915 ;; This function sets up the necessary environment, and decides
928 ;; Prevent insertion before the first text.
933 ;; Prevent insertion after the last text.
941 ;; We have tallied the number of markers and dynamic texts,
942 ;; so we can allocate the arrays now.
960 ;; (list 'face forms--ro-face
963 ;; 'rear-nonsticky '(read-only face insert-in-front-hooks)))
972 ;; (list 'face forms--rw-face
973 ;; 'front-sticky '(face))))
979 ;; (list 'face forms--ro-face
982 ;; 'rear-nonsticky '(read-only face insert-in-front-hooks)))
990 ;; (list 'face forms--ro-face
993 ;; 'rear-nonsticky '(read-only face insert-in-front-hooks)))
995 ;; ;; Prevent insertion before the first text.
998 ;; ;; Prevent insertion after the last text.
1014 (list 'face forms--ro-face ; read-only appearance
1018 'rear-nonsticky '(face read-only insert-in-front-hooks
1031 (list 'face forms--rw-face
1032 'front-sticky '(face)))))))
1043 (list 'face forms--ro-face
1047 'rear-nonsticky '(read-only face insert-in-front-hooks
1056 ;; If we're not using text properties, the format routine
1090 "Generate `forms--parser' from the information in `forms-format-list'."
1094 ;; Otherwise, the function is constructed using a mapcar of
1105 ;; Note: we add a nil element to the list passed to `mapcar',
1120 ;; Using text properties, we can simply jump to the markers, and
1121 ;; extract the information up to the following read-only segment.
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.
1223 ;; Visit the file and extract the first record.
1226 (the-record))
1227 (setq the-record
1235 ;; the normal processing.
1238 ;; Count the number of fields in `the-record'.
1244 (string-match forms-field-sep the-record start-pos))
1259 "Set the keymaps used in this mode."
1266 "Fill the Forms mode keymaps."
1284 ;; `forms-mode-ro-map' replaces the local map when in read-only mode.
1302 ;; This is the normal, local map.
1479 "Fetch the current record from the file buffer."
1481 ;; This function is executed in the context of the `forms--file-buffer'.
1491 (defun forms--show-record (the-record)
1492 "Format THE-RECORD and display it in the current buffer."
1494 ;; Split the-record.
1495 (let (the-result
1500 (forms--trans the-record forms-multi-line "\n"))
1502 (setq the-record (concat the-record forms-field-sep))
1503 (while (setq found-pos (string-match forms-field-sep the-record start-pos))
1504 (let ((ent (substring the-record start-pos found-pos)))
1505 (setq the-result
1506 (append the-result (list ent)))
1508 (setq forms--the-record-list the-result))
1516 ;; Verify the number of fields, extend forms--the-record-list if needed.
1517 (if (= (length forms--the-record-list) forms-number-of-fields)
1522 (length forms--the-record-list) forms-number-of-fields))
1523 (if (< (length forms--the-record-list) forms-number-of-fields)
1524 (setq forms--the-record-list
1525 (append forms--the-record-list
1528 (length forms--the-record-list))
1531 ;; Call the formatter function.
1532 (setq forms-fields (append (list nil) forms--the-record-list nil))
1533 (funcall forms--format forms--the-record-list)
1545 ;; The contents of the form are parsed, and a new list of strings
1547 ;; A vector with the strings from the original record is
1548 ;; constructed, which is updated with the new contents. Therefore
1549 ;; fields which were not in the form are not modified.
1550 ;; Finally, the vector is transformed into a list for further processing.
1554 ;; Build the vector.
1555 (setq forms--recordv (vconcat forms--the-record-list))
1557 ;; Parse the form and update the vector.
1562 ;; As a service to the user, we add a zeroth element so she
1563 ;; can use the same indices as in the forms definition.
1564 (let ((the-fields (vconcat [nil] forms--recordv)))
1565 (setq the-fields (funcall forms-modified-record-filter the-fields))
1566 (cdr (append the-fields nil)))
1573 As a side effect: sets `forms--the-record-list'."
1578 (let (the-record)
1580 (setq forms--the-record-list (forms--parse-form))
1581 (setq the-record
1582 (mapconcat 'identity forms--the-record-list forms-field-sep))
1585 (mapconcat 'identity forms--the-record-list ""))
1590 (forms--trans the-record "\n" forms-multi-line))
1593 (if (string-match "\n" the-record)
1598 ;; adding junk to the kill-ring.
1600 (insert the-record)
1646 "Advance to the ARGth following record."
1651 "Advance to the ARGth previous record."
1657 If CURRENT is provided, it specifies the current record and can be used
1658 to speed up access to RN. Returns the number of records missing, if any."
1661 ;; goto-line does not do what we want when the buffer is narrowed.
1669 ;; Verify that the record number is within range.
1673 ;; Don't give the message if just paging.
1688 ;; Get the record and show it.
1693 ;; Move, and adjust the amount if needed (shouldn't happen).
1711 As a side effect: re-calculates the number of records in the data file."
1728 With an argument, enables read-only mode if the argument is positive.
1729 Otherwise enables edit mode if the visited file is writable."
1759 ;; (defun my-new-record-filter (the-fields)
1761 ;; (aset the-fields 4 (current-time-string))
1762 ;; (aset the-fields 6 (user-login-name))
1763 ;; the-list)
1767 "Create a new record before the current one.
1768 With ARG: store the record after the current one.
1769 If `forms-new-record-filter' contains the name of a function,
1770 it is called to fill (some of) the fields with default values.
1771 If `forms-insert-after is non-nil, the default behavior is to insert
1772 after the current record."
1779 (let (ln the-list the-record)
1788 ;; As a service to the user, we add a zeroth element so she
1789 ;; can use the same indices as in the forms definition.
1790 (let ((the-fields (make-vector (1+ forms-number-of-fields) "")))
1791 (setq the-fields (funcall forms-new-record-filter the-fields))
1792 (setq the-list (cdr (append the-fields nil))))
1793 (setq the-list (make-list forms-number-of-fields "")))
1795 (setq the-record
1798 the-list
1804 (insert the-record)
1826 ;; adding junk to the kill-ring.
1848 (let (the-line the-record here)
1858 (setq the-record (forms--get-record))
1859 (setq the-line (1+ (count-lines (point-min) (point))))
1864 (setq forms--current-record the-line)
1865 (forms--show-record the-record))
1882 (let (the-line the-record here)
1892 (setq the-record (forms--get-record))
1893 (setq the-line (1+ (count-lines (point-min) (point))))
1898 (setq forms--current-record the-line)
1899 (forms--show-record the-record))
1905 It saves the data buffer instead of the forms buffer.
1907 after writing out the data."
1920 ;; If they have a write-file-filter, force the buffer to be
1922 ;; might have changed the write-file-filter; and second, if
1932 ;; Make sure we end up with the same record number as we started.
1934 ;; the data buffer contents, save-excursion is not enough.
2002 "Send the records to the printer with `print-buffer', one record per page."
2029 (defun forms-enumerate (the-fields)
2031 The first symbol gets number 1, the second 2 and so on.
2032 It returns the highest number.
2038 (let ((the-index 0))
2039 (while the-fields
2040 (setq the-index (1+ the-index))
2041 (let ((el (car-safe the-fields)))
2042 (setq the-fields (cdr-safe the-fields))
2043 (set el the-index)))
2044 the-index))