LoginSignup
1
3

More than 3 years have passed since last update.

Windows 10 WSL (Windows Subsystem for Linux) 上のUbuntuからemacsを起動する

Last updated at Posted at 2019-12-28

1. Windows 10 WSLの有効化

コントロールパネル > プログラムの左カラムにある Windows の機能の有効化または無効化(Control Panel > Programs and Features > Turn Windows features on or off) をクリックすると開くWindowsの機能(Windows Features)から、Windows Subsystem for Linux にチェックを入れ、OKボタンをクリック。
wsl.jpg
もしくはWindows PowerShellを管理者権限で開いて、以下を実行。

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

(参考:Install the Windows Subsystem for Linux | Microsoft Docs)

2. WSL Distro (Ubuntu) をインストール

インストール後Ubuntuを起動、ユーザー名とパスワードを設定して、
パッケージ更新:

$ sudo apt update && sudo apt upgrade

3. emacs パッケージのレポジトリ追加と emacs 26 のインストール

$ sudo add-apt-repository ppa:kelleyk/emacs
$ sudo apt-get update
$ sudo apt install emacs26

(参考:Reddit r/emacs: What is the most painless way to install Emacs 26 on Ubuntu 18.4?)

4. lxde デスクトップのインストール

$ sudo apt install lxde

5. Windows用 X サーバー(vcxsrv)のインストール

VcxSrvをダウンロード、インストールして起動。ウィンドウズショートカットを作り以下コマンドをターゲットにしておくと良い:

”C:\Program Files\VcXsrv\vcxsrv.exe” :0 -multiwindow -clipboard -wgl

6. emacsを起動

$ emacs26 --display :0.0

.bashrcに以下 alias を追加しておくと、emacs起動後にUbuntuウィンドウを閉じてくれるので便利:

alias emacs='
export DISPLAY=:0.0
export LIBGL_ALWAYS_INDIRECT=1

# キーボード設定
setxkbmap -layout us

setsid emacs26
exit
'

(参考:hubisan/emacs-wsl: Install and run emacs with the Windows Subsystem for Linux (WSL) in Windows 10. )

7. 日本語環境の設定

- 日本語パッケージのインストール

$ sudo apt install language-pack-ja

もしロケール変更したい場合は:

$ sudo update-locale LANG=ja_JP.UTF-8
## ここで一旦再起動。 exec bash では不可。
$ date
2020年  1月  4日 土曜日 09:14:44 PST

英語に戻したい場合は en_US.UTF-8 を指定する。

- 日本語入力環境 (fcitx-mozc)

$ sudo apt -y install \
fcitx-mozc \
emacs-mozc-bin \
dbus-x11 x11-xserver-utils

-- wsl/emacs手探りの続き --

1
3
0

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
1
3