]> git.eshelyaron.com Git - emacs.git/commitdiff
(font-lock-after-change-function): Refontify next line as well if end is at BOL.
authorStefan Monnier <monnier@iro.umontreal.ca>
Thu, 28 Sep 2006 20:02:45 +0000 (20:02 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Thu, 28 Sep 2006 20:02:45 +0000 (20:02 +0000)
(font-lock-extend-jit-lock-region-after-change): Be more careful to
only extend the region as much as needed.

lisp/ChangeLog
lisp/font-lock.el

index 3555287724f400fa1baffb2950b556b0d461955b..0d54130794947839a84bddaf5269db2fd0c00789 100644 (file)
@@ -1,12 +1,19 @@
+2006-09-28  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * font-lock.el (font-lock-after-change-function): Refontify next line
+       as well if end is at BOL.
+       (font-lock-extend-jit-lock-region-after-change): Be more careful to
+       only extend the region as much as needed.
+
 2006-09-28  Richard Stallman  <rms@gnu.org>
 
        * comint.el (comint-mode): Bind font-lock-defaults non-nil.
 
        * subr.el (insert-for-yank-1): Handle `font-lock-face' specially.
 
-       * international/mule.el (after-insert-file-set-coding): 
+       * international/mule.el (after-insert-file-set-coding):
        If VISIT, don't let set-buffer-multibyte make undo info.
-       
+
 2006-09-28  Osamu Yamane  <yamane@green.ocn.ne.jp> (tiny change)
 
        * mail/smtpmail.el (smtpmail-try-auth-methods): Do not break long
index 28577bcdccdb05d640d73e4f32ff22d9acd1273b..a6f079e608f32fc0f706c5a676fad63d6e3b3354 100644 (file)
@@ -1168,7 +1168,12 @@ what properties to clear before refontifying a region.")
           ;; number of lines.
          ;; (setq beg (progn (goto-char beg) (line-beginning-position))
          ;;       end (progn (goto-char end) (line-beginning-position 2)))
-          )
+         (unless (eq end (point-max))
+           ;; Rounding up to a whole number of lines should include the
+           ;; line right after `end'.  Typical case: the first char of
+           ;; the line was deleted.  Or a \n was inserted in the middle
+           ;; of a line.
+           (setq end (1+ end))))
        (font-lock-fontify-region beg end)))))
 
 (defvar jit-lock-start) (defvar jit-lock-end)
@@ -1205,9 +1210,17 @@ This function does 2 things:
         (setq beg (or (previous-single-property-change
                        beg 'font-lock-multiline)
                       (point-min))))
-      (setq end (or (text-property-any end (point-max)
-                                       'font-lock-multiline nil)
-                    (point-max)))
+      (when (< end (point-max))
+        (setq end
+              (if (get-text-property end 'font-lock-multiline)
+                  (or (text-property-any end (point-max)
+                                         'font-lock-multiline nil)
+                      (point-max))
+                ;; Rounding up to a whole number of lines should include the
+                ;; line right after `end'.  Typical case: the first char of
+                ;; the line was deleted.  Or a \n was inserted in the middle
+                ;; of a line.
+                (1+ end))))
       ;; Finally, pre-enlarge the region to a whole number of lines, to try
       ;; and anticipate what font-lock-default-fontify-region will do, so as to
       ;; avoid double-redisplay.
@@ -1217,11 +1230,11 @@ This function does 2 things:
       (when (memq 'font-lock-extend-region-wholelines
                   font-lock-extend-region-functions)
         (goto-char beg)
-        (forward-line 0)
-        (setq jit-lock-start (min jit-lock-start (point)))
+        (setq jit-lock-start (min jit-lock-start (line-beginning-position)))
         (goto-char end)
-        (forward-line 1)
-        (setq jit-lock-end (max jit-lock-end (point)))))))
+        (setq jit-lock-end
+              (max jit-lock-end
+                   (if (bolp) (point) (line-beginning-position 2))))))))
 
 (defun font-lock-fontify-block (&optional arg)
   "Fontify some lines the way `font-lock-fontify-buffer' would.