/[emacs]/emacs/lisp/generic.el
ViewVC logotype

Diff of /emacs/lisp/generic.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.37 by lute, Mon Apr 11 08:07:14 2005 UTC revision 1.38 by lute, Mon Apr 11 23:32:17 2005 UTC
# Line 222  See the file generic-x.el for some examp Line 222  See the file generic-x.el for some examp
222      ;; Font-lock functionality.      ;; Font-lock functionality.
223      ;; Font-lock-defaults is always set even if there are no keywords      ;; Font-lock-defaults is always set even if there are no keywords
224      ;; or font-lock expressions, so comments can be highlighted.      ;; or font-lock expressions, so comments can be highlighted.
225      (setq generic-font-lock-keywords      (setq generic-font-lock-keywords font-lock-list)
226            (append      (when keyword-list
227             (when keyword-list        (push (concat "\\_<" (regexp-opt keyword-list t) "\\_>")
228               (list (generic-make-keywords-list keyword-list              generic-font-lock-keywords))
                                                font-lock-keyword-face)))  
            font-lock-list))  
229      (setq font-lock-defaults '(generic-font-lock-keywords nil))      (setq font-lock-defaults '(generic-font-lock-keywords nil))
230    
231      ;; Call a list of functions      ;; Call a list of functions
# Line 324  Some generic modes are defined in `gener Line 322  Some generic modes are defined in `gener
322          imenu-case-fold-search t))          imenu-case-fold-search t))
323    
324  ;;;###autoload  ;;;###autoload
325  (defun generic-make-keywords-list (keywords-list face &optional prefix suffix)  (defun generic-make-keywords-list (keyword-list face &optional prefix suffix)
326    "Return a regular expression matching the specified KEYWORDS-LIST.    "Return a `font-lock-keywords' construct that highlights KEYWORD-LIST.
327  The regexp is highlighted with FACE."  KEYWORD-LIST is a list of keyword strings that should be
328    (unless (listp keywords-list)  highlighted with face FACE.  This function calculates a regular
329    expression that matches these keywords and concatenates it with
330    PREFIX and SUFFIX.  Then it returns a construct based on this
331    regular expression that can be used as an element of
332    `font-lock-keywords'."
333      (unless (listp keyword-list)
334      (error "Keywords argument must be a list of strings"))      (error "Keywords argument must be a list of strings"))
335    (list (concat prefix "\\_<"    (list (concat prefix "\\_<"
336                  ;; Use an optimized regexp.                  ;; Use an optimized regexp.
337                  (regexp-opt keywords-list t)                  (regexp-opt keyword-list t)
338                  "\\_>" suffix)                  "\\_>" suffix)
339          1          1
340          face))          face))

Legend:
Removed from v.1.37  
changed lines
  Added in v.1.38

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26