aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el30
1 files changed, 16 insertions, 14 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 3cbd744e3e7..8844480a95f 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -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
@@ -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