chiark / gitweb /
dot/emacs, el/dot-emacs.el: Fontification for Pyrex code.
[profile] / el / dot-emacs.el
index d0be013fe9fea3bfc81842101a3dafb75290b5b6..c9b9623eb25c379af5d696e2dd505617d196339c 100644 (file)
@@ -1372,9 +1372,7 @@ (defun perl-number-tests (&optional arg)
 
 ;;;----- Python programming style -------------------------------------------
 
-;; --- Define Python fontification style ---
-
-(defun mdw-fontify-python ()
+(defun mdw-fontify-pythonic (keywords)
 
   ;; --- Miscellaneous fiddling ---
 
@@ -1383,31 +1381,44 @@ (defun mdw-fontify-python ()
   ;; --- Now define fontification things ---
 
   (make-local-variable 'font-lock-keywords)
-  (let ((python-keywords
-        (mdw-regexps "and" "as" "assert" "break" "class" "continue" "def"
-                     "del" "elif" "else" "except" "exec" "finally" "for"
-                     "from" "global" "if" "import" "in" "is" "lambda"
-                     "not" "or" "pass" "print" "raise" "return" "try"
-                     "while" "with" "yield")))
-    (setq font-lock-keywords
-         (list
+  (setq font-lock-keywords
+       (list
 
-          ;; --- Set up the keywords defined above ---
+        ;; --- Set up the keywords defined above ---
 
-          (list (concat "\\<\\(" python-keywords "\\)\\>")
-                '(0 font-lock-keyword-face))
+        (list (concat "\\<\\(" keywords "\\)\\>")
+              '(0 font-lock-keyword-face))
 
-          ;; --- At least numbers are simpler than C ---
+        ;; --- At least numbers are simpler than C ---
 
-          (list (concat "\\<0\\([xX][0-9a-fA-F_]+\\|[0-7_]+\\)\\|"
-                        "\\<[0-9][0-9_]*\\(\\.[0-9_]*\\|\\)"
-                        "\\([eE]\\([-+]\\|\\)[0-9_]+\\|[lL]\\|\\)")
-                '(0 mdw-number-face))
+        (list (concat "\\<0\\([xX][0-9a-fA-F_]+\\|[0-7_]+\\)\\|"
+                      "\\<[0-9][0-9_]*\\(\\.[0-9_]*\\|\\)"
+                      "\\([eE]\\([-+]\\|\\)[0-9_]+\\|[lL]\\|\\)")
+              '(0 mdw-number-face))
 
-          ;; --- And anything else is punctuation ---
+        ;; --- And anything else is punctuation ---
 
-          (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
-                '(0 mdw-punct-face))))))
+        (list "\\(\\s.\\|\\s(\\|\\s)\\|\\s\\\\|\\s/\\)"
+              '(0 mdw-punct-face)))))
+
+;; --- Define Python fontification style ---
+
+(defun mdw-fontify-python ()
+  (mdw-fontify-pythonic
+   (mdw-regexps "and" "as" "assert" "break" "class" "continue" "def"
+               "del" "elif" "else" "except" "exec" "finally" "for"
+               "from" "global" "if" "import" "in" "is" "lambda"
+               "not" "or" "pass" "print" "raise" "return" "try"
+               "while" "with" "yield")))
+
+(defun mdw-fontify-pyrex ()
+  (mdw-fontify-pythonic
+   (mdw-regexps "and" "as" "assert" "break" "cdef" "class" "continue"
+               "ctypedef" "def" "del" "elif" "else" "except" "exec"
+               "extern" "finally" "for" "from" "global" "if"
+               "import" "in" "is" "lambda" "not" "or" "pass" "print"
+               "raise" "return" "struct" "try" "while" "with"
+               "yield")))
 
 ;;;----- Icon programming style ---------------------------------------------