From: Mark Wooding Date: Sun, 10 Mar 2024 17:46:19 +0000 (+0000) Subject: el/dot-emacs.el: Treat the Python soft keywords more carefully. X-Git-Url: https://git.distorted.org.uk/~mdw/profile/commitdiff_plain/ca976cbce9e23106651a6774a4ee367ac100d622 el/dot-emacs.el: Treat the Python soft keywords more carefully. In particular, `match' gets used heavily as a method name when working with regices, so bolding it everywhere is quite bad. --- diff --git a/el/dot-emacs.el b/el/dot-emacs.el index cd2d13b..cd648c1 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -3450,7 +3450,7 @@ strip numbers instead." python-indent-offset 2 python-fill-docstring-style 'symmetric) -(defun mdw-fontify-pythonic (keywords builtins) +(defun mdw-fontify-pythonic (keywords soft-keywords builtins) ;; Miscellaneous fiddling. (mdw-standard-fill-prefix "\\([ \t]*#+[ \t]*\\)") @@ -3465,6 +3465,8 @@ strip numbers instead." ;; Set up the keywords defined above. (list (concat "\\_<\\(" keywords "\\)\\_>") '(0 font-lock-keyword-face)) + (list (concat "\\(^\\|[^.]\\)\\_<\\(" soft-keywords "\\)\\_>") + '(2 font-lock-keyword-face)) (list (concat "\\(^\\|[^.]\\)\\_<\\(" builtins "\\)\\_>") '(2 font-lock-variable-name-face)) (list (concat "\\_<\\(__\\(\\sw+\\|\\s_+\\)+__\\)\\_>") @@ -3486,14 +3488,13 @@ strip numbers instead." (mdw-fontify-pythonic (mdw-regexps "and" "as" "assert" "async" "await" "break" - "case" "class" "continue" + "class" "continue" "def" "del" "elif" "else" "except" ;"exec" "finally" "for" "from" "global" "if" "import" "in" "is" "lambda" - "match" "nonlocal" "not" "or" @@ -3503,6 +3504,9 @@ strip numbers instead." "while" "with" "yield") + (mdw-regexps "case" + "match") + (mdw-regexps "Ellipsis" "False" "None" "NotImplemented" @@ -3615,6 +3619,7 @@ strip numbers instead." "import" "in" "is" "lambda" "not" "or" "pass" "print" "property" "raise" "return" "struct" "try" "while" "with" "yield") + "" "")) (define-derived-mode pyrex-mode python-mode "Pyrex"