From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: master 7362554: Widen around c-font-lock-fontify-region. This fixes bug #38049. Date: Fri, 15 Nov 2019 18:27:21 -0500 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> <83woc24ets.fsf@gnu.org> <83h836466w.fsf@gnu.org> <83r22932if.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="240617"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: acm@muc.de, emacs-devel@gnu.org, dgutov@yandex.ru To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Nov 16 00:27:47 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 1iVl0F-0010Ey-AJ for ged-emacs-devel@m.gmane.org; Sat, 16 Nov 2019 00:27:47 +0100 Original-Received: from localhost ([::1]:45606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVl0E-0005ys-6F for ged-emacs-devel@m.gmane.org; Fri, 15 Nov 2019 18:27:46 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33579) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVl04-0005ye-Ta for emacs-devel@gnu.org; Fri, 15 Nov 2019 18:27:38 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iVl02-0006Pu-Ro for emacs-devel@gnu.org; Fri, 15 Nov 2019 18:27:35 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:41999) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iVl00-0006OV-2h; Fri, 15 Nov 2019 18:27:32 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 12D101004B3; Fri, 15 Nov 2019 18:27:30 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 26DC51002B3; Fri, 15 Nov 2019 18:27:28 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1573860448; bh=kmOaZ0I1KK27cSd3BE2onLtYhXYIO0ElqerN6X/MM0E=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=eW+JIw+GanR8eJO3sVtoTvqLYvfmoskir9HvkVlE0LBxbW5wzxlrQ/YH9RigFqwVi /o2Is6M7EXYg9P9XCysWCUzvHVJ7e5H0SyNnmekNIhPSMppxyNn3bMd9uQNoHg40kp kmFPal/bqnkpatiD061lH81pDgk4h4nIbHIdVm9Cu0mnDxXVcLCyJnIduRelTOndGz If9Yt7t7nIrDIlvxS/+gUrJtuvDmjtj104eLirUnJe//d1JOrsqbiNWZmmsNsyueJg dLLzUAH/fviIXyG2g/426fvBFzQ9V8zXdAyNmMm/sAzPMuDiCCY8DkNGemzTIsGRHG u3O1rxUrUlbQQ== Original-Received: from pastel (206-248-133-142.dsl.teksavvy.com [206.248.133.142]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id D0196121213; Fri, 15 Nov 2019 18:27:27 -0500 (EST) In-Reply-To: <83r22932if.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 15 Nov 2019 11:36:08 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 132.204.25.50 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:242250 Archived-At: >> IIUC this can't be fixed in font-lock or jit-lock. > Why not? Good question. Looks like I was wrong. I think the patch below is a better general solution. Stefan diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 01c19e6e87..9c1c193eda 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el @@ -1071,7 +1071,9 @@ font-lock-fontify-region If LOUDLY is non-nil, print status messages while fontifying. This works by calling `font-lock-fontify-region-function'." (font-lock-set-defaults) - (funcall font-lock-fontify-region-function beg end loudly)) + (save-restriction + (unless font-lock-dont-widen (widen)) + (funcall font-lock-fontify-region-function beg end loudly))) (defun font-lock-unfontify-region (beg end) "Unfontify the text between BEG and END. @@ -1221,8 +1221,6 @@ (save-buffer-state ;; Use the fontification syntax table, if any. (with-syntax-table (or font-lock-syntax-table (syntax-table)) - (save-restriction - (unless font-lock-dont-widen (widen)) ;; Extend the region to fontify so that it starts and ends at ;; safe places. (let ((funs font-lock-extend-region-functions) @@ -1251,7 +1249,7 @@ (unless font-lock-keywords-only (font-lock-fontify-syntactically-region beg end loudly)) (font-lock-fontify-keywords-region beg end loudly) - `(jit-lock-bounds ,beg . ,end))))) + `(jit-lock-bounds ,beg . ,end)))) ;; The following must be rethought, since keywords can override fontification. ;; ;; Now scan for keywords, but not if we are inside a comment now.