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