Variable: magit-save-repository-buffers-predicate
magit-save-repository-buffers-predicate is a variable defined in
magit-mode.el.
Value
#[257
"\303!\304 \205=\305 !\211\205=\306!\205=\n?\205=\303 !\232\205=\210\304A\2065\307\310!BC\262\232\205=\311 !)\207"
[default-directory buffer-file-name magit-inhibit-refresh-save
file-remote-p nil file-name-directory
file-exists-p magit-rev-parse-safe
"--show-toplevel" file-writable-p]
6 ("/root/.emacs.d/elpa/magit-20260411.1452/magit-mode.elc" . 47233)]
Documentation
Predicate for magit-save-repository-buffers(var)/magit-save-repository-buffers(fun).
This function is called for each buffer that might need saving with one argument, the working tree of the respective repository. If it returns non-nil, the current buffer is saved.
Source Code
;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-mode.el
(defvar magit-save-repository-buffers-predicate
(lambda (topdir)
(let ((remote (file-remote-p default-directory))
(topdirs nil)
;; If the current file is modified and resides inside
;; a repository, and a let-binding is in effect, which
;; places us in another repository, then this binding
;; is needed to prevent that file from being saved.
(default-directory default-directory))
(and buffer-file-name
(setq default-directory (file-name-directory buffer-file-name))
;; Check whether the repository still exists.
(file-exists-p default-directory)
;; Check whether refreshing is disabled.
(not magit-inhibit-refresh-save)
;; Check whether the visited file is either on the
;; same remote as the repository, or both are on
;; the local system.
(equal (file-remote-p buffer-file-name) remote)
;; Delayed checks that are more expensive for remote
;; repositories, due to the required network access.
;;
;; Check whether the file is inside the repository.
(equal (or (cdr (assoc default-directory topdirs))
(let ((top (magit-rev-parse-safe "--show-toplevel")))
(push (cons default-directory top) topdirs)
top))
topdir)
;; Check whether the file is actually writable.
(file-writable-p buffer-file-name))))
"Predicate for `magit-save-repository-buffers'.
This function is called for each buffer that might need saving with
one argument, the working tree of the respective repository. If it
returns non-nil, the current buffer is saved.")