LoginSignup
16
14

More than 5 years have passed since last update.

MSYS2のEmacsパッケージにIME Patchを適用する方法

Last updated at Posted at 2015-05-18

【始めに】

MSYS2にはEmacsパッケージ[MINGW32/64]が準備されていのですが、日本語で使用する場合IME周りの挙動で使いにくいものとなっています。
そこで、現状のEmacsパッケージに、rzl24ozi氏が公開しているIME PATCHを適用する手順をまとめました。

【MSYS2の起動】

Emacsパッケージは[mingw64 / 32]にカテゴライズされたパッケージですので、ビルド環境としてはシェルをmingw64[32]_shell.batスクリプトから起動します。

【コンパイル環境の構築】

Emacsをコンパイルするための環境の構築します。
まず始めに、コンパイラ(gcc)をインストールします。

[64bit]

$ pacman -S  mingw-w64-x86_64-gcc  mingw-w64-x86_64-gcc-libs

[32bit]

$ pacman -S mingw-w64-i686-gcc mingw-w64-i686-gcc-libs

次にツール郡をインストールします。

$ pacman -S base-devel
:: There are 52 members in group base-devel:
:: リポジトリ msys
   1) asciidoc  2) autoconf  3) autoconf2.13  4) autogen  5) automake-wrapper
   6) automake1.10  7) automake1.11  8) automake1.12  9) automake1.13
   10) automake1.14  11) automake1.6  12) automake1.7  13) automake1.8
   14) automake1.9  15) bison  16) diffstat  17) diffutils  18) dos2unix
   19) file  20) flex  21) gawk  22) gdb  23) gettext  24) gperf  25) grep
   26) groff  27) help2man  28) intltool  29) lemon  30) libtool  31) libunrar
   32) m4  33) make  34) man-db  35) nasm  36) pacman  37) patch
   38) patchutils  39) perl  40) pkg-config  41) pkgfile  42) rcs  43) scons
   44) sed  45) swig  46) texinfo  47) texinfo-tex  48) unrar  49) wget
   50) xmlto  51) yasm  52) yasm-devel

選択して下さい (デフォルト=all):                      <-特に問題ない場合はそのまま[Enter]

...

【Emacsパッケージのビルドスクリプトの編集】

次にMINGWの標準パッケージのビルドスクリプト一式をダウンロードします。
適当な作業ディレクトリに移動して、

$ git clone https://github.com/Alexpux/MINGW-packages.git

としてスクリプト一式をダウンロードしたら、Emacsパッケージのディレクトリに移動し、

$ cd MINGW-packages/mingw-w64-emacs

このディレクトリー内にあるEmacs用のビルドスクリプトPKGBUILDを編集します。
編集内容は以下の通り

PKGBUILD.diff
--- PKGBUILD.org        2015-01-01 12:00:00.244774500 +0900
+++ PKGBUILD.new        2015-01-01 12:00:00.697704400 +0900
@@ -27,18 +29,21 @@
 source=("http://ftp.gnu.org/gnu/${_realname}/${_realname}-${pkgver}.tar.xz"{,.sig}
         'image.c.diff'
         'lread.c.diff'
-        'Makefile.in.diff')
+        'Makefile.in.diff'
+        'https://gist.githubusercontent.com/rzl24ozi/a282260d2dd136daab14/raw/d544078827f90a10c53e0840a9faefed53187f25/emacs-24.4-w32-ime.diff')
 sha256sums=('dd47d71dd2a526cf6b47cb49af793ec2e26af69a0951cc40e43ae290eacfc34e'
             'SKIP'
             '4571d45ec26fd556e73a70bb0ab0a2a8fa1efc5e3b3c5b472ab68bb7dc9bf52c'
             'b9db1b7d939301d0fedf52db6ac055f7265ee5bc0c3c757e394700ca39577b7f'
-            '1a49a2d4711d0204db80a88c120510168b2eb7649888de65634da252f03b7f16')
+            '1a49a2d4711d0204db80a88c120510168b2eb7649888de65634da252f03b7f16'
+            'SKIP')

 prepare() {
   cd "${_realname}-${pkgver}"
   patch --binary --forward -p0 < "${srcdir}/image.c.diff"
   patch --binary --forward -p0 < "${srcdir}/lread.c.diff"
   patch --binary --forward -p0 < "${srcdir}/Makefile.in.diff"
+  patch --binary --forward -p0 < "${srcdir}/emacs-24.4-w32-ime.diff"
   ./autogen.sh
 }

編集箇所としては、

  • source に IME_PATCH の URL を追加
  • sha256sums に IME_PATCH用の検証用チェックサム値を追加('SKIP'で問題なし)
  • prepare()内に patch処理部を追加

の3箇所となります。

【Emacsパッケージのビルド】

パッケージのビルドの前にEmacsのパッケージに依存関係のある(オプション)パッケージをインストールしておきます。
[64bit]

$ pacman -S mingw-w64-x86_64-librsvg mingw-w64-x86_64-libxml2 mingw-w64-x86_64-librsvg mingw-w64-x86_64-xpm-nox mingw-w64-x86_64-gnutls mingw-w64-x86_64-zlib

[32bit]

$ pacman -S mingw-w64-i686-librsvg mingw-w64-i686-libxml2 mingw-w64-i686-librsvg mingw-w64-i686-xpm-nox mingw-w64-i686-gnutls mingw-w64-i686-zlib

それではパッケージをビルドします。

[64bit]

$ MINGW_CHOST=x86_64-w64-mingw32 MINGW_PACKAGE_PREFIX=mingw-w64-x86_64 MINGW_PREFIX=/mingw64 makepkg -s --skippgpcheck

[32bit]

$ MINGW_CHOST=i686-w64-mingw32 MINGW_PACKAGE_PREFIX=mingw-w64-i686 MINGW_PREFIX=/mingw32 makepkg -s --skippgpcheck

(途中経過)

  Where should the build process find the source code?    /C/msys64/home/yourname/workdir/MINGW-packages/mingw-w64-emacs/src/emacs-24.5
  What compiler should emacs be built with?               gcc  -std=gnu99 -pipe -O3 -fomit-frame-pointer -funroll-loops
  Should Emacs use the GNU version of malloc?             yes
  Should Emacs use a relocating allocator for buffers?    yes
  Should Emacs use mmap(2) for buffer allocation?         no
  What window system should Emacs use?                    w32
  What toolkit should Emacs use?                          none
  Where do we find X Windows header files?                NONE
  Where do we find X Windows libraries?                   NONE
  Does Emacs use -lXaw3d?                                 no
  Does Emacs use -lXpm?                                   yes
  Does Emacs use -ljpeg?                                  yes
  Does Emacs use -ltiff?                                  yes
  Does Emacs use a gif library?                           yes
  Does Emacs use a png library?                           yes
  Does Emacs use -lrsvg-2?                                yes
  Does Emacs use imagemagick?                             yes
  Does Emacs support sound?                               yes
  Does Emacs use -lgpm?                                   no
  Does Emacs use -ldbus?                                  yes
  Does Emacs use -lgconf?                                 no
  Does Emacs use GSettings?                               no
  Does Emacs use a file notification library?             yes (w32)
  Does Emacs use access control lists?                    yes
  Does Emacs use -lselinux?                               no
  Does Emacs use -lgnutls?                                yes
  Does Emacs use -lxml2?                                  yes
  Does Emacs use -lfreetype?                              no
  Does Emacs use -lm17n-flt?                              no
  Does Emacs use -lotf?                                   no
  Does Emacs use -lxft?                                   no
  Does Emacs directly use zlib?                           yes
  Does Emacs use toolkit scroll bars?                     yes
  Does Emacs support W32-IME?                             yes
  Does Emacs support RECONVERSION?                        yes
  Does Emacs support DOCUMENTFEED?                        yes

しばらく待つと、パッケージファイルmingw-w64-x86_64[i686]-emacs-24.5-1-any.pkg.tar.xz が作成されます。

インストールは

$ pacman -U mingw-w64-x86_64[i686]-emacs-24.5-1-any.pkg.tar.xz

でできます。

[err setting certificate verify location]のエラーでgitでのダウンロードに失敗する場合は
 pacman -S ca-certificates
にて、CA証明書の再インストールしてください。

【参考】

16
14
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
16
14