mirror of
https://github.com/python/cpython.git
synced 2025-10-22 06:32:43 +00:00
(python-font-lock-keywords): Much improved descrimination between
keywords and names with keywords in them.
This commit is contained in:
parent
fd0fb38055
commit
33ab6e4915
1 changed files with 23 additions and 23 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue