aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorLele Gaifax2016-04-06 10:38:23 +0200
committerJorgen Schaefer2016-04-06 10:51:09 +0200
commit1f6b0bc1512de08fd542df0234476788038c8c82 (patch)
tree520ca1eabf4f5438466d771d872aa7d70f6578b0 /lisp/progmodes/python.el
parentbd2b14f20726e0f210a62edc610fac4c5bc45760 (diff)
downloademacs-1f6b0bc1512de08fd542df0234476788038c8c82.tar.gz
emacs-1f6b0bc1512de08fd542df0234476788038c8c82.zip
Add new keywords of Python 3.5
Python 3.5, released in mid September 2015, introduced a few new keywords to better support asynchronous code, "async" and "await" in particular. See https://www.python.org/dev/peps/pep-0492/ for details. (Bug#21783) * lisp/progmodes/python.el (python-rx-constituents): Add async def/for/with as block-start and async def as defun. * lisp/progmodes/python.el (python-font-lock-keywords): Add async def/for/with as keyword. * test/automated/python-tests.el (python-indent-after-async-block-1, python-indent-after-async-block-2, python-indent-after-async-block-3, python-nav-beginning-of-defun-3): New tests to test indentation and navigation for the async keyword.
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el13
1 files changed, 11 insertions, 2 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 01f7f251edd..375b9fedc9d 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -384,7 +384,10 @@
384 (defconst python-rx-constituents 384 (defconst python-rx-constituents
385 `((block-start . ,(rx symbol-start 385 `((block-start . ,(rx symbol-start
386 (or "def" "class" "if" "elif" "else" "try" 386 (or "def" "class" "if" "elif" "else" "try"
387 "except" "finally" "for" "while" "with") 387 "except" "finally" "for" "while" "with"
388 ;; Python 3.5+ PEP492
389 (and "async" (+ space)
390 (or "def" "for" "with")))
388 symbol-end)) 391 symbol-end))
389 (dedenter . ,(rx symbol-start 392 (dedenter . ,(rx symbol-start
390 (or "elif" "else" "except" "finally") 393 (or "elif" "else" "except" "finally")
@@ -395,7 +398,11 @@
395 symbol-end)) 398 symbol-end))
396 (decorator . ,(rx line-start (* space) ?@ (any letter ?_) 399 (decorator . ,(rx line-start (* space) ?@ (any letter ?_)
397 (* (any word ?_)))) 400 (* (any word ?_))))
398 (defun . ,(rx symbol-start (or "def" "class") symbol-end)) 401 (defun . ,(rx symbol-start
402 (or "def" "class"
403 ;; Python 3.5+ PEP492
404 (and "async" (+ space) "def"))
405 symbol-end))
399 (if-name-main . ,(rx line-start "if" (+ space) "__name__" 406 (if-name-main . ,(rx line-start "if" (+ space) "__name__"
400 (+ space) "==" (+ space) 407 (+ space) "==" (+ space)
401 (any ?' ?\") "__main__" (any ?' ?\") 408 (any ?' ?\") "__main__" (any ?' ?\")
@@ -527,6 +534,8 @@ The type returned can be `comment', `string' or `paren'."
527 ;; fontified like that in order to keep font-lock consistent between 534 ;; fontified like that in order to keep font-lock consistent between
528 ;; Python versions. 535 ;; Python versions.
529 "nonlocal" 536 "nonlocal"
537 ;; Python 3.5+ PEP492
538 (and "async" (+ space) (or "def" "for" "with"))
530 ;; Extra: 539 ;; Extra:
531 "self") 540 "self")
532 symbol-end) 541 symbol-end)