From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ergus Newsgroups: gmane.emacs.devel Subject: Re: Issue with hide-ifdef and cc-mode Date: Sun, 30 May 2021 20:14:11 +0200 Message-ID: <20210530181411.jquh47dwgxtctmzc@Ergus> References: <20210530070822.h57mmtpp2n7dvpbf.ref@Ergus> <20210530070822.h57mmtpp2n7dvpbf@Ergus> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20951"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, Alan Mackenzie To: Daniel =?utf-8?Q?Mart=C3=ADn?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun May 30 20:17:54 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 1lnQ0Y-0005Kj-3c for ged-emacs-devel@m.gmane-mx.org; Sun, 30 May 2021 20:17:54 +0200 Original-Received: from localhost ([::1]:58634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lnQ0R-0001DS-SP for ged-emacs-devel@m.gmane-mx.org; Sun, 30 May 2021 14:17:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36972) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnPxP-0000G5-NU for emacs-devel@gnu.org; Sun, 30 May 2021 14:14:40 -0400 Original-Received: from sonic315-13.consmr.mail.bf2.yahoo.com ([74.6.134.123]:39039) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lnPxM-0001j5-FC for emacs-devel@gnu.org; Sun, 30 May 2021 14:14:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1622398474; bh=uZ9AlmsLjXBaqYRm0lmlfAqjN/iDYXYF6q5sS/T5yHw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From:Subject:Reply-To; b=oyEYfjkcuO+NGSlE2AFBD6QaVcSr6TrWrEWn57JE7KA+ZycS7ZTylBHPaLXvDhxlseQU4YdL679HZ67xLgWTe5IGebN9Q+94IQ/0+ueTy0SHc0VRxy1ZQFV7FLTrA6oxAwAXSf+AEi25CqnhKJfHotav7vqMTX2w5SCrP9oQknmlwxkXR0QNd5Q1sRo1XUfL2Z6NNpHxRpfJMZmCY6Z4SCNvHSVZaPdW9G9pCkun8e89jkxLpxttblVDZTZHM4KuokBYH4ekzm/FBcUCz0rx9r0QSZmIEvwbkdV9GXauLhWpCDYyDRC74BsDZEaSliIeDCFXILQN3/Wyrt7s9+MQHA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1622398474; bh=a9T9efvccvnZe0To20eeoqwH8xh//PwZBMRCoyocDb3=; h=X-Sonic-MF:Date:From:To:Subject:From:Subject; b=HNaMj8Sy5VlZJtMPjSpYZEfBjnmka+B2vCfCenxWlKN6Ra+dCv4yLKF5xZgKQ3LXTpiHZylR8OBF+JXyrakTm+71gBcLpd33vZoW/JmCUwPP453TxTTPXjTc2F4u+MfJ/XkB4mwbMVT0e1if833CSUmzNz19AXP0oDMNk6hCGDkLk8w8lJhrD1TClxe232HeJ9P23BHixSjCHzp2sax2/ZqlA6AcUT83fAq5fPo4DgbLqDH5g5kmIpmghE4QTC7mWc8YeK4/uH4ESto5SeSc8Z7TPKUcxBPtnr4YkKvMl4YMMYvFI0zuK/3gZ/B3S8uwUtte40U8hJsrULoqbarlrA== X-YMail-OSG: tj8BglgVM1kCUB.OC.9sun5h2eDeFFHxlo3zlJflsuBqakSILJ1CDc52ubkvXDW 5Osgcxf3s6bxxLtuXY0qjV1necYX8J.L4osQmRgcY4m16AxnaBQV3Zg5s6ZTmXaymDtzq8GGfqaO eTNzc2MJO.FWkcGTBpDv4_reFZl5fAr8zqqbxhSJPpO7HxN67GlhfBvj89MxSMHMmlwH3rdsX3F1 J.bScedSoPQ9chViuW1miSg8lNXySPDr35DJOb8zEfYJyIZFsZ_uyABmQRYMRV31wQyJbDWH0UJl wd4vipKfbCIxJOPvXwqLX6LAwap_Qe6tWgL9R3bfDY1tY42pGY6pSQQ236bgaA8s4ba.8DEhHZVE uf6GfQlCluT9_PDosICFYBDbeVT0P6W.4Bzbv_MExl0G4eEincguAQrMm9ulgS37X9fg.JOBhr4s IwHiFSseo8hXBoPPUBzEpkGvyuDmt_qUyPFu1jCU_pmeOwEzTNg6_VFZyi7GkE52RVu0LoHGKZ1a UTOKb6Y1FPFQ56o3SRHqYw33liaMBw4pyjDNXA6f7yo9rcp_SlWRTYQEGphT.VIVOkuSw7mhbalx 2672oD1PdOL_ZnVuKYary6OFwAErUBEKBHLLiLVnbWHA.ZkBpDH2q6GLPmxmLmORwvbabNMct_AK GGPRSN6XAqw.5Nh_Pw83rHJXahjsGX2oeJseRNUKbr56B5tcbLKtPzhd.K3EqrV9QoRa8b9WskHl dyZ1m_RSRO4rVqZXrk.x027rFtcGFwhglj3bE2_GHhrftWgDKELr_sYtWs2jqj_lQbjd93p4SUXp zkM.NyF7VpDVvF.YtBOsfcAgo.cV_h2_7hnBo2yODl X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic315.consmr.mail.bf2.yahoo.com with HTTP; Sun, 30 May 2021 18:14:34 +0000 Original-Received: by kubenode530.mail-prod1.omega.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 3ffd3839f1172c57dfa501fa6bc71e26; Sun, 30 May 2021 18:14:30 +0000 (UTC) Content-Disposition: inline In-Reply-To: X-Mailer: WebService/1.1.18368 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.aol Received-SPF: pass client-ip=74.6.134.123; envelope-from=spacibba@aol.com; helo=sonic315-13.consmr.mail.bf2.yahoo.com 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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:270141 Archived-At: On Sun, May 30, 2021 at 01:01:36PM +0200, Daniel Mart�n wrote: >Ergus writes: > >> >> I am trying to use hide-ifdef to shadow code like: >> >> #if 0 >> >> #endif >> >> But I found that either >> >> #if 0 >> >> or >> #if 1 >> >> produces the same result disabling the code inside. >> > >I tested the following from emacs -Q in Emacs 28: > >New C buffer with > >#if 0 >int i = 0; >#endif > >M-x hide-ifdef-mode >M-x hide-ifdef-toggle-shadowing >M-x hide-ifdefs > >And the variable definition is shown with a comment font-lock face, as >expected. > >If I change it to "#if 1" and M-x hide-ifdefs again, the comment >font-lock face is removed, as expected. Perhaps some Emacs >customization is getting in the way? > >For something more complex than a #if 0, you probably need to ask the C >preprocessor or build system for the defined variables and configure >hide-ifdef-mode accordingly. > Hi Daniel: Thanks for the reply. It looks like I didn't understand the documentation properly. (It is only a few lines) I didn't know I need to manually call hide-ifdefs every time I change the preprocessor argument. Because none of this is documented in the manual. But also calling that makes the functionality pretty sub-optimal. It is bad that this functionality works fine out of the box either in vim and in VS Code and other editors but not in emacs without user explicit intervention. So I am not sure how difficult may be to do it automatic without killing the performance... Like font-lock does with everything else... Soes it really kills performance to add his to font-lock? I hope probably Alan may have an idea about how to solve this in a more cc-mode way... Without forcing the user to interactively call hide-ifdefs. We do something similar with /* */ multi-line comments... I can't understand why this may be so different for if 0 macros... But I may be wrong.