bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#48752: 28.0.50; Feature request: Hook hide-ifdef into font-lock


From: Eli Zaretskii
Subject: bug#48752: 28.0.50; Feature request: Hook hide-ifdef into font-lock
Date: Mon, 31 May 2021 15:01:42 +0300

> Date: Sun, 30 May 2021 22:26:06 +0200
> From:  Ergus via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> 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
> <CODE>
> #endif
> 
> M-x hide-ifdef-mode
> M-x hide-ifdef-toggle-shadowing
> 
> does not shadows/hides the region <CODE>.
> 
> 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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]