When the magit-commit-popup window opens, there are one or two lines that are just below the screen. Calling fit-window-to-buffer in the popup buffer fixes the problem, but I would like to automate the process.

However, none of the following seems to work:

(add-hook 'magit-popup-mode-hook #'fit-window-to-buffer)
(add-hook 'magit-create-buffer-hook #'fit-window-to-buffer)
(add-hook 'magit-popup-help-mode-hook #'fit-window-to-buffer)
(add-hook 'magit-refresh-popup-buffer-hook #'fit-window-to-buffer)

Is there some hook that I'm missing?

1 Answer 1


Normally that does not happen and I suspect your frame is very narrow in height. If you want to keep using such a narrow frame, then you have two options.

  1. The window is displayed using (display-buffer buffer magit-popup-display-buffer-action). By adjusting magit-popup-display-buffer-action you should be able to accomplish what you want, but that might involve reading Action Functions for display-buffer and related nodes.

  2. Since you already know fit-window-to-buffer gets the job done, you can also just stick to that, and magit-popup-mode-hook should work for that.

    That hook is actually an abnormal hook and should be named magit-popup-mode-functions, but it is obsolete and I won't rename it. Because it is an abnormal hook (a hook that calls the functions with arguments), you have to think about the arguments and wrap fit-window-to-buffer accordingly.

    This is how it is called: (run-hook-with-args 'magit-popup-setup-hook val def).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.