Subject: bug#77731: [PATCH] Add yank-media-handler for copied files from file manager

From: Visuwesh <[email-masked]>
Date: Sun, 11 May 2025 01:03:53 +0530

I am quite confused as to what Po Lu wants me to do, TBH.  I can start working on the patch again if I get an explanation of the work that needs to be done.

On 10 May 2025 14:57:32 GMT+05:30, Eli Zaretskii <[email-masked]> wrote:
>Ping! Ping!  Would people please respond?
>
>> Cc: [email-masked], [email-masked]
>> Date: Sat, 26 Apr 2025 14:25:39 +0300
>> From: Eli Zaretskii <[email-masked]>
>> 
>> Ping!  How can we make progress with this issue?
>> 
>> > From: Visuwesh <[email-masked]>
>> > Cc: Eli Zaretskii <[email-masked]>,  [email-masked]
>> > Date: Fri, 11 Apr 2025 18:41:08 +0530
>> > 
>> > [வெள்ளி ஏப்ரல் 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.
>> > 
>> > > 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.
>> > 
>> > 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?
>> > 
>> 
>> 
>> 
>>