LoginSignup
6

More than 3 years have passed since last update.

emacsのテーマについて

Posted at

emacsの見た目

 前回の投稿ではMSYS2を使って下記のような見た目のemacsを使用できるようにしましたね。

2019-08-10_01h55_22.png

※前回の記事 「MSYS2でemacs生活開始」
https://qiita.com/RIO18020/items/2ef7a4973384463d554e

これは"monokai theme"を使用していました。ただ、個人的にもう少し綺麗な色にしたいなーとか思うので、別のテーマについても取り入れていきたいと思います。

atom-one-dark-theme

まずは「atom-one-dark-theme」というものを取り入れていきたいと思います。

参考サイト
「Emacsでもしゃれた画面でプログラミングがしたい!!」
https://qiita.com/itome/items/05dc50f6bfbdfb04c0cf

まずは、mingw32, mingw64のどちらかを起動し、emacsを起動しましょう。

起動できたらAlt+Xを押しましょう。そうするとemacsの下部(MINI-BUFFER : 下図参照)に"M-X "と表示されますね。この状態で"package-install"と入力し「Enter」を押しましょう。この流れで必要なパッケージがインストールできます。emacsを知らない人からするとこの辺から意味が分からない気がしますね(笑)。VSCodeの拡張機能のようなものを入れられるようなイメージです。

INewImage31.png

図の引用は下記から。
https://www.softantenna.com/wp/webservice/absolute-beginners-guide-to-emacs/

「Enter」を押すと先程のミニバッファに"Install package: "と表示されます。そこで"atom-one-dark-theme"と入力しましょう。atom-oneあたりまで入力すればTabキーを入力して補完できると思います。パッケージが見つからない場合や補完が働かない場合は、パッケージリストが更新されていない可能性があります。その場合は"M-x package-refresh-contents"コマンドでパッケージのリフレッシュをしましょう。
もしくはinit.elなどの設定ファイルにパッケージリポジトリが設定されていない可能性もあるでしょう。
下記のサイトを参考にして設定ファイルを編集しましょう。
https://emacs-jp.github.io/packages/package-management/package-el
具体的には下記の内容があれば問題ないでしょうと思います。

(require 'package)
;; MELPAを追加
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; MELPA-stableを追加
(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
;; Marmaladeを追加
(add-to-list 'package-archives  '("marmalade" . "http://marmalade-repo.org/packages/") t)
;; Orgを追加
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
;; 初期化
(package-initialize)

"atom-one-dark-theme"がインストールされましたらemacsに戻り、Ctrl+X Ctrl+Fを入力し、ファイルを開きましょう。init.elなどの設定ファイルを開きます。
2019-08-12_06h34_18.png

前回の設定ファイルのままだとmonokai-themeが利用されていると思いますので、その行をコメントアウトしましょう(行頭に;;を入力)。(load-theme 'atom-one-dark t)を入力しましょう。

;; color theme
;; (load-theme 'monokai t)
(load-theme 'atom-one-dark t)

そして、"M-X eval-buffer"を入力することでemacsを再起動することなく設定を反映させることができます。
すると下図のようになりました!

2019-08-12_06h41_06.png

いい感じですね。

Doom

 Doom Emacsというものがあるのですが、こちらを使うとvimのキーバインドを使っていくこともできるらしい。vimの移動に慣れるのは大変ですが、いつからDoom Emacsを導入していく予定です。
 今回はdoom-themesを導入してみたいと思います。atom-one-darkの時と同様にpackage-installを行い、doom-themesをインストールします。その後、init.elに下記を追記しましょう。

(require 'doom-themes)
;; Global settings (defaults)
(setq doom-themes-enable-bold t    ; if nil, bold is universally disabled
      doom-themes-enable-italic t) ; if nil, italics is universally disabled
;; Load the theme (doom-one, doom-molokai, etc); keep in mind that each theme
;; may have their own settings.
(load-theme 'doom-dracula t)
;; Enable flashing mode-line on errors
(doom-themes-visual-bell-config)
;; Enable custom neotree theme (all-the-icons must be installed!)
(doom-themes-neotree-config)
;; or for treemacs users
(setq doom-themes-treemacs-theme "doom-colors") ; use the colorful treemacs theme
(doom-themes-treemacs-config)
;; Corrects (and improves) org-mode's native fontification.
(doom-themes-org-config)

そうすると下記のようなテーマが導入できます!

2019-08-20_02h56_13.png

色が気に食わない場合には"M-X list-faces-display"によってコメントアウトの色とか細かいところも変更できます。

2019-08-20_02h58_37.png

いじりだすと時間が溶けますが、コツコツと好みを追求していくのも一興でしょう。

@Ladicleさんの下記のサイトは非常に素晴らしいなーと思いますが、私にはまだまだ分からないところだらけ。emacsをこれから手足になるように使いこなしていこう:relaxed:

参考サイト
「Emacsモダン化計画 -かわEmacs編-」
https://qiita.com/Ladicle/items/feb5f9dce9adf89652cf

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6