如何设置Emacs中括号/大括号/括号的颜色?

如何设置Emacs中括号/大括号/括号的颜色?,emacs,elisp,dot-emacs,Emacs,Elisp,Dot 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 (

我想在自定义颜色主题中指定
{}
()
[]
的颜色。这可能吗

更新:这是来源。请注意该主题的发展状况;无论是在工作场所还是在家中使用都是不安全的

;;; 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"))))
     )
   )
  )
尝试:

仅适用于父匹配:

计算以下表达式或将其放入.emacs中:

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

您可以使用rainbow delimiters模式,您可以从Emacs24软件包系统中的MELPA安装它,也可以从以下位置下载rainbow-delimiters.el:

在emacs加载路径上放置rainbow-delimiters.el

在.emacs文件中写入初始化代码:

(require 'rainbow-delimiters)

(global-rainbow-delimiters-mode)

这似乎只在光标位于paren上时才起作用。还是我遗漏了什么?哦,你从一开始就想给它上色。编辑了答案。试试我建议的方法。我可以让它只在我编辑主题的缓冲区中的圆括号上色,而且只是有时候?如果我将其添加到主题中并打开另一个emacs,它将不会起任何作用。奇怪@MDCore编辑。你能再试一次吗?还是不高兴。我已经用完整的源代码更新了这个问题,结果是:
Symbol的函数定义无效:全局彩虹分隔符模式
(require 'rainbow-delimiters)

(global-rainbow-delimiters-mode)