Commit | Line | Data |
---|---|---|
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 | ||
12 | ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 | ;; it under the terms of the GNU General Public License as published by | |
1a484753 | 14 | ;; the Free Software Foundation; either version 3, or (at your option) |
66b08d69 GM |
15 | ;; any later version. |
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 | |
23 | ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
24 | ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
25 | ;; Boston, MA 02110-1301, USA. | |
26 | ||
27 | ;;; Commentary: | |
28 | ||
29 | ;; Major mode for editing Python, with support for inferior processes. | |
30 | ||
31 | ;; There is another Python mode, python-mode.el, used by XEmacs and | |
32 | ;; maintained with Python. That isn't covered by an FSF copyright | |
33 | ;; assignment, unlike this code, and seems not to be well-maintained | |
34 | ;; for Emacs (though I've submitted fixes). This mode is rather | |
35 | ;; simpler and is better in other ways. In particular, using the | |
36 | ;; syntax functions with text properties maintained by font-lock makes | |
37 | ;; it more correct with arbitrary string and comment contents. | |
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 | |
47 | ;; feature, `c-subword-mode' which is intended to have a similar | |
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 | ||
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 | ||
73 | (autoload 'comint-mode "comint") | |
74 | ||
75 | (defgroup python nil | |
76 | "Silly walks in the Python language." | |
77 | :group 'languages | |
78 | :version "22.1" | |
79 | :link '(emacs-commentary-link "python")) | |
80 | \f | |
81 | ;;;###autoload | |
82 | (add-to-list 'interpreter-mode-alist '("jython" . jython-mode)) | |
83 | ;;;###autoload | |
84 | (add-to-list 'interpreter-mode-alist '("python" . python-mode)) | |
85 | ;;;###autoload | |
86 | (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)) | |
87 | \f | |
88 | ;;;; Font lock | |
89 | ||
90 | (defvar python-font-lock-keywords | |
91 | `(,(rx symbol-start | |
308114ef | 92 |