From 2246213a74a87b6fe12ca01cfaea3e345cb6e29d Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Mon, 24 Mar 2014 13:42:24 +0900 Subject: [PATCH] add emacs keyword highlight plugins --- etc/picrin-c-keyword-highlight.el | 16 ++++++++++++++ etc/picrin-scheme-keyword-highlight.el | 29 ++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 etc/picrin-c-keyword-highlight.el create mode 100644 etc/picrin-scheme-keyword-highlight.el diff --git a/etc/picrin-c-keyword-highlight.el b/etc/picrin-c-keyword-highlight.el new file mode 100644 index 00000000..54fbb35c --- /dev/null +++ b/etc/picrin-c-keyword-highlight.el @@ -0,0 +1,16 @@ +;;; ADD ME TO YOUR .emacs.d/init.el + +(defun font-lock-user-keywords (mode &optional keywords) + "Add user highlighting on KEYWORDS to given MODE. +See `font-lock-add-keywords' and `font-lock-defaults'." + (unless mode + (error "mode should be non-nil ")) + (font-lock-remove-keywords mode (get mode 'font-lock-user-keywords)) + (font-lock-add-keywords mode keywords) + (put mode 'font-lock-user-keywords keywords)) + +(font-lock-user-keywords + 'c-mode + '(("pic_try" . font-lock-keyword-face) + ("pic_catch" . font-lock-keyword-face) + ("pic_for_each" . font-lock-keyword-face))) diff --git a/etc/picrin-scheme-keyword-highlight.el b/etc/picrin-scheme-keyword-highlight.el new file mode 100644 index 00000000..e14e61d1 --- /dev/null +++ b/etc/picrin-scheme-keyword-highlight.el @@ -0,0 +1,29 @@ +;;; ADD ME TO YOUR .emacs.d/init.el + +(defun scheme-add-keywords (face-name keyword-rules) + (let* ((keyword-list (mapcar #'(lambda (x) + (symbol-name (cdr x))) + keyword-rules)) + (keyword-regexp (concat "(\\(" + (regexp-opt keyword-list) + "\\)[ \n]"))) + (font-lock-add-keywords 'scheme-mode + `((,keyword-regexp 1 ',face-name)))) + (mapc #'(lambda (x) + (put (cdr x) + 'scheme-indent-function + (car x))) + keyword-rules)) + +(scheme-add-keywords + 'font-lock-keyword-face + '((1 . when) + (1 . unless) + (1 . define-library) + (0 . import) + (0 . export) + (1 . letrec*) + (1 . define-values) + (1 . define-record-type) + (1 . parameterize) + (0 . values)))