Subject: Re: bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled

From: Jared Finder <[email-masked]>
Date: Fri, 20 Dec 2024 10:48:18 -0800

On 2024-12-19 09:23, Ship Mints wrote:
> On Thu, Dec 19, 2024 at 6:16 AM Jared Finder <[email-masked]> wrote:
>> On 2024-12-18 09:50, Ship Mints wrote:
>>> 
>>> I think someone suggested bringing xclip (seems properly licensed) 
>>> into
>>> the core and now might be a good time to consider that.
>> 
>> This seems like a good idea to me too. I think we'd also want a 
>> variable
>> to disable auto-enabling xclip-mode (let's call it
>> "xterm-enable-xclip-fallback" and assume it defaults to t). So when
>> Emacs detects it is running in Terminal.app and
>> xterm-enable-xclip-fallback is set, it enables xclip-mode. In all 
>> other
>> cases, no change is made.
>> 
>> This does still result in a user-facing behavior change: instead of
>> pressing Command-c, a user would have to press Emacs' key binding, M-w
>> (or C-c if cua-mode is enabled).
>> 
> I took a look at xclip's code, and its scope is larger than just macOS 
> pasteboard integration. If I volunteered to help adopt xclip into 
> Emacs, I'd have no easy way to test its scope beyond macOS. Perhaps it 
> should remain an external package and people just install when needed. 
> Equivalent mac-specific pasteboard integration could live in ns-win.el 
> and be narrower in scope just for macOS users.

I tried a handful of terminal in Linux and it appears that while the 
majority support OSC 52, a significant amount of them don't. The biggest 
gap is all the vte based ones like Gnome Terminal or XFCE Terminal. 
These are their windowing system's default terminals, so there's likely 
a lot of usage here.

If we want to ensure mouse drag to highlight, copy within the terminal 
Emacs, followed by a paste outside of the terminal still work we would 
need to bring xclip into core. I think this would be generally good to 
do anyways. I didn't know about the xclip package and it would have 
significantly improved my workflows with xterm-mouse-mode. I suspect 
many other users of xterm-mouse-mode are in the same boat.

   -- MJF