Function: magit-save-repository-buffers

magit-save-repository-buffers is an interactive and byte-compiled function defined in magit-mode.el.

Signature

(magit-save-repository-buffers &optional ARG)

Documentation

Save file-visiting buffers belonging to the current repository.

After any buffer where buffer-save-without-query is non-nil is saved without asking, the user is asked about each modified buffer, which visits a file in the current repository. Optional argument (the prefix) non-nil means save all with no questions.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-mode.el
(defun magit-save-repository-buffers (&optional arg)
  "Save file-visiting buffers belonging to the current repository.
After any buffer where `buffer-save-without-query' is non-nil
is saved without asking, the user is asked about each modified
buffer, which visits a file in the current repository.  Optional
argument (the prefix) non-nil means save all with no questions."
  (interactive "P")
  (when-let ((topdir (magit-rev-parse-safe "--show-toplevel")))
    (let ((save-some-buffers-action-alist
           `((?Y ,(##with-current-buffer %
                    (setq buffer-save-without-query t)
                    (save-buffer))
                 "to save the current buffer and remember choice")
             (?N ,(##with-current-buffer %
                    (setq magit-inhibit-refresh-save t))
                 "to skip the current buffer and remember choice")
             ,@save-some-buffers-action-alist))
          ;; Create a single wip commit for all saved files.
          (magit--wip-inhibit-autosave t)
          (saved nil))
      (unwind-protect
          (save-some-buffers
           arg
           (lambda ()
             (and (funcall magit-save-repository-buffers-predicate topdir)
                  (prog1 t
                    (when magit-wip-mode
                      (push (expand-file-name buffer-file-name) saved))))))
        (when saved
          (let ((default-directory topdir))
            (magit-wip-commit-worktree
             (magit-wip-get-ref)
             saved
             (if (cdr saved)
                 (format "autosave %s files after save" (length saved))
               (format "autosave %s after save"
                       (file-relative-name (car saved)))))))))))