diff options
| author | Colin Walters | 2002-06-08 20:39:29 +0000 |
|---|---|---|
| committer | Colin Walters | 2002-06-08 20:39:29 +0000 |
| commit | 1b6adddbc333390fa3a66c4d698b4b7c79105f56 (patch) | |
| tree | 9a0dbcc9cbc4aaeef3dfdafcfb2daee9941438cd | |
| parent | 1f63f8141f593bd57508b107d7240f4d82f85000 (diff) | |
| download | emacs-1b6adddbc333390fa3a66c4d698b4b7c79105f56.tar.gz emacs-1b6adddbc333390fa3a66c4d698b4b7c79105f56.zip | |
(font-lock-category-alist): Delete.
(turn-on-font-lock-if-enabled): Don't use it.
(font-lock-symbol-category-alist): Delete.
(font-lock-default-function): Use new `char-property-alias-alist' to
make `font-lock-face' an alias for `face' when font-lock mode is
enabled.
| -rw-r--r-- | lisp/font-core.el | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/lisp/font-core.el b/lisp/font-core.el index f7964b609fe..fff4820e28a 100644 --- a/lisp/font-core.el +++ b/lisp/font-core.el | |||
| @@ -136,23 +136,6 @@ Major/minor modes can set this variable if they know which option applies.") | |||
| 136 | 136 | ||
| 137 | (defvar font-lock-fontified nil) ; Whether we have fontified the buffer. | 137 | (defvar font-lock-fontified nil) ; Whether we have fontified the buffer. |
| 138 | 138 | ||
| 139 | (defvar font-lock-category-alist nil | ||
| 140 | "An alist of (CATEGORY-SYMBOL . FACE-PROP) controlled by Font Lock. | ||
| 141 | This variable is intended to be used by special modes which construct | ||
| 142 | buffer text for display to the user (i.e. buffer-menu, occur), but | ||
| 143 | wish to have fontification turned on and off by Font Lock. If this | ||
| 144 | variable is non-nil, then calling `font-lock-mode' will simply toggle | ||
| 145 | the symbol property `face' of CATEGORY-SYMBOL.") | ||
| 146 | |||
| 147 | (defvar font-lock-symbol-category-alist nil | ||
| 148 | "An alist of (SYMBOL . CATEGORY-SYMBOL) to help maintain categories. | ||
| 149 | This variable is not directly used by font-lock; instead it is | ||
| 150 | intended to be used by modes which use `font-lock-category-alist'. | ||
| 151 | Normally, you want category symbols to be uninterned, so that their | ||
| 152 | properties can be local to a buffer. This variable helps you maintain | ||
| 153 | a mapping between normal category names (i.e. interned symbols) and | ||
| 154 | their local uninterned versions.") | ||
| 155 | |||
| 156 | (defvar font-lock-function 'font-lock-default-function | 139 | (defvar font-lock-function 'font-lock-default-function |
| 157 | "A function which is called when `font-lock-mode' is toggled. | 140 | "A function which is called when `font-lock-mode' is toggled. |
| 158 | It will be passed one argument, which is the current value of | 141 | It will be passed one argument, which is the current value of |
| @@ -229,8 +212,16 @@ your own function which is called when `font-lock-mode' is toggled via | |||
| 229 | ;; Turn on Font Lock mode. | 212 | ;; Turn on Font Lock mode. |
| 230 | (when font-lock-mode | 213 | (when font-lock-mode |
| 231 | (font-lock-set-defaults) | 214 | (font-lock-set-defaults) |
| 232 | (dolist (elt font-lock-category-alist) | 215 | (set (make-local-variable 'char-property-alias-alist) |
| 233 | (put (car elt) 'face (cdr elt))) | 216 | (copy-tree char-property-alias-alist)) |
| 217 | ;; Add `font-lock-face' as an alias for the `face' property. | ||
| 218 | (let ((elt (assq 'face char-property-alias-alist))) | ||
| 219 | (if elt | ||
| 220 | (unless (memq 'font-lock-face (cdr elt)) | ||
| 221 | (setcdr elt (nconc (cdr elt) (list 'font-lock-face)))) | ||
| 222 | (push (list 'face 'font-lock-face) char-property-alias-alist))) | ||
| 223 | ;; Only do hard work if the mode has specified stuff in | ||
| 224 | ;; `font-lock-defaults'. | ||
| 234 | (when font-lock-defaults | 225 | (when font-lock-defaults |
| 235 | (add-hook 'after-change-functions 'font-lock-after-change-function t t) | 226 | (add-hook 'after-change-functions 'font-lock-after-change-function t t) |
| 236 | (font-lock-turn-on-thing-lock) | 227 | (font-lock-turn-on-thing-lock) |
| @@ -245,8 +236,14 @@ your own function which is called when `font-lock-mode' is toggled via | |||
| 245 | (buffer-name))))))) | 236 | (buffer-name))))))) |
| 246 | ;; Turn off Font Lock mode. | 237 | ;; Turn off Font Lock mode. |
| 247 | (unless font-lock-mode | 238 | (unless font-lock-mode |
| 248 | (dolist (elt font-lock-category-alist) | 239 | ;; Remove `font-lock-face' as an alias for the `face' property. |
| 249 | (put (car elt) 'face nil)) | 240 | (set (make-local-variable 'char-property-alias-alist) |
| 241 | (copy-tree char-property-alias-alist)) | ||
| 242 | (let ((elt (assq 'face char-property-alias-alist))) | ||
| 243 | (when elt | ||
| 244 | (setcdr elt (remq 'font-lock-face (cdr elt))) | ||
| 245 | (when (null (cdr elt)) | ||
| 246 | (setq char-property-alias-alist (delq elt char-property-alias-alist))))) | ||
| 250 | (when font-lock-defaults | 247 | (when font-lock-defaults |
| 251 | (remove-hook 'after-change-functions 'font-lock-after-change-function t) | 248 | (remove-hook 'after-change-functions 'font-lock-after-change-function t) |
| 252 | (font-lock-unfontify-buffer) | 249 | (font-lock-unfontify-buffer) |
| @@ -347,7 +344,6 @@ means that Font Lock mode is turned on for buffers in C and C++ modes only." | |||
| 347 | 344 | ||
| 348 | (defun turn-on-font-lock-if-enabled () | 345 | (defun turn-on-font-lock-if-enabled () |
| 349 | (when (and (or font-lock-defaults | 346 | (when (and (or font-lock-defaults |
| 350 | font-lock-category-alist | ||
| 351 | (assq major-mode font-lock-defaults-alist)) | 347 | (assq major-mode font-lock-defaults-alist)) |
| 352 | (or (eq font-lock-global-modes t) | 348 | (or (eq font-lock-global-modes t) |
| 353 | (if (eq (car-safe font-lock-global-modes) 'not) | 349 | (if (eq (car-safe font-lock-global-modes) 'not) |