GNU bug report logs -
#77731
[PATCH] Add yank-media-handler for copied files from file manager
Previous Next
Full log
View this message in rfc822 format
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Visuwesh <visuweshm <at> gmail.com>
>> Date: Fri, 11 Apr 2025 14:58:32 +0530
>>
>> [ This has been sitting in my drafts folder for many months now. ]
>>
>> Attached patch adds a yank-media-handler to message-mode to attach files
>> copied/cut from a file manager. I tested this patch using pcmanfm and
>> xfe. The regexp for the media-type was chosen after the blogpost [1],
>> pcmanfm in particular sets the media-type to
>> x-special/gnome-copied-files.
>
> Thanks, but copy/paste operations on files should first and foremost
> be supported in Dired, no? Limiting such support to message-mode
> seems too narrow and much less useful than it could be, let alone what
> users would expect.
>
> Can we support this in Dired?
+1.
>> I strip the null byte in the split-string call in the handler because
>> pcmanfm adds a null byte at the end of clipboard selection. I don't
>> know if this is the case with other file managers.
>>
>> I also cannot find the spec of this clipboard type but [2] and pcmanfm
>> suggests that the selection is
>>
>> OPERATION
>> file://FILE1
>> file://FILE2...
>>
>> where OPERATION is either cut or copy, and the rest of the lines are
>> links to the files. I do the same as what Org does to parse the above.
>>
>> 1. https://larsee.com/blog/2019/05/clipboard-files/
>> 2. https://indigo.re/posts/2021-12-21-clipboard-data.html
>
> I wonder if this is too specific to the specific file managers you
> tested this with. If it is, should we try to support more file
> managers?
>
>> +(defun message--yank-media-copied-files-handler (_ data)
>> + "Attach files copied/cut from the file manager.
>
> 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.
If you like, you may implement a rough draft that functions
satisfactorily with whatever file managers you test, and I shall supply
its deficiencies as best I can.
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.