|
From: | Ergus |
Subject: | Re: Issue with hide-ifdef and cc-mode |
Date: | Sun, 30 May 2021 20:14:11 +0200 |
On Sun, May 30, 2021 at 01:01:36PM +0200, Daniel Mart�n wrote:
Ergus <spacibba@aol.com> writes:I am trying to use hide-ifdef to shadow code like: #if 0 <code> #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.
[Prev in Thread] | Current Thread | [Next in Thread] |