aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorJoakim Verona2012-06-19 19:19:07 +0200
committerJoakim Verona2012-06-19 19:19:07 +0200
commitabef2047941f87ae4baa34b3a8675de4d0068b7a (patch)
tree63042e6c3037100412816200e03c04affc7fe071 /lisp/progmodes/python.el
parent58a90697e8f15a2722100ac489df200ad31d3086 (diff)
parent68f12411893785de1cfc2c24ec36059e49af5d55 (diff)
downloademacs-abef2047941f87ae4baa34b3a8675de4d0068b7a.tar.gz
emacs-abef2047941f87ae4baa34b3a8675de4d0068b7a.zip
upstream
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el42
1 files changed, 22 insertions, 20 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index dfa72a3084a..a43dc1eb1d3 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1,4 +1,4 @@
1;;; python.el --- Python's flying circus support for Emacs 1;;; python.el --- Python's flying circus support for Emacs -*- coding: utf-8 -*-
2 2
3;; Copyright (C) 2003-2012 Free Software Foundation, Inc. 3;; Copyright (C) 2003-2012 Free Software Foundation, Inc.
4 4
@@ -308,29 +308,31 @@
308 308
309(eval-when-compile 309(eval-when-compile
310 (defconst python-rx-constituents 310 (defconst python-rx-constituents
311 (list 311 `((block-start . ,(rx symbol-start
312 `(block-start . ,(rx symbol-start
313 (or "def" "class" "if" "elif" "else" "try" 312 (or "def" "class" "if" "elif" "else" "try"
314 "except" "finally" "for" "while" "with") 313 "except" "finally" "for" "while" "with")
315 symbol-end)) 314 symbol-end))
316 `(decorator . ,(rx line-start (* space) ?@ (any letter ?_) 315 (decorator . ,(rx line-start (* space) ?@ (any letter ?_)
317 (* (any word ?_)))) 316 (* (any word ?_))))
318 `(defun . ,(rx symbol-start (or "def" "class") symbol-end)) 317 (defun . ,(rx symbol-start (or "def" "class") symbol-end))
319 `(if-name-main . ,(rx line-start "if" (+ space) "__name__" 318 (if-name-main . ,(rx line-start "if" (+ space) "__name__"
320 (+ space) "==" (+ space) 319 (+ space) "==" (+ space)
321 (any ?' ?\") "__main__" (any ?' ?\") 320 (any ?' ?\") "__main__" (any ?' ?\")
322 (* space) ?:)) 321 (* space) ?:))
323 `(symbol-name . ,(rx (any letter ?_) (* (any word ?_)))) 322 (symbol-name . ,(rx (any letter ?_) (* (any word ?_))))
324 `(open-paren . ,(rx (or "{" "[" "("))) 323 (open-paren . ,(rx (or "{" "[" "(")))
325 `(close-paren . ,(rx (or "}" "]" ")"))) 324 (close-paren . ,(rx (or "}" "]" ")")))
326 `(simple-operator . ,(rx (any ?+ ?- ?/ ?& ?^ ?~ ?| ?* ?< ?> ?= ?%))) 325 (simple-operator . ,(rx (any ?+ ?- ?/ ?& ?^ ?~ ?| ?* ?< ?> ?= ?%)))
327 `(not-simple-operator . ,(rx 326 ;; FIXME: rx should support (not simple-operator).
327 (not-simple-operator . ,(rx
328 (not 328 (not
329 (any ?+ ?- ?/ ?& ?^ ?~ ?| ?* ?< ?> ?= ?%)))) 329 (any ?+ ?- ?/ ?& ?^ ?~ ?| ?* ?< ?> ?= ?%))))
330 `(operator . ,(rx (or "+" "-" "/" "&" "^" "~" "|" "*" "<" ">" 330 ;; FIXME: Use regexp-opt.
331 (operator . ,(rx (or "+" "-" "/" "&" "^" "~" "|" "*" "<" ">"
331 "=" "%" "**" "//" "<<" ">>" "<=" "!=" 332 "=" "%" "**" "//" "<<" ">>" "<=" "!="
332 "==" ">=" "is" "not"))) 333 "==" ">=" "is" "not")))
333 `(assignment-operator . ,(rx (or "=" "+=" "-=" "*=" "/=" "//=" "%=" "**=" 334 ;; FIXME: Use regexp-opt.
335 (assignment-operator . ,(rx (or "=" "+=" "-=" "*=" "/=" "//=" "%=" "**="
334 ">>=" "<<=" "&=" "^=" "|=")))) 336 ">>=" "<<=" "&=" "^=" "|="))))
335 "Additional Python specific sexps for `python-rx'")) 337 "Additional Python specific sexps for `python-rx'"))
336 338
@@ -1569,10 +1571,10 @@ there for compatibility with CEDET.")
1569 (get-buffer-process proc-buffer-name))) 1571 (get-buffer-process proc-buffer-name)))
1570 1572
1571(define-obsolete-function-alias 1573(define-obsolete-function-alias
1572 'python-proc 'python-shell-internal-get-or-create-process "23.3") 1574 'python-proc 'python-shell-internal-get-or-create-process "24.2")
1573 1575
1574(define-obsolete-variable-alias 1576(define-obsolete-variable-alias
1575 'python-buffer 'python-shell-internal-buffer "23.3") 1577 'python-buffer 'python-shell-internal-buffer "24.2")
1576 1578
1577(defun python-shell-send-string (string &optional process msg) 1579(defun python-shell-send-string (string &optional process msg)
1578 "Send STRING to inferior Python PROCESS. 1580 "Send STRING to inferior Python PROCESS.
@@ -1627,10 +1629,10 @@ Returns the output. See `python-shell-send-string-no-output'."
1627 (python-shell-internal-get-or-create-process) nil)) 1629 (python-shell-internal-get-or-create-process) nil))
1628 1630
1629(define-obsolete-function-alias 1631(define-obsolete-function-alias
1630 'python-send-receive 'python-shell-internal-send-string "23.3") 1632 'python-send-receive 'python-shell-internal-send-string "24.2")
1631 1633
1632(define-obsolete-function-alias 1634(define-obsolete-function-alias
1633 'python-send-string 'python-shell-internal-send-string "23.3") 1635 'python-send-string 'python-shell-internal-send-string "24.2")
1634 1636
1635(defun python-shell-send-region (start end) 1637(defun python-shell-send-region (start end)
1636 "Send the region delimited by START and END to inferior Python process." 1638 "Send the region delimited by START and END to inferior Python process."
@@ -2146,6 +2148,7 @@ the if condition."
2146 "Define a `python-mode' skeleton using NAME DOC and SKEL. 2148 "Define a `python-mode' skeleton using NAME DOC and SKEL.
2147The skeleton will be bound to python-skeleton-NAME and will 2149The skeleton will be bound to python-skeleton-NAME and will
2148be added to `python-mode-abbrev-table'." 2150be added to `python-mode-abbrev-table'."
2151 (declare (indent 2))
2149 (let* ((name (symbol-name name)) 2152 (let* ((name (symbol-name name))
2150 (function-name (intern (concat "python-skeleton-" name)))) 2153 (function-name (intern (concat "python-skeleton-" name))))
2151 `(progn 2154 `(progn
@@ -2156,11 +2159,11 @@ be added to `python-mode-abbrev-table'."
2156 ,(or doc 2159 ,(or doc
2157 (format "Insert %s statement." name)) 2160 (format "Insert %s statement." name))
2158 ,@skel)))) 2161 ,@skel))))
2159(put 'python-skeleton-define 'lisp-indent-function 2)
2160 2162
2161(defmacro python-define-auxiliary-skeleton (name doc &optional &rest skel) 2163(defmacro python-define-auxiliary-skeleton (name doc &optional &rest skel)
2162 "Define a `python-mode' auxiliary skeleton using NAME DOC and SKEL. 2164 "Define a `python-mode' auxiliary skeleton using NAME DOC and SKEL.
2163The skeleton will be bound to python-skeleton-NAME." 2165The skeleton will be bound to python-skeleton-NAME."
2166 (declare (indent 2))
2164 (let* ((name (symbol-name name)) 2167 (let* ((name (symbol-name name))
2165 (function-name (intern (concat "python-skeleton--" name))) 2168 (function-name (intern (concat "python-skeleton--" name)))
2166 (msg (format 2169 (msg (format
@@ -2176,7 +2179,6 @@ The skeleton will be bound to python-skeleton-NAME."
2176 (unless (y-or-n-p ,msg) 2179 (unless (y-or-n-p ,msg)
2177 (signal 'quit t)) 2180 (signal 'quit t))
2178 ,@skel))) 2181 ,@skel)))
2179(put 'python-define-auxiliary-skeleton 'lisp-indent-function 2)
2180 2182
2181(python-define-auxiliary-skeleton else nil) 2183(python-define-auxiliary-skeleton else nil)
2182 2184
@@ -2800,7 +2802,7 @@ Optional argument DIRECTION defines the direction to move to."
2800 2802
2801 2803
2802;;;###autoload 2804;;;###autoload
2803(define-derived-mode python-mode fundamental-mode "Python" 2805(define-derived-mode python-mode prog-mode "Python"
2804 "Major mode for editing Python files. 2806 "Major mode for editing Python files.
2805 2807
2806\\{python-mode-map} 2808\\{python-mode-map}