Function: magit-todos--set-visibility

magit-todos--set-visibility is a natively compiled function defined in magit-todos.el.

Signature

(magit-todos--set-visibility &key SECTION NUM-ITEMS DEPTH)

Documentation

Set the visibility of SECTION.

If the section's visibility is cached by Magit, the cached setting is applied. Otherwise, visibility is set according to whether NUM-ITEMS is greater than magit-todos-max-items.

When DEPTH is greater than 0, NUM-ITEMS is compared to magit-todos-max-items divided by DEPTH multiplied by 2, i.e. the max number of items which cause sections to be automatically hidden halves at each deeper level.

Source Code

;; Defined in /nix/store/xy37aj9089qvbs5clw0qszpi3hrh3mxx-emacs-packages-deps/share/emacs/site-lisp/elpa/magit-todos-20250928.1611/magit-todos.el
(cl-defun magit-todos--set-visibility (&key section num-items depth)
  "Set the visibility of SECTION.

If the section's visibility is cached by Magit, the cached
setting is applied.  Otherwise, visibility is set according to
whether NUM-ITEMS is greater than `magit-todos-max-items'.

When DEPTH is greater than 0, NUM-ITEMS is compared to
`magit-todos-max-items' divided by DEPTH multiplied by 2,
i.e. the max number of items which cause sections to be
automatically hidden halves at each deeper level."
  (declare (indent defun))
  (pcase (magit-section-cached-visibility section)
    ('hide (magit-section-hide section))
    ('show (magit-section-show section))
    (_ (if (> num-items (pcase depth
                          (0 magit-todos-max-items)
                          (_ (/ magit-todos-max-items (* depth 2)))))
           ;; HACK: We have to do this manually because the set-visibility-hook doesn't work.
           (magit-section-hide section)
         ;; Not hidden: show section manually (necessary for some reason)
         (magit-section-show section)))))