5

Using Emacs 24.5 on a Gentoo/Kde workstation. Drag-and-drop of files used to work okay (as far as I remember), to open a new buffer on the dragged file.

Same behaviour when using emacs -Q.

It does not work anymore (FYI, I downgraded to emacs-23 (after reading Boregard's comment) and the drag-n-drop works perfectly.), or rather it sometimes works, but more often than not Emacs only displays "5 1" on the command line and adds "5 1" in the messages buffer.

This occurs for all users on the relevant computer. I guess it comes from some weird configuration on our side (otherwise other people would complain about this missing functionality). But how to pinpoint the source of this problem (and solve it, of course)?

Here is the output of M-x describe-variable x-dnd-types-alist requested by Nsukami _:

x-dnd-types-alist is a variable defined in `x-dnd.el'.
Value: (("text/uri-list" . x-dnd-handle-uri-list)
   ("text/x-moz-url" . x-dnd-handle-moz-url)
   ("_NETSCAPE_URL" . x-dnd-handle-uri-list)
   ("FILE_NAME" . x-dnd-handle-file-name)
   ("UTF8_STRING" . x-dnd-insert-utf8-text)
   ("text/plain;charset=UTF-8" . x-dnd-insert-utf8-text)
   ("text/plain;charset=utf-8" . x-dnd-insert-utf8-text)
   ("text/unicode" . x-dnd-insert-utf16-text)
   ("text/plain" . dnd-insert-text)
   ("COMPOUND_TEXT" . x-dnd-insert-ctext)
   ("STRING" . dnd-insert-text)
   ("TEXT" . dnd-insert-text))

EDIT: Sorry to be late in answering questions...

@Drew : same behaviour when using 'emacs -Q'

@Nsukami : here is the data

x-dnd-types-alist is a variable defined in `x-dnd.el'.
Value: (("text/uri-list" . x-dnd-handle-uri-list)
   ("text/x-moz-url" . x-dnd-handle-moz-url)
   ("_NETSCAPE_URL" . x-dnd-handle-uri-list)
   ("FILE_NAME" . x-dnd-handle-file-name)
   ("UTF8_STRING" . x-dnd-insert-utf8-text)
   ("text/plain;charset=UTF-8" . x-dnd-insert-utf8-text)
   ("text/plain;charset=utf-8" . x-dnd-insert-utf8-text)
   ("text/unicode" . x-dnd-insert-utf16-text)
   ("text/plain" . dnd-insert-text)
   ("COMPOUND_TEXT" . x-dnd-insert-ctext)
   ("STRING" . dnd-insert-text)
   ("TEXT" . dnd-insert-text))

FYI, I downgraded to emacs-23 (after reading Boregard's comment) and the drag-n-drop works perfectly.

Drew
  • 77,472
  • 10
  • 114
  • 243
NdC
  • 51
  • 1
  • 1
    "5 1"? What is that from? Do you see this behavior if you start Emacs using emacs -Q (no init file)? If so, and it is reproducible, consider filing an Emacs bug report (M-x report-emacs-bug), providing a reproducible recipe from emacs -Q. – Drew Oct 24 '15 at 08:09
  • 1
    Can you please tell us the result of M-x describe-variable x-dnd-types-alist? – Nsukami _ Oct 24 '15 at 09:57
  • 1
    I'vo got the same problem in Debian Jessie with KDE. It works with emacs 23, but with emacs 24 the message buffer shows "5 1" as soon as a file is dragged over emacs (not yet dropped, still holding the mouse button pressed). The problem also occurs with emacs -Q. –  Nov 15 '15 at 16:04
  • I tackled the same issue with the same output in the echo ("5 1"). Meanwhile, I tried to dnd text from Chrome (you have not indicated where from you were dragging), which did not work, but it works perfectly with Firefox. – stlk Jan 31 '19 at 10:46

1 Answers1

1

The "5 1" is coming from the x-dnd-handle-xdnd function. According to bug#19885 in the GNU Bug Tracker, the reason that drag-and-drop from Chrome does not work is that Emacs uses the XdndActionPrivate action, which Chrome does not honor. A workaround from the bug report is to customize Emacs to use the XdndActionCopy action instead:

(defun my-x-dnd-test-function (_window _action types)
  "X-DND test function that returns copy instead of private as action
Otherwise the same as the default function"
  (let ((type (x-dnd-choose-type types)))
    (when type (cons 'copy type))))

(setq x-dnd-test-function #'my-x-dnd-test-function)

Miciah
  • 31
  • 2