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?

  • 7890yuiop@fediverser.communick.devB
    link
    fedilink
    English
    arrow-up
    1
    ·
    11 months ago

    I think you need to define your requirements in more detail. What if you call magit-status while using Magit? Does that change what the “previous window configuration” should be? (I suspect it does, in which case it’s not going to be “the previous window configuration” that you want). If I’m correct, you should clarify exactly which window configuration you want to restore, and when (in which specific circumstances) that should be captured.

  • 404cn@fediverser.communick.devB
    link
    fedilink
    English
    arrow-up
    1
    ·
    11 months ago

    Install package fullframe then (fullframe magit-status magit-mode-quit-window)

    Others: bind q to this function

    ```elisp

    (defun eat/quit ()

    “Delete current window switch to prevous buffer.”

    (interactive)

    (if (> (seq-length (window-list (selected-frame))) 1)

    (delete-window)

    (previous-buffer)))

    ```

    • jvillasante@fediverser.communick.devB
      link
      fedilink
      English
      arrow-up
      1
      ·
      11 months ago

      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)))