我想用不同的颜色显示我的模式线的一部分,但它没有按预期工作,我找不到一个好的网络参考。我可以将文本更改为粗体或斜体,但不能根据需要更改颜色。
最简单的示例是显示一个简单的模式行,其中缓冲区文件名为白色,而不是默认的面颜色。
(custom-set-variables
'(mode-line-format
(quote
("%e" mode-line-front-space
"[" mode-name "] %l:%i"
"\t"
propertize buffer-file-name 'font-lock-face '(:foreground "white")))))
感谢 legosica 指出我应该包括我尝试过的其他示例...
用 'face 替换 'font-lock-face:
propertize buffer-file-name 'face '(:foreground "white")))))
跟进
多亏了 TacticalCoder,我现在拥有了我想要的东西——我的模式行中有多种字体和颜色。设置不起作用的原因'face '(:foreground "white")
是它需要包装在'(:eval ...)中。
我最终得到了这个......
(setq-default mode-line-format
(list
mode-line-front-space ; +-- just like in the default mode-line-format
'(:eval (propertize (concat "\t[" mode-name "] %l:%i\t") 'face '(:foreground "black" :height 0.9 :weight normal)
'help-echo (buffer-file-name)))
'(:eval (propertize (file-name-directory buffer-file-name) 'face 'info-title-4
'help-echo (buffer-file-name)))
'(:eval (propertize (file-name-nondirectory buffer-file-name) 'face 'info-title-3
'help-echo (buffer-file-name)))
))
结合...
(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.
'(info-title-3 ((t (:inherit info-title-4 :foreground "white" :height 1.2))))
'(info-title-4 ((t (:inherit info-title-4 :foreground "black"))))
'(mode-line ((t (:background "#6483af" :foreground "#001122" :box (:line-width 3 :color "#6483af") :weight ultra-bold :height 118 :family "Monospace")))))
...我得到了一个很好的简单模式行,它展示了我想要的大部分内容。更多的工作要做,但感谢 TacticalCoder,我回到了正轨。