Function: outline-minor-mode

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

Signature

(outline-minor-mode &optional ARG)

Documentation

Toggle Outline minor mode.

See the command outline-mode for more information on this mode.

This is a minor mode. If called interactively, toggle the Outline 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 outline-minor-mode(var)/outline-minor-mode(fun).

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

View in manual

Probably introduced at or before Emacs version 19.20.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/outline.el.gz
;;;###autoload
(define-minor-mode outline-minor-mode
  "Toggle Outline minor mode.

See the command `outline-mode' for more information on this mode."
  :lighter " Outl"
  :keymap (define-keymap
            :parent outline-minor-mode-cycle-map
            "<menu-bar>" outline-minor-mode-menu-bar-map
            (key-description outline-minor-mode-prefix) outline-mode-prefix-map)
  (if outline-minor-mode
      (progn
        (when outline-minor-mode-use-buttons
          (add-hook 'after-change-functions
                    #'outline--fix-buttons-after-change nil t)
          (when (eq (current-bidi-paragraph-direction) 'right-to-left)
            (setq-local outline--use-rtl t))
          (setq-local outline--button-icons (outline--create-button-icons))
          (when (and (eq outline-minor-mode-use-buttons 'in-margins)
                     (> 1 (if outline--use-rtl right-margin-width
                            left-margin-width)))
            (setq outline--margin-width
                  (or outline-margin-width
                      (ceiling
                       (/ (seq-max
                           (seq-map #'string-pixel-width
                                    (seq-map #'icon-string
                                             `(outline-open-in-margins
                                               ,(if outline--use-rtl
                                                    'outline-close-rtl-in-margins
                                                  'outline-close-in-margins)))))
                          (* (default-font-width) 1.0)))))
            (if outline--use-rtl
                (setq-local right-margin-width (+ right-margin-width
                                                  outline--margin-width))
              (setq-local left-margin-width (+ left-margin-width
                                               outline--margin-width)))
            (setq-local fringes-outside-margins t)
            ;; Force display of margins
            (when (eq (current-buffer) (window-buffer))
              (set-window-buffer nil (window-buffer)))))
        (when outline-minor-mode-highlight
          (if (and global-font-lock-mode (font-lock-specified-p major-mode))
              (progn
                (font-lock-add-keywords nil outline-font-lock-keywords t)
                (font-lock-flush))
            (outline-minor-mode-highlight-buffer)))
        (outline--fix-up-all-buttons)
	;; Turn off this mode if we change major modes.
	(add-hook 'change-major-mode-hook
		  (lambda () (outline-minor-mode -1))
		  nil t)
        (setq-local line-move-ignore-invisible t)
	;; Cause use of ellipses for invisible text.
	(add-to-invisibility-spec '(outline . t))
	(outline-apply-default-state))
    (setq line-move-ignore-invisible nil)
    ;; Cause use of ellipses for invisible text.
    (remove-from-invisibility-spec '(outline . t))
    ;; When turning off outline mode, get rid of any outline hiding.
    (outline-show-all)
    (when outline-minor-mode-highlight
      (if font-lock-fontified
          (font-lock-remove-keywords nil outline-font-lock-keywords))
      (font-lock-flush)
      (remove-overlays nil nil 'outline-highlight t))
    (when outline-minor-mode-use-buttons
      (remove-overlays nil nil 'outline-button t)
      (when (and (eq outline-minor-mode-use-buttons 'in-margins)
                 (< 0 (if outline--use-rtl right-margin-width
                        left-margin-width)))
        (if outline--use-rtl
            (setq-local right-margin-width (- right-margin-width
                                              outline--margin-width))
          (setq-local left-margin-width (- left-margin-width
                                           outline--margin-width)))
        (setq-local fringes-outside-margins nil)
        ;; Force removal of margins
        (when (eq (current-buffer) (window-buffer))
          (set-window-buffer nil (window-buffer)))))))