Next: , Previous: Window System Selections, Up: Frames

29.19 Drag and Drop

When a user drags something from another application over Emacs, that other application expects Emacs to tell it if Emacs can handle the data that is dragged. The variable x-dnd-test-function is used by Emacs to determine what to reply. The default value is x-dnd-default-test-function which accepts drops if the type of the data to be dropped is present in x-dnd-known-types. You can customize x-dnd-test-function and/or x-dnd-known-types if you want Emacs to accept or reject drops based on some other criteria.

If you want to change the way Emacs handles drop of different types or add a new type, customize x-dnd-types-alist. This requires detailed knowledge of what types other applications use for drag and drop.

When an URL is dropped on Emacs it may be a file, but it may also be another URL type (ftp, http, etc.). Emacs first checks dnd-protocol-alist to determine what to do with the URL. If there is no match there and if browse-url-browser-function is an alist, Emacs looks for a match there. If no match is found the text for the URL is inserted. If you want to alter Emacs behavior, you can customize these variables.