7

I'd like to specify the colour of {}, () and [] in a custom colour theme. Is this possible?

Update: Here's the source. Please note the in-development status of this theme; it is unsafe for use both at the workplace and around the home.

;;; Color theme based on Moria for VIM.
(defun color-theme-moria ()
  "A color theme based on Moria for VIM."
  (interactive)
  (color-theme-install
   '(color-theme-moria
     ((foreground-color . "#000000") ;done
      (cursor-color . "#ffffff")
      (background-color . "#f0f0f0") ;done
      (background-mode . light)) ;done
     (default ((t (nil)))) ;done
     (underline ((t (:underline t)))) ;done
     (modeline ((t (:foreground "black" :background "#000000"))))
     (modeline-buffer-id ((t (:foreground "red" :background "#0000ff"))))
     (modeline-mousable ((t (:foreground "cyan" :background "#007080"))))
     (modeline-mousable-minor-mode ((t (:foreground "cyan" :background "#007080"))))
     (highlight ((t (:background "#d0d0d0")))) ;done
     (region ((t (:background "#c0c0c0")))) ;done
     (font-lock-builtin-face ((t (:foreground "black"))))
     (font-lock-constant-face ((t (:foreground "#ff0000")))) ;hmmm
     (font-lock-comment-face ((t (:foreground "#786000")))) ;done
     (font-lock-function-name-face ((t (:foreground "#000000" )))) ;done
     ; highlight ma brackets
     (font-lock-add-keywords nil '(("\\([\{\}\\[\]\(\)]+\\)" 1 font-lock-keyword-face prepend)))
     (font-lock-preprocessor-face ((t (:foreground "#912F11" :bold t))))
     (font-lock-keyword-face ((t (:foreground "#1f3f81" :bold t)))) ; done e.g. defun

     (font-lock-string-face ((t (:foreground "#077807")))) ;done
     (font-lock-variable-name-face ((t (:foreground "#ff0000" )))) ;hmmm
     (font-lock-warning-face ((t (:foreground "#ff0000"))))
     (highlight-changes-face ((t (:background "#ff0000"))))
     (highlight-changes-delete-face ((t (:foreground "red" :background "pink"))))
     (show-paren-match ((t (:foreground "#2e3436" :background "#73d216"))))

     (widget-field-face ((t (:foreground "pink" :background "red"))))
     (widget-inactive-face ((t (:foreground "gray"))))
     (custom-button-face ((t (:foreground "yellow" :background "dark blue"))))
     (custom-state-face ((t (:foreground "mediumaquamarine"))))
     (custom-face-tag-face ((t (:foreground "goldenrod" :underline t))))
     (custom-documentation-face ((t (:foreground "#10D010"))))
     (custom-set-face ((t (:foreground "#2020D0"))))
     )
   )
  )
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
MDCore
  • 17,583
  • 8
  • 43
  • 48

2 Answers2

2

You can use rainbow-delimiters mode, you can install it from MELPA in Emacs24 packages system or download rainbow-delimiters.el from:

emacswiki-RainbowDelimiters

place rainbow-delimiters.el on your emacs load-path

write init code in your .emacs file:

(require 'rainbow-delimiters)

(global-rainbow-delimiters-mode)
Bin Chen
  • 81
  • 7
2

Try:

(font-lock-add-keywords nil '(("\\([\{\}\\[\]\(\)]+\\)" 1 font-lock-keyword-face prepend)))

For parent match only:

Evaluate the following expression or put it into your .emacs:

(custom-set-faces
 '(show-paren-match ((t (:background "blue"))))
 '(show-paren-mismatch ((((class color)) (:background "red" :foreground "white")))))
OTZ
  • 3,003
  • 4
  • 29
  • 41
  • That only seems to do it when your cursor is over a paren. Or am I missing something? – MDCore Sep 27 '10 at 09:56
  • Oh you wanted to colorize it from the start. Edited the answer. Try the one suggested. – OTZ Sep 27 '10 at 10:18
  • I can get it to colorize just the round brackets only in the buffer where I'm editing the theme and only sometimes? If I add that to the theme and open another emacs it doesn't do anything. Strange?! – MDCore Sep 27 '10 at 11:34
  • @MDCore Edited. can you try again? – OTZ Sep 27 '10 at 17:52
  • Still not getting joy. I've updated the question with the full source – MDCore Sep 27 '10 at 18:43