Commit 33ab6e49 authored by Barry Warsaw's avatar Barry Warsaw

(python-font-lock-keywords): Much improved descrimination between

keywords and names with keywords in them.
parent fd0fb380
...@@ -204,29 +204,29 @@ the Emacs bell is also rung as a warning.") ...@@ -204,29 +204,29 @@ the Emacs bell is also rung as a warning.")
;; well. ;; well.
;; ;;
(defvar python-font-lock-keywords (defvar python-font-lock-keywords
(list (let* ((keywords '("access" "and" "break" "continue"
(cons (concat "del" "elif" "else:" "except"
"\\b\\(" "except:" "exec" "finally:" "for"
(mapconcat "from" "global" "if" "import"
'identity "in" "is" "lambda" "not"
'("access" "and" "break" "continue" "or" "pass" "print" "raise"
"del" "elif" "else:" "except" "return" "try:" "while"
"except:" "exec" "finally:" "for" ))
"from" "global" "if" "import" (kwregex (mapconcat 'identity keywords "\\|")))
"in" "is" "lambda" "not" (list
"or" "pass" "print" "raise" ;; keywords not at beginning of line
"return" "try:" "while" (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.
"\\)[ \n\t(]") ;; prove me wrong!
1) (cons (concat "^\\(" kwregex "\\)[ \n\t(]") 1)
;; classes ;; classes
'("\\bclass[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)" '("\\bclass[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)"
1 font-lock-type-face) 1 font-lock-type-face)
;; functions ;; functions
'("\\bdef[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)" '("\\bdef[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)"
1 font-lock-function-name-face) 1 font-lock-function-name-face)
) ))
"*Additional expressions to highlight in Python mode.") "*Additional expressions to highlight in Python mode.")
;; R Lindsay Todd <toddr@rpi.edu> suggests these changes to the ;; R Lindsay Todd <toddr@rpi.edu> suggests these changes to the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment