*** empty log message ***
[bpt/emacs.git] / lisp / progmodes / python.el
CommitLineData
308114ef 1;;; python.el --- silly walks for Python -*- coding: iso-8859-1 -*-
66b08d69 2
e18cc61c
GM
3;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
4;; Free Software Foundation, Inc.
66b08d69
GM
5
6;; Author: Dave Love <fx@gnu.org>
7;; Maintainer: FSF
8;; Created: Nov 2003
9;; Keywords: languages
10
11;; This file is part of GNU Emacs.
12
b1fc2b50 13;; GNU Emacs is free software: you can redistribute it and/or modify
66b08d69 14;; it under the terms of the GNU General Public License as published by
b1fc2b50
GM
15;; the Free Software Foundation, either version 3 of the License, or
16;; (at your option) any later version.
66b08d69
GM
17
18;; GNU Emacs is distributed in the hope that it will be useful,
19;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21;; GNU General Public License for more details.
22
23;; You should have received a copy of the GNU General Public License
b1fc2b50 24;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
66b08d69
GM
25
26;;; Commentary:
27
28;; Major mode for editing Python, with support for inferior processes.
29
e18cc61c
GM
30;; There is another Python mode, python-mode.el:
31;; http://launchpad.net/python-mode
32;; used by XEmacs, and originally maintained with Python.
33;; That isn't covered by an FSF copyright assignment (?), unlike this
34;; code, and seems not to be well-maintained for Emacs (though I've
35;; submitted fixes). This mode is rather simpler and is better in
36;; other ways. In particular, using the syntax functions with text
37;; properties maintained by font-lock makes it more correct with
38;; arbitrary string and comment contents.
66b08d69
GM
39
40;; This doesn't implement all the facilities of python-mode.el. Some
41;; just need doing, e.g. catching exceptions in the inferior Python
42;; buffer (but see M-x pdb for debugging). [Actually, the use of
43;; `compilation-shell-minor-mode' now is probably enough for that.]
44;; Others don't seem appropriate. For instance,
45;; `forward-into-nomenclature' should be done separately, since it's
46;; not specific to Python, and I've installed a minor mode to do the
47;; job properly in Emacs 23. [CC mode 5.31 contains an incompatible
48;; feature, `c-subword-mode' which is intended to have a similar
49;; effect, but actually only affects word-oriented keybindings.]
50
51;; Other things seem more natural or canonical here, e.g. the
52;; {beginning,end}-of-defun implementation dealing with nested
53;; definitions, and the inferior mode following `cmuscheme'. (The
54;; inferior mode can find the source of errors from
55;; `python-send-region' & al via `compilation-shell-minor-mode'.)
56;; There is (limited) symbol completion using lookup in Python and
57;; Eldoc support also using the inferior process. Successive TABs
58;; cycle between possible indentations for the line.
59
60;; Even where it has similar facilities, this mode is incompatible
61;; with python-mode.el in some respects. For instance, various key
62;; bindings are changed to obey Emacs conventions.
63
64;; TODO: See various Fixmes below.
65
2bcda1d5
CY
66;; Fixme: This doesn't support (the nascent) Python 3 .
67
66b08d69
GM
68;;; Code:
69
d550787c
NR
70(require 'comint)
71
66b08d69 72(eval-when-compile
66b08d69 73 (require 'compile)
66b08d69
GM
74 (require 'hippie-exp))
75
2bcda1d5 76(require 'sym-comp)
66b08d69
GM
77(autoload 'comint-mode "comint")
78
79(defgroup python nil
80 "Silly walks in the Python language."
81 :group 'languages
82 :version "22.1"
83 :link '(emacs-commentary-link "python"))
84\f
85;;;###autoload
86(add-to-list 'interpreter-mode-alist '("jython" . jython-mode))
87;;;###autoload
88(add-to-list 'interpreter-mode-alist '("python" . python-mode))
89;;;###autoload
90(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
2bcda1d5 91(add-to-list 'same-window-buffer-names "*Python*")
66b08d69
GM
92\f
93;;;; Font lock
94
95(defvar python-font-lock-keywords
96 `(,(rx symbol-start
308114ef 97