comparison lisp/generic.el @ 21014:e3e68c9d2e35

Several doc fixes.
author Richard M. Stallman <rms@gnu.org>
date Mon, 02 Mar 1998 03:48:45 +0000
parents adb28ace7f33
children cc3f3c1ea725
comparison
equal deleted inserted replaced
21013:adb28ace7f33 21014:e3e68c9d2e35
31 ;;; Commentary: 31 ;;; Commentary:
32 32
33 ;; INTRODUCTION: 33 ;; INTRODUCTION:
34 34
35 ;; Generic-mode is a meta-mode which can be used to define small modes 35 ;; Generic-mode is a meta-mode which can be used to define small modes
36 ;; which provide basic comment and font-lock support. These modes are 36 ;; which provide basic comment and font-lock support. These modes are
37 ;; intended for the many configuration files and such which are too small 37 ;; intended for the many configuration files and such which are too small
38 ;; for a "real" mode, but still have a regular syntax, comment characters 38 ;; for a "real" mode, but still have a regular syntax, comment characters
39 ;; and the like. 39 ;; and the like.
40 ;; 40 ;;
41 ;; Each generic mode can define the following: 41 ;; Each generic mode can define the following:
42 ;; 42 ;;
43 ;; * List of comment-characters. The entries in this list should be 43 ;; * List of comment-characters. The entries in this list should be
44 ;; either a character, a one or two character string or a cons pair. 44 ;; either a character, a one or two character string or a cons pair.
45 ;; If the entry is a character or a one-character string 45 ;; If the entry is a character or a one-character string
46 ;; LIMITATIONS: Emacs does not support comment strings of more than 46 ;; LIMITATIONS: Emacs does not support comment strings of more than
47 ;; two characters in length. 47 ;; two characters in length.
48 ;; 48 ;;
49 ;; * List of keywords to font-lock. Each keyword should be a string. 49 ;; * List of keywords to font-lock. Each keyword should be a string.
50 ;; If you have additional keywords which should be highlighted in a face 50 ;; If you have additional keywords which should be highlighted in a face
51 ;; different from 'font-lock-keyword-face', you can use the convenience 51 ;; different from 'font-lock-keyword-face', you can use the convenience
52 ;; function 'generic-make-keywords-list' (which see), and add the 52 ;; function 'generic-make-keywords-list' (which see), and add the
53 ;; result to the following list: 53 ;; result to the following list:
54 ;; 54 ;;
55 ;; * Additional expressions to font-lock. This should be a list of 55 ;; * Additional expressions to font-lock. This should be a list of
56 ;; expressions, each of which should be of the same form 56 ;; expressions, each of which should be of the same form
57 ;; as those in 'font-lock-defaults-alist'. 57 ;; as those in 'font-lock-defaults-alist'.
58 ;; 58 ;;
59 ;; * List of regular expressions to be placed in auto-mode-alist. 59 ;; * List of regular expressions to be placed in auto-mode-alist.
60 ;; 60 ;;
86 ;; nil 86 ;; nil
87 ;; (list "\.FOO") 87 ;; (list "\.FOO")
88 ;; (list 'foo-setup-function)) 88 ;; (list 'foo-setup-function))
89 ;; 89 ;;
90 ;; defines a new generic-mode 'foo-generic-mode', which has '%' as a 90 ;; defines a new generic-mode 'foo-generic-mode', which has '%' as a
91 ;; comment character, and "keyword" as a keyword. When files which end in 91 ;; comment character, and "keyword" as a keyword. When files which end in
92 ;; '.FOO' are loaded, Emacs will go into foo-generic-mode and call 92 ;; '.FOO' are loaded, Emacs will go into foo-generic-mode and call
93 ;; foo-setup-function. You can also use the function 'foo-generic-mode' 93 ;; foo-setup-function. You can also use the function 'foo-generic-mode'
94 ;; (which is interactive) to put a buffer into foo-generic-mode. 94 ;; (which is interactive) to put a buffer into foo-generic-mode.
95 ;; 95 ;;
96 ;; AUTOMATICALLY ENTERING GENERIC MODE: 96 ;; AUTOMATICALLY ENTERING GENERIC MODE:
97 ;; 97 ;;
98 ;; Generic-mode provides a hook which automatically puts a 98 ;; Generic-mode provides a hook which automatically puts a
99 ;; file into default-generic-mode if the first few lines of a file in 99 ;; file into default-generic-mode if the first few lines of a file in
100 ;; fundamental mode start with a hash comment character. To disable 100 ;; fundamental mode start with a hash comment character. To disable
101 ;; this functionality, set the variable 'generic-use-find-file-hook' 101 ;; this functionality, set the variable 'generic-use-find-file-hook'
102 ;; to nil BEFORE loading generic-mode. See the variables 102 ;; to nil BEFORE loading generic-mode. See the variables
103 ;; 'generic-lines-to-scan' and 'generic-find-file-regexp' for customization 103 ;; 'generic-lines-to-scan' and 'generic-find-file-regexp' for customization
104 ;; options. 104 ;; options.
105 ;; 105 ;;
106 ;; GOTCHAS: 106 ;; GOTCHAS:
107 ;; 107 ;;
108 ;; Be careful that your font-lock definitions are correct. Getting them 108 ;; Be careful that your font-lock definitions are correct. Getting them
109 ;; wrong can cause emacs to continually attempt to fontify! This problem 109 ;; wrong can cause emacs to continually attempt to fontify! This problem
110 ;; is not specific to generic-mode. 110 ;; is not specific to generic-mode.
111 ;; 111 ;;
112 112
113 ;; Credit for suggestions, brainstorming, patches and bug-fixes: 113 ;; Credit for suggestions, brainstorming, patches and bug-fixes:
114 ;; ACorreir@pervasive-sw.com (Alfred Correira) 114 ;; ACorreir@pervasive-sw.com (Alfred Correira)
115
116 ;;; Change log:
117 ;; $Log: generic.el,v $
118 ;; Revision 1.2 1997/12/12 16:53:45 fx
119 ;; Use imenu-case-fold-search.
120 ;;
121 ;; Revision 1.1 1997/06/15 07:01:26 rms
122 ;; Initial revision
123 ;;
124 ;; Revision 1.6 1996/11/01 17:27:47 peter
125 ;; Changed the function generic-function-name to return a string instead
126 ;; of a symbol. Generic-mode now uses this for the mode's name
127 ;;
128 ;; Revision 1.5 1996/11/01 16:45:20 peter
129 ;; Added GPL and LCD information.
130 ;; Updated documentation
131 ;; Added generic-find-file-regexp variable
132 ;; Added generic-make-keywords-list function
133 ;;
134 ;; Revision 1.4 1996/10/19 12:16:59 peter
135 ;; Small bug fixes: fontlock -> font-lock
136 ;; New entries are added to the end of auto-mode-alist
137 ;; Generic-font-lock-defaults are set to nil, not (list nil)
138 ;; Comment-regexp in generic-mode-find-file-hook changed to allow optional
139 ;; blank lines
140 ;;
141 ;; Revision 1.3 1996/10/17 08:24:25 peter
142 ;; Added generic-mode-find-file-hook and associated variables
143 ;;
144 ;; Revision 1.2 1996/10/17 01:00:45 peter
145 ;; Moved from a data-centered approach (generic-mode-alist) to
146 ;; a function-based one (define-generic-mode)
147 ;;
148 ;; Revision 1.1 1996/10/10 11:37:36 peter
149 ;; Initial revision
150 ;;
151 115
152 ;;; Code: 116 ;;; Code:
153 117
154 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 118 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
155 ;; Variables 119 ;; Variables
264 FONT-LOCK-LIST is a list of additional expressions to highlight. Each entry 228 FONT-LOCK-LIST is a list of additional expressions to highlight. Each entry
265 in the list should have the same form as an entry in `font-lock-defaults-alist' 229 in the list should have the same form as an entry in `font-lock-defaults-alist'
266 230
267 AUTO-MODE-LIST is a list of regular expressions to add to auto-mode-alist. 231 AUTO-MODE-LIST is a list of regular expressions to add to auto-mode-alist.
268 These regexps are added to auto-mode-alist as soon as `define-generic-mode' 232 These regexps are added to auto-mode-alist as soon as `define-generic-mode'
269 is called; any old regexps with the same name are removed. To modify the 233 is called; any old regexps with the same name are removed.
270 auto-mode-alist expressions, use `alter-generic-mode-auto-mode' (which see).
271 234
272 FUNCTION-LIST is a list of functions to call to do some additional setup. 235 FUNCTION-LIST is a list of functions to call to do some additional setup.
273 236
274 See the file generic-extras.el for some examples of `define-generic-mode'." 237 See the file generic-x.el for some examples of `define-generic-mode'."
275 238
276 ;; Basic sanity check 239 ;; Basic sanity check
277 (generic-mode-sanity-check name 240 (generic-mode-sanity-check name
278 comment-list keyword-list font-lock-list 241 comment-list keyword-list font-lock-list
279 auto-mode-list function-list description) 242 auto-mode-list function-list description)
386 "A mode to do basic comment and font-lock functionality 349 "A mode to do basic comment and font-lock functionality
387 for files which are too small to warrant their own mode, but have 350 for files which are too small to warrant their own mode, but have
388 comment characters, keywords, and the like. 351 comment characters, keywords, and the like.
389 352
390 To define a generic-mode, use the function `define-generic-mode'. 353 To define a generic-mode, use the function `define-generic-mode'.
391 To alter an existing generic-mode, use the `alter-generic-mode-' 354 Some generic modes are defined in `generic-x.el'."
392 convenience functions.
393 Some generic modes are defined in generic-extras.el"
394 (interactive 355 (interactive
395 (list (generic-read-type))) 356 (list (generic-read-type)))
396 (generic-mode-with-type (intern type))) 357 (generic-mode-with-type (intern type)))
397 358
398 ;;; Comment Functionality 359 ;;; Comment Functionality