web-dev-qa-db-ja.com

Emacs構文の強調表示色を変更する

Emacsを実行し、C++モードとPHPモードでファイルを編集します。構文としての強調表示は概念として大好きですが、デフォルトの色は悲惨なものです。それらの値を変更する最も簡単な方法は何ですか?これについてはウェブ上で見つけることができないようです。自分のEmacsをコンパイルしているので、バイナリを変更することさえ気にしません。青が#0000FFと表示されている場所を、たとえば#AAAAFFに変更します。

58
adum

私はこの種のことのためにカラーテーマを使用するのが最も簡単だと思います。

https://www.emacswiki.org/emacs/ColorThemes

しかし、それをしたくない場合は、問題のテキストの上にカーソルを置き、M-x customize-face。デフォルトでは、カーソルが上にある面になります。

http://www.gnu.org/software/emacs/manual/html_node/emacs/Specific-Customization.html

65
seth

2つの方法-パッケージのカラーテーマをインストールできます。これには、選択するニーススキームが多数あり、手作業で簡単に実行できます。手作業は次のようになります(.emacs内)

(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.
  '(default ((t (:inherit nil :stipple nil :background "lightyellow2" :foreground "gray20" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight bold :width normal :family "liberation mono"))))
  '(background "blue")
  '(font-lock-builtin-face ((((class color) (background dark)) (:foreground "Turquoise"))))
  '(font-lock-comment-face ((t (:foreground "MediumAquamarine"))))
  '(font-lock-constant-face ((((class color) (background dark)) (:bold t :foreground "DarkOrchid"))))
  '(font-lock-doc-string-face ((t (:foreground "green2"))))
  '(font-lock-function-name-face ((t (:foreground "SkyBlue"))))
  '(font-lock-keyword-face ((t (:bold t :foreground "CornflowerBlue"))))
  '(font-lock-preprocessor-face ((t (:italic nil :foreground "CornFlowerBlue"))))
  '(font-lock-reference-face ((t (:foreground "DodgerBlue"))))
  '(font-lock-string-face ((t (:foreground "LimeGreen"))))

...

などなど.

入力することもできます

`M-x customize-face RET`

これにより、設定するすべてのカスタマイズが行われ、最終的に.emacsになります。

26
Steve B.

変更する面(「色」)にカーソルを置きます。ヒット C-u C-x =。これにより、その位置にどの顔が存在するかがわかり、クリックしてカスタマイズできます。カスタマイズを保存します。

16
Drew

色の強調表示をまったく気にかけない場合、または上記の回答のいずれもうまくいかない場合(または理解するのに時間がかかりすぎる場合)、色を完全に削除する非常に簡単なソリューションを以下に示します。

次を入力すると、色が取り除かれます。

M-x global-font-lock-mode

これを暫定的な手順として実行して、画面のすべてを実際に表示し、上記の回答のいずれかを試すこともできます。私の場合、これは非常に便利でした。なぜなら、色の変更を可能にする特定の主要なテキストの色自体はほとんど見えなかったからです-たとえば、M-xのプロンプト。

変更を永続的にしたい場合は、これを.emacsファイルに追加できます。

(setq-default global-font-lock-mode nil)

2
Michael