GNU bug report logs - #77731
[PATCH] Add yank-media-handler for copied files from file manager

Previous Next

Package: emacs;

Reported by: Visuwesh <visuweshm <at> gmail.com>

Date: Fri, 11 Apr 2025 09:29:01 UTC

Severity: normal

Tags: patch

Full log


View this message in rfc822 format

From: Po Lu <luangruo <at> yahoo.com>
To: Visuwesh <visuweshm <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 77731 <at> debbugs.gnu.org
Subject: bug#77731: [PATCH] Add yank-media-handler for copied files from file manager
Date: Sat, 12 Apr 2025 09:28:57 +0800
Visuwesh <visuweshm <at> gmail.com> writes:

> [வெள்ளி ஏப்ரல் 11, 2025] Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" wrote:
>
>>> The name and the doc string should be more specific to the file
>>> managers for which this is supposed to work.  I doubt that these
>>> details are general enough to say that any file manager capable of
>>> copy/pasting files will behave like that.
>>
>>> Btw, isn't copy/paste of files similar or maybe even equivalent to
>>> drag-n-drop?  If so, perhaps a better way would be to use the DND
>>> machinery we have in Emacs?  Adding Po Lu in case he has opinions or
>>> comments about this.
>>
>> Regrettably not, since the formats concerned differ subtly and DND gives
>> a weight to negotiating actions on dropped data that is undue for a
>> simple copy/paste operation.  The selection formats you must recognize
>> are `text/uri-list' (which is identical to its Xdnd variant), FILE_NAME,
>> and FILE, which are NULL-separated lists of strings, and numerous ad hoc
>> formats defined by file managers and desktop environments.
>
> What's wrong with doing the following?
>
>     (defun message--yank-media-copied-files-handler (_ data)
>       "Attach files copied/cut from the file manager.
>     DATA is a string where the first line is the operation to
>     perform: copy or cut.  Rest are file: links.  The operation is
>     always ignored, and the files are only attached."
>       (let ((files (split-string data "[\0\n\r]" t)))
>         (dnd-handle-multiple-urls (selected-window)
>                                   (cdr files)
>                                   (pcase (car files)
>                                     (`"copy" 'copy)
>                                     (`"cut" 'move)
>                                     (_ 'private)))))
>
> It calls mml-dnd-attach-file in message-mode buffer.

It expects and respects options specific to drag and drop.  `(car
files)' is also certainly not guaranteed to designate the action to
take.

> Considering that text/uri-list and friends seem to be considered in
> others part of the code, is there a function that would parse its
> format?

Not that I'm aware of.




This bug report was last modified 9 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.