From: Mark Wooding Date: Sun, 4 Oct 2009 23:09:21 +0000 (+0100) Subject: dot/emacs, el/dot-emacs.el: Fontification for Pyrex code. X-Git-Url: https://git.distorted.org.uk/~mdw/profile/commitdiff_plain/99fe6ef5f1b75f8d040e36e7050ec5623d6318b8?hp=9165ea47616fd15b905ff52508abce5195a0e152 dot/emacs, el/dot-emacs.el: Fontification for Pyrex code. One function doing the heavy lifting, with separate lists of keywords. --- diff --git a/dot/emacs b/dot/emacs index 35e4f7a..9e1f688 100644 --- a/dot/emacs +++ b/dot/emacs @@ -479,7 +479,8 @@ (mapcar (lambda (hook) (add-hook hook 'mdw-misc-mode-config)) '(c-mode-hook c++-mode-hook objc-mode-hook java-mode-hook csharp-mode-hook perl-mode-hook cperl-mode-hook - python-mode-hook icon-mode-hook awk-mode-hook tcl-mode-hook + python-mode-hook pyrec-mode-hook icon-mode-hook awk-mode-hook + tcl-mode-hook asm-mode-hook TeX-mode-hook LaTeX-mode-hook TeXinfo-mode-hook tex-mode-hook latex-mode-hook texinfo-mode-hook emacs-lisp-mode-hook scheme-mode-hook @@ -567,6 +568,7 @@ (setq-default py-indent-offset 2) (add-hook 'python-mode-hook 'mdw-fontify-python t) +(add-hook 'pyrex-mode-hook 'mdw-fontify-pyrex t) (setq py-python-command-args `("-i" "-colors" ,(if mdw-black-background "Linux" "LightBG"))) diff --git a/el/dot-emacs.el b/el/dot-emacs.el index d0be013..c9b9623 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -1372,9 +1372,7 @@ strip numbers instead." ;;;----- Python programming style ------------------------------------------- -;; --- Define Python fontification style --- - -(defun mdw-fontify-python () +(defun mdw-fontify-pythonic (keywords) ;; --- Miscellaneous fiddling --- @@ -1383,31 +1381,44 @@ strip numbers instead." ;; --- 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 ---------------------------------------------