2011-02-12

Setting syntax coloring for rst.el

I often use reStructuredText for writing documentation or papers. By the way I like Markdown too. I found that there have been a variety of opinions on comparison of them. I find reST useful because docutils provides some tools for converting reST files to some formats.

There are many tools for editing reST. There is rst.el as an Emacs major mode for editing reStructuredText.

I always use emacs with a dark background and light text. So according to rst.el, I need only set the variable frame-background-mode to the symbol dark for suitable display.

(setq frame-background-mode 'dark)

But my emacs didn't properly reflect the setting.


Probably other settings conflict in my .emacs. Therefore I manually set the colors of rst.el.

I used customize and customize-face for this setting. I referred to the color of org-mode (org-level-*) for syntax coloring of sections.

M-x customize
> [Faces group] - [Rst Faces] - [Rst Faces Defaults] - [Rst Level Face Base Light]
#=> 50
M-x customize-face
> rst-level-1-face ~ rst-level-6-face
#=> same as org-level-1 ~ org-level-6


I got the following settings by using customize and customize-face.

(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(rst-level-1-face ((t (:foreground "LightSkyBlue"))) t)
 '(rst-level-2-face ((t (:foreground "LightGoldenrod"))) t)
 '(rst-level-3-face ((t (:foreground "Cyan1"))) t)
 '(rst-level-4-face ((t (:foreground "chocolate1"))) t)
 '(rst-level-5-face ((t (:foreground "PaleGreen"))) t)
 '(rst-level-6-face ((t (:foreground "Aquamarine"))) t))
 ;; (rst-level-7-face ((t (:foreground "LightSteelBlue"))) t)  ;; I don't use
 ;; (rst-level-8-face ((t (:foreground "LightSalmon"))) t)
(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(rst-level-face-base-light 50))

Now I'm pleasant to write documentation by reST.

Thanks.

0 comments:

Post a Comment