From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ergus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#48752: 28.0.50; Feature request: Hook hide-ifdef into font-lock Date: Mon, 31 May 2021 16:29:59 +0200 Message-ID: <20210531142959.3sjh4g5ucu5xc4of@Ergus> References: <20210530202606.qlopn6lmwzfa75z5.ref@Ergus> <20210530202606.qlopn6lmwzfa75z5@Ergus> <83eedn2jtl.fsf@gnu.org> Reply-To: Ergus 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="26157"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 48752@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 31 16:31:28 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 1lniwy-0006fJ-A3 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 31 May 2021 16:31:28 +0200 Original-Received: from localhost ([::1]:58450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lniwx-0002Dk-BA for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 31 May 2021 10:31:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38992) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lniwY-0001pS-MW for bug-gnu-emacs@gnu.org; Mon, 31 May 2021 10:31:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51279) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lniwY-0001fG-8V for bug-gnu-emacs@gnu.org; Mon, 31 May 2021 10:31:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lniwY-0004FR-5s for bug-gnu-emacs@gnu.org; Mon, 31 May 2021 10:31:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ergus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 31 May 2021 14:31:02 +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.162247143216290 (code B ref 48752); Mon, 31 May 2021 14:31:02 +0000 Original-Received: (at 48752) by debbugs.gnu.org; 31 May 2021 14:30:32 +0000 Original-Received: from localhost ([127.0.0.1]:34592 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lniw4-0004Eg-0t for submit@debbugs.gnu.org; Mon, 31 May 2021 10:30:32 -0400 Original-Received: from sonic315-13.consmr.mail.bf2.yahoo.com ([74.6.134.123]:38324) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lniw1-0004ES-WD for 48752@debbugs.gnu.org; Mon, 31 May 2021 10:30:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1622471424; bh=7RlMWR1qi51vCPmJx2wqhNMKOz41PnvHbcn/gC84ZaQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From:Subject:Reply-To; b=EtPrtOmKpbCe/qGyVjEcKYWhMT3JiDCi+B20keD1mAuTAQk/I6NeIcCoxqdC2KYUdSHbYs76bny7Y0BwGdMetu67/GtnsV90QjoDibXaGSPAbh69TZUEGW/DugFHYoq908RFIxNW/VSWJlwuwRG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z8zGIxSeR6E4SHUR0OPhtZHKtI9g7wpHwjpGrC_QhxSuhuOQDyKuyu7BJd6qh3hRdAXhei TQHoB76CkUAjwkKspPGxwVKQJUgOrGpniOCTCmo1N83rKiDRNVXURN_gU15sJVTh8HM98a4yyZ1D SC8y0Czwci1xlXBUA8uS2.Gy0qW00m4SRSa5Yn2pTQn9XaygorB2ZJII5wHPLy3xANn74Fo96HLl dGpNCE2hHBeeVLgaCfe7pb4vSe0EleOABAuSpSyVByAxMsPQMIln_mpDhr.URum4HxvoS7b39ony EGPPB9VYMoB8r0643Knhmwoj50JmfTGGleka3vrSrsEHLLRCjSe7IDjECDkB8iNQP1jWxWOgcp8s vAjXqU8hKMeF8NtslhGxgIdfAPOrdCLkMNBWECVesN38Y.vARklrXYxVdk6.ewQ6qK8b1QgRvkBQ UfnAzpClmP0M6ugvihAdgxGp2o9T7pigMxNhuPX3sv X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic315.consmr.mail.bf2.yahoo.com with HTTP; Mon, 31 May 2021 14:30:24 +0000 Original-Received: by kubenode522.mail-prod1.omega.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 6f0409fcb3a956a801195149f30a399e; Mon, 31 May 2021 14:30:19 +0000 (UTC) Content-Disposition: inline In-Reply-To: <83eedn2jtl.fsf@gnu.org> X-Mailer: WebService/1.1.18368 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol 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:207702 Archived-At: On Mon, May 31, 2021 at 03:01:42PM +0300, Eli Zaretskii wrote: >> 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. Hi Eli: I understand that emacs tries to do something smarter than what vim and the other editors do, but this is limiting the basic trivial use case. I don;t actually think many people are using the hide-ifdef package... specially not new users. In the general case I understand that the block under this could appear and disappear, but that will be also a feedback for the user to know if the region will be enabled or not. For example in the case we have #if #else #endif That may be also very useful to know which branch will be compiled. I don't intend to get something very complex here, but at least the most basic highlight with trivial symbols may work. We use emacs to develop code, so, our code is not really production most of the time. And the #if 0 is very common in many code I have seen around. While the /* // */ Approach I use is not common at all.