Übersicht Letzte Änderungen Neuigkeiten Suchen ElispSektion KurzAnleitung Impressum
Jemen: Haupt-Nationalfeiertag - Wiedervereinigung von Nord- und Süd-Jemen 1990

ProgrammingWithPythonModeDotEl

Letzte Änderung

Eingefügt:

> When you execute a buffer with C-c C-c, the Python shell is launched as the top buffer (rather than the bottom?). How do you make it load the shell on the bottom buffer as python.el does?


python-mode.el is part of the Python distribution. You can also download it from launchpad:

The relevant page also has installation instructions. The following was enough for me, though:

 (autoload 'python-mode "python-mode" "Python Mode." t)
 (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
 (add-to-list 'interpreter-mode-alist '("python" . python-mode))

this could be useful: (RichardRiley : why?)

 (add-hook 'python-mode-hook
           (lambda ()
             (set (make-variable-buffer-local 'beginning-of-defun-function)
                  'py-beginning-of-def-or-class)
             (setq outline-regexp "def\\|class ")))
It should be noted that python-mode.el, since it is part of python, doesn’t usually need to be separately installed. Also, many distros will also add relevant autoloads e.g. Gentoo adds it to site-lisp/site-gentoo.el or possibly site-lisp/site-gentoo.d – CH

For Emacs 22 and after, consider ProgrammingWithPythonDotEl

some more commands

 (defun py-next-block ()
   "go to the next block.  Cf. `forward-sexp' for lisp-mode"
   (interactive)
   (py-mark-block nil 't)
   (back-to-indentation))

ElDoc works with the python mode in GNU Emacs 22. (For Emacs 21, see the back-port of Eldoc.) To enable it by default in your python mode buffers, you might want something like:

   (add-hook 'python-mode-hook
          '(lambda () (eldoc-mode 1)) t)

‘py-help-at-point’ can be used to get the internal python documentation on the function at point.

For Emacs 23: C-c C-f “sys” – this works, and describes the “sys” module in a separate Emacs help buffer.

If I define function “zoot”, help doesn’t on it – it’s only for global things.

Integrating python-mode's pdbtrack with xpdb and making it aware of generator expressions

AlexCoventry

I have found the following settings helpful in using xpdb:

;; Let python-mode know about xpdb and generator expressions.
(setq py-pdbtrack-input-prompt "\n[(<]*x?pdb[>)]+ "
      py-pdbtrack-stack-entry-regexp
      (concat "^> \\(.*\\)(\\([0-9]+\\))"
	      "\\([?a-zA-Z0-9_]+\\|<genexpr>\\)()"))

xpdb is a fork of the standard library pdb, available here: https://code.launchpad.net/~eyal-lotem+launchpad/xpdb/main

When you execute a buffer with C-c C-c, the Python shell is launched as the top buffer (rather than the bottom?). How do you make it load the shell on the bottom buffer as python.el does?

other things you may be interested in