Next: , Previous: Accessing Documentation, Up: Documentation


23.3 説明文内のキーバインディングの置換

説明文字列からキー列を参照するときには、 現在の活性なキーバインディングを使うべきです。 これは以下に述べる特別なテキスト列でできます。 普通の方法で説明文字列を参照すると、 これらの特別な列は現在のキーバインディング情報で置き換えられます。 置き換えはsubstitute-command-keysを呼び出して行います。 読者自身がこの関数を使うこともできます。

特別な列とその意味を以下にあげます。

\[command]
コマンドcommandを起動するキー列を表す。 commandにキーバインディングがなければ、 ‘M-x command’を表す。
\{mapvar}
変数mapvarの値であるキーマップの概要を表す。 この概要はdescribe-bindingsを使って作成する。
\<mapvar>
空テキストを表す。 副作用のためだけに使う。 つまり、この説明文字列内のこれ以降にある列‘\[command]’に 対するキーマップとしてmapvarの値を指定する。
\=
後続の文字をクォートし‘\=’は破棄する。 したがって、‘\=\[’は‘\[’という出力になり、 ‘\=\=’は‘\=’という出力になる。

注意: Emacs Lispでは、文字列内の‘\’は、2つ続けて書くこと。

— Function: substitute-command-keys string

この関数は、stringから上記の特別な列を探し、 それらをそれらが意味するものに置き換え、結果を文字列で返す。 これにより、説明文の表示では、 ユーザー独自のカスタマイズしたキーバインディングを実際に参照できる。

特別な列の例を示します。

     (substitute-command-keys
        "To abort recursive edit, type: \\[abort-recursive-edit]")
     ⇒ "To abort recursive edit, type: C-]"
     
     (substitute-command-keys
        "The keys that are defined for the minibuffer here are:
       \\{minibuffer-local-must-match-map}")
     ⇒ "The keys that are defined for the minibuffer here are:
     
     ?               minibuffer-completion-help
     SPC             minibuffer-complete-word
     TAB             minibuffer-complete
     C-j             minibuffer-complete-and-exit
     RET             minibuffer-complete-and-exit
     C-g             abort-recursive-edit
     "
     
     (substitute-command-keys
        "To abort a recursive edit from the minibuffer, type\
     \\<minibuffer-local-must-match-map>\\[abort-recursive-edit].")
     ⇒ "To abort a recursive edit from the minibuffer, type C-g."