I've been using hide-ifdef-mode with c-mode buffers for a while, but it is quite tedious to have to manually run hide-ifdefs (C-c @ h) every time a block of code containing preprocessors changes.

Is there any way this can be run automatically? (for example during syntax highlighting)

1 Answer 1


After a while, I think I have found a viable solution: run hide-ifdefs on c-mode-hook's after-file-save hook like so:

  (add-hook 'c-mode-common-hook
             (lambda ()
               ;... your other hook code here
               (add-hook 'after-save-hook (lambda () (hide-ifdefs)))

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.