emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master 7362554: Widen around c-font-lock-fontify-region. This fixes


From: Dmitry Gutov
Subject: Re: master 7362554: Widen around c-font-lock-fontify-region. This fixes bug #38049.
Date: Thu, 14 Nov 2019 17:02:36 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

On 14.11.2019 16:55, Stefan Monnier wrote:
diff --git a/lisp/reposition.el b/lisp/reposition.el
index 22f9986efb..5d9c3180ad 100644
--- a/lisp/reposition.el
+++ b/lisp/reposition.el
@@ -174,8 +174,8 @@ reposition-window
  (defun repos-count-screen-lines (start end)
    (save-excursion
      (save-restriction
-      (narrow-to-region start end)
-      (goto-char (point-min))
+      (narrow-to-region (point-min) end)
+      (goto-char start)
        (vertical-motion (- (point-max) (point-min))))))

This looks like a good change in any case, tho it does beg the question:
why does it narrow?

I think it does that simply because vertical-motion takes LINES as an argument, and not LIMIT. And it's easier to narrow the buffer than compute the number of lines between start and end.

Also, I think I'm beginning to understand: the issue is that
vertical-motion uses the redisplay code, which in turn calls jit-lock
when needed.

Exactly.

So, your earlier patch which added a call to
`font-lock-ensure` was "more or less right", except that it should have
used `jit-lock-ensure` (currently called `jit-lock-fontify-now`)

But wouldn't this fail to work when jit-lock is not used? And we'll need a guard to make sure font-lock is used as well. (*)

and
could have a comment explaining that vertical-motion will trigger
jit-lock anyway so it's better to do it once beforehand on the whole
region, not only so it can be done outside of the narrowing but also so
it can be done more efficiently than one jit-lock-chunk-size at a time.

That's a good explanation as well, yes.

So, if you like, I can push a patch with both of these changes. If you could only clarify what condition to use in (*).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]