Mercurial > emacs
changeset 21879:14316c9ecdac
(generic): Added defgroup declaration.
(generic-make-keywords-list): Uses regexp-opt.
(generic-mode-set-font-lock): Uses regexp-opt.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 01 May 1998 04:11:54 +0000 |
parents | 8941ce81cd7c |
children | 0a3488a71129 |
files | lisp/generic.el |
diffstat | 1 files changed, 18 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/generic.el Fri May 01 03:51:57 1998 +0000 +++ b/lisp/generic.el Fri May 01 04:11:54 1998 +0000 @@ -162,6 +162,11 @@ ;; Customization Variables ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defgroup generic nil + "Define simple major modes with comment and font-lock support." + :prefix "generic-" + :group 'extensions) + (defcustom generic-use-find-file-hook t "*If non-nil, add a hook to enter default-generic-mode automatically if the first few lines of a file in fundamental mode start with a hash @@ -499,13 +504,10 @@ (setq generic-font-lock-expressions (append - (list - (list - (concat - "\\(\\<" - (mapconcat 'identity keywords "\\>\\|\\<") - "\\>\\)") - 1 'font-lock-keyword-face)) + (list (let ((regexp (regexp-opt keywords))) + (list (concat "\\<\\(" regexp "\\)\\>") + 1 + 'font-lock-keyword-face))) generic-font-lock-expressions))) ;; Other font-lock expressions (and font-lock-expressions @@ -570,21 +572,17 @@ (defun generic-make-keywords-list (keywords-list face &optional prefix suffix) "Return a regular expression matching the specified keywords. The regexp is highlighted with FACE." - ;; Sanity checks - ;; Don't check here; face may not be defined yet - ;; (if (not (facep face)) - ;; (error "Face %s is not defined" (princ face))) (and (not (listp keywords-list)) (error "Keywords argument must be a list of strings")) - (list - (concat - (or prefix "") - "\\(\\<" - (mapconcat 'identity keywords-list "\\>\\|\\<") - "\\>\\)" - (or suffix "") - ) 1 face)) + (list (concat (or prefix "") + "\\<\\(" + ;; Use an optimized regexp. + (regexp-opt keywords-list t) + "\\)\\>" + (or suffix "")) + 1 + face))) (provide 'generic) -;;; generic.el ends here +;;; generic.el ends here \ No newline at end of file