From the command line, I want to open an inferior Python process in a full window. I have tried: emacs --eval '(run-python)', but when Emacs opens, the *scratch* buffer is shown instead of the inferior Python process buffer. The Python process is started, but it is not the focused buffer. From the command line, how do I focus the inferior Python process in a full window when starting Emacs?

Assume that I am using GNU Emacs 26.3 with no custom configuration (i.e. emacs --no-site-file --no-init-file ...).

  • Things within the .emacs / init.el, if any, can affect what is displayed at startup. The last hook to be called during startup (that is related to startup) is the emacs-startup-hook: gnu.org/software/emacs/manual/html_node/elisp/… One idea would be to add your function to that hook and see if that does the trick. Other things to try are using switch-to-buffer or set-window-buffer, and if there are too many windows displayed, then delete-other-windows. The startup.el cannot be modified once Emacs has been built from source; i.e., it's baked-in. – lawlist Jan 28 at 19:09
  • @lawlist Assume that I have no custom configuration (i.e. emacs --no-site-file --no-init-file ...). – Flux Jan 29 at 2:59

I have found a solution:

emacs --eval '(progn (pop-to-buffer (process-buffer (run-python))) (delete-other-windows))'

This starts an inferior Python process, focuses it, and makes it take up the whole frame.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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