1

In cc-mode, I want a way set all syntax highlight colours to slightly more desaturated versions when inside a #if 0 ... #endif block. If that would be troublesome/hard to maintain (having to set all the colours manually), just setting all the text inside the block to a single colour would be fine too. I've tried this, but is intended for use with a single keyword.

I'm using spacemacs 0.300.0@26.3

1

Emacs has a built-in package for ifdefs. To quote from https://www.gnu.org/software/emacs/manual/html_node/emacs/Other-C-Commands.html:

 ‘M-x hide-ifdef-mode’
      Hide-ifdef minor mode hides selected code within ‘#if’ and ‘#ifdef’
      preprocessor blocks.  If you change the variable
      ‘hide-ifdef-shadow’ to ‘t’, Hide-ifdef minor mode shadows
      preprocessor blocks by displaying them with a less prominent face,
      instead of hiding them entirely.  See the documentation string of
      ‘hide-ifdef-mode’ for more information.
2
  • I will read the doc more later, but it seems that it is what I'm looking for, thanks. – Luctins Jan 19 at 13:17
  • Can it update automatically, or do i need to call hide-ifdefs to update? – Luctins Jan 20 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.