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

Lines Matching +refs:generic +refs:mode +refs:list

0 ;;; generic.el --- defining simple major modes with comment and font-lock
8 ;; Keywords: generic, comment, font-lock
31 ;; The macro `define-generic-mode' can be used to define small modes
34 ;; small for a "real" mode, but still have a regular syntax, comment
37 ;; Each generic mode can define the following:
39 ;; * List of comment-characters. The elements of this list should be
42 ;; the mode's syntax table with "comment starter" syntax. If the
52 ;; convenience function `generic-make-keywords-list' (which see),
53 ;; and add the result to the following list:
55 ;; * Additional expressions to font-lock. This should be a list of
59 ;; * List of regular expressions to be placed in auto-mode-alist.
65 ;; perhaps you should be writing a major mode instead!
69 ;; You can use `define-generic-mode' like this:
71 ;; (define-generic-mode 'foo-generic-mode
72 ;; (list ?%)
73 ;; (list "keyword")
75 ;; (list "\\.FOO\\'")
76 ;; (list 'foo-setup-function))
78 ;; to define a new generic-mode `foo-generic-mode', which has '%' as a
80 ;; end in '.FOO' are loaded, Emacs will go into foo-generic-mode and
82 ;; `foo-generic-mode' (which is interactive) to put a buffer into
83 ;; foo-generic-mode.
89 ;; problem is not specific to generic-mode.
102 (defvar generic-font-lock-keywords nil
103 "Keywords for `font-lock-defaults' in a generic mode.")
104 (make-variable-buffer-local 'generic-font-lock-keywords)
105 (define-obsolete-variable-alias 'generic-font-lock-defaults 'generic-font-lock-keywords "22.1")
108 (defvar generic-mode-list nil
109 "A list of mode names for `generic-mode'.
110 Do not add entries to this list directly; use `define-generic-mode'
118 (defmacro define-generic-mode (mode comment-list keyword-list
119 font-lock-list auto-mode-list
120 function-list &optional docstring)
121 "Create a new generic mode MODE.
123 MODE is the name of the command for the generic mode; don't quote it.
124 The optional DOCSTRING is the documentation for the mode command. If
125 you do not supply it, `define-generic-mode' uses a default
128 COMMENT-LIST is a list in which each element is either a character, a
130 string is set up in the mode's syntax table as a \"comment starter\".
137 KEYWORD-LIST is a list of keywords to highlight with
140 FONT-LOCK-LIST is a list of additional expressions to highlight. Each
141 element of this list should have the same form as an element of
144 AUTO-MODE-LIST is a list of regular expressions to add to
145 `auto-mode-alist'. These regular expressions are added when Emacs
148 FUNCTION-LIST is a list of functions to call to do some additional
149 setup. The mode command calls these functions just before it runs the
150 mode hook `MODE-hook'.
152 See the file generic-x.el for some examples of `define-generic-mode'."
158 (when (eq (car-safe mode) 'quote)
159 (setq mode (eval mode)))
161 (let* ((name (symbol-name mode))
163 "-mode\\'" "" name))))
167 (add-to-list 'generic-mode-list ,name)
169 ;; Add it to auto-mode-alist
170 (dolist (re ,auto-mode-list)
171 (add-to-list 'auto-mode-alist (cons re ',mode)))
173 (defun ,mode ()
175 (concat pretty-name " mode.\n"
176 "This a generic mode defined with `define-generic-mode'.\n"
179 (generic-mode-internal ',mode ,comment-list ,keyword-list
180 ,font-lock-list ,function-list)))))
183 (defun generic-mode-internal (mode comment-list keyword-list
184 font-lock-list function-list)
185 "Go into the generic mode MODE."
186 (let* ((name (symbol-name mode))
188 "-mode\\'" "" name)))
189 (mode-hook (intern (concat name "-hook"))))
193 (setq major-mode mode
194 mode-name pretty-name)
196 (generic-mode-set-comments comment-list)
201 (setq generic-font-lock-keywords font-lock-list)
202 (when keyword-list
203 (push (concat "\\_<" (regexp-opt keyword-list t) "\\_>")
204 generic-font-lock-keywords))
205 (setq font-lock-defaults '(generic-font-lock-keywords))
207 ;; Call a list of functions
208 (mapcar 'funcall function-list)
210 (run-mode-hooks mode-hook)))
213 (defun generic-mode (mode)
214 "Enter generic mode MODE.
217 for \"generic\" files. (Files which are too small to warrant their
218 own mode, but have comment characters, keywords, and the like.)
220 To define a generic-mode, use the function `define-generic-mode'.
221 Some generic modes are defined in `generic-x.el'."
223 (list (completing-read "Generic mode: " generic-mode-list nil t)))
224 (funcall (intern mode)))
227 (defun generic-mode-set-comments (comment-list)
228 "Set up comment functionality for generic mode."
237 (dolist (start comment-list)
294 (defun generic-bracket-support ()
296 (setq imenu-generic-expression
301 (defun generic-make-keywords-list (keyword-list face &optional prefix suffix)
303 KEYWORD-LIST is a list of keyword strings that should be
309 (unless (listp keyword-list)
310 (error "Keywords argument must be a list of strings"))
311 (list (concat prefix "\\_<"
313 (regexp-opt keyword-list t)
318 (provide 'generic)
321 ;;; generic.el ends here