From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#48752: 28.0.50; Feature request: Hook hide-ifdef into font-lock Date: Mon, 31 May 2021 15:01:42 +0300 Message-ID: <83eedn2jtl.fsf@gnu.org> References: <20210530202606.qlopn6lmwzfa75z5.ref@Ergus> <20210530202606.qlopn6lmwzfa75z5@Ergus> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1524"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 48752@debbugs.gnu.org To: Ergus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 31 14:02:11 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1lngcU-0000Ar-FO for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 31 May 2021 14:02:10 +0200 Original-Received: from localhost ([::1]:37180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lngcS-0000je-J9 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 31 May 2021 08:02:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lngcM-0000jW-5w for bug-gnu-emacs@gnu.org; Mon, 31 May 2021 08:02:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49593) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lngcL-0003zV-S7 for bug-gnu-emacs@gnu.org; Mon, 31 May 2021 08:02:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lngcL-0006OU-Q8 for bug-gnu-emacs@gnu.org; Mon, 31 May 2021 08:02:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 31 May 2021 12:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48752 X-GNU-PR-Package: emacs Original-Received: via spool by 48752-submit@debbugs.gnu.org id=B48752.162246249724541 (code B ref 48752); Mon, 31 May 2021 12:02:01 +0000 Original-Received: (at 48752) by debbugs.gnu.org; 31 May 2021 12:01:37 +0000 Original-Received: from localhost ([127.0.0.1]:32903 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lngbw-0006Nh-Lz for submit@debbugs.gnu.org; Mon, 31 May 2021 08:01:37 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:41360) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lngbv-0006NM-14 for 48752@debbugs.gnu.org; Mon, 31 May 2021 08:01:35 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:41934) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lngbp-0003YL-ND; Mon, 31 May 2021 08:01:29 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4597 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lngbn-0006bc-Ed; Mon, 31 May 2021 08:01:28 -0400 In-Reply-To: <20210530202606.qlopn6lmwzfa75z5@Ergus> (bug-gnu-emacs@gnu.org) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:207691 Archived-At: > Date: Sun, 30 May 2021 22:26:06 +0200 > From: Ergus via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > The use of hide-ifdef is a bit outdated and it requires to manually > call: `M-x hide-ifdefs` to update the buffer > > #if 0 > > #endif > > M-x hide-ifdef-mode > M-x hide-ifdef-toggle-shadowing > > does not shadows/hides the region . > > It requires to explicitly call: M-x hide-ifdefs. Did you try customizing hide-ifdef-initially to a non-nil value? > Then if we change #if 0 -> #if 1; > > the shadow does not disappears/appears either until we call: M-x > hide-ifdefs again. > > This part may be automatized. Calling hide-ifdefs every time is annoying > and unneeded. Vim and most of other editors already do the > re-fontification automatically. So we can take that behavior as a good > starting point. As mentioned on emacs-devel, how exactly to automate this should be carefully thought-out, because blindly using the JIT font-lock mechanism will cause code blocks to appear and disappear several time as long as the user types the preprocessor directive. It sounds like a no-brainer for a simple "#if 0" (which btw is rarely if ever used in real-life production code), but think about typing something like this: #if (defined __has_attribute \ && (!defined __clang_minor__ \ || 3 < __clang_major__ + (5 <= __clang_minor__))) (This is a real-life example from our conf_post.h, and there are a lot like it all over our code.) Depending on how each of the symbols are defined, the block under this could appear and disappear several times until you end typing. I'm quite sure we want to avoid this annoying effect as much as possible.