From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: master 7362554: Widen around c-font-lock-fontify-region. This fixes bug #38049. Date: Thu, 14 Nov 2019 17:02:36 +0200 Message-ID: References: <20191109144026.20810.76129@vcs0.savannah.gnu.org> <20191109144027.DDC3720927@vcs0.savannah.gnu.org> <38328d99-23c8-7ba7-a23d-e70ac0aab67a@yandex.ru> <20191111203445.GA5135@ACM> <7497e71d-bab6-fa04-bbc4-f52fadeda16d@yandex.ru> <20191113211936.GB4942@ACM> <6fc930a1-eb47-9e54-8752-8cf7ff041586@yandex.ru> <03042d05-2160-77c4-9abd-b0f13f638247@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="129564"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 Cc: Alan Mackenzie , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 14 16:02:54 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iVGe6-000XZv-7e for ged-emacs-devel@m.gmane.org; Thu, 14 Nov 2019 16:02:54 +0100 Original-Received: from localhost ([::1]:58474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVGe4-00005H-LL for ged-emacs-devel@m.gmane.org; Thu, 14 Nov 2019 10:02:52 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56280) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVGdu-00004w-3k for emacs-devel@gnu.org; Thu, 14 Nov 2019 10:02:47 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iVGdt-0002Vn-0o for emacs-devel@gnu.org; Thu, 14 Nov 2019 10:02:42 -0500 Original-Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:42223) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iVGds-0002Tm-P1 for emacs-devel@gnu.org; Thu, 14 Nov 2019 10:02:40 -0500 Original-Received: by mail-wr1-x435.google.com with SMTP id a15so6822203wrf.9 for ; Thu, 14 Nov 2019 07:02:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=gAsQqINCJwQnME+vRbjjxyrFpnj+ten4PvSkjLa2BM8=; b=bY8VweWlBAcEW1oFHwScZzR8tUo2yZg0lxkwaaJw3EyuEh9DJxNjT8xMaFNSIhKPrW +mjBTkqlMNH1V9s6Sj/nQMoHD9BysiB7WDE8+dthBg/trIrisHxSJ2aLpWAbfqUgO8em AzppfX8hQzfIvY0Ecvuwv6ZK7WAzQlwB+pTJVSyhN5XuUG/XkOLETG1SaQyu5aQ+0jEh Ot7ojVabmB8/u4RJ6pVuFbwz70cXuX6QszrOYGng7w/FR3SlBOm4S/zyrHI7FpphQl1D kKSC/sdl6Rp4LkLhOTWk0AXZrKYe70Wws1wLBWlgaQL8U6jhNtnlCjBYFZP+hFuTXxX6 We0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=gAsQqINCJwQnME+vRbjjxyrFpnj+ten4PvSkjLa2BM8=; b=V5yGrzPEwuuLB6q7EA35FpDvRJmBCiiFaTJ75Y+l1gtwrH8q1GO6iiwLgqCb2O0Ner aKXwkYL/tUu0Kt5L5drmU+s+vX2cHBskpDosterctoD6RWeKSIVHQ6TE7tQdicC82A1z MgUjRfgan/mNpyaQptALV6T7XaYPHIiVFWHKnMev/+fGpLQbaGSzYpgSSP/U5i/DwQfr 6lMqojkzGXbMQ+LQz8c5x1XGQ5vA6hw+RT+Na1kZm5bnN+ztfUpuB2j/3UDg8C/5QEdp CAe/uwhRDWOjrd6j4AZh6Go+bT1qTwytE0lBuoyUc5e0FHAkPuZwr5OW6VtzuYOVj1u/ 7LOw== X-Gm-Message-State: APjAAAVzBkN8LVWWZKYWltkZVbpxjSE7tgX6RBaVEfKjK2B+HtSzPmJh aLxRrlOJA40frQTi4qUQ0ye+2nEzYyU= X-Google-Smtp-Source: APXvYqxVtdU0ynwujE1t43PQ4rwLDtO6JwEtTBKX/lxGycR+HLygRHcFnI+wfdVoOdhLnP8f0DcEig== X-Received: by 2002:adf:d091:: with SMTP id y17mr9057470wrh.182.1573743758425; Thu, 14 Nov 2019 07:02:38 -0800 (PST) Original-Received: from [192.168.0.149] ([109.110.245.170]) by smtp.googlemail.com with ESMTPSA id 91sm8160637wrm.42.2019.11.14.07.02.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Nov 2019 07:02:37 -0800 (PST) In-Reply-To: Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::435 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:242182 Archived-At: 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 (*).