Function: majutsu-interactive-toggle-file

majutsu-interactive-toggle-file is an interactive and natively compiled function defined in majutsu-interactive.el.

Signature

(majutsu-interactive-toggle-file)

Documentation

Toggle all hunks, or a whole-file change with no text hunks, at point.

Key Bindings

This command is not in any keymaps.

Source Code

;; Defined in /nix/store/jagqw3nms546pad0gxi5f3wsckk6pji7-emacs-packages-deps/share/emacs/site-lisp/majutsu-interactive.el
(defun majutsu-interactive-toggle-file ()
  "Toggle all hunks, or a whole-file change with no text hunks, at point."
  (interactive)
  (let (file-section)
    (magit-section-case
      (jj-hunk (setq file-section (oref it parent)))
      (jj-file (setq file-section it)))
    (let ((file (and file-section (oref file-section value))))
      (when (and file-section (magit-section-match 'jj-file file-section))
        (unless (majutsu-interactive--file-section-hunks file-section)
          (setq file-section
                (or (majutsu-interactive--file-section-with-hunks file)
                    (majutsu-interactive--file-section-for-file file))))
        (unless file-section
          (user-error "No file change at point"))
        (let ((hunks (majutsu-interactive--file-section-hunks file-section)))
          (if (null hunks)
              (majutsu-interactive--toggle-whole-file file-section)
            (let ((all-selected
                   (cl-every
                    (lambda (h)
                      (majutsu-interactive--get-selection
                       (majutsu-interactive--hunk-id h)))
                    hunks)))
              (dolist (hunk hunks)
                (majutsu-interactive--set-selection
                 (majutsu-interactive--hunk-id hunk)
                 (unless all-selected :all)))
              (majutsu-interactive--render-overlays)
              (message "%s all hunks in file"
                       (if all-selected "Deselected" "Selected")))))))))