Variable: python-font-lock-keywords-maximum-decoration
python-font-lock-keywords-maximum-decoration is a variable defined in
python.el.gz.
Value
Large value
((python--font-lock-f-strings)
("\\_<def[[:space:]]+\\(\\(?:[[:word:]]\\|_\\)+\\)"
(1 font-lock-function-name-face))
("\\_<class[[:space:]]+\\(\\(?:[[:word:]]\\|_\\)+\\)"
(1 font-lock-type-face))
"\\_<\\(?:and\\|del\\|from\\|not\\|while\\|as\\|elif\\|global\\|or\\|with\\|assert\\|else\\|if\\|pass\\|yield\\|break\\|except\\|import\\|class\\|in\\|raise\\|continue\\|finally\\|is\\|return\\|def\\|for\\|lambda\\|try\\|nonlocal\\|async[[:space:]]+\\(?:def\\|for\\|with\\)\\|await\\|self\\)\\_>"
("\\_<\\(?:__\\(?:\\(?:a\\(?:ll\\|nnotations\\)\\|c\\(?:\\(?:losur\\|od\\)e\\)\\|d\\(?:efaults\\|ict\\|oc\\)\\|globals\\|import\\|kwdefaults\\|\\(?:modul\\|nam\\|packag\\|qualnam\\)e\\)__\\)\\|a\\(?:bs\\|ll\\|ny\\|pply\\|scii\\)\\|b\\(?:asestring\\|in\\|ool\\|reakpoint\\|uffer\\|yte\\(?:array\\|s\\)\\)\\|c\\(?:allable\\|hr\\|lassmethod\\|mp\\|o\\(?:erce\\|mp\\(?:ile\\|lex\\)\\)\\)\\|d\\(?:elattr\\|i\\(?:ct\\|r\\|vmod\\)\\)\\|e\\(?:numerate\\|val\\|xec\\(?:file\\)?\\)\\|f\\(?:il\\(?:e\\|ter\\)\\|\\(?:loa\\|orma\\|rozense\\)t\\)\\|g\\(?:etattr\\|lobals\\)\\|h\\(?:as\\(?:attr\\|h\\)\\|e\\(?:lp\\|x\\)\\)\\|i\\(?:d\\|n\\(?:put\\|t\\(?:ern\\)?\\)\\|s\\(?:instance\\|subclass\\)\\|ter\\)\\|l\\(?:en\\|ist\\|o\\(?:cals\\|ng\\)\\)\\|m\\(?:a[px]\\|emoryview\\|in\\)\\|next\\|o\\(?:bject\\|ct\\|pen\\|rd\\)\\|p\\(?:ow\\|r\\(?:int\\|operty\\)\\)\\|r\\(?:a\\(?:nge\\|w_input\\)\\|e\\(?:duce\\|load\\|pr\\|versed\\)\\|ound\\)\\|s\\(?:et\\(?:attr\\)?\\|lice\\|orted\\|t\\(?:aticmethod\\|r\\)\\|u\\(?:m\\|per\\)\\)\\|t\\(?:\\(?:upl\\|yp\\)e\\)\\|unic\\(?:hr\\|ode\\)\\|vars\\|xrange\\|zip\\)\\_>" . font-lock-builtin-face)
("\\_<\\(?:Ellipsis\\|False\\|No\\(?:ne\\|tImplemented\\)\\|True\\|__debug__\\|c\\(?:opyright\\|redits\\)\\|exit\\|license\\|quit\\)\\_>" . font-lock-constant-face)
("^[ ]*\\(@\\(?:[[:word:]]\\|_\\)+\\(?:\\.\\(?:[[:word:]]\\|_\\)+\\)*\\)"
(1 font-lock-type-face))
("\\_<\\(?:A\\(?:\\(?:rithmetic\\|ssertion\\|ttribute\\)Error\\)\\|B\\(?:aseException\\|lockingIOError\\|rokenPipeError\\|ufferError\\|ytesWarning\\)\\|C\\(?:\\(?:hildProcess\\|onnection\\(?:Aborted\\|Re\\(?:fused\\|set\\)\\)?\\)Error\\)\\|DeprecationWarning\\|E\\(?:OFError\\|nvironmentError\\|xception\\)\\|F\\(?:ile\\(?:\\(?:Exists\\|NotFound\\)Error\\)\\|loatingPointError\\|utureWarning\\)\\|GeneratorExit\\|I\\(?:OError\\|mport\\(?:Error\\|Warning\\)\\|\\(?:n\\(?:de\\(?:ntation\\|x\\)\\|terrupted\\)\\|sADirectory\\)Error\\)\\|Key\\(?:Error\\|boardInterrupt\\)\\|LookupError\\|MemoryError\\|N\\(?:\\(?:ame\\|ot\\(?:ADirectory\\|Implemented\\)\\)Error\\)\\|O\\(?:\\(?:S\\|verflow\\)Error\\)\\|P\\(?:e\\(?:ndingDeprecationWarning\\|rmissionError\\)\\|rocessLookupError\\)\\|R\\(?:e\\(?:cursionError\\|ferenceError\\|sourceWarning\\)\\|untime\\(?:Error\\|Warning\\)\\)\\|S\\(?:t\\(?:andardError\\|op\\(?:\\(?:Async\\)?Iteration\\)\\)\\|y\\(?:ntax\\(?:Error\\|Warning\\)\\|stemE\\(?:rror\\|xit\\)\\)\\)\\|T\\(?:\\(?:ab\\|imeout\\|ype\\)Error\\)\\|U\\(?:n\\(?:boundLocalError\\|icode\\(?:DecodeError\\|E\\(?:\\(?:ncodeE\\)?rror\\)\\|TranslateError\\|Warning\\)\\)\\|serWarning\\)\\|V\\(?:\\(?:MS\\|alue\\)Error\\)\\|W\\(?:arning\\|indowsError\\)\\|ZeroDivisionError\\)\\_>" . font-lock-type-face)
(#[257 "\301\300\302#\303 A@\206`f\304=?\205\211\207"
["\\(?:[([][[:space:]]*\\)?\\*?\\(?:[_[:alpha:]][_[:word:]]*\\.\\)*\\([_[:alpha:]][_[:word:]]*\\)\\(?:\\[[^]]+]\\)?[[:space:]]*,[[:space:]]*\\(?:\\*?\\(?:[_[:alpha:]][_[:word:]]*\\.\\)*[_[:alpha:]][_[:word:]]*\\(?:\\[[^]]+]\\)?[[:space:]]*,[[:space:]]*\\)*\\(?:\\*?\\(?:[_[:alpha:]][_[:word:]]*\\.\\)*[_[:alpha:]][_[:word:]]*\\(?:\\[[^]]+]\\)?[[:space:]]*\\)?\\(?:,[[:space:]]*\\)?\\(?:[])][[:space:]]*\\)?\\(\\(?:\\(?:\\*\\*\\|//\\|<<\\|>>\\|[%&*+/|^-]\\)?=\\)\\)" re-search-forward t syntax-ppss 61]
5 "\n\n(fn LIMIT)"]
(1 font-lock-variable-name-face)
("\\*?\\(?:[_[:alpha:]][_[:word:]]*\\.\\)*\\([_[:alpha:]][_[:word:]]*\\)\\(?:\\[[^]]+]\\)?"
(progn
(goto-char
(match-end 1))
(match-beginning 2))
nil
(1 font-lock-variable-name-face)))
(#[257 "\301\300\302#\303 A@\206`f\304=?\205\211\207"
["\\*?\\(?:[_[:alpha:]][_[:word:]]*\\.\\)*\\([_[:alpha:]][_[:word:]]*\\)\\(?:\\[[^]]+]\\)?[[:space:]]*\\(?::[[:space:]]*[^%&*+/<->^|~-]+[[:space:]]*\\)?\\(?:\\(?:\\*\\*\\|//\\|<<\\|>>\\|[%&*+/|^-]\\)?=\\)" re-search-forward t syntax-ppss 61]
5 "\n\n(fn LIMIT)"]
(1 font-lock-variable-name-face))
(#[257 "\301\300\302#\303 A@\206`f\304=?\205\211\207"
["[([][[:space:]]*\\*?\\(?:[_[:alpha:]][_[:word:]]*\\.\\)*\\([_[:alpha:]][_[:word:]]*\\)\\(?:\\[[^]]+]\\)?[[:space:]]*[])][[:space:]]*\\(?:\\(?:\\*\\*\\|//\\|<<\\|>>\\|[%&*+/|^-]\\)?=\\)" re-search-forward t syntax-ppss 61]
5 "\n\n(fn LIMIT)"]
(1 font-lock-variable-name-face)))
Documentation
Font lock keywords to use in python-mode for maximum decoration.
This decoration level includes everything in
python-font-lock-keywords-level-2, as well as constants,
decorators, exceptions, and assignments.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/python.el.gz
(defvar python-font-lock-keywords-maximum-decoration
`((python--font-lock-f-strings)
,@python-font-lock-keywords-level-2
;; Constants
(,(rx symbol-start
(or
"Ellipsis" "False" "None" "NotImplemented" "True" "__debug__"
;; copyright, license, credits, quit and exit are added by the site
;; module and they are not intended to be used in programs
"copyright" "credits" "exit" "license" "quit")
symbol-end)
. font-lock-constant-face)
;; Decorators.
(,(rx line-start (* (any " \t")) (group "@" (1+ (or word ?_))
(0+ "." (1+ (or word ?_)))))
(1 font-lock-type-face))
;; Builtin Exceptions
(,(rx symbol-start
(or
;; Python 2 and 3:
"ArithmeticError" "AssertionError" "AttributeError" "BaseException"
"BufferError" "BytesWarning" "DeprecationWarning" "EOFError"
"EnvironmentError" "Exception" "FloatingPointError" "FutureWarning"
"GeneratorExit" "IOError" "ImportError" "ImportWarning"
"IndentationError" "IndexError" "KeyError" "KeyboardInterrupt"
"LookupError" "MemoryError" "NameError" "NotImplementedError"
"OSError" "OverflowError" "PendingDeprecationWarning"
"ReferenceError" "RuntimeError" "RuntimeWarning" "StopIteration"
"SyntaxError" "SyntaxWarning" "SystemError" "SystemExit" "TabError"
"TypeError" "UnboundLocalError" "UnicodeDecodeError"
"UnicodeEncodeError" "UnicodeError" "UnicodeTranslateError"
"UnicodeWarning" "UserWarning" "ValueError" "Warning"
"ZeroDivisionError"
;; Python 2:
"StandardError"
;; Python 3:
"BlockingIOError" "BrokenPipeError" "ChildProcessError"
"ConnectionAbortedError" "ConnectionError" "ConnectionRefusedError"
"ConnectionResetError" "FileExistsError" "FileNotFoundError"
"InterruptedError" "IsADirectoryError" "NotADirectoryError"
"PermissionError" "ProcessLookupError" "RecursionError"
"ResourceWarning" "StopAsyncIteration" "TimeoutError"
;; OS specific
"VMSError" "WindowsError"
)
symbol-end)
. font-lock-type-face)
;; multiple assignment
;; (note that type hints are not allowed for multiple assignments)
;; a, b, c = 1, 2, 3
;; a, *b, c = 1, 2, 3, 4, 5
;; [a, b] = (1, 2)
;; (l[1], l[2]) = (10, 11)
;; (a, b, c, *d) = *x, y = 5, 6, 7, 8, 9
;; (a,) = 'foo'
;; (*a,) = ['foo', 'bar', 'baz']
;; d.x, d.y[0], *d.z = 'a', 'b', 'c', 'd', 'e'
;; and variants thereof
;; the cases
;; (a) = 5
;; [a] = 5
;; [*a] = 5, 6
;; are handled separately below
(,(python-font-lock-assignment-matcher
(python-rx (? (or "[" "(") (* space))
grouped-assignment-target (* space) ?, (* space)
(* assignment-target (* space) ?, (* space))
(? assignment-target (* space))
(? ?, (* space))
(? (or ")" "]") (* space))
(group assignment-operator)))
(1 font-lock-variable-name-face)
(,(python-rx grouped-assignment-target)
(progn
(goto-char (match-end 1)) ; go back after the first symbol
(match-beginning 2)) ; limit the search until the assignment
nil
(1 font-lock-variable-name-face)))
;; single assignment with type hints, e.g.
;; a: int = 5
;; b: Tuple[Optional[int], Union[Sequence[str], str]] = (None, 'foo')
;; c: Collection = {1, 2, 3}
;; d: Mapping[int, str] = {1: 'bar', 2: 'baz'}
(,(python-font-lock-assignment-matcher
(python-rx grouped-assignment-target (* space)
(? ?: (* space) (+ not-simple-operator) (* space))
assignment-operator))
(1 font-lock-variable-name-face))
;; special cases
;; (a) = 5
;; [a] = 5
;; [*a] = 5, 6
(,(python-font-lock-assignment-matcher
(python-rx (or "[" "(") (* space)
grouped-assignment-target (* space)
(or ")" "]") (* space)
assignment-operator))
(1 font-lock-variable-name-face)))
"Font lock keywords to use in `python-mode' for maximum decoration.
This decoration level includes everything in
`python-font-lock-keywords-level-2', as well as constants,
decorators, exceptions, and assignments.")