diff options
| author | Christoph Scholtes | 2010-07-06 21:46:58 -0700 |
|---|---|---|
| committer | Glenn Morris | 2010-07-06 21:46:58 -0700 |
| commit | 4565b08e186d740b61d073d12ed4d59f912e7048 (patch) | |
| tree | d4e1dd64c41b22f8eca7fd8c9523587abaf89fce | |
| parent | 49554388208ef121ca91a20212645d47d8cd56ed (diff) | |
| download | emacs-4565b08e186d740b61d073d12ed4d59f912e7048.tar.gz emacs-4565b08e186d740b61d073d12ed4d59f912e7048.zip | |
Add some font-locking for Python 2.7.
* lisp/progmodes/python.el (python-font-lock-keywords): Add Python 2.7
builtins (BufferError, BytesWarning, WindowsError; callables
bin, bytearray, bytes, format, memoryview, next, print; __package__).
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/progmodes/python.el | 18 |
2 files changed, 18 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 1aa812bb534..eb8f0785b26 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2010-07-07 Christoph Scholtes <cschol2112@gmail.com> | ||
| 2 | |||
| 3 | * progmodes/python.el (python-font-lock-keywords): Add Python 2.7 | ||
| 4 | builtins (BufferError, BytesWarning, WindowsError; callables | ||
| 5 | bin, bytearray, bytes, format, memoryview, next, print; __package__). | ||
| 6 | |||
| 1 | 2010-07-07 Glenn Morris <rgm@gnu.org> | 7 | 2010-07-07 Glenn Morris <rgm@gnu.org> |
| 2 | 8 | ||
| 3 | * play/zone.el (zone-fall-through-ws): Fix next-line -> | 9 | * play/zone.el (zone-fall-through-ws): Fix next-line -> |
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 4e0f326e2d4..2b09e346331 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -93,7 +93,7 @@ | |||
| 93 | 93 | ||
| 94 | (defvar python-font-lock-keywords | 94 | (defvar python-font-lock-keywords |
| 95 | `(,(rx symbol-start | 95 | `(,(rx symbol-start |
| 96 | ;; From v 2.5 reference, § keywords. | 96 | ;; From v 2.7 reference, § keywords. |
| 97 | ;; def and class dealt with separately below | 97 | ;; def and class dealt with separately below |
| 98 | (or "and" "as" "assert" "break" "continue" "del" "elif" "else" | 98 | (or "and" "as" "assert" "break" "continue" "del" "elif" "else" |
| 99 | "except" "exec" "finally" "for" "from" "global" "if" | 99 | "except" "exec" "finally" "for" "from" "global" "if" |
| @@ -102,7 +102,7 @@ | |||
| 102 | ;; Not real keywords, but close enough to be fontified as such | 102 | ;; Not real keywords, but close enough to be fontified as such |
| 103 | "self" "True" "False") | 103 | "self" "True" "False") |
| 104 | symbol-end) | 104 | symbol-end) |
| 105 | (,(rx symbol-start "None" symbol-end) ; see § Keywords in 2.5 manual | 105 | (,(rx symbol-start "None" symbol-end) ; see § Keywords in 2.7 manual |
| 106 | . font-lock-constant-face) | 106 | . font-lock-constant-face) |
| 107 | ;; Definitions | 107 | ;; Definitions |
| 108 | (,(rx symbol-start (group "class") (1+ space) (group (1+ (or word ?_)))) | 108 | (,(rx symbol-start (group "class") (1+ space) (group (1+ (or word ?_)))) |
| @@ -117,7 +117,7 @@ | |||
| 117 | (0+ "." (1+ (or word ?_))))) | 117 | (0+ "." (1+ (or word ?_))))) |
| 118 | (1 font-lock-type-face)) | 118 | (1 font-lock-type-face)) |
| 119 | ;; Built-ins. (The next three blocks are from | 119 | ;; Built-ins. (The next three blocks are from |
| 120 | ;; `__builtin__.__dict__.keys()' in Python 2.5.1.) These patterns | 120 | ;; `__builtin__.__dict__.keys()' in Python 2.7) These patterns |
| 121 | ;; are debateable, but they at least help to spot possible | 121 | ;; are debateable, but they at least help to spot possible |
| 122 | ;; shadowing of builtins. | 122 | ;; shadowing of builtins. |
| 123 | (,(rx symbol-start (or | 123 | (,(rx symbol-start (or |
| @@ -135,7 +135,9 @@ | |||
| 135 | "SystemExit" "TabError" "TypeError" "UnboundLocalError" | 135 | "SystemExit" "TabError" "TypeError" "UnboundLocalError" |
| 136 | "UnicodeDecodeError" "UnicodeEncodeError" "UnicodeError" | 136 | "UnicodeDecodeError" "UnicodeEncodeError" "UnicodeError" |
| 137 | "UnicodeTranslateError" "UnicodeWarning" "UserWarning" | 137 | "UnicodeTranslateError" "UnicodeWarning" "UserWarning" |
| 138 | "ValueError" "Warning" "ZeroDivisionError") symbol-end) | 138 | "ValueError" "Warning" "ZeroDivisionError" |
| 139 | ;; Python 2.7 | ||
| 140 | "BufferError" "BytesWarning" "WindowsError") symbol-end) | ||
| 139 | . font-lock-type-face) | 141 | . font-lock-type-face) |
| 140 | (,(rx (or line-start (not (any ". \t"))) (* (any " \t")) symbol-start | 142 | (,(rx (or line-start (not (any ". \t"))) (* (any " \t")) symbol-start |
| 141 | (group (or | 143 | (group (or |
| @@ -152,12 +154,16 @@ | |||
| 152 | "range" "raw_input" "reduce" "reload" "repr" "reversed" | 154 | "range" "raw_input" "reduce" "reload" "repr" "reversed" |
| 153 | "round" "set" "setattr" "slice" "sorted" "staticmethod" | 155 | "round" "set" "setattr" "slice" "sorted" "staticmethod" |
| 154 | "str" "sum" "super" "tuple" "type" "unichr" "unicode" "vars" | 156 | "str" "sum" "super" "tuple" "type" "unichr" "unicode" "vars" |
| 155 | "xrange" "zip")) symbol-end) | 157 | "xrange" "zip" |
| 158 | ;; Python 2.7. | ||
| 159 | "bin" "bytearray" "bytes" "format" "memoryview" "next" "print" | ||
| 160 | )) symbol-end) | ||
| 156 | (1 font-lock-builtin-face)) | 161 | (1 font-lock-builtin-face)) |
| 157 | (,(rx symbol-start (or | 162 | (,(rx symbol-start (or |
| 158 | ;; other built-ins | 163 | ;; other built-ins |
| 159 | "True" "False" "None" "Ellipsis" | 164 | "True" "False" "None" "Ellipsis" |
| 160 | "_" "__debug__" "__doc__" "__import__" "__name__") symbol-end) | 165 | "_" "__debug__" "__doc__" "__import__" "__name__" "__package__") |
| 166 | symbol-end) | ||
| 161 | . font-lock-builtin-face))) | 167 | . font-lock-builtin-face))) |
| 162 | 168 | ||
| 163 | (defconst python-font-lock-syntactic-keywords | 169 | (defconst python-font-lock-syntactic-keywords |