el/dot-emacs.el: Treat the Python soft keywords more carefully.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 10 Mar 2024 17:46:19 +0000 (17:46 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 10 Mar 2024 17:54:17 +0000 (17:54 +0000)
In particular, `match' gets used heavily as a method name when working
with regices, so bolding it everywhere is quite bad.

el/dot-emacs.el

index cd2d13b..cd648c1 100644 (file)
@@ -3450,7 +3450,7 @@ strip numbers instead."
              python-indent-offset 2
              python-fill-docstring-style 'symmetric)
 
              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]*\\)")
 
   ;; 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))
           ;; 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_+\\)+__\\)\\_>")
           (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"
   (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"
                "def" "del"
                "elif" "else" "except" ;"exec"
                "finally" "for" "from"
                "global"
                "if" "import" "in" "is"
                "lambda"
-               "match"
                "nonlocal"
                "not"
                "or"
                "nonlocal"
                "not"
                "or"
@@ -3503,6 +3504,9 @@ strip numbers instead."
                "while" "with"
                "yield")
 
                "while" "with"
                "yield")
 
+   (mdw-regexps "case"
+               "match")
+
    (mdw-regexps "Ellipsis"
                "False"
                "None" "NotImplemented"
    (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")
                "import" "in" "is" "lambda" "not" "or" "pass" "print"
                "property" "raise" "return" "struct" "try" "while" "with"
                "yield")
+   ""
    ""))
 
 (define-derived-mode pyrex-mode python-mode "Pyrex"
    ""))
 
 (define-derived-mode pyrex-mode python-mode "Pyrex"