Mercurial > emacs
comparison lisp/font-lock.el @ 12047:e6001f10daad
Made font-lock-compile-keywords not compile if it looks like it already has.
author | Simon Marshall <simon@gnu.org> |
---|---|
date | Thu, 01 Jun 1995 09:08:29 +0000 |
parents | a4ab2659db4f |
children | f22803cfdc5c |
comparison
equal
deleted
inserted
replaced
12046:d23f2c9990b2 | 12047:e6001f10daad |
---|---|
495 ; (or (nth 4 state) (nth 7 state)))) | 495 ; (or (nth 4 state) (nth 7 state)))) |
496 ; (font-lock-hack-keywords beg end)) | 496 ; (font-lock-hack-keywords beg end)) |
497 | 497 |
498 ;;; Fontifying arbitrary patterns | 498 ;;; Fontifying arbitrary patterns |
499 | 499 |
500 (defun font-lock-compile-keywords () | 500 (defun font-lock-compile-keywords (&optional keywords) |
501 ;; Compile `font-lock-keywords' into the form (t KEYWORD ...) where KEYWORD | 501 ;; Compile `font-lock-keywords' into the form (t KEYWORD ...) where KEYWORD |
502 ;; is the (MATCHER HIGHLIGHT ...) shown in the variable's doc string. | 502 ;; is the (MATCHER HIGHLIGHT ...) shown in the variable's doc string. |
503 (setq font-lock-keywords | 503 (let ((keywords (or keywords font-lock-keywords))) |
504 (cons t | 504 (setq font-lock-keywords |
505 (mapcar (function | 505 (if (eq (car-safe keywords) t) |
506 (lambda (item) | 506 keywords |
507 (cond ((nlistp item) | 507 (cons t |
508 (list item '(0 font-lock-keyword-face))) | 508 (mapcar |
509 ((numberp (cdr item)) | 509 (function (lambda (item) |
510 (list (car item) (list (cdr item) | 510 (cond ((nlistp item) |
511 'font-lock-keyword-face))) | 511 (list item '(0 font-lock-keyword-face))) |
512 ((symbolp (cdr item)) | 512 ((numberp (cdr item)) |
513 (list (car item) (list 0 (cdr item)))) | 513 (list (car item) (list (cdr item) 'font-lock-keyword-face))) |
514 ((nlistp (nth 1 item)) | 514 ((symbolp (cdr item)) |
515 (list (car item) (cdr item))) | 515 (list (car item) (list 0 (cdr item)))) |
516 (t | 516 ((nlistp (nth 1 item)) |
517 item)))) | 517 (list (car item) (cdr item))) |
518 font-lock-keywords)))) | 518 (t |
519 item)))) | |
520 keywords)))))) | |
519 | 521 |
520 (defsubst font-lock-apply-highlight (highlight) | 522 (defsubst font-lock-apply-highlight (highlight) |
521 "Apply HIGHLIGHT following a match. See `font-lock-keywords'." | 523 "Apply HIGHLIGHT following a match. See `font-lock-keywords'." |
522 (let* ((match (nth 0 highlight)) | 524 (let* ((match (nth 0 highlight)) |
523 (beg (match-beginning match)) (end (match-end match)) | 525 (beg (match-beginning match)) (end (match-end match)) |