Advice for using emacs python-mode
Syver Enstad
syver-en+usenet at online.no
Wed Nov 20 16:48:13 EST 2002
Andrew Koenig <ark at research.att.com> writes:
> I'm writing a program using Emacs and python-mode, and have run into
> a few problems.
Hi Andrew, I've been where you are, and it's not a great place to
be. One thing I did was to put Python Output into a separate frame
(another toplevel window). This keeps the main frame of emacs more
stable.
(setq special-display-buffer-names '("*Python*" "*Python Output*"))
The other problem (when running the interpreter and the module needs
to be reloaded), I solved by not using that feature much. I've instead
bound a key to an lisp function that uses compile mode to run the
current python file. I find that this solution solves two problems, it
doesn't freeze emacs and it avoids the problems with reloading.
(defun py-unittest ()
"run unittest on file in the current bufffer "
(interactive)
(compile
(format "python \"%s\""
(buffer-file-name))))
The thing about it running unittest on the current buffer really is a
lying comment. It just so happens that all my modules have a
if __name__ == '__main__':
unittest.main()
in the bottom of them, so that running them as a main program is the
same as running the unittests contained in the file.
In addition if you want to be able to step around your source for
tracebacks in the compilation buffer:
;; python TraceBack
;; File "h:/mydocuments/Kode/pythonscript/AdoDb.py", line 496
(add-to-list 'compilation-error-regexp-alist
'(".*File \"\\(.+\\)\", line \\([0-9]+\\)" 1 2))
Hope this helps.
--
Vennlig hilsen
Syver Enstad
More information about the Python-list
mailing list