diff options
author | Barry Warsaw <barry@python.org> | 1996-03-05 00:44:31 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 1996-03-05 00:44:31 (GMT) |
commit | 33ab6e4915a41299d76f5f78dee9dbb20bbc6c5a (patch) | |
tree | b73aa6355b64f7b8ed2e7f1104a91cdb3428fae8 /Misc/python-mode.el | |
parent | fd0fb38055f030b3947179d0f362b97c7bf06c72 (diff) | |
download | cpython-33ab6e4915a41299d76f5f78dee9dbb20bbc6c5a.zip cpython-33ab6e4915a41299d76f5f78dee9dbb20bbc6c5a.tar.gz cpython-33ab6e4915a41299d76f5f78dee9dbb20bbc6c5a.tar.bz2 |
(python-font-lock-keywords): Much improved descrimination between
keywords and names with keywords in them.
Diffstat (limited to 'Misc/python-mode.el')
-rw-r--r-- | Misc/python-mode.el | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/Misc/python-mode.el b/Misc/python-mode.el index 3dd533b..5ac7982 100644 --- a/Misc/python-mode.el +++ b/Misc/python-mode.el @@ -204,29 +204,29 @@ the Emacs bell is also rung as a warning.") ;; well. ;; (defvar python-font-lock-keywords - (list - (cons (concat - "\\b\\(" - (mapconcat - 'identity - '("access" "and" "break" "continue" - "del" "elif" "else:" "except" - "except:" "exec" "finally:" "for" - "from" "global" "if" "import" - "in" "is" "lambda" "not" - "or" "pass" "print" "raise" - "return" "try:" "while" - ) - "\\|") - "\\)[ \n\t(]") - 1) - ;; classes - '("\\bclass[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)" - 1 font-lock-type-face) - ;; functions - '("\\bdef[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)" - 1 font-lock-function-name-face) - ) + (let* ((keywords '("access" "and" "break" "continue" + "del" "elif" "else:" "except" + "except:" "exec" "finally:" "for" + "from" "global" "if" "import" + "in" "is" "lambda" "not" + "or" "pass" "print" "raise" + "return" "try:" "while" + )) + (kwregex (mapconcat 'identity keywords "\\|"))) + (list + ;; keywords not at beginning of line + (cons (concat "\\s-\\(" kwregex "\\)[ \n\t(]") 1) + ;; keywords at beginning of line. i don't think regexps are + ;; powerful enough to handle these two cases in one regexp. + ;; prove me wrong! + (cons (concat "^\\(" kwregex "\\)[ \n\t(]") 1) + ;; classes + '("\\bclass[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)" + 1 font-lock-type-face) + ;; functions + '("\\bdef[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)" + 1 font-lock-function-name-face) + )) "*Additional expressions to highlight in Python mode.") ;; R Lindsay Todd <toddr@rpi.edu> suggests these changes to the |