From a3609743156ca71f1e33aeafb1c803ec7a5176c0 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 15 Feb 2007 16:36:58 +0000 Subject: (font-lock-extend-region-wholelines): Only return non-nil if the region has really been changed. Reported by David Hansen --- lisp/font-lock.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lisp/font-lock.el') diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 69ba694340b..62008ac295b 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -1090,7 +1090,10 @@ Put first the functions more likely to cause a change and cheaper to compute.") (goto-char font-lock-beg) (unless (bolp) (setq changed t font-lock-beg (line-beginning-position))) (goto-char font-lock-end) - (unless (bolp) (setq changed t font-lock-end (line-beginning-position 2))) + (unless (bolp) + (unless (eq font-lock-end + (setq font-lock-end (line-beginning-position 2))) + (setq changed t))) changed)) (defun font-lock-default-fontify-region (beg end loudly) -- cgit v1.2.1 From ead4759c9c241f5179249859a283809e43c4b1bd Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 17 Feb 2007 11:28:18 +0000 Subject: (font-lock-extend-region-wholelines): Test for EOB in addition to BOL. --- lisp/font-lock.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lisp/font-lock.el') diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 62008ac295b..fd2dedc1dae 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -1075,20 +1075,20 @@ Put first the functions more likely to cause a change and cheaper to compute.") (setq font-lock-beg (or (previous-single-property-change font-lock-beg 'font-lock-multiline) (point-min)))) - ;; + ;; (when (get-text-property font-lock-end 'font-lock-multiline) (setq changed t) (setq font-lock-end (or (text-property-any font-lock-end (point-max) 'font-lock-multiline nil) (point-max)))) changed)) - - + (defun font-lock-extend-region-wholelines () "Move fontification boundaries to beginning of lines." (let ((changed nil)) (goto-char font-lock-beg) - (unless (bolp) (setq changed t font-lock-beg (line-beginning-position))) + (unless (or (bolp) (eobp)) + (setq changed t font-lock-beg (line-beginning-position))) (goto-char font-lock-end) (unless (bolp) (unless (eq font-lock-end -- cgit v1.2.1 From dfee9538a14db844e318393dd87985941526841f Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sun, 18 Feb 2007 18:52:18 +0000 Subject: (font-lock-extend-region-wholelines): Revert last change. --- lisp/font-lock.el | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'lisp/font-lock.el') diff --git a/lisp/font-lock.el b/lisp/font-lock.el index fd2dedc1dae..1e27daa89ec 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -350,7 +350,7 @@ Each element in a user-level keywords list should have one of these forms: (MATCHER . SUBEXP) (MATCHER . FACENAME) (MATCHER . HIGHLIGHT) - (MATCHER HIGHLIGHT ...) + (MATCHER . HIGHLIGHTS) (eval . FORM) where MATCHER can be either the regexp to search for, or the function name to @@ -1040,6 +1040,13 @@ The region it returns may start or end in the middle of a line.") Useful for things like RMAIL and Info where the whole buffer is not a very meaningful entity to highlight.") +(defvar font-lock-syntax-props-depend-on-themselves nil + "If non-nil, syntax-table changes may influence syntactic keywords. +If the syntax-table properties set by syntactic-keywords themselves depend +on syntax-table properties set on the text before it by syntactic-keywords, +this variable should be set to non-nil, so that whenever syntaxtic-keywords +is applied, the subsequent text is marked for syntactic re-fontification.") + (defvar font-lock-beg) (defvar font-lock-end) (defvar font-lock-extend-region-functions @@ -1087,7 +1094,7 @@ Put first the functions more likely to cause a change and cheaper to compute.") "Move fontification boundaries to beginning of lines." (let ((changed nil)) (goto-char font-lock-beg) - (unless (or (bolp) (eobp)) + (unless (bolp) (setq changed t font-lock-beg (line-beginning-position))) (goto-char font-lock-end) (unless (bolp) @@ -1124,11 +1131,25 @@ Put first the functions more likely to cause a change and cheaper to compute.") (setq beg font-lock-beg end font-lock-end)) ;; 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)) + (cond + ((< font-lock-syntactically-fontified sbeg) + ;; Ensure the syntax-table prop is properly set on the text + ;; before beg. + (setq sbeg (max font-lock-syntactically-fontified (point-min))) + (setq font-lock-syntactically-fontified end)) + ((and font-lock-syntax-props-depend-on-themselves + (> font-lock-syntactically-fontified end)) + ;; If the syntax-table properties set by + ;; font-lock-syntactic-keywords themselves depend on + ;; syntax-table props set in the text above it, then we'll + ;; need to update all the syntax-table props below end. + (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 beg end loudly)) + (font-lock-fontify-keywords-region beg end loudly)) ;; Clean up. (set-syntax-table old-syntax-table)))) @@ -1418,11 +1439,6 @@ LIMIT can be modified by the value of its PRE-MATCH-FORM." (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 -- cgit v1.2.1 From 700b8e66472752e3709bf3cae08cc82be70432a7 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sun, 18 Feb 2007 20:36:06 +0000 Subject: Revert the accidental commit of unrelated patches in the previous commit. --- lisp/font-lock.el | 38 +++++++++++--------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) (limited to 'lisp/font-lock.el') diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 1e27daa89ec..ecd4dd56d9e 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -350,7 +350,7 @@ Each element in a user-level keywords list should have one of these forms: (MATCHER . SUBEXP) (MATCHER . FACENAME) (MATCHER . HIGHLIGHT) - (MATCHER . HIGHLIGHTS) + (MATCHER HIGHLIGHT ...) (eval . FORM) where MATCHER can be either the regexp to search for, or the function name to @@ -1040,13 +1040,6 @@ The region it returns may start or end in the middle of a line.") Useful for things like RMAIL and Info where the whole buffer is not a very meaningful entity to highlight.") -(defvar font-lock-syntax-props-depend-on-themselves nil - "If non-nil, syntax-table changes may influence syntactic keywords. -If the syntax-table properties set by syntactic-keywords themselves depend -on syntax-table properties set on the text before it by syntactic-keywords, -this variable should be set to non-nil, so that whenever syntaxtic-keywords -is applied, the subsequent text is marked for syntactic re-fontification.") - (defvar font-lock-beg) (defvar font-lock-end) (defvar font-lock-extend-region-functions @@ -1131,25 +1124,11 @@ Put first the functions more likely to cause a change and cheaper to compute.") (setq beg font-lock-beg end font-lock-end)) ;; Now do the fontification. (font-lock-unfontify-region beg end) - (let ((sbeg beg)) - (cond - ((< font-lock-syntactically-fontified sbeg) - ;; Ensure the syntax-table prop is properly set on the text - ;; before beg. - (setq sbeg (max font-lock-syntactically-fontified (point-min))) - (setq font-lock-syntactically-fontified end)) - ((and font-lock-syntax-props-depend-on-themselves - (> font-lock-syntactically-fontified end)) - ;; If the syntax-table properties set by - ;; font-lock-syntactic-keywords themselves depend on - ;; syntax-table props set in the text above it, then we'll - ;; need to update all the syntax-table props below end. - (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 beg end loudly)) - (font-lock-fontify-keywords-region beg end loudly)) + (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)) ;; Clean up. (set-syntax-table old-syntax-table)))) @@ -1439,6 +1418,11 @@ LIMIT can be modified by the value of its PRE-MATCH-FORM." (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 -- cgit v1.2.1