Variable: hs-minor-mode

hs-minor-mode is a buffer-local variable defined in hideshow.el.gz.

Documentation

Non-nil if hs minor mode is enabled.

Use the command hs-minor-mode(var)/hs-minor-mode(fun) to change this variable.

View in manual

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'.

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)

  (cond
   ((and hs-minor-mode
         (not (and comment-start comment-end)))
    (setq hs-minor-mode nil)
    (message "%S doesn't support the Hideshow minor mode"
             major-mode))

   (hs-minor-mode
    ;; Set the old variables
    (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))
    ;; Add block indicators
    (when (and hs-show-indicators
               (or (and (integerp hs-indicator-maximum-buffer-size)
                        (< (buffer-size) hs-indicator-maximum-buffer-size))
                   (not hs-indicator-maximum-buffer-size)))
      (when (and (not (display-graphic-p))
                 (eq hs-indicator-type 'fringe))
        (setq-local hs-indicator-type 'margin))
      (when (eq hs-indicator-type 'margin)
        (setq-local left-margin-width (1+ left-margin-width))
        (setq-local fringes-outside-margins t)
        ;; Force display of margins
        (when (eq (current-buffer) (window-buffer))
          (set-window-buffer nil (window-buffer))))
      (jit-lock-register #'hs--add-indicators)))

   (t
    (remove-from-invisibility-spec '(hs . t))
    (remove-overlays nil nil 'hs-indicator t)
    (remove-overlays nil nil 'invisible 'hs)
    (when hs-show-indicators
      (jit-lock-unregister #'hs--add-indicators)
      (when (and (eq hs-indicator-type 'margin)
                 (< 0 left-margin-width))
        (setq-local left-margin-width (1- left-margin-width))
        (kill-local-variable 'fringes-outside-margins)
        ;; Force removal of margins
        (when (eq (current-buffer) (window-buffer))
          (set-window-buffer nil (window-buffer))))))))