2010-09-27 3 views
5

Desidero specificare il colore di {}, () e [] in un tema di colori personalizzato. È possibile?Come si imposta il colore delle parentesi/parentesi/parentesi in Emacs?

Aggiornamento: Ecco la fonte. Si prega di notare lo stato di sviluppo di questo tema; non è sicuro per l'uso sia sul posto di lavoro che in casa.

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

risposta

1

Prova:

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

Per partita genitore solo:

Valutare la seguente espressione o metterlo nel vostro .emacs:

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

Quello sembra solo farlo quando il cursore è sopra un paren. O mi sta sfuggendo qualcosa? – MDCore

+0

Oh, volevi colorarlo dall'inizio. Modificato la risposta. Prova quello suggerito. – OTZ

+0

Posso far sì che colorizzi solo le parentesi tonde solo nel buffer in cui sto modificando il tema e solo qualche volta? Se aggiungo questo al tema e apro un altro emacs non fa nulla. Strano?! – MDCore

3

È possibile utilizzare arcobaleno -delimitatori, è possibile installarlo da MELPA nel sistema di pacchetti Emacs24 o r scaricare arcobaleno-delimiters.el da:

emacswiki-RainbowDelimiters

posto arcobaleno-delimiters.el sui vostri emacs load-path

Scrivi codice init nel vostro file .emacs:

(require 'rainbow-delimiters) 

(global-rainbow-delimiters-mode) 
+0

Ciò si traduce in: 'La definizione della funzione del simbolo è nulla: global-rainbow-delimiters-mode' – Zelphir