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.el88
1 files changed, 54 insertions, 34 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 3dd94c3793f..51727be901a 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -345,14 +345,22 @@ This variant of `rx' supports common python named REGEXPS."
345 345
346 346
347;;; Font-lock and syntax 347;;; Font-lock and syntax
348
349(defvar python-font-lock-keywords 348(defvar python-font-lock-keywords
350 ;; Keywords 349 ;; Keywords
351 `(,(rx symbol-start 350 `(,(rx symbol-start
352 (or "and" "del" "from" "not" "while" "as" "elif" "global" "or" "with" 351 (or
353 "assert" "else" "if" "pass" "yield" "break" "except" "import" 352 "and" "del" "from" "not" "while" "as" "elif" "global" "or" "with"
354 "print" "class" "exec" "in" "raise" "continue" "finally" "is" 353 "assert" "else" "if" "pass" "yield" "break" "except" "import" "class"
355 "return" "def" "for" "lambda" "try" "self") 354 "in" "raise" "continue" "finally" "is" "return" "def" "for" "lambda"
355 "try"
356 ;; Python 2:
357 "print" "exec"
358 ;; Python 3:
359 ;; False, None, and True are listed as keywords on the Python 3
360 ;; documentation, but since they also qualify as constants they are
361 ;; fontified like that in order to keep font-lock consistent between
362 ;; Python versions.
363 "nonlocal")
356 symbol-end) 364 symbol-end)
357 ;; functions 365 ;; functions
358 (,(rx symbol-start "def" (1+ space) (group (1+ (or word ?_)))) 366 (,(rx symbol-start "def" (1+ space) (group (1+ (or word ?_))))
@@ -362,10 +370,11 @@ This variant of `rx' supports common python named REGEXPS."
362 (1 font-lock-type-face)) 370 (1 font-lock-type-face))
363 ;; Constants 371 ;; Constants
364 (,(rx symbol-start 372 (,(rx symbol-start
365 ;; copyright, license, credits, quit, exit are added by the 373 (or
366 ;; site module and since they are not intended to be used in 374 "Ellipsis" "False" "None" "NotImplemented" "True" "__debug__"
367 ;; programs they are not added here either. 375 ;; copyright, license, credits, quit and exit are added by the site
368 (or "None" "True" "False" "Ellipsis" "__debug__" "NotImplemented") 376 ;; module and they are not intended to be used in programs
377 "copyright" "credits" "exit" "license" "quit")
369 symbol-end) . font-lock-constant-face) 378 symbol-end) . font-lock-constant-face)
370 ;; Decorators. 379 ;; Decorators.
371 (,(rx line-start (* (any " \t")) (group "@" (1+ (or word ?_)) 380 (,(rx line-start (* (any " \t")) (group "@" (1+ (or word ?_))
@@ -373,34 +382,45 @@ This variant of `rx' supports common python named REGEXPS."
373 (1 font-lock-type-face)) 382 (1 font-lock-type-face))
374 ;; Builtin Exceptions 383 ;; Builtin Exceptions
375 (,(rx symbol-start 384 (,(rx symbol-start
376 (or "ArithmeticError" "AssertionError" "AttributeError" 385 (or
377 "BaseException" "BufferError" "BytesWarning" "DeprecationWarning" 386 "ArithmeticError" "AssertionError" "AttributeError" "BaseException"
378 "EOFError" "EnvironmentError" "Exception" "FloatingPointError" 387 "DeprecationWarning" "EOFError" "EnvironmentError" "Exception"
379 "FutureWarning" "GeneratorExit" "IOError" "ImportError" 388 "FloatingPointError" "FutureWarning" "GeneratorExit" "IOError"
380 "ImportWarning" "IndentationError" "IndexError" "KeyError" 389 "ImportError" "ImportWarning" "IndexError" "KeyError"
381 "KeyboardInterrupt" "LookupError" "MemoryError" "NameError" 390 "KeyboardInterrupt" "LookupError" "MemoryError" "NameError"
382 "NotImplementedError" "OSError" "OverflowError" 391 "NotImplementedError" "OSError" "OverflowError"
383 "PendingDeprecationWarning" "ReferenceError" "RuntimeError" 392 "PendingDeprecationWarning" "ReferenceError" "RuntimeError"
384 "RuntimeWarning" "StandardError" "StopIteration" "SyntaxError" 393 "RuntimeWarning" "StopIteration" "SyntaxError" "SyntaxWarning"
385 "SyntaxWarning" "SystemError" "SystemExit" "TabError" "TypeError" 394 "SystemError" "SystemExit" "TypeError" "UnboundLocalError"
386 "UnboundLocalError" "UnicodeDecodeError" "UnicodeEncodeError" 395 "UnicodeDecodeError" "UnicodeEncodeError" "UnicodeError"
387 "UnicodeError" "UnicodeTranslateError" "UnicodeWarning" 396 "UnicodeTranslateError" "UnicodeWarning" "UserWarning" "VMSError"
388 "UserWarning" "ValueError" "Warning" "ZeroDivisionError") 397 "ValueError" "Warning" "WindowsError" "ZeroDivisionError"
398 ;; Python 2:
399 "StandardError"
400 ;; Python 3:
401 "BufferError" "BytesWarning" "IndentationError" "ResourceWarning"
402 "TabError")
389 symbol-end) . font-lock-type-face) 403 symbol-end) . font-lock-type-face)
390 ;; Builtins 404 ;; Builtins
391 (,(rx symbol-start 405 (,(rx symbol-start
392 (or "_" "__doc__" "__import__" "__name__" "__package__" "abs" "all" 406 (or
393 "any" "apply" "basestring" "bin" "bool" "buffer" "bytearray" 407 "abs" "all" "any" "bin" "bool" "callable" "chr" "classmethod"
394 "bytes" "callable" "chr" "classmethod" "cmp" "coerce" "compile" 408 "compile" "complex" "delattr" "dict" "dir" "divmod" "enumerate"
395 "complex" "delattr" "dict" "dir" "divmod" "enumerate" "eval" 409 "eval" "filter" "float" "format" "frozenset" "getattr" "globals"
396 "execfile" "file" "filter" "float" "format" "frozenset" 410 "hasattr" "hash" "help" "hex" "id" "input" "int" "isinstance"
397 "getattr" "globals" "hasattr" "hash" "help" "hex" "id" "input" 411 "issubclass" "iter" "len" "list" "locals" "map" "max" "memoryview"
398 "int" "intern" "isinstance" "issubclass" "iter" "len" "list" 412 "min" "next" "object" "oct" "open" "ord" "pow" "print" "property"
399 "locals" "long" "map" "max" "min" "next" "object" "oct" "open" 413 "range" "repr" "reversed" "round" "set" "setattr" "slice" "sorted"
400 "ord" "pow" "print" "property" "range" "raw_input" "reduce" 414 "staticmethod" "str" "sum" "super" "tuple" "type" "vars" "zip"
401 "reload" "repr" "reversed" "round" "set" "setattr" "slice" 415 "__import__"
402 "sorted" "staticmethod" "str" "sum" "super" "tuple" "type" 416 ;; Python 2:
403 "unichr" "unicode" "vars" "xrange" "zip") 417 "basestring" "cmp" "execfile" "file" "long" "raw_input" "reduce"
418 "reload" "unichr" "unicode" "xrange" "apply" "buffer" "coerce"
419 "intern"
420 ;; Python 3:
421 "ascii" "bytearray" "bytes" "exec"
422 ;; Extra:
423 "__all__" "__doc__" "__name__" "__package__")
404 symbol-end) . font-lock-builtin-face) 424 symbol-end) . font-lock-builtin-face)
405 ;; asignations 425 ;; asignations
406 ;; support for a = b = c = 5 426 ;; support for a = b = c = 5