emacsの単語補完には、動的略語展開と静的略語展開があります。
M-/ で動的略語展開
動的略語展開では、カーソル位置にある単語をバッファ内の単語で補完します。特に設定は必要ない為、いつでも試すことができます。
静的略語展開は、先ず.abbrev_defsを登録
一方、静的略語展開では予め設定された略語を使用して補完します。この機能を使用するには先ず、~/.abbrev_defs というファイルに略語をメジャーモード毎に登録する必要があります。
※「C-x a i l」等のコマンドでも登録できますが、直接、.abbrev_defsを編集する方が簡単だと思います
※.emacsに特に設定を追加する必要はありません
私の環境にある.abbrev_defsは次のとおりです。
;;-*-coding: emacs-mule;-*- ;;略語に「-」を含めると、うまく動作しないみたい (define-abbrev-table 'comint-mode-abbrev-table '( )) (define-abbrev-table 'emacs-lisp-mode-abbrev-table '( )) (define-abbrev-table 'fundamental-mode-abbrev-table '( )) (define-abbrev-table 'global-abbrev-table '( )) (define-abbrev-table 'html-helper-mode-abbrev-table '( ("doctype" "<script type=\"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">" nil 1) ("css" "<link rel=\"stylesheet\" type=\"text/css\" href=\"\">" nil 1) ("script" "<script type=\"text/javascript\" src=\"\"></script>" nil 1) ("table" "<table>\n<thead><tr></tr></thead>\n<tbody><tr></tr></tbody>\n</talbe>" nil 1) )) (define-abbrev-table 'lisp-mode-abbrev-table '( )) (define-abbrev-table 'occur-mode-abbrev-table '( )) (define-abbrev-table 'text-mode-abbrev-table '( )) (define-abbrev-table 'yaml-mode-abbrev-table '( ))
静的略語展開の実行は「C-x '」または「M-Space」
デフォルトでは「C-x '」により静的略語展開を実行できますが、
私の場合、.emacsに次のように登録して「M-Space」で実行しています。
(define-key esc-map " " 'expand-abbrev) ;静的略語展開は M-SPCに変更
.emacsは以前のエントリをご覧ください
以前のエントリに私の環境の.emacsを記載しているので、参考にしてください。
http://d.hatena.ne.jp/end0tknr/20090404/1238798480