From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gregory Heytings Newsgroups: gmane.emacs.devel Subject: Re: master 2399541: Remove font-lock toggle from font-lock-update Date: Mon, 29 Mar 2021 14:40:19 +0000 Message-ID: References: <20210324143048.23515.75257@vcs0.savannah.gnu.org> <20210324143050.40C6E20D10@vcs0.savannah.gnu.org> <8786a8e8fa731c1bd1ef@heytings.org> <87h7l0blrc.fsf@gnus.org> <87czvobksy.fsf@gnus.org> <87r1k4a1c0.fsf@gnus.org> <8786a8e8fa96815c66e3@heytings.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16221"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Mar 29 16:42:08 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lQt5j-00046T-MV for ged-emacs-devel@m.gmane-mx.org; Mon, 29 Mar 2021 16:42:07 +0200 Original-Received: from localhost ([::1]:37798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lQt5i-0008Q3-NT for ged-emacs-devel@m.gmane-mx.org; Mon, 29 Mar 2021 10:42:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQt45-0007PD-M5 for emacs-devel@gnu.org; Mon, 29 Mar 2021 10:40:26 -0400 Original-Received: from heytings.org ([95.142.160.155]:49926) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQt42-00061Y-NG for emacs-devel@gnu.org; Mon, 29 Mar 2021 10:40:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org; s=20210101; t=1617028819; bh=jGZB28pNQQB+Fqr+AVe5YpN9POy/98ISVSx0Qse+9Ac=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From; b=aVb/toVGdMzzQz9K7a7oisGBqlH2mnC021+ms/KipRX+3VKIwR5y+Qoeg82gR/4Hw 5MRBWJiQixw1fAmq67augvl/ATQRTd5DcTEKkhRFjcQET3yKrGVWppTm3PPDXGHJJc rrK+MzFwYZgSJPqN3mRCvPoFSFtuDMcOoAmjokMVB/WQ/8bQQ+T01WS6EbfCtBJ2rW tV5xO+2VMD6IdFgH1uDYMo+xsoDfkjNm/9T3y3+2PK4IDM88YZZQLhgOQDTkNwLeXt j12biJzsx7e01iyrdZgf66IjyHCl4BhWSSVPlC8qIYjn/01iSIW62NSxPx9N5ZdIlg DwkrDT9RNh23Q== In-Reply-To: Received-SPF: pass client-ip=95.142.160.155; envelope-from=gregory@heytings.org; helo=heytings.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:267151 Archived-At: >> One thing I'm not entirely sure is whether the second case is (and >> font-lock-mode (not font-lock-keywords)) or (and font-lock-mode (not >> font-lock-fontified)), but my guess is that font-lock-fontified is an >> internal variable and that it is safer to use font-lock-keywords here. > > I'm not entirely sure what is the best way to detect this middle-point > either. The code that decides whether to activate the font-lock > machinery calls `font-lock-specified-p` for that, but maybe there are > corner cases where the machinery can be activated even when > `font-lock-specified-p` returns nil? Similarly, I'm not sure if > `font-lock-fontified` is always non-nil when the font-lock machinery is > activated and always nil when it isn't. > > IOW, someone needs to look carefully at the code to find out (and > presumably then document the result e.g. by adding a function that > returns this info, or with comments, or by adding a variable which keeps > track of this info or ...). > I guess that Someone^TM is me? ;-) I'll have a look. >>>> +Otherwise, with prefix ARG, toggle Font Lock mode." >>> >>> Is this behavior useful? >> >> I think it is, yes, and I think it makes sense to use the prefix >> argument for that. M-x font-lock-mode does not always produce the >> expected effect, which can be puzzling, so having a way to "do what I >> mean" in a command is useful. > > Could you describe what you mean by "does not always produce the > expected effect" here? [ And maybe how the prefix ARG to > `font-lock-dwim` avoids those problems? ] > By "does not always produce the expected effect", I mean for example that M-x font-lock-mode in a text-mode or fundamental-mode buffer does not remove then fontification from a piece of code that was killed-yanked from a prog-mode buffer, and M-x font-lock-mode again (which re-enables font lock mode) still does not remove the fontification. From a certain point of view, this is perhaps expected, but from a user point of view it is not. With the prefix ARG, font-lock-update-region is called before toggling font-lock-mode, which ensures that the fontification is coherent with the current major-mode before disabling/enabling font-lock-mode.