9

I am using ELPY in emacs in Windows. How do I eval current file inside emacs using a Shortcut.

When I use eval-buffer. I get below messages.

Flymake unable to run without a buffer file name

Removed if main == 'main' construct, use a prefix argument to evaluate.

1 Answer 1

12

There is a built in feature in emacs when working with the python (inferior) shell, to prevent people from running the whole script unintentionally, which is does by redefining (or removing) __name__ before it runs.

Your script does send __name__ = "__main__" but it is overwritten, due to this 'safety feature'.

To execute as you wish, running it as main, use the key binding:

`C-u C-c C-c`

If you would like to remap this to be something quicker or more familiar, try something like this:

(global-set-key (kbd "<f7>") (kbd "C-u C-c C-c"))

this was discussed in this thread here, where there is also some related extra information.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.