Function: hs-minor-mode

hs-minor-mode is an autoloaded, interactive and byte-compiled function defined in hideshow.el.gz.

Signature

(hs-minor-mode &optional ARG)

Documentation

Minor mode to selectively hide/show code and comment blocks.

This is a minor mode. If called interactively, toggle the hs minor mode mode. If the prefix argument is positive, enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is toggle. Enable the mode if ARG is nil, omitted, or is a positive number. Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer, evaluate hs-minor-mode(var)/hs-minor-mode(fun).

The mode's hook is called both when the mode is enabled and when it is disabled.

When hideshow minor mode is on, the menu bar is augmented with hideshow commands and the hideshow commands are enabled. The value (hs . t) is added to buffer-invisibility-spec.

The main commands are: hs-hide-all, hs-show-all, hs-hide-block, hs-show-block, hs-hide-level and hs-toggle-hiding. There is also hs-hide-initial-comment-block.

Turning hideshow minor mode off reverts the menu bar and the variables to default values and disables the hideshow commands.

Lastly, the normal hook hs-minor-mode-hook is run using run-hooks.

Key bindings:
C-c @ C-M-h hs-hide-all
C-c @ C-M-s hs-show-all
C-c @ C-a hs-show-all
C-c @ C-c hs-toggle-hiding
C-c @ C-d hs-hide-block
C-c @ C-e hs-toggle-hiding
C-c @ C-h hs-hide-block
C-c @ C-l hs-hide-level
C-c @ C-s hs-show-block
C-c @ C-t hs-hide-all
S-<mouse-2> hs-toggle-hiding

Probably introduced at or before Emacs version 20.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/hideshow.el.gz
;;;###autoload
(define-minor-mode hs-minor-mode
  "Minor mode to selectively hide/show code and comment blocks.

When hideshow minor mode is on, the menu bar is augmented with hideshow
commands and the hideshow commands are enabled.
The value (hs . t) is added to `buffer-invisibility-spec'.

The main commands are: `hs-hide-all', `hs-show-all', `hs-hide-block',
`hs-show-block', `hs-hide-level' and `hs-toggle-hiding'.  There is also
`hs-hide-initial-comment-block'.

Turning hideshow minor mode off reverts the menu bar and the
variables to default values and disables the hideshow commands.

Lastly, the normal hook `hs-minor-mode-hook' is run using `run-hooks'.

Key bindings:
\\{hs-minor-mode-map}"
  :group 'hideshow
  :lighter " hs"
  :keymap hs-minor-mode-map
  (setq hs-headline nil)
  (if hs-minor-mode
      (progn
        (hs-grok-mode-type)
        ;; Turn off this mode if we change major modes.
        (add-hook 'change-major-mode-hook
                  #'turn-off-hideshow
                  nil t)
        (setq-local line-move-ignore-invisible t)
        (add-to-invisibility-spec '(hs . t)))
    (remove-from-invisibility-spec '(hs . t))
    ;; hs-show-all does nothing unless h-m-m is non-nil.
    (let ((hs-minor-mode t))
      (hs-show-all))))