キルリングはテキスト文字列のリストです。見た目は以下の通りです:
("some text" "a different piece of text" "yet more text")
これがキルリングの内容で、C-yを押した場合、‘some text’という文字列が、カーソルがあるこのバッファに挿入されます。
yank
コマンドは、テキストをコピーして複製する場合にも使用されます。コピーされたテキストはバッファから切り出されるのではなく、そのコピーがキルリングに配置され、ヤンクすることで挿入されます。
キルリングからテキストを呼び戻すには、3つの関数が使用されます。通常はC-yにバインドされているyank、通常はM-yにバインドされているyank-pop、そして他の2つの関数で使用されるrotate-yank-pointerです。
これらの関数は、kill-ring-yank-pointer
という変数を介してキルリングを参照します。実際、yank と yank-pop の両関数における挿入コードは以下の通りです:
(insert (car kill-ring-yank-pointer))
(Well, no more. In GNU Emacs 22, the function has been replaced by insert-for-yank which calls insert-for-yank-1 repetitively for each yank-handler segment. In turn, insert-for-yank-1 strips text properties from the
inserted text according to yank-excluded-properties. Otherwise, it is just like
insert. We will stick with plain insert since it is easier to understand.)
yank と yank-pop
の仕組みを理解し始めるには、まず kill-ring-yank-pointer
変数を確認する必要があります。