Created
June 7, 2010 12:28
-
-
Save noidi/428610 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; parenface.el --- Provide a face for parens in lisp modes. | |
;; By Dave Pearson <[email protected]> | |
;; $Revision: 1.1 $ | |
;; Add a paren-face to emacs and add support for it to the various lisp modes. | |
;; | |
;; Based on some code that Boris Schaefer <[email protected]> posted | |
;; to comp.lang.scheme in message <[email protected]>. | |
(defvar paren-face 'paren-face) | |
(defface paren-face | |
'((((class color)) | |
(:foreground "DimGray"))) | |
"Face for displaying a paren." | |
:group 'faces) | |
(defmacro paren-face-add-support (keywords) | |
"Generate a lambda expression for use in a hook." | |
`(lambda () | |
(let* ((regexp "(\\|)") | |
(match (assoc regexp ,keywords))) | |
(unless (eq (cdr match) paren-face) | |
(setq ,keywords (append (list (cons regexp paren-face)) ,keywords)))))) | |
;; Keep the compiler quiet. | |
(eval-when-compile | |
(defvar scheme-font-lock-keywords-2 nil) | |
(defvar lisp-font-lock-keywords-2 nil) | |
(defvar clojure-font-lock-keywords nil)) | |
(add-hook 'scheme-mode-hook (paren-face-add-support scheme-font-lock-keywords-2)) | |
(add-hook 'lisp-mode-hook (paren-face-add-support lisp-font-lock-keywords-2)) | |
(add-hook 'emacs-lisp-mode-hook (paren-face-add-support lisp-font-lock-keywords-2)) | |
(add-hook 'lisp-interaction-mode-hook (paren-face-add-support lisp-font-lock-keywords-2)) | |
(add-hook 'clojure-mode-hook (paren-face-add-support clojure-font-lock-keywords)) | |
(provide 'parenface) | |
;; parenface.el ends here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment