unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* jit-lock refontifies too much
@ 2005-09-12  6:25 martin rudalics
  2005-09-12 13:37 ` Stefan Monnier
  0 siblings, 1 reply; 24+ messages in thread
From: martin rudalics @ 2005-09-12  6:25 UTC (permalink / raw)


`jit-lock-fontify-now' contains the line

     (setq next (line-beginning-position 2))

`font-lock-default-fontify-region' contains the line

     (setq end (line-beginning-position 2))

In practice this means that when jit-lock is turned on, every time you
type a character jit-lock refontifies the current _and_ the following
line.  Chunks fontified stealthily always overlap by one line.

One might argue that `font-lock-after-change-function' contains

	 (progn (goto-char end) (forward-line 1) (point)))))))

but there the adjustment might be useful - albeit undocumented - since
it allows to correct the syntactic context for the following line.
jit-lock mode has `jit-lock-context-fontify' handle syntactic context
and unconditionally refontifying the second line is plain overkill.

In `font-lock-default-fontify-region' I'd therefore replace the lines:

	  (when font-lock-multiline
	    (setq end (or (text-property-any end (point-max)
					     'font-lock-multiline nil)
			  (point-max))))
	  (goto-char end)
	  (setq end (line-beginning-position 2))
	  ;; Now do the fontification.

either by

	  (cond
            (font-lock-multiline
	    (setq end (or (text-property-any end (point-max)
					     'font-lock-multiline nil)
			  (point-max)))
             (goto-char end) (setq end (line-beginning-position 2)))
            ;; don't modify end in jit-lock-mode
            ((and (boundp 'jit-lock-mode) jit-lock-mode))
            (t (goto-char end) (setq end (line-beginning-position 2))))
	  ;; Now do the fontification.

or - but this might disturb people accustomed to the current behavior of
plain font-lock -

	  (when font-lock-multiline
	    (setq end (or (text-property-any end (point-max)
					     'font-lock-multiline nil)
			  (point-max)))
             (goto-char end)
             (setq end (line-beginning-position 2)))
	  ;; Now do the fontification.

Finally one could introduce a variable `font-lock-lines-after'

(defcustom font-lock-lines-after 0
   "*Number of lines after the changed text to include in refontification."
   :type 'integer
   :group 'font-lock
   :version "22.1")

and use

           (goto-char end)
           (setq end (line-beginning-position (1+ font-lock-lines-after)))
	  (when font-lock-multiline
	    (setq end (or (text-property-any end (point-max)
					     'font-lock-multiline nil)
			  (point-max)))
             (goto-char end)
             (setq end (line-beginning-position 2)))
	  ;; Now do the fontification.

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2005-10-02 14:53 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-12  6:25 jit-lock refontifies too much martin rudalics
2005-09-12 13:37 ` Stefan Monnier
2005-09-14  5:48   ` martin rudalics
2005-09-14 11:53     ` Stefan Monnier
2005-09-15  5:31       ` martin rudalics
2005-09-20  0:03       ` Richard M. Stallman
2005-09-20 13:53         ` Stefan Monnier
2005-09-21  9:24           ` martin rudalics
2005-09-21 13:34             ` Stefan Monnier
2005-09-22  6:52               ` martin rudalics
2005-09-22 17:37                 ` Stefan Monnier
2005-09-25 13:17                   ` martin rudalics
2005-09-26 23:56                     ` Richard M. Stallman
2005-09-27 13:09                       ` martin rudalics
2005-09-28 17:10                         ` Richard M. Stallman
2005-10-01  7:34                           ` martin rudalics
2005-10-01 23:25                             ` Richard M. Stallman
2005-10-02 14:53                               ` Stefan Monnier
2005-09-27 15:54                       ` Stefan Monnier
2005-09-28 12:26                         ` martin rudalics
2005-09-28 14:16                           ` Stefan Monnier
2005-09-29  6:29                             ` martin rudalics
2005-09-29 20:25                               ` Stefan Monnier
2005-09-25  2:40             ` Richard M. Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).