unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Ergus <spacibba@aol.com>
Cc: 48752@debbugs.gnu.org
Subject: bug#48752: 28.0.50; Feature request: Hook hide-ifdef into font-lock
Date: Mon, 31 May 2021 15:01:42 +0300	[thread overview]
Message-ID: <83eedn2jtl.fsf@gnu.org> (raw)
In-Reply-To: <20210530202606.qlopn6lmwzfa75z5@Ergus> (bug-gnu-emacs@gnu.org)

> 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	other threads:[~2021-05-31 12:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210530202606.qlopn6lmwzfa75z5.ref@Ergus>
2021-05-30 20:26 ` bug#48752: 28.0.50; Feature request: Hook hide-ifdef into font-lock Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-31 12:01   ` Eli Zaretskii [this message]
2021-05-31 14:29     ` Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-31 15:44     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83eedn2jtl.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=48752@debbugs.gnu.org \
    --cc=spacibba@aol.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).