diff options
| author | Richard M. Stallman | 1998-05-01 04:11:54 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-05-01 04:11:54 +0000 |
| commit | 4eea26a9879a33e7161d00de1d7d367b3148e230 (patch) | |
| tree | d393cd3623d0a9bf3fb22e2e1451794ff186516b | |
| parent | 3d5b2234041e5077ebb29bdc9a4b6805aac74fd2 (diff) | |
| download | emacs-4eea26a9879a33e7161d00de1d7d367b3148e230.tar.gz emacs-4eea26a9879a33e7161d00de1d7d367b3148e230.zip | |
(generic): Added defgroup declaration.
(generic-make-keywords-list): Uses regexp-opt.
(generic-mode-set-font-lock): Uses regexp-opt.
| -rw-r--r-- | lisp/generic.el | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/lisp/generic.el b/lisp/generic.el index 9e4f15086b3..fd7117c3a78 100644 --- a/lisp/generic.el +++ b/lisp/generic.el | |||
| @@ -162,6 +162,11 @@ instead (which see).") | |||
| 162 | ;; Customization Variables | 162 | ;; Customization Variables |
| 163 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 163 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 164 | 164 | ||
| 165 | (defgroup generic nil | ||
| 166 | "Define simple major modes with comment and font-lock support." | ||
| 167 | :prefix "generic-" | ||
| 168 | :group 'extensions) | ||
| 169 | |||
| 165 | (defcustom generic-use-find-file-hook t | 170 | (defcustom generic-use-find-file-hook t |
| 166 | "*If non-nil, add a hook to enter default-generic-mode automatically | 171 | "*If non-nil, add a hook to enter default-generic-mode automatically |
| 167 | if the first few lines of a file in fundamental mode start with a hash | 172 | if the first few lines of a file in fundamental mode start with a hash |
| @@ -499,13 +504,10 @@ Some generic modes are defined in `generic-x.el'." | |||
| 499 | (setq | 504 | (setq |
| 500 | generic-font-lock-expressions | 505 | generic-font-lock-expressions |
| 501 | (append | 506 | (append |
| 502 | (list | 507 | (list (let ((regexp (regexp-opt keywords))) |
| 503 | (list | 508 | (list (concat "\\<\\(" regexp "\\)\\>") |
| 504 | (concat | 509 | 1 |
| 505 | "\\(\\<" | 510 | 'font-lock-keyword-face))) |
| 506 | (mapconcat 'identity keywords "\\>\\|\\<") | ||
| 507 | "\\>\\)") | ||
| 508 | 1 'font-lock-keyword-face)) | ||
| 509 | generic-font-lock-expressions))) | 511 | generic-font-lock-expressions))) |
| 510 | ;; Other font-lock expressions | 512 | ;; Other font-lock expressions |
| 511 | (and font-lock-expressions | 513 | (and font-lock-expressions |
| @@ -570,21 +572,17 @@ This hook is NOT installed by default." | |||
| 570 | (defun generic-make-keywords-list (keywords-list face &optional prefix suffix) | 572 | (defun generic-make-keywords-list (keywords-list face &optional prefix suffix) |
| 571 | "Return a regular expression matching the specified keywords. | 573 | "Return a regular expression matching the specified keywords. |
| 572 | The regexp is highlighted with FACE." | 574 | The regexp is highlighted with FACE." |
| 573 | ;; Sanity checks | ||
| 574 | ;; Don't check here; face may not be defined yet | ||
| 575 | ;; (if (not (facep face)) | ||
| 576 | ;; (error "Face %s is not defined" (princ face))) | ||
| 577 | (and (not (listp keywords-list)) | 575 | (and (not (listp keywords-list)) |
| 578 | (error "Keywords argument must be a list of strings")) | 576 | (error "Keywords argument must be a list of strings")) |
| 579 | (list | 577 | (list (concat (or prefix "") |
| 580 | (concat | 578 | "\\<\\(" |
| 581 | (or prefix "") | 579 | ;; Use an optimized regexp. |
| 582 | "\\(\\<" | 580 | (regexp-opt keywords-list t) |
| 583 | (mapconcat 'identity keywords-list "\\>\\|\\<") | 581 | "\\)\\>" |
| 584 | "\\>\\)" | 582 | (or suffix "")) |
| 585 | (or suffix "") | 583 | 1 |
| 586 | ) 1 face)) | 584 | face))) |
| 587 | 585 | ||
| 588 | (provide 'generic) | 586 | (provide 'generic) |
| 589 | 587 | ||
| 590 | ;;; generic.el ends here | 588 | ;;; generic.el ends here \ No newline at end of file |