this post was submitted on 18 Oct 2023
1 points (100.0% liked)

Emacs

305 readers
1 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
 

I'd like magit-status to open full frame, ie a single window. When I hit q to exit, I'd like my previous window configuration to be restored.

What's the best way to do this? Setting the follow var causes it to open full frame, but removes all windows except for one upon exit:

 (setq magit-display-buffer-function
  #'magit-display-buffer-fullframe-status-v1)

I can get to my previous window layout with winner-undo, but I'd like q to do the right thing in this case.

Any thoughts?

you are viewing a single comment's thread
view the rest of the comments
[–] fiverniner@alien.top 1 points 11 months ago (2 children)

u/unhammer commented this in another post that: https://www.reddit.com/r/emacs/comments/179t67l/window_management_share_your_displaybufferalist/k5b56i2/

(setq magit-display-buffer-function 'magit-display-buffer-fullframe-status-topleft-v1)
(setq magit-bury-buffer-function 'magit-restore-window-configuration)
[–] unduly-noted@alien.top 1 points 11 months ago

That's the ticket! Thank you!

[–] jvillasante@alien.top 1 points 11 months ago (1 children)

This configuration only buries the magit buffer which may or may not be what you want, I prefer to actually kill the buffer so this is what I use instead:

(use-package magit
    :preface (defun my/magit-kill-buffers ()
                 "Restore window configuration and kill all Magit buffers."
                 (interactive)
                 (let ((buffers (magit-mode-get-buffers)))
                     (magit-restore-window-configuration)
                     (mapc #'kill-buffer buffers)))
    :bind (:map magit-status-mode-map
                ("q" . #'my/magit-kill-buffers)
                ("C-x k" . #'my/magit-kill-buffers))
    :custom ((magit-display-buffer-function 'magit-display-buffer-same-window-except-diff-v1)
             (git-commit-summary-max-length 50)
             (magit-diff-refine-hunk t) ; show granular diffs in selected hunk.
             (magit-save-repository-buffers nil)
             (magit-define-global-key-bindings nil)))
[–] unduly-noted@alien.top 1 points 11 months ago (1 children)

Curious why you prefer killing?

[–] jvillasante@alien.top 1 points 11 months ago (1 children)

I just like to have a clean ibuffer :)

After done with magit I want all magit buffers killed so that I can have a clean buffer list.

[–] unduly-noted@alien.top 1 points 11 months ago

Makes sense. I tried to keep my buffer list clean at first, but kinda gave up cause so many things in emacs create buffers