Function: magit-setup-buffer-internal
magit-setup-buffer-internal is a byte-compiled function defined in
magit-mode.el.
Signature
(magit-setup-buffer-internal MODE LOCKED BINDINGS &key BUFFER DIRECTORY INITIAL-SECTION SELECT-SECTION)
Source Code
;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-mode.el
(cl-defun magit-setup-buffer-internal
( mode locked bindings
&key buffer directory initial-section select-section)
(let* ((value (and locked
(with-temp-buffer
(pcase-dolist (`(,var ,val) bindings)
(set (make-local-variable var) val))
(let ((major-mode mode))
(magit-buffer-value)))))
(buffer (if buffer
(get-buffer-create buffer)
(magit-get-mode-buffer mode value)))
(section (and buffer (magit-current-section)))
(created (not buffer)))
(unless buffer
(setq buffer (magit-generate-new-buffer mode value)))
(with-current-buffer buffer
(setq magit-previous-section section)
(when directory
(setq default-directory directory))
(funcall mode)
(magit-xref-setup #'magit-setup-buffer-internal bindings)
(pcase-dolist (`(,var ,val) bindings)
(set (make-local-variable var) val))
(when created
(run-hooks 'magit-create-buffer-hook)))
(magit-display-buffer buffer)
(with-current-buffer buffer
(run-hooks 'magit-setup-buffer-hook)
(magit-refresh-buffer created
:initial-section initial-section
:select-section select-section)
(when created
(run-hooks 'magit-post-create-buffer-hook)))
buffer))