23.14 ドラッグアンドドロップ

ほとんどのグラフィカルなデスクトップ環境で、Emacsはドラッグアンドドロップ(drag and drop)操作にたいする、基本的なサポートを提供します。たとえばEmacsのフレームにテキストをドロップすると、ドロップされた箇所にテキストを挿入し、ファイルをドロップすると、Emacsフレームはそのファイルをvisitします。特別なケースとしては、Diredバッファーにファイルをドロップすることにより、バッファーに表示されているディレクトリーにファイルを移動またはコピーします(アプリケーションの慣例に基づきます)。

ファイルをドロップすると、通常はドロップされたウィンドウでファイルをvisitします。そのような場合に、新しいウィンドウでファイルをvisitしたいときは、変数dnd-open-file-other-windowをカスタマイズします。

現在のところ、XDNDおよびMotif drag and drop protocolsと、古いKDE 1.x protocolがサポートされています。

Emacsのウィンドウにテキストをドラッグしている際に、スクロールやドロップされたテキストが挿入される場所を判断するのが難しい場合があるでしょう。オプションdnd-indicate-insertion-pointを非nil値にセットすれば、ドラッグ中にマウスがウィンドウ内を移動する際にドロップされるテキストが挿入される位置にポイント移動がするようにできます。またdnd-scroll-marginを整数値にセットすれば、ドラッグ中にウィンドウの上端または下端の指定した行数部分にマウスが移動するとウィンドウがスクロールするようにできます。

Emacs can also optionally drag the region with the mouse into another portion of this or another buffer. To enable that, customize the variable mouse-drag-and-drop-region to a non-nil value. Normally, the text is moved, i.e. cut and pasted, when the destination is the same buffer as the origin; dropping the region on another buffer copies the text instead. If the value of this variable names a modifier key, such as ‘shift’, ‘control’ or ‘alt’, then pressing that modifier key when dropping the text will copy it instead of cutting it, even if you drop on the same buffer as the one from which the text came.

ドラッグ元とドロップ先が異なるバッファーのときにもテキストをカットするためには、オプションmouse-drag-and-drop-region-cut-when-buffers-differを非nil値にセットします。デフォルトでは、グラフィカルなディスプレイの選択されたテキストはツールチップ内に表示され、ドラッグ中にはマウスカーソルとともにポイントが移動します。このような動作を抑止するには、オプションmouse-drag-and-drop-region-show-tooltip、および/またはmouse-drag-and-drop-region-show-cursornilをセットしてください。

Emacsから他のプログラムにテキストをドラッグできるようにするには、オプションmouse-drag-and-drop-region-cross-programに非nil値をセットしてください。

Xウィンドウシステムでは、Emacsによるファイルの保存を期待してファイルをEmacsにドロップできるプログラムがいくつかあります。通常だとEmacsはファイルを保存する名前の入力を求めた後にそのファイルをオープンしますが、変数x-dnd-direct-save-functionを変更することによってこの挙動を変えることができます。Drag and Drop in The Emacs Lisp Reference Manualを参照してください。

This page has generated for branch:work/emacs-30_8ac894e2246f25d2a2a97d866b10e6e0b0fede5a, commit:b7b3c5b81a7a4eec61faa3ed3d7c731d52d3987b to check Japanese translation.