diff options
| author | Simon Marshall | 1996-02-08 10:08:08 +0000 |
|---|---|---|
| committer | Simon Marshall | 1996-02-08 10:08:08 +0000 |
| commit | a465832f096eda14c0b403557d3754fd50c6ea5c (patch) | |
| tree | e3120af472bf0bffb158d4d92947dddbd1647462 | |
| parent | a860d25f73df4dc12b52e74359ff4d6d05feb653 (diff) | |
| download | emacs-a465832f096eda14c0b403557d3754fd50c6ea5c.tar.gz emacs-a465832f096eda14c0b403557d3754fd50c6ea5c.zip | |
Moved `supported' from turn-on-font-lock-if-supported to turn-on-font-lock.
| -rw-r--r-- | lisp/font-lock.el | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/lisp/font-lock.el b/lisp/font-lock.el index b7df4df0599..0358e357a3e 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el | |||
| @@ -402,10 +402,6 @@ the major mode's hook. For example, put in your ~/.emacs: | |||
| 402 | 402 | ||
| 403 | (add-hook 'c-mode-hook 'turn-on-font-lock) | 403 | (add-hook 'c-mode-hook 'turn-on-font-lock) |
| 404 | 404 | ||
| 405 | Or for any visited file with the following in your ~/.emacs: | ||
| 406 | |||
| 407 | (add-hook 'find-file-hooks 'turn-on-font-lock) | ||
| 408 | |||
| 409 | Alternatively, you can use Global Font Lock mode to automagically turn on Font | 405 | Alternatively, you can use Global Font Lock mode to automagically turn on Font |
| 410 | Lock mode in buffers whose major mode supports it, or in buffers whose major | 406 | Lock mode in buffers whose major mode supports it, or in buffers whose major |
| 411 | mode is one of `font-lock-global-modes'. For example, put in your ~/.emacs: | 407 | mode is one of `font-lock-global-modes'. For example, put in your ~/.emacs: |
| @@ -480,8 +476,12 @@ syntactic change on other lines, you can use \\[font-lock-fontify-block]." | |||
| 480 | 476 | ||
| 481 | ;;;###autoload | 477 | ;;;###autoload |
| 482 | (defun turn-on-font-lock () | 478 | (defun turn-on-font-lock () |
| 483 | "Turn on Font Lock mode, if the terminal can display it." | 479 | "Turn on Font Lock mode conditionally. |
| 484 | (if window-system (font-lock-mode t))) | 480 | Turn on only if the buffer mode supports it and the terminal can display it." |
| 481 | (if (and window-system | ||
| 482 | (not font-lock-mode) | ||
| 483 | (or font-lock-defaults (assq major-mode font-lock-defaults-alist))) | ||
| 484 | (font-lock-mode t))) | ||
| 485 | 485 | ||
| 486 | ;; Code for Global Font Lock mode. | 486 | ;; Code for Global Font Lock mode. |
| 487 | 487 | ||
| @@ -500,7 +500,7 @@ syntactic change on other lines, you can use \\[font-lock-fontify-block]." | |||
| 500 | ;; hook is run, the major mode is in the process of being changed and we do not | 500 | ;; hook is run, the major mode is in the process of being changed and we do not |
| 501 | ;; know what the final major mode will be. So, `font-lock-change-major-mode' | 501 | ;; know what the final major mode will be. So, `font-lock-change-major-mode' |
| 502 | ;; only (a) notes the name of the current buffer, and (b) adds our function | 502 | ;; only (a) notes the name of the current buffer, and (b) adds our function |
| 503 | ;; `turn-on-font-lock-if-supported' to the hook variable `post-command-hook'. | 503 | ;; `turn-on-font-lock-if-enabled' to the hook variable `post-command-hook'. |
| 504 | ;; By the time the functions on `post-command-hook' are run, the new major mode | 504 | ;; By the time the functions on `post-command-hook' are run, the new major mode |
| 505 | ;; is assumed to be in place. | 505 | ;; is assumed to be in place. |
| 506 | 506 | ||
| @@ -545,33 +545,29 @@ turned on in a buffer if its major mode is one of `font-lock-global-modes'." | |||
| 545 | (memq 'font-lock-change-major-mode change-major-mode-hook)) | 545 | (memq 'font-lock-change-major-mode change-major-mode-hook)) |
| 546 | (remove-hook 'change-major-mode-hook 'font-lock-change-major-mode) | 546 | (remove-hook 'change-major-mode-hook 'font-lock-change-major-mode) |
| 547 | (add-hook 'change-major-mode-hook 'font-lock-change-major-mode) | 547 | (add-hook 'change-major-mode-hook 'font-lock-change-major-mode) |
| 548 | (add-hook 'post-command-hook 'turn-on-font-lock-if-supported) | 548 | (add-hook 'post-command-hook 'turn-on-font-lock-if-enabled) |
| 549 | (setq font-lock-cache-buffers (buffer-list)))) | 549 | (setq font-lock-cache-buffers (buffer-list)))) |
| 550 | 550 | ||
| 551 | (defun font-lock-change-major-mode () | 551 | (defun font-lock-change-major-mode () |
| 552 | ;; Gross hack warning: Delicate readers should avert eyes now. | 552 | ;; Gross hack warning: Delicate readers should avert eyes now. |
| 553 | ;; Something is running `kill-all-local-variables', which generally means | 553 | ;; Something is running `kill-all-local-variables', which generally means |
| 554 | ;; the major mode is being changed. Run `turn-on-font-lock-if-supported' | 554 | ;; the major mode is being changed. Run `turn-on-font-lock-if-enabled' after |
| 555 | ;; after the current command has finished. | 555 | ;; the current command has finished. |
| 556 | (add-hook 'post-command-hook 'turn-on-font-lock-if-supported) | 556 | (add-hook 'post-command-hook 'turn-on-font-lock-if-enabled) |
| 557 | (add-to-list 'font-lock-cache-buffers (current-buffer))) | 557 | (add-to-list 'font-lock-cache-buffers (current-buffer))) |
| 558 | 558 | ||
| 559 | (defun turn-on-font-lock-if-supported () | 559 | (defun turn-on-font-lock-if-enabled () |
| 560 | ;; Gross hack warning: Delicate readers should avert eyes now. | 560 | ;; Gross hack warning: Delicate readers should avert eyes now. |
| 561 | ;; Turn on Font Lock mode if (a) it's not already on, (b) the major mode | 561 | ;; Turn on Font Lock mode if it's one of `font-lock-global-modes'. |
| 562 | ;; supports Font Lock mode, and (c) it's one of `font-lock-global-modes'. | 562 | (remove-hook 'post-command-hook 'turn-on-font-lock-if-enabled) |
| 563 | (remove-hook 'post-command-hook 'turn-on-font-lock-if-supported) | ||
| 564 | (while font-lock-cache-buffers | 563 | (while font-lock-cache-buffers |
| 565 | (if (buffer-name (car font-lock-cache-buffers)) | 564 | (if (buffer-live-p (car font-lock-cache-buffers)) |
| 566 | (save-excursion | 565 | (save-excursion |
| 567 | (set-buffer (car font-lock-cache-buffers)) | 566 | (set-buffer (car font-lock-cache-buffers)) |
| 568 | (if (and (not font-lock-mode) | 567 | (if (or (eq font-lock-global-modes t) |
| 569 | (or font-lock-defaults | 568 | (if (eq (car-safe font-lock-global-modes) 'not) |
| 570 | (assq major-mode font-lock-defaults-alist)) | 569 | (not (memq major-mode (cdr font-lock-global-modes))) |
| 571 | (or (eq font-lock-global-modes t) | 570 | (memq major-mode font-lock-global-modes))) |
| 572 | (if (eq (car-safe font-lock-global-modes) 'not) | ||
| 573 | (not (memq major-mode (cdr font-lock-global-modes))) | ||
| 574 | (memq major-mode font-lock-global-modes)))) | ||
| 575 | (turn-on-font-lock)))) | 571 | (turn-on-font-lock)))) |
| 576 | (setq font-lock-cache-buffers (cdr font-lock-cache-buffers)))) | 572 | (setq font-lock-cache-buffers (cdr font-lock-cache-buffers)))) |
| 577 | 573 | ||
| @@ -672,12 +668,12 @@ turned on in a buffer if its major mode is one of `font-lock-global-modes'." | |||
| 672 | (defun font-lock-fontify-block (&optional arg) | 668 | (defun font-lock-fontify-block (&optional arg) |
| 673 | "Fontify some lines the way `font-lock-fontify-buffer' would. | 669 | "Fontify some lines the way `font-lock-fontify-buffer' would. |
| 674 | The lines could be a function or paragraph, or a specified number of lines. | 670 | The lines could be a function or paragraph, or a specified number of lines. |
| 675 | If `font-lock-mark-block-function' non-nil and no ARG is given, it is used to | ||
| 676 | delimit the region to fontify. | ||
| 677 | If ARG is given, fontify that many lines before and after point, or 16 lines if | 671 | If ARG is given, fontify that many lines before and after point, or 16 lines if |
| 678 | no ARG is given and `font-lock-mark-block-function' is nil." | 672 | no ARG is given and `font-lock-mark-block-function' is nil. |
| 673 | If `font-lock-mark-block-function' non-nil and no ARG is given, it is used to | ||
| 674 | delimit the region to fontify." | ||
| 679 | (interactive "P") | 675 | (interactive "P") |
| 680 | (let ((font-lock-beginning-of-syntax-function nil)) | 676 | (let (font-lock-beginning-of-syntax-function deactivate-mark) |
| 681 | ;; Make sure we have the right `font-lock-keywords' etc. | 677 | ;; Make sure we have the right `font-lock-keywords' etc. |
| 682 | (if (not font-lock-mode) (font-lock-set-defaults)) | 678 | (if (not font-lock-mode) (font-lock-set-defaults)) |
| 683 | (save-excursion | 679 | (save-excursion |