migemo対応の helm sourceを書く(helm-migemo不要)

昔 helmは migemo対応していたのですが(anything時代から), それが除去され, migemo機能を有効にする helm-migemoというパッケージが作成されさました. しかし最近 helmが再度 migemo対応しました. これにより helmだけで migemo対応の sourceが書けるようになりました. その手順を示します(作者の方が主導的に行われたので再度外される可能性はないとはいえませんが, 高くはないと思います).

バージョン

1.7.9以上を使う必要があります.

事前準備

migemoの設定を行い(以下は cmigemo), helm-modeを有効にします. (NOTE helm-migemo-modeは autoloadできないので, 事前に helmをロードしています)

(require 'migemo)
(setq migemo-command "migemo")
(setq migemo-options '("-q" "--emacs"))

;; Set your installed path
(setq migemo-dictionary
      (expand-file-name "/usr/local/share/migemo/utf-8/migemo-dict"))

(setq migemo-user-dictionary nil)
(setq migemo-regex-dictionary nil)
(setq migemo-coding-system 'utf-8-unix)
(migemo-init)

(require 'helm)
(helm-migemo-mode +1)

サンプル

source作成マクロで migemo属性を non-nilに設定します.

(defvar sample-source
  (helm-build-sync-source "Sample helm-migemo"
    :candidates '("りんご" "みかん" "メロン")
    :action 'message
    :migemo t))

(defun sample-helm-migemo ()
  (interactive)
  (helm :sources '(sample-source) :buffer "*helm-sample*"))

イメージ

上記の実行結果(M-x sample-helm-migemo)は以下のようになります.

f:id:syohex:20151010171556g:plain