自定义emacs语法着色 [英] Customizing emacs syntax coloring

查看:161
本文介绍了自定义emacs语法着色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何设置emacs只使用两种颜色,一种用于注释,另一种用于所有语言模式下的常规代码。
当然可以设置每个块的颜色,除了注释到第二个颜色,但我不知道所有可用的块是什么。



到目前为止,我发现所有的都是
(setq-default global-font-lock-mode nil)
,但这也会导致着色注释。



<我想这是一个非常容易的时间证明的emacs战士。

解决方案

请参阅愤怒的水果沙拉维基页面,以清除字体锁定面孔。您可以稍微修改代码,以免发表评论。



如果您真的必须删除所有颜色,除了警告和评论,所有面孔都将执行此操作:

 (defun deolorize-font-lock()
从字体锁定面除去注释的所有颜色并且警告
(let((fg(face-attribute'default:foreground))
(bg(face-attribute'default:background)))
(mapc
(当face
(set-face-attribute face nil
:foreground fg
:background bg)))
(mapcar(lambda(f)
(if(and(string-match^ font-lock(symbol-name f))
(not(string-match-comment\\ | -warning(symbol-name f)) ))
f
nil))
(face-list)))))

(脱色字体锁)


I can't figure out how to set emacs to use just two colors, one for comments and the other for the regular code across all language modes. There is, of course the possibility to set the colors of each block except comment to the second color, but I'm not sure what ALL available blocks are.

Until now all I found is (setq-default global-font-lock-mode nil) but this also kills coloring for comments.

I guess this must be fairly easy for time-proven emacs warriors.

解决方案

See the angry fruit salad wiki page to wash out font-lock faces. You can modify the code slightly to exempt comments.

If you really must remove all colors this code will do it for all faces except warning and comment:

(defun decolorize-font-lock ()
  "remove all colors from font-lock faces except comment and warning"
  (let ((fg (face-attribute 'default :foreground))
        (bg (face-attribute 'default :background)))
    (mapc (lambda (face)
            (when face
              (set-face-attribute face nil
                                  :foreground fg
                                  :background bg)))
          (mapcar (lambda (f)
                    (if (and (string-match "^font-lock" (symbol-name f))
                             (not (string-match "-comment\\|-warning" (symbol-name f))))
                        f
                      nil))
                  (face-list)))))

(decolorize-font-lock)

这篇关于自定义emacs语法着色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆