2010-09-27 164 views
5

我想在自定义颜色主题中指定颜色{},()[]。这可能吗?如何在Emacs中设置括号/括号/圆括号的颜色?

更新:这是源代码。请注意这个主题的发展状态;在工作场所和家庭使用都是不安全的。

;;; 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")))) 
    ) 
    ) 
) 

回答

1

尝试:

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

仅适用于父比赛:

评估下面的表达式或把它放到你的.emacs:

(custom-set-faces 
'(show-paren-match ((t (:background "blue")))) 
'(show-paren-mismatch ((((class color)) (:background "red" :foreground "white"))))) 
+0

那只有当你的光标超过paren时才会这样做。或者我错过了什么? – MDCore 2010-09-27 09:56:10

+0

哦,你想从一开始就着色它。编辑答案。尝试一个建议。 – OTZ 2010-09-27 10:18:48

+0

我可以让它只着色在我正在编辑主题的缓冲区中的圆括号,并且有时只有?如果我将其添加到主题并打开另一个emacs,它不会执行任何操作。奇怪?! – MDCore 2010-09-27 11:34:51

3

您可以使用彩虹-delimiters模式,您可以从MELPA在Emacs24软件包系统o中安装它R下载彩虹delimiters.el从:在您的Emacs负载路径

写初始化代码在你的.emacs文件

emacswiki-RainbowDelimiters

地方彩虹delimiters.el:

(require 'rainbow-delimiters) 

(global-rainbow-delimiters-mode) 
+0

结果如下:'Symbol的函数定义为void:global-rainbow-delimiters-mode' – Zelphir 2015-11-13 17:55:23