GNU bug report logs -
#77731
[PATCH] Add yank-media-handler for copied files from file manager
Previous Next
Full log
Message #11 received at 77731 <at> debbugs.gnu.org (full text, mbox):
[வெள்ளி ஏப்ரல் 11, 2025] Eli Zaretskii wrote:
>> 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?
Sure, I can prepare a patch that would copy/rename the file if the user
has copy/cut the file from her file manager. I have code for this
living in my init file.
>> 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?
I believe covering x-special/gnome-copied-files will cover a large
ground of file managers. Obviously, I have no idea how to support file
managers in MacOS or Windows.
>> +(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.
See above. I can say that it works with pcmanfm, xfe, and thunar if my
memory serves right.
> Btw, isn't copy/paste of files similar or maybe even equivalent to
> drag-n-drop?
They essentially serve to perform the same function in most cases, yes.
> 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.
As in, call the relevant function in dnd-protocol-alist for ^file:///?
This hasn't crossed my mind. I am not opposed to this idea.
This bug report was last modified 62 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.