unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Juri Linkov <juri@linkov.net>
Cc: 38049@debbugs.gnu.org
Subject: bug#38049: C mode fontification broken with reposition-window
Date: Tue, 5 Nov 2019 21:07:37 +0000	[thread overview]
Message-ID: <20191105210737.GA6303__4155.84047311626$1572989895$gmane$org@ACM> (raw)
In-Reply-To: <8736f4k8mi.fsf@mail.linkov.net>

Hello, Juri.

On Sun, Nov 03, 2019 at 22:28:05 +0200, Juri Linkov wrote:
> Version: 27.0.50

> This is a reproducible test case:

> 0. emacs -Q
> 1. C-x C-f emacs/lib-src/emacsclient.c
> 2. M-: (progn (search-forward "create-frame" nil t) (reposition-window))

> Then half screen displays unfontified lines.

> Fontification doesn't fail in other modes, only in C mode.

> This has something to do with interaction between c-font-lock
> and buffer navigation in reposition-window.

Indeed it does.

Briefly,
(i) reposition-window narrows to (2758 3940) in
repos-count-screen-lines.
(ii) This latter function uses vertical-motion to count the lines.
(iii) vertical-motion triggers jit-lock fontification.
(iv) This calls (eventually) c-font-lock-fontify-region.
(v) c-font-lock-fontify-region attempts to examine buffer text before
  the start of the jit-lock chunk to find syntactic context.
(vi) This is outside the visible region, so Emacs raises an exception.
(vii) The exception is caught and discarded by an unwind-protect in
  c-font-lock-fontify-region.
(viii) The jit-lock chunk remains unfontified.

As Stefan M has sometimes remarked, narrowing is often not a good idea.

It would seem undesirable for the vertical-motion in (iii) to trigger
font-locking, since it is merely trying to count lines.  Perhaps there
should be a macro `without-fontifying' which could be wrapped around
this call to vertical-motion, if there isn't such a thing anyway.

Maybe there are other calls of vertical-motion which are similarly
dangerous.

-- 
Alan Mackenzie (Nuremberg, Germany).





  parent reply	other threads:[~2019-11-05 21:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-03 20:28 bug#38049: C mode fontification broken with reposition-window Juri Linkov
     [not found] ` <mailman.552.1572813126.13325.bug-gnu-emacs@gnu.org>
2019-11-03 21:27   ` Alan Mackenzie
2019-11-05 21:07 ` Alan Mackenzie [this message]
     [not found] ` <20191105210737.GA6303@ACM>
2019-11-05 22:10   ` Juri Linkov
2019-11-06 17:13   ` Eli Zaretskii
2019-11-06 20:56     ` Alan Mackenzie
2019-11-09 14:45   ` Alan Mackenzie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='20191105210737.GA6303__4155.84047311626$1572989895$gmane$org@ACM' \
    --to=acm@muc.de \
    --cc=38049@debbugs.gnu.org \
    --cc=juri@linkov.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).