[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: perl mode color highlighting working badly
From: |
Stefan Monnier |
Subject: |
Re: perl mode color highlighting working badly |
Date: |
Tue, 25 Oct 2005 22:52:13 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
> I knew the file alone wouldn't be enough. So I can try and explain what I do
> to see the problems.
Can you try the patch below and tell me if it improves anything?
And if so, at what performance cost (it only costs to perl-mode buffers)?
Stefan
--- orig/lisp/progmodes/perl-mode.el
+++ mod/lisp/progmodes/perl-mode.el
@@ -534,6 +534,7 @@
. perl-font-lock-syntactic-keywords)
(font-lock-syntactic-face-function
. perl-font-lock-syntactic-face-function)
+ (font-lock-fontify-syntactically-eagerly . t)
(parse-sexp-lookup-properties . t)))
;; Tell imenu how to handle Perl.
(set (make-local-variable 'imenu-generic-expression)
--- orig/lisp/font-lock.el
+++ mod/lisp/font-lock.el
@@ -1033,6 +1033,12 @@
Useful for things like RMAIL and Info where the whole buffer is not
a very meaningful entity to highlight.")
+(defvar font-lock-fontify-syntactically-eagerly nil
+ "If non-nil, `font-lock-fontify-syntactically-region' is applied to
non-displayed text.
+For modes which set syntax-table properties from
+`font-lock-syntactic-face-function', it may be necessary to also apply
+`font-lock-fontify-syntactically-region' on all the buffer before point.")
+
(defun font-lock-default-fontify-region (beg end loudly)
(save-buffer-state
((parse-sexp-lookup-properties
@@ -1064,11 +1070,23 @@
(unless (bolp) (setq end (line-beginning-position 2)))
;; Now do the fontification.
(font-lock-unfontify-region beg end)
- (when font-lock-syntactic-keywords
- (font-lock-fontify-syntactic-keywords-region beg end))
- (unless font-lock-keywords-only
- (font-lock-fontify-syntactically-region beg end loudly))
- (font-lock-fontify-keywords-region beg end loudly))
+ (let ((sbeg beg))
+ ;; Ensure the beginning of the file is properly
syntactic-fontified.
+ (when (and font-lock-syntactically-fontified
+ (< font-lock-syntactically-fontified sbeg))
+ (setq sbeg (max font-lock-syntactically-fontified (point-min)))
+ (setq font-lock-syntactically-fontified end))
+ (when font-lock-syntactic-keywords
+ (font-lock-fontify-syntactic-keywords-region sbeg end))
+ (unless font-lock-keywords-only
+ (font-lock-fontify-syntactically-region
+ ;; For modes which set syntax-table properties from
+ ;; font-lock-syntactic-face-function, it may be necessary to
+ ;; also apply font-lock-fontify-syntactically-region on all
+ ;; the buffer before point.
+ (if font-lock-fontify-syntactically-eagerly sbeg beg)
+ end loudly)))
+ (font-lock-fontify-keywords-region beg end loudly))
;; Clean up.
(set-syntax-table old-syntax-table))))
@@ -1282,11 +1300,6 @@
(defun font-lock-fontify-syntactic-keywords-region (start end)
"Fontify according to `font-lock-syntactic-keywords' between START and END.
START should be at the beginning of a line."
- ;; Ensure the beginning of the file is properly syntactic-fontified.
- (when (and font-lock-syntactically-fontified
- (< font-lock-syntactically-fontified start))
- (setq start (max font-lock-syntactically-fontified (point-min)))
- (setq font-lock-syntactically-fontified end))
;; If `font-lock-syntactic-keywords' is a symbol, get the real keywords.
(when (symbolp font-lock-syntactic-keywords)
(setq font-lock-syntactic-keywords (font-lock-eval-keywords
- Re: perl mode color highlighting working badly, (continued)
- Re: perl mode color highlighting working badly, Richard M. Stallman, 2005/10/23
- Re: perl mode color highlighting working badly, Stefan Monnier, 2005/10/24
- Re: perl mode color highlighting working badly, Richard M. Stallman, 2005/10/25
- Re: perl mode color highlighting working badly, Stefan Monnier, 2005/10/25
- Re: perl mode color highlighting working badly, Warren L Dodge, 2005/10/25
- Re: perl mode color highlighting working badly, Stefan Monnier, 2005/10/25
- Re: perl mode color highlighting working badly, Warren L Dodge, 2005/10/25
- Re: perl mode color highlighting working badly, Stefan Monnier, 2005/10/25
- Re: perl mode color highlighting working badly, Warren L Dodge, 2005/10/25
- Re: perl mode color highlighting working badly, Stefan Monnier, 2005/10/25
- Re: perl mode color highlighting working badly,
Stefan Monnier <=
- Re: perl mode color highlighting working badly, Warren L Dodge, 2005/10/26
- Re: perl mode color highlighting working badly, Richard M. Stallman, 2005/10/26
- Re: perl mode color highlighting working badly, Stefan Monnier, 2005/10/31
Re: perl mode color highlighting working badly, martin rudalics, 2005/10/12
Re: perl mode color highlighting working badly, martin rudalics, 2005/10/13
Re: perl mode color highlighting working badly, Stefan Monnier, 2005/10/13