Search code examples
pythonemacsmode

python.el shell and execute buffer


I am using the python.el from fgallina python.el github There is a long list of features but I am unaware of how to use them.

EDIT: Found this mode was working, however didn't automatically open the interpreter went the information was sent there. How can I send/load my current python buffer to be evaluated? I am trying to use C-c C-c but I don't get any output.

Python shell integration and shell completion? Do I need to add something beside the standard load-path and require statements for this?

Imenu support this isn't showing for me either. Edit I tried adding this to my emacs but that hasn't worked.

add-hook 'python-mode-hook 'imenu-add-menubar-index)

I am using emacs 23 on ubuntu


Solution

  • For your first question: Usually you can load a buffer/file using C-c C-l. (Just tested this for python.el, and it works for this one as well) This will send the file to the inferior python process -- so you should open the *Python* buffer to see the results. The *Python* buffer is also your regular python interpreter/shell/REPL. C-M-x is bound to python-send-defun which sends a method/function definition to the interpreting process. For other bindings just hit M-x describe-bindings and then look for "python-" (under "Major Mode Bindings") in the opened *Help* buffer window.

    There is some more documentation at the beginning of python.el if you want to know more about completion:

    Quote:

    Shell completion: hitting tab will try to complete the current word. Shell completion is implemented in a manner that if you change the python-shell-interpreter to any other (for example IPython) it should be easy to integrate another way to calculate completions. You just need to specify your custom python-shell-completion-setup-code and python-shell-completion-string-code.

    Quote:

    Symbol completion: you can complete the symbol at point. It uses the shell completion in background so you should run python-shell-send-buffer from time to time to get better results.

    Skeletons: 6 skeletons are provided for simple inserting of class, def, for, if, try and while. These skeletons are integrated with dabbrev. If you have dabbrev-mode activated and python-skeleton-autoinsert is set to t, then whenever you type the name of any of those defined and hit SPC, they will be automatically expanded.

    The imenu entry shows up for me without adding the hook, just (require 'python) in a configuration file.