/[emacs]/emacs/lisp/font-lock.el
ViewVC logotype

Diff of /emacs/lisp/font-lock.el

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

revision 1.209 by monnier, Mon Apr 14 15:04:16 2003 UTC revision 1.210 by monnier, Mon Apr 14 23:07:39 2003 UTC
# Line 565  This is normally set via `font-lock-defa Line 565  This is normally set via `font-lock-defa
565  Currently, valid mode names are `fast-lock-mode', `jit-lock-mode' and  Currently, valid mode names are `fast-lock-mode', `jit-lock-mode' and
566  `lazy-lock-mode'.  This is normally set via `font-lock-defaults'.")  `lazy-lock-mode'.  This is normally set via `font-lock-defaults'.")
567    
568    (defvar font-lock-multiline nil
569      "Whether font-lock should cater to multiline keywords.
570    If nil, don't try to handle multiline patterns.
571    If t, always handle multiline patterns.
572    If `undecided', don't try to handle multiline patterns until you see one.
573    Major/minor modes can set this variable if they know which option applies.")
574    
575    (defvar font-lock-fontified nil)        ; Whether we have fontified the buffer.
576    
577  ;; Font Lock mode.  ;; Font Lock mode.
578    
# Line 598  Currently, valid mode names are `fast-lo Line 606  Currently, valid mode names are `fast-lo
606    (defvar font-lock-face-attributes))   ; Obsolete but respected if set.    (defvar font-lock-face-attributes))   ; Obsolete but respected if set.
607    
608  ;;;###autoload  ;;;###autoload
609    (defun font-lock-mode-internal (arg)
610      ;; Turn on Font Lock mode.
611      (when arg
612        (add-hook 'after-change-functions 'font-lock-after-change-function t t)
613        (font-lock-set-defaults)
614        (font-lock-turn-on-thing-lock)
615        ;; Fontify the buffer if we have to.
616        (let ((max-size (font-lock-value-in-major-mode font-lock-maximum-size)))
617          (cond (font-lock-fontified
618                 nil)
619                ((or (null max-size) (> max-size (buffer-size)))
620                 (font-lock-fontify-buffer))
621                (font-lock-verbose
622                 (message "Fontifying %s...buffer size greater than font-lock-maximum-size"
623                          (buffer-name))))))
624      ;; Turn off Font Lock mode.
625      (unless font-lock-mode
626        (remove-hook 'after-change-functions 'font-lock-after-change-function t)
627        (font-lock-unfontify-buffer)
628        (font-lock-turn-off-thing-lock)))
629    
630    ;;;###autoload
631  (defun font-lock-add-keywords (mode keywords &optional append)  (defun font-lock-add-keywords (mode keywords &optional append)
632    "Add highlighting KEYWORDS for MODE.    "Add highlighting KEYWORDS for MODE.
633  MODE should be a symbol, the major mode command name, such as `c-mode'  MODE should be a symbol, the major mode command name, such as `c-mode'
# Line 1446  A LEVEL of nil is equal to a LEVEL of 0, Line 1476  A LEVEL of nil is equal to a LEVEL of 0,
1476          (t          (t
1477           (car keywords))))           (car keywords))))
1478    
1479  (defun font-lock-set-defaults-1 ()  (defvar font-lock-set-defaults nil)     ; Whether we have set up defaults.
1480    (let* ((defaults (or font-lock-defaults  
1481                         (cdr (assq major-mode font-lock-defaults-alist))))  (defun font-lock-set-defaults ()
1482           (keywords    "Set fontification defaults appropriately for this mode.
1483            (font-lock-choose-keywords (nth 0 defaults)  Sets various variables using `font-lock-defaults' (or, if nil, using
1484                                       (font-lock-value-in-major-mode font-lock-maximum-decoration)))  `font-lock-defaults-alist') and `font-lock-maximum-decoration'."
1485           (local (cdr (assq major-mode font-lock-keywords-alist)))    ;; Set fontification defaults iff not previously set.
1486           (removed-keywords    (unless font-lock-set-defaults
1487            (cdr-safe (assq major-mode font-lock-removed-keywords-alist))))      (set (make-local-variable 'font-lock-set-defaults) t)
1488      (set (make-local-variable 'font-lock-defaults) defaults)      (make-local-variable 'font-lock-fontified)
1489      ;; Syntactic fontification?      (make-local-variable 'font-lock-multiline)
1490      (when (nth 1 defaults)      (let* ((defaults (or font-lock-defaults
1491        (set (make-local-variable 'font-lock-keywords-only) t))                           (cdr (assq major-mode font-lock-defaults-alist))))
1492      ;; Case fold during regexp fontification?             (keywords
1493      (when (nth 2 defaults)              (font-lock-choose-keywords (nth 0 defaults)
1494        (set (make-local-variable 'font-lock-keywords-case-fold-search) t))                                         (font-lock-value-in-major-mode font-lock-maximum-decoration)))
1495      ;; Syntax table for regexp and syntactic fontification?             (local (cdr (assq major-mode font-lock-keywords-alist)))
1496      (when (nth 3 defaults)             (removed-keywords
1497        (set (make-local-variable 'font-lock-syntax-table)              (cdr-safe (assq major-mode font-lock-removed-keywords-alist))))
1498             (copy-syntax-table (syntax-table)))        (set (make-local-variable 'font-lock-defaults) defaults)
1499        (dolist (selem (nth 3 defaults))        ;; Syntactic fontification?
1500          ;; The character to modify may be a single CHAR or a STRING.        (when (nth 1 defaults)
1501          (let ((syntax (cdr selem)))          (set (make-local-variable 'font-lock-keywords-only) t))
1502            (dolist (char (if (numberp (car selem))        ;; Case fold during regexp fontification?
1503                              (list (car selem))        (when (nth 2 defaults)
1504                            (mapcar 'identity (car selem))))          (set (make-local-variable 'font-lock-keywords-case-fold-search) t))
1505              (modify-syntax-entry char syntax font-lock-syntax-table)))))        ;; Syntax table for regexp and syntactic fontification?
1506      ;; Syntax function for syntactic fontification?        (when (nth 3 defaults)
1507      (when (nth 4 defaults)          (set (make-local-variable 'font-lock-syntax-table)
1508        (set (make-local-variable 'font-lock-beginning-of-syntax-function)               (copy-syntax-table (syntax-table)))
1509             (nth 4 defaults)))          (dolist (selem (nth 3 defaults))
1510      ;; Variable alist?            ;; The character to modify may be a single CHAR or a STRING.
1511      (dolist (x (nthcdr 5 defaults))            (let ((syntax (cdr selem)))
1512        (set (make-local-variable (car x)) (cdr x)))              (dolist (char (if (numberp (car selem))
1513      ;; Setup `font-lock-keywords' last because its value might depend                                (list (car selem))
1514      ;; on other settings (e.g. font-lock-compile-keywords uses                              (mapcar 'identity (car selem))))
1515      ;; font-lock-beginning-of-syntax-function).                (modify-syntax-entry char syntax font-lock-syntax-table)))))
1516      (set (make-local-variable 'font-lock-keywords)        ;; Syntax function for syntactic fontification?
1517           (font-lock-compile-keywords (font-lock-eval-keywords keywords) t))        (when (nth 4 defaults)
1518      ;; Local fontification?          (set (make-local-variable 'font-lock-beginning-of-syntax-function)
1519      (while local               (nth 4 defaults)))
1520        (font-lock-add-keywords nil (car (car local)) (cdr (car local)))        ;; Variable alist?
1521        (setq local (cdr local)))        (dolist (x (nthcdr 5 defaults))
1522      (when removed-keywords          (set (make-local-variable (car x)) (cdr x)))
1523        (font-lock-remove-keywords nil removed-keywords))))        ;; Setup `font-lock-keywords' last because its value might depend
1524          ;; on other settings (e.g. font-lock-compile-keywords uses
1525          ;; font-lock-beginning-of-syntax-function).
1526          (set (make-local-variable 'font-lock-keywords)
1527               (font-lock-compile-keywords (font-lock-eval-keywords keywords) t))
1528          ;; Local fontification?
1529          (while local
1530            (font-lock-add-keywords nil (car (car local)) (cdr (car local)))
1531            (setq local (cdr local)))
1532          (when removed-keywords
1533            (font-lock-remove-keywords nil removed-keywords)))))
1534    
1535  ;;; Colour etc. support.  ;;; Colour etc. support.
1536    

Legend:
Removed from v.1.209  
changed lines
  Added in v.1.210

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