python-mode & emacs settings (was: Re: Tabbing/Spaces & python-mode)
Erno Kuusela
erno-news at erno.iki.fi
Sun Jan 21 09:50:59 EST 2001
In article <mailman.980032109.7884.python-list at python.org>, barry at digicool.com (Barry A. Warsaw) writes:
| If you're in the indentation, just use M-m (ESC m) to get you to the
| first non-whitespace character and C-a to get you to the beginning of
| the line.
thanks! i actually had found that eariler, but i forgot to start
using it because M-m is a somewhat awkward key combination. but
now i've rebound it.
anyone want to share the python-related .emacs tweaks they are using?
here are some from mine:
(i have recycled my caps lock to work as a hyper key,
change modifier to taste)
-- erno
(global-font-lock-mode 1)
(global-set-key [?\H-l] 'goto-line)
(global-set-key [\H-left] 'back-to-indentation)
(global-set-key [\H-right] 'end-of-line)
;; this is in global keymap so that i can open C-x C-f ~/bin/quick-hack
;; and hit H-M-p
(global-set-key [?\H-\M-p] 'py-template)
(add-hook 'python-mode-hook
(lambda ()
(define-key py-mode-map [?\H-d] 'py-module-doc)))
;; when you have something for reference in the other window
(global-set-key [C-next] 'scroll-other-window)
(global-set-key [C-prior] 'scroll-other-window-down)
(defun py-template ()
"Insert a python program skeleton"
(interactive)
(insert
"#!/usr/bin/env python\n"
"# -*- mode: python; py-indent-offset: 4; indent-tabs-mode: f -*-\n"
"import os, sys, string\n"
"\n"
"def main():\n"
" pass\n"
"\n"
"if __name__ == '__main__':\n"
" try:\n"
" main()\n"
" except KeyboardInterrupt:\n"
" sys.exit('%s: break' % os.path.basename(sys.argv[0]))\n")
(python-mode))
(defun py-module-doc (module-name)
"Open a netscape window showing the documentation for the requested module"
(interactive "smodule name: ")
(shell-command (format "gnome-moz-remote "
"'http://www.cwi.nl/www.python.org/doc/current/"
"lib/module-%s.html'"
module-name)))
More information about the Python-list
mailing list