chiark / gitweb /
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 cd2d13b5a10e18be317d3b5bb7f1587f3da2b5c5..cd648c146037829b26bbcdc2de2160e9964a7e33 100644 (file)
@@ -3450,7 +3450,7 @@ (setq-default py-indent-offset 2
              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 @@ (defun mdw-fontify-pythonic (keywords builtins)
           ;; 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 @@ (defun mdw-fontify-python ()
   (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 @@ (defun mdw-fontify-python ()
                "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 @@ (defun mdw-fontify-pyrex ()
                "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"