mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-12 09:00:40 -08:00
Updated `python-font-lock-keywords' to match latest Python 2.7 and 3.2 documentation.
This commit is contained in:
parent
6cad4c6e30
commit
27d7f16f7a
1 changed files with 54 additions and 34 deletions
|
|
@ -345,14 +345,22 @@ This variant of `rx' supports common python named REGEXPS."
|
||||||
|
|
||||||
|
|
||||||
;;; Font-lock and syntax
|
;;; Font-lock and syntax
|
||||||
|
|
||||||
(defvar python-font-lock-keywords
|
(defvar python-font-lock-keywords
|
||||||
;; Keywords
|
;; Keywords
|
||||||
`(,(rx symbol-start
|
`(,(rx symbol-start
|
||||||
(or "and" "del" "from" "not" "while" "as" "elif" "global" "or" "with"
|
(or
|
||||||
"assert" "else" "if" "pass" "yield" "break" "except" "import"
|
"and" "del" "from" "not" "while" "as" "elif" "global" "or" "with"
|
||||||
"print" "class" "exec" "in" "raise" "continue" "finally" "is"
|
"assert" "else" "if" "pass" "yield" "break" "except" "import" "class"
|
||||||
"return" "def" "for" "lambda" "try" "self")
|
"in" "raise" "continue" "finally" "is" "return" "def" "for" "lambda"
|
||||||
|
"try"
|
||||||
|
;; Python 2:
|
||||||
|
"print" "exec"
|
||||||
|
;; Python 3:
|
||||||
|
;; False, None, and True are listed as keywords on the Python 3
|
||||||
|
;; documentation, but since they also qualify as constants they are
|
||||||
|
;; fontified like that in order to keep font-lock consistent between
|
||||||
|
;; Python versions.
|
||||||
|
"nonlocal")
|
||||||
symbol-end)
|
symbol-end)
|
||||||
;; functions
|
;; functions
|
||||||
(,(rx symbol-start "def" (1+ space) (group (1+ (or word ?_))))
|
(,(rx symbol-start "def" (1+ space) (group (1+ (or word ?_))))
|
||||||
|
|
@ -362,10 +370,11 @@ This variant of `rx' supports common python named REGEXPS."
|
||||||
(1 font-lock-type-face))
|
(1 font-lock-type-face))
|
||||||
;; Constants
|
;; Constants
|
||||||
(,(rx symbol-start
|
(,(rx symbol-start
|
||||||
;; copyright, license, credits, quit, exit are added by the
|
(or
|
||||||
;; site module and since they are not intended to be used in
|
"Ellipsis" "False" "None" "NotImplemented" "True" "__debug__"
|
||||||
;; programs they are not added here either.
|
;; copyright, license, credits, quit and exit are added by the site
|
||||||
(or "None" "True" "False" "Ellipsis" "__debug__" "NotImplemented")
|
;; module and they are not intended to be used in programs
|
||||||
|
"copyright" "credits" "exit" "license" "quit")
|
||||||
symbol-end) . font-lock-constant-face)
|
symbol-end) . font-lock-constant-face)
|
||||||
;; Decorators.
|
;; Decorators.
|
||||||
(,(rx line-start (* (any " \t")) (group "@" (1+ (or word ?_))
|
(,(rx line-start (* (any " \t")) (group "@" (1+ (or word ?_))
|
||||||
|
|
@ -373,34 +382,45 @@ This variant of `rx' supports common python named REGEXPS."
|
||||||
(1 font-lock-type-face))
|
(1 font-lock-type-face))
|
||||||
;; Builtin Exceptions
|
;; Builtin Exceptions
|
||||||
(,(rx symbol-start
|
(,(rx symbol-start
|
||||||
(or "ArithmeticError" "AssertionError" "AttributeError"
|
(or
|
||||||
"BaseException" "BufferError" "BytesWarning" "DeprecationWarning"
|
"ArithmeticError" "AssertionError" "AttributeError" "BaseException"
|
||||||
"EOFError" "EnvironmentError" "Exception" "FloatingPointError"
|
"DeprecationWarning" "EOFError" "EnvironmentError" "Exception"
|
||||||
"FutureWarning" "GeneratorExit" "IOError" "ImportError"
|
"FloatingPointError" "FutureWarning" "GeneratorExit" "IOError"
|
||||||
"ImportWarning" "IndentationError" "IndexError" "KeyError"
|
"ImportError" "ImportWarning" "IndexError" "KeyError"
|
||||||
"KeyboardInterrupt" "LookupError" "MemoryError" "NameError"
|
"KeyboardInterrupt" "LookupError" "MemoryError" "NameError"
|
||||||
"NotImplementedError" "OSError" "OverflowError"
|
"NotImplementedError" "OSError" "OverflowError"
|
||||||
"PendingDeprecationWarning" "ReferenceError" "RuntimeError"
|
"PendingDeprecationWarning" "ReferenceError" "RuntimeError"
|
||||||
"RuntimeWarning" "StandardError" "StopIteration" "SyntaxError"
|
"RuntimeWarning" "StopIteration" "SyntaxError" "SyntaxWarning"
|
||||||
"SyntaxWarning" "SystemError" "SystemExit" "TabError" "TypeError"
|
"SystemError" "SystemExit" "TypeError" "UnboundLocalError"
|
||||||
"UnboundLocalError" "UnicodeDecodeError" "UnicodeEncodeError"
|
"UnicodeDecodeError" "UnicodeEncodeError" "UnicodeError"
|
||||||
"UnicodeError" "UnicodeTranslateError" "UnicodeWarning"
|
"UnicodeTranslateError" "UnicodeWarning" "UserWarning" "VMSError"
|
||||||
"UserWarning" "ValueError" "Warning" "ZeroDivisionError")
|
"ValueError" "Warning" "WindowsError" "ZeroDivisionError"
|
||||||
|
;; Python 2:
|
||||||
|
"StandardError"
|
||||||
|
;; Python 3:
|
||||||
|
"BufferError" "BytesWarning" "IndentationError" "ResourceWarning"
|
||||||
|
"TabError")
|
||||||
symbol-end) . font-lock-type-face)
|
symbol-end) . font-lock-type-face)
|
||||||
;; Builtins
|
;; Builtins
|
||||||
(,(rx symbol-start
|
(,(rx symbol-start
|
||||||
(or "_" "__doc__" "__import__" "__name__" "__package__" "abs" "all"
|
(or
|
||||||
"any" "apply" "basestring" "bin" "bool" "buffer" "bytearray"
|
"abs" "all" "any" "bin" "bool" "callable" "chr" "classmethod"
|
||||||
"bytes" "callable" "chr" "classmethod" "cmp" "coerce" "compile"
|
"compile" "complex" "delattr" "dict" "dir" "divmod" "enumerate"
|
||||||
"complex" "delattr" "dict" "dir" "divmod" "enumerate" "eval"
|
"eval" "filter" "float" "format" "frozenset" "getattr" "globals"
|
||||||
"execfile" "file" "filter" "float" "format" "frozenset"
|
"hasattr" "hash" "help" "hex" "id" "input" "int" "isinstance"
|
||||||
"getattr" "globals" "hasattr" "hash" "help" "hex" "id" "input"
|
"issubclass" "iter" "len" "list" "locals" "map" "max" "memoryview"
|
||||||
"int" "intern" "isinstance" "issubclass" "iter" "len" "list"
|
"min" "next" "object" "oct" "open" "ord" "pow" "print" "property"
|
||||||
"locals" "long" "map" "max" "min" "next" "object" "oct" "open"
|
"range" "repr" "reversed" "round" "set" "setattr" "slice" "sorted"
|
||||||
"ord" "pow" "print" "property" "range" "raw_input" "reduce"
|
"staticmethod" "str" "sum" "super" "tuple" "type" "vars" "zip"
|
||||||
"reload" "repr" "reversed" "round" "set" "setattr" "slice"
|
"__import__"
|
||||||
"sorted" "staticmethod" "str" "sum" "super" "tuple" "type"
|
;; Python 2:
|
||||||
"unichr" "unicode" "vars" "xrange" "zip")
|
"basestring" "cmp" "execfile" "file" "long" "raw_input" "reduce"
|
||||||
|
"reload" "unichr" "unicode" "xrange" "apply" "buffer" "coerce"
|
||||||
|
"intern"
|
||||||
|
;; Python 3:
|
||||||
|
"ascii" "bytearray" "bytes" "exec"
|
||||||
|
;; Extra:
|
||||||
|
"__all__" "__doc__" "__name__" "__package__")
|
||||||
symbol-end) . font-lock-builtin-face)
|
symbol-end) . font-lock-builtin-face)
|
||||||
;; asignations
|
;; asignations
|
||||||
;; support for a = b = c = 5
|
;; support for a = b = c = 5
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue