Commit | Line | Data |
---|---|---|
308114ef | 1 | ;;; python.el --- silly walks for Python -*- coding: iso-8859-1 -*- |
66b08d69 | 2 | |
acaf905b | 3 | ;; Copyright (C) 2003-2012 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 | ||
e18cc61c GM |
29 | ;; There is another Python mode, python-mode.el: |
30 | ;; http://launchpad.net/python-mode | |
31 | ;; used by XEmacs, and originally maintained with Python. | |
32 | ;; That isn't covered by an FSF copyright assignment (?), unlike this | |
33 | ;; code, and seems not to be well-maintained for Emacs (though I've | |
34 | ;; submitted fixes). This mode is rather simpler and is better in | |
35 | ;; other ways. In particular, using the syntax functions with text | |
36 | ;; properties maintained by font-lock makes it more correct with | |
37 | ;; arbitrary string and comment contents. | |
66b08d69 GM |
38 | |
39 | ;; This doesn't implement all the facilities of python-mode.el. Some | |
40 | ;; just need doing, e.g. catching exceptions in the inferior Python | |
41 | ;; buffer (but see M-x pdb for debugging). [Actually, the use of | |
42 | ;; `compilation-shell-minor-mode' now is probably enough for that.] | |
43 | ;; Others don't seem appropriate. For instance, | |
44 | ;; `forward-into-nomenclature' should be done separately, since it's | |
45 | ;; not specific to Python, and I've installed a minor mode to do the | |
46 | ;; job properly in Emacs 23. [CC mode 5.31 contains an incompatible | |
aaef4f91 | 47 | ;; feature, `subword-mode' which is intended to have a similar |
66b08d69 GM |
48 | ;; effect, but actually only affects word-oriented keybindings.] |
49 | ||
50 | ;; Other things seem more natural or canonical here, e.g. the | |
51 | ;; {beginning,end}-of-defun implementation dealing with nested | |
52 | ;; definitions, and the inferior mode following `cmuscheme'. (The | |
53 | ;; inferior mode can find the source of errors from | |
54 | ;; `python-send-region' & al via `compilation-shell-minor-mode'.) | |
55 | ;; There is (limited) symbol completion using lookup in Python and | |
56 | ;; Eldoc support also using the inferior process. Successive TABs | |
57 | ;; cycle between possible indentations for the line. | |
58 | ||
59 | ;; Even where it has similar facilities, this mode is incompatible | |
60 | ;; with python-mode.el in some respects. For instance, various key | |
61 | ;; bindings are changed to obey Emacs conventions. | |
62 | ||
63 | ;; TODO: See various Fixmes below. | |
64 | ||
2bcda1d5 CY |
65 | ;; Fixme: This doesn't support (the nascent) Python 3 . |
66 | ||
66b08d69 GM |
67 | ;;; Code: |
68 | ||
d550787c NR |
69 | (require 'comint) |
70 | ||
66b08d69 | 71 | (eval-when-compile |
66b08d69 | 72 | (require 'compile) |
66b08d69 GM |
73 | (require 'hippie-exp)) |
74 | ||
75 | (autoload 'comint-mode "comint") | |
76 | ||
77 | (defgroup python nil | |
78 | "Silly walks in the Python language." | |
79 | :group 'languages | |
80 | :version "22.1" | |
81 | :link '(emacs-commentary-link "python")) | |
82 | \f | |
83 | ;;;###autoload | |
1e8780b1 | 84 | (add-to-list 'interpreter-mode-alist (cons (purecopy "jython") 'jython-mode)) |
66b08d69 | 85 | ;;;###autoload |
1e8780b1 | 86 | (add-to-list 'interpreter-mode-alist (cons (purecopy "python") 'python-mode)) |
66b08d69 | 87 | ;;;###autoload |
ca0a881a | 88 | (add-to-list 'auto-mode-alist (cons (purecopy "\\.py\\'") 'python-mode)) |
66b08d69 GM |
89 | \f |
90 | ;;;; Font lock | |
91 | ||
92 | (defvar python-font-lock-keywords | |
93 | `(,(rx symbol-start | |
4565b08e | 94 |