0

I do not prefer python-mode. I would like a generic way so that I can understand emacs.

I wish the file be saved and python file command then be run as if in a shell.

1
  • You can run a shell under emacs: M-x shell RET and execute commands in it.
    – NickD
    Jan 2, 2020 at 17:30

2 Answers 2

1

Use M-! (M-x shell-command) if you want to run a shell command, e.g. python file.py and print the output in a new buffer (*Shell Command Output*). That does not open a shell in a new buffer.

Use M-x shell to run a shell in a new buffer as pointed by @NickD.

1

You could use M-x compile with an appropriate compile-command value. e.g. as a file-local variable:

# -*- compile-command: "python file.py"; -*-

Emacs will prompt you to save (or not) the file before running the command.

Your Answer

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

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