2

モード ラインの一部を異なる色で表示したいのですが、期待どおりに動作せず、適切な Web リファレンスが見つかりません。テキストを太字または斜体に変更できますが、必要に応じて色を変更することはできません。

最も単純な例は、単純なモード ラインをデフォルトのフェイス カラーではなく白でbuffer-file-nameで表示することです。

(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に感謝します...

  1. 「font-lock-face」を「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 のおかげで軌道に乗っています。

4

1 に答える 1

3

これは、私が使用しているカスタム モードラインのごく一部です (どこで見つけたかは覚えていません)。バッファ名を別の色で表示するように要求されたので変更されています。私が使用しているこの例ではfont-lock-warning-face(これは私の配色では「赤」です):

これは決して完全なモードラインではありません:

(setq-default mode-line-format
  (list

    mode-line-front-space ; +-- just like in the default mode-line-format
    mode-line-mule-info   ; |
    mode-line-client      ; |

    ;; the buffer name; the file name as a tool tip if you hover the mouse on it
    '(:eval (propertize "%b " 'face 'font-lock-warning-face
        'help-echo (buffer-file-name)))

    '(:eval (propertize (if overwrite-mode "OVERWRITE" "")
              'face 'font-lock-warning-face
              'help-echo (concat "Buffer is in "
                           (if overwrite-mode "overwrite" "insert") " mode")))

    "%-"                  ; fill what's left with '-'
    ))

それはあなたのために働きますか?font-lock-warning-face上書きをオンにした場合に備えて、OVERWRITE が表示される部分も入れました (上書きモードになるのがちょっと嫌いなので、非常に明白にしたいと思います)。

于 2014-07-21T11:52:49.500 に答える