Variable: hide-ifdef-mode

hide-ifdef-mode is a buffer-local variable defined in hideif.el.gz.

Documentation

Non-nil if Hide-Ifdef mode is enabled.

Use the command hide-ifdef-mode(var)/hide-ifdef-mode(fun) to change this variable.

View in manual

Probably introduced at or before Emacs version 22.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/hideif.el.gz
;;;###autoload
(define-minor-mode hide-ifdef-mode
  "Toggle features to hide/show #ifdef blocks (Hide-Ifdef mode).

\\<hide-ifdef-mode-map>Hide-Ifdef mode is a buffer-local minor mode for use with C and
C-like major modes.  When enabled, code within #ifdef constructs
that the C preprocessor would eliminate may be hidden from view.

Use \\[hide-ifdefs] to hide ifdefs and \\[hide-ifdefs] to show them.
Use  \\[hif-show-all] to show all ifdefs.

Several variables affect how the hiding is done:

`hide-ifdef-env'
        An association list of defined and undefined symbols for the
        current project.  Use \\[hide-ifdef-define] and \\[hide-ifdef-undef] to update the value of
        this list with defined or undefined symbols.
        We've extended hideif to support parsing a C/C++ project
        containing multiple C/C++ source files opened simultaneously in
        different buffers.  Therefore `hide-ifdef-env' can no longer be
        buffer local but must be global.

`hide-ifdef-initially'
        Customize this to a non-nil value to cause ifdefs be hidden as
        soon as `hide-ifdef-mode' is turned on.

`hide-ifdef-lines'
        Customize to non-nil to hide the #if, #ifdef, #ifndef, #else,
        and #endif lines when hiding ifdefs.

`hide-ifdef-define-alist'
        An association list of defined symbol lists.
        Use `hide-ifdef-set-define-alist' to save the current `hide-ifdef-env'
        and `hide-ifdef-use-define-alist' to set the current `hide-ifdef-env'
        from one of the lists in `hide-ifdef-define-alist'.

`hide-ifdef-read-only'
        Set to non-nil if you want to make buffers read only while hiding.
        After `show-ifdefs', read-only status is restored to previous value.

\\{hide-ifdef-mode-map}"
  :group 'hide-ifdef :lighter " Ifdef"
  (if hide-ifdef-mode
      (progn
        ;; inherit global values

        ;; `hide-ifdef-env' is now a global variable.
        ;; We can still simulate the behavior of older hideif versions (i.e.
        ;; `hide-ifdef-env' being buffer local) by clearing this variable
        ;; (C-c @ C) every time before hiding current buffer.
;;      (setq-local hide-ifdef-env
;;           (default-value 'hide-ifdef-env))
        (setq hide-ifdef-env (default-value 'hide-ifdef-env))
        ;; Some C/C++ headers might have other ways to prevent reinclusion and
        ;; thus would like `hide-ifdef-expand-reinclusion-guard' to be nil.
        (setq-local hide-ifdef-expand-reinclusion-guard
                    (default-value 'hide-ifdef-expand-reinclusion-guard))
        (setq-local hide-ifdef-hiding
                    (default-value 'hide-ifdef-hiding))
        (setq-local hif-outside-read-only buffer-read-only)
        (setq-local line-move-ignore-invisible t)
        (add-hook 'change-major-mode-hook
                  (lambda () (hide-ifdef-mode -1)) nil t)

        (add-to-invisibility-spec '(hide-ifdef . t))

        (if hide-ifdef-initially
            (hide-ifdefs)
          (show-ifdefs)))
    ;; else end hide-ifdef-mode
    (kill-local-variable 'line-move-ignore-invisible)
    (remove-from-invisibility-spec '(hide-ifdef . t))
    (when hide-ifdef-hiding
      (show-ifdefs))))