unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
@ 2024-12-12 17:54 Filipp Gunbin
  2024-12-12 18:08 ` Ship Mints
                   ` (2 more replies)
  0 siblings, 3 replies; 51+ messages in thread
From: Filipp Gunbin @ 2024-12-12 17:54 UTC (permalink / raw)
  To: 74833

macOS, Terminal.app, xterm-mouse-mode enabled
emacs -nw -Q
Select something with mouse, press Command-c
Try to paste into another program - text is not in the clipboard

Perhaps this is not new, I just tried xterm-mouse-mode for the first
time, given that it's now the default in master.

Trying different combinations of select-enable-clipboard and
select-enable-primary did not help (that variables are all I know in
this area).

Thanks.


In GNU Emacs 31.0.50 (build 43, aarch64-apple-darwin23.6.0, NS
 appkit-2487.70 Version 14.6 (Build 23G80)) of 2024-12-12 built on
 localhost
Repository revision: 9ccd459e8452cc9e6e81e53f26bbeef20d2d5bb7
Repository branch: master
System Description:  macOS 14.6

Configured using:
 'configure --enable-check-lisp-object-type --with-file-notification=no
 --with-native-compilation=no'

Configured features:
ACL GLIB GNUTLS LCMS2 LIBXML2 MODULES NS PDUMPER PNG RSVG SQLITE3
THREADS TOOLKIT_SCROLL_BARS WEBP XIM ZLIB





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-12 17:54 bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled Filipp Gunbin
@ 2024-12-12 18:08 ` Ship Mints
  2024-12-12 18:18   ` Filipp Gunbin
  2024-12-12 19:15 ` Eli Zaretskii
  2024-12-16  1:41 ` Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2 siblings, 1 reply; 51+ messages in thread
From: Ship Mints @ 2024-12-12 18:08 UTC (permalink / raw)
  To: 74833

[-- Attachment #1: Type: text/plain, Size: 1275 bytes --]

You need something like https://elpa.gnu.org/packages/xclip.html to assist
connecting macOS terminal Emacs to the system pasteboard/clipboard.

On Thu, Dec 12, 2024 at 12:56 PM Filipp Gunbin <fgunbin@fastmail.fm> wrote:

> macOS, Terminal.app, xterm-mouse-mode enabled
> emacs -nw -Q
> Select something with mouse, press Command-c
> Try to paste into another program - text is not in the clipboard
>
> Perhaps this is not new, I just tried xterm-mouse-mode for the first
> time, given that it's now the default in master.
>
> Trying different combinations of select-enable-clipboard and
> select-enable-primary did not help (that variables are all I know in
> this area).
>
> Thanks.
>
>
> In GNU Emacs 31.0.50 (build 43, aarch64-apple-darwin23.6.0, NS
>  appkit-2487.70 Version 14.6 (Build 23G80)) of 2024-12-12 built on
>  localhost
> Repository revision: 9ccd459e8452cc9e6e81e53f26bbeef20d2d5bb7
> Repository branch: master
> System Description:  macOS 14.6
>
> Configured using:
>  'configure --enable-check-lisp-object-type --with-file-notification=no
>  --with-native-compilation=no'
>
> Configured features:
> ACL GLIB GNUTLS LCMS2 LIBXML2 MODULES NS PDUMPER PNG RSVG SQLITE3
> THREADS TOOLKIT_SCROLL_BARS WEBP XIM ZLIB
>
>
>
>

[-- Attachment #2: Type: text/html, Size: 1778 bytes --]

^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-12 18:08 ` Ship Mints
@ 2024-12-12 18:18   ` Filipp Gunbin
  2024-12-12 18:20     ` Ship Mints
  0 siblings, 1 reply; 51+ messages in thread
From: Filipp Gunbin @ 2024-12-12 18:18 UTC (permalink / raw)
  To: Ship Mints; +Cc: 74833

On 12/12/2024 13:08 -0500, Ship Mints wrote:

> You need something like https://elpa.gnu.org/packages/xclip.html to assist
> connecting macOS terminal Emacs to the system pasteboard/clipboard.

Thanks, BTW paste with Command-V works, it's just copy that doesn't
work.  Probably I'll disable xterm-mouse-mode anyway, but it would be
nice to have this resolved in Emacs.





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-12 18:18   ` Filipp Gunbin
@ 2024-12-12 18:20     ` Ship Mints
  0 siblings, 0 replies; 51+ messages in thread
From: Ship Mints @ 2024-12-12 18:20 UTC (permalink / raw)
  To: Filipp Gunbin; +Cc: 74833

[-- Attachment #1: Type: text/plain, Size: 702 bytes --]

I think that's because Terminal.app is providing paste, not Emacs. If you
use Emacs commands to put text into the kill-ring, it has to make it from
there into the pasteboard/clipboard and that's what xclip does for you.

On Thu, Dec 12, 2024 at 1:18 PM Filipp Gunbin <fgunbin@fastmail.fm> wrote:

> On 12/12/2024 13:08 -0500, Ship Mints wrote:
>
> > You need something like https://elpa.gnu.org/packages/xclip.html to
> assist
> > connecting macOS terminal Emacs to the system pasteboard/clipboard.
>
> Thanks, BTW paste with Command-V works, it's just copy that doesn't
> work.  Probably I'll disable xterm-mouse-mode anyway, but it would be
> nice to have this resolved in Emacs.
>

[-- Attachment #2: Type: text/html, Size: 1187 bytes --]

^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-12 17:54 bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled Filipp Gunbin
  2024-12-12 18:08 ` Ship Mints
@ 2024-12-12 19:15 ` Eli Zaretskii
  2024-12-12 19:18   ` Ship Mints
  2024-12-12 19:55   ` Gerd Möllmann
  2024-12-16  1:41 ` Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2 siblings, 2 replies; 51+ messages in thread
From: Eli Zaretskii @ 2024-12-12 19:15 UTC (permalink / raw)
  To: Filipp Gunbin; +Cc: 74833

> From: Filipp Gunbin <fgunbin@fastmail.fm>
> Date: Thu, 12 Dec 2024 20:54:53 +0300
> 
> macOS, Terminal.app, xterm-mouse-mode enabled
> emacs -nw -Q
> Select something with mouse, press Command-c
> Try to paste into another program - text is not in the clipboard
> 
> Perhaps this is not new, I just tried xterm-mouse-mode for the first
> time, given that it's now the default in master.
> 
> Trying different combinations of select-enable-clipboard and
> select-enable-primary did not help (that variables are all I know in
> this area).

Does the macOS Terminal.app support the xterm mouse protocol?





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-12 19:15 ` Eli Zaretskii
@ 2024-12-12 19:18   ` Ship Mints
  2024-12-12 19:32     ` Eli Zaretskii
  2024-12-12 19:55   ` Gerd Möllmann
  1 sibling, 1 reply; 51+ messages in thread
From: Ship Mints @ 2024-12-12 19:18 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 74833, Filipp Gunbin

[-- Attachment #1: Type: text/plain, Size: 892 bytes --]

It supports a subset of mouse behavior via this user setting:

https://support.apple.com/guide/terminal/turn-on-mouse-reporting-trmlc69728a5/2.12/mac/11.0

On Thu, Dec 12, 2024 at 2:16 PM Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Filipp Gunbin <fgunbin@fastmail.fm>
> > Date: Thu, 12 Dec 2024 20:54:53 +0300
> >
> > macOS, Terminal.app, xterm-mouse-mode enabled
> > emacs -nw -Q
> > Select something with mouse, press Command-c
> > Try to paste into another program - text is not in the clipboard
> >
> > Perhaps this is not new, I just tried xterm-mouse-mode for the first
> > time, given that it's now the default in master.
> >
> > Trying different combinations of select-enable-clipboard and
> > select-enable-primary did not help (that variables are all I know in
> > this area).
>
> Does the macOS Terminal.app support the xterm mouse protocol?
>
>
>
>

[-- Attachment #2: Type: text/html, Size: 1628 bytes --]

^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-12 19:18   ` Ship Mints
@ 2024-12-12 19:32     ` Eli Zaretskii
  2024-12-12 20:07       ` Gerd Möllmann
  2024-12-12 20:31       ` Ship Mints
  0 siblings, 2 replies; 51+ messages in thread
From: Eli Zaretskii @ 2024-12-12 19:32 UTC (permalink / raw)
  To: Ship Mints; +Cc: 74833, fgunbin

> From: Ship Mints <shipmints@gmail.com>
> Date: Thu, 12 Dec 2024 14:18:47 -0500
> Cc: Filipp Gunbin <fgunbin@fastmail.fm>, 74833@debbugs.gnu.org
> 
> It supports a subset of mouse behavior via this user setting:
> 
> https://support.apple.com/guide/terminal/turn-on-mouse-reporting-trmlc69728a5/2.12/mac/11.0

That doesn't tell enough.  xterm.el and xterm-mouse assume full
support for the xterm protocols, so partial support could well explain
why things don't work.

In general, I don't recommend turn on xterm features on terminals
other than xterm, unless they are faithful emulations of xterm.





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-12 19:15 ` Eli Zaretskii
  2024-12-12 19:18   ` Ship Mints
@ 2024-12-12 19:55   ` Gerd Möllmann
  1 sibling, 0 replies; 51+ messages in thread
From: Gerd Möllmann @ 2024-12-12 19:55 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 74833, Filipp Gunbin

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Filipp Gunbin <fgunbin@fastmail.fm>
>> Date: Thu, 12 Dec 2024 20:54:53 +0300
>> 
>> macOS, Terminal.app, xterm-mouse-mode enabled
>> emacs -nw -Q
>> Select something with mouse, press Command-c
>> Try to paste into another program - text is not in the clipboard
>> 
>> Perhaps this is not new, I just tried xterm-mouse-mode for the first
>> time, given that it's now the default in master.
>> 
>> Trying different combinations of select-enable-clipboard and
>> select-enable-primary did not help (that variables are all I know in
>> this area).
>
> Does the macOS Terminal.app support the xterm mouse protocol?

Yes it does.

The clipboard problem is something unrelated. Terminal applications can
access the macOS clipboard via command line utilities pbcopy and
pbpaste. I'm using the package xclip for that, which is very simple to
use

  ;; Clipboard support in terminal Emacs using pbcopy/pbpaste.
  (use-package xclip :straight t
    :if (not (display-graphic-p))
    :config (xclip-mode 1))

Command-C, Command-V in Terminal.app are used by Terminal.app itself and
not by applications running in the terminal emulator. For example, to
copy shell output or paste something as shell input.

I don't think Terminal.app allows altering Command-V etc. so that Emacs
could use them. Other terminal emulators like iTerm allow doing that.

In summary, this is not a bug.





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-12 19:32     ` Eli Zaretskii
@ 2024-12-12 20:07       ` Gerd Möllmann
  2024-12-12 20:31       ` Ship Mints
  1 sibling, 0 replies; 51+ messages in thread
From: Gerd Möllmann @ 2024-12-12 20:07 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 74833, fgunbin, Ship Mints

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Ship Mints <shipmints@gmail.com>
>> Date: Thu, 12 Dec 2024 14:18:47 -0500
>> Cc: Filipp Gunbin <fgunbin@fastmail.fm>, 74833@debbugs.gnu.org
>> 
>> It supports a subset of mouse behavior via this user setting:
>> 
>> https://support.apple.com/guide/terminal/turn-on-mouse-reporting-trmlc69728a5/2.12/mac/11.0
>
> That doesn't tell enough.  xterm.el and xterm-mouse assume full
> support for the xterm protocols, so partial support could well explain
> why things don't work.
>
> In general, I don't recommend turn on xterm features on terminals
> other than xterm, unless they are faithful emulations of xterm.

There is, for some reason, a checkbox in Terminal.app Settings dialog
with which one can make Terminal.app not send xterm mouse escape
sequences. If it's off when Emacs runs it doesn't get informed about
mouse clicks and so on. So nothing happens.





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-12 19:32     ` Eli Zaretskii
  2024-12-12 20:07       ` Gerd Möllmann
@ 2024-12-12 20:31       ` Ship Mints
  2024-12-13  7:21         ` Eli Zaretskii
  1 sibling, 1 reply; 51+ messages in thread
From: Ship Mints @ 2024-12-12 20:31 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 74833, fgunbin

[-- Attachment #1: Type: text/plain, Size: 986 bytes --]

I have xterm-mouse-mode enabled when in tty mode on macOS and it does work
for clicking/selecting but this is independent of integrating the kill ring
with the pasteboard. I am unaware of how to test the completeness of the
xterm mouse protocol support, however.

On Thu, Dec 12, 2024 at 2:32 PM Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Ship Mints <shipmints@gmail.com>
> > Date: Thu, 12 Dec 2024 14:18:47 -0500
> > Cc: Filipp Gunbin <fgunbin@fastmail.fm>, 74833@debbugs.gnu.org
> >
> > It supports a subset of mouse behavior via this user setting:
> >
> >
> https://support.apple.com/guide/terminal/turn-on-mouse-reporting-trmlc69728a5/2.12/mac/11.0
>
> That doesn't tell enough.  xterm.el and xterm-mouse assume full
> support for the xterm protocols, so partial support could well explain
> why things don't work.
>
> In general, I don't recommend turn on xterm features on terminals
> other than xterm, unless they are faithful emulations of xterm.
>

[-- Attachment #2: Type: text/html, Size: 1721 bytes --]

^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-12 20:31       ` Ship Mints
@ 2024-12-13  7:21         ` Eli Zaretskii
  2024-12-13 14:46           ` Ship Mints
  2024-12-13 16:35           ` Filipp Gunbin
  0 siblings, 2 replies; 51+ messages in thread
From: Eli Zaretskii @ 2024-12-13  7:21 UTC (permalink / raw)
  To: Ship Mints; +Cc: 74833, fgunbin

> From: Ship Mints <shipmints@gmail.com>
> Date: Thu, 12 Dec 2024 15:31:00 -0500
> Cc: fgunbin@fastmail.fm, 74833@debbugs.gnu.org
> 
> I have xterm-mouse-mode enabled when in tty mode on macOS and it does work for clicking/selecting but
> this is independent of integrating the kill ring with the pasteboard. I am unaware of how to test the
> completeness of the xterm mouse protocol support, however.

So why is this an Emacs bug?  It sounds like the OP expects something
to happen which shouldn't, because the xterm protocol for selections
and the clipboard are not supported by Terminal.app?  In that case,
this could be at best a feature request, not a bug.





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-13  7:21         ` Eli Zaretskii
@ 2024-12-13 14:46           ` Ship Mints
  2024-12-13 16:35           ` Filipp Gunbin
  1 sibling, 0 replies; 51+ messages in thread
From: Ship Mints @ 2024-12-13 14:46 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 74833, fgunbin

[-- Attachment #1: Type: text/plain, Size: 969 bytes --]

I agree. I think OP was expressing surprise at features not working "out of
the box." I suppose macOS terminal xmouse and kill-ring pasteboard
integration deserve a mention in PROBLEMS.

On Fri, Dec 13, 2024 at 2:21 AM Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Ship Mints <shipmints@gmail.com>
> > Date: Thu, 12 Dec 2024 15:31:00 -0500
> > Cc: fgunbin@fastmail.fm, 74833@debbugs.gnu.org
> >
> > I have xterm-mouse-mode enabled when in tty mode on macOS and it does
> work for clicking/selecting but
> > this is independent of integrating the kill ring with the pasteboard. I
> am unaware of how to test the
> > completeness of the xterm mouse protocol support, however.
>
> So why is this an Emacs bug?  It sounds like the OP expects something
> to happen which shouldn't, because the xterm protocol for selections
> and the clipboard are not supported by Terminal.app?  In that case,
> this could be at best a feature request, not a bug.
>

[-- Attachment #2: Type: text/html, Size: 1553 bytes --]

^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-13  7:21         ` Eli Zaretskii
  2024-12-13 14:46           ` Ship Mints
@ 2024-12-13 16:35           ` Filipp Gunbin
  2024-12-13 16:42             ` Ship Mints
  2024-12-13 16:49             ` Eli Zaretskii
  1 sibling, 2 replies; 51+ messages in thread
From: Filipp Gunbin @ 2024-12-13 16:35 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 74833, Ship Mints

On 13/12/2024 09:21 +0200, Eli Zaretskii wrote:

>> From: Ship Mints <shipmints@gmail.com>
>> Date: Thu, 12 Dec 2024 15:31:00 -0500
>> Cc: fgunbin@fastmail.fm, 74833@debbugs.gnu.org
>> 
>> I have xterm-mouse-mode enabled when in tty mode on macOS and it does work for clicking/selecting but
>> this is independent of integrating the kill ring with the pasteboard. I am unaware of how to test the
>> completeness of the xterm mouse protocol support, however.
>
> So why is this an Emacs bug?  It sounds like the OP expects something
> to happen which shouldn't, because the xterm protocol for selections
> and the clipboard are not supported by Terminal.app?  In that case,
> this could be at best a feature request, not a bug.

I'll try to explain differently.

Without xterm-mouse-mode you can copy/paste from/into Terminal.app
window, looks like Terminal.app gives this ability on its own.  This is
not integration with Emacs kill ring, no.  Emacs cursor does not react
to mouse clicks, and selection happens with OS mouse pointer.  Paste
works rather slow (bad idea to paste large chunks of text), but
tolerable.

Now, yesterday my daily master build got me xterm-mouse-mode enabled, so
I did some testing just out of curiosity.  Most of the things work,
including clicking and selection.  However, Command-C now just doesn't
copy text to OS clipboard.  And it's non-obvious that you should disable
xterm-mouse-mode to be able to copy.

That's why I filed this bug - because previous behavior was not ideal
but working, and now only paste works.

Maybe we should just avoid enabling xterm-mouse-mode in Terminal.app.
Maybe functionality of xclip should be in core.





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-13 16:35           ` Filipp Gunbin
@ 2024-12-13 16:42             ` Ship Mints
  2024-12-13 16:52               ` Ship Mints
  2024-12-13 16:49             ` Eli Zaretskii
  1 sibling, 1 reply; 51+ messages in thread
From: Ship Mints @ 2024-12-13 16:42 UTC (permalink / raw)
  To: Filipp Gunbin; +Cc: Eli Zaretskii, 74833

[-- Attachment #1: Type: text/plain, Size: 2554 bytes --]

What you describe is normal behavior, even if it appears confusing. It's an
"impedance mismatch" between terminal.app and being in a "curses" window.
Terminal doesn't "see" selected text and hence Command-C is disabled. This
is the opposite for a basic shell where terminal sees the text because
it controls selection. You can see this by pulling down the Edit menu and
seeing Copy grayed out. As far as how xterm-mouse-mode interferes with
Command-C I'd have to disable it myself and see what's going on. Not sure
how much value that adds, though. If you enable xclip, you'll get what you
want being inside Emacs, after all, using M-w gets your selected text
copied to the pasteboard.

On Fri, Dec 13, 2024 at 11:35 AM Filipp Gunbin <fgunbin@fastmail.fm> wrote:

> On 13/12/2024 09:21 +0200, Eli Zaretskii wrote:
>
> >> From: Ship Mints <shipmints@gmail.com>
> >> Date: Thu, 12 Dec 2024 15:31:00 -0500
> >> Cc: fgunbin@fastmail.fm, 74833@debbugs.gnu.org
> >>
> >> I have xterm-mouse-mode enabled when in tty mode on macOS and it does
> work for clicking/selecting but
> >> this is independent of integrating the kill ring with the pasteboard. I
> am unaware of how to test the
> >> completeness of the xterm mouse protocol support, however.
> >
> > So why is this an Emacs bug?  It sounds like the OP expects something
> > to happen which shouldn't, because the xterm protocol for selections
> > and the clipboard are not supported by Terminal.app?  In that case,
> > this could be at best a feature request, not a bug.
>
> I'll try to explain differently.
>
> Without xterm-mouse-mode you can copy/paste from/into Terminal.app
> window, looks like Terminal.app gives this ability on its own.  This is
> not integration with Emacs kill ring, no.  Emacs cursor does not react
> to mouse clicks, and selection happens with OS mouse pointer.  Paste
> works rather slow (bad idea to paste large chunks of text), but
> tolerable.
>
> Now, yesterday my daily master build got me xterm-mouse-mode enabled, so
> I did some testing just out of curiosity.  Most of the things work,
> including clicking and selection.  However, Command-C now just doesn't
> copy text to OS clipboard.  And it's non-obvious that you should disable
> xterm-mouse-mode to be able to copy.
>
> That's why I filed this bug - because previous behavior was not ideal
> but working, and now only paste works.
>
> Maybe we should just avoid enabling xterm-mouse-mode in Terminal.app.
> Maybe functionality of xclip should be in core.
>

[-- Attachment #2: Type: text/html, Size: 3323 bytes --]

^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-13 16:35           ` Filipp Gunbin
  2024-12-13 16:42             ` Ship Mints
@ 2024-12-13 16:49             ` Eli Zaretskii
  2024-12-13 20:32               ` Filipp Gunbin
  1 sibling, 1 reply; 51+ messages in thread
From: Eli Zaretskii @ 2024-12-13 16:49 UTC (permalink / raw)
  To: Filipp Gunbin; +Cc: 74833, shipmints

> From: Filipp Gunbin <fgunbin@fastmail.fm>
> Cc: Ship Mints <shipmints@gmail.com>,  74833@debbugs.gnu.org
> Date: Fri, 13 Dec 2024 19:35:15 +0300
> 
> On 13/12/2024 09:21 +0200, Eli Zaretskii wrote:
> 
> > So why is this an Emacs bug?  It sounds like the OP expects something
> > to happen which shouldn't, because the xterm protocol for selections
> > and the clipboard are not supported by Terminal.app?  In that case,
> > this could be at best a feature request, not a bug.
> 
> I'll try to explain differently.
> 
> Without xterm-mouse-mode you can copy/paste from/into Terminal.app
> window, looks like Terminal.app gives this ability on its own.  This is
> not integration with Emacs kill ring, no.  Emacs cursor does not react
> to mouse clicks, and selection happens with OS mouse pointer.  Paste
> works rather slow (bad idea to paste large chunks of text), but
> tolerable.
> 
> Now, yesterday my daily master build got me xterm-mouse-mode enabled, so
> I did some testing just out of curiosity.  Most of the things work,
> including clicking and selection.  However, Command-C now just doesn't
> copy text to OS clipboard.  And it's non-obvious that you should disable
> xterm-mouse-mode to be able to copy.

xterm-mouse-mode is supposed to be enabled only on terminals that load
xterm.el, which means they are xterm-compatible.  Does Terminal.app
load xterm.el on startup?

> Maybe we should just avoid enabling xterm-mouse-mode in Terminal.app.

It should already be so, AFAIU.

> Maybe functionality of xclip should be in core.

Only if its developer submits it for inclusion.





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-13 16:42             ` Ship Mints
@ 2024-12-13 16:52               ` Ship Mints
  2024-12-13 20:46                 ` Filipp Gunbin
  0 siblings, 1 reply; 51+ messages in thread
From: Ship Mints @ 2024-12-13 16:52 UTC (permalink / raw)
  To: Filipp Gunbin; +Cc: Eli Zaretskii, 74833

[-- Attachment #1: Type: text/plain, Size: 3165 bytes --]

Try experimenting with alternative terminals such as
https://wezfurlong.org/wezterm/ which I've used and where I remap all of
the keys to pass through to Emacs vs. letting the terminal application
abscond with functions like Command-C. I can share my wezterm configuration
off line if you're interested. I still remain mostly GUI on macOS but
occasionally use the terminal, and especially useful for running Emacs via
ssh on a remote computer (vs. tramp).

On Fri, Dec 13, 2024 at 11:42 AM Ship Mints <shipmints@gmail.com> wrote:

> What you describe is normal behavior, even if it appears confusing. It's
> an "impedance mismatch" between terminal.app and being in a "curses"
> window. Terminal doesn't "see" selected text and hence Command-C is
> disabled. This is the opposite for a basic shell where terminal sees the
> text because it controls selection. You can see this by pulling down the
> Edit menu and seeing Copy grayed out. As far as how xterm-mouse-mode
> interferes with Command-C I'd have to disable it myself and see what's
> going on. Not sure how much value that adds, though. If you enable xclip,
> you'll get what you want being inside Emacs, after all, using M-w gets your
> selected text copied to the pasteboard.
>
> On Fri, Dec 13, 2024 at 11:35 AM Filipp Gunbin <fgunbin@fastmail.fm>
> wrote:
>
>> On 13/12/2024 09:21 +0200, Eli Zaretskii wrote:
>>
>> >> From: Ship Mints <shipmints@gmail.com>
>> >> Date: Thu, 12 Dec 2024 15:31:00 -0500
>> >> Cc: fgunbin@fastmail.fm, 74833@debbugs.gnu.org
>> >>
>> >> I have xterm-mouse-mode enabled when in tty mode on macOS and it does
>> work for clicking/selecting but
>> >> this is independent of integrating the kill ring with the pasteboard.
>> I am unaware of how to test the
>> >> completeness of the xterm mouse protocol support, however.
>> >
>> > So why is this an Emacs bug?  It sounds like the OP expects something
>> > to happen which shouldn't, because the xterm protocol for selections
>> > and the clipboard are not supported by Terminal.app?  In that case,
>> > this could be at best a feature request, not a bug.
>>
>> I'll try to explain differently.
>>
>> Without xterm-mouse-mode you can copy/paste from/into Terminal.app
>> window, looks like Terminal.app gives this ability on its own.  This is
>> not integration with Emacs kill ring, no.  Emacs cursor does not react
>> to mouse clicks, and selection happens with OS mouse pointer.  Paste
>> works rather slow (bad idea to paste large chunks of text), but
>> tolerable.
>>
>> Now, yesterday my daily master build got me xterm-mouse-mode enabled, so
>> I did some testing just out of curiosity.  Most of the things work,
>> including clicking and selection.  However, Command-C now just doesn't
>> copy text to OS clipboard.  And it's non-obvious that you should disable
>> xterm-mouse-mode to be able to copy.
>>
>> That's why I filed this bug - because previous behavior was not ideal
>> but working, and now only paste works.
>>
>> Maybe we should just avoid enabling xterm-mouse-mode in Terminal.app.
>> Maybe functionality of xclip should be in core.
>>
>

[-- Attachment #2: Type: text/html, Size: 4287 bytes --]

^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-13 16:49             ` Eli Zaretskii
@ 2024-12-13 20:32               ` Filipp Gunbin
  2024-12-13 20:54                 ` Ship Mints
  2024-12-14  7:52                 ` Eli Zaretskii
  0 siblings, 2 replies; 51+ messages in thread
From: Filipp Gunbin @ 2024-12-13 20:32 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 74833, shipmints

On 13/12/2024 18:49 +0200, Eli Zaretskii wrote:

>> From: Filipp Gunbin <fgunbin@fastmail.fm>
>> Cc: Ship Mints <shipmints@gmail.com>,  74833@debbugs.gnu.org
>> Date: Fri, 13 Dec 2024 19:35:15 +0300
>>
>> On 13/12/2024 09:21 +0200, Eli Zaretskii wrote:
>>
>> > So why is this an Emacs bug?  It sounds like the OP expects something
>> > to happen which shouldn't, because the xterm protocol for selections
>> > and the clipboard are not supported by Terminal.app?  In that case,
>> > this could be at best a feature request, not a bug.
>>
>> I'll try to explain differently.
>>
>> Without xterm-mouse-mode you can copy/paste from/into Terminal.app
>> window, looks like Terminal.app gives this ability on its own.  This is
>> not integration with Emacs kill ring, no.  Emacs cursor does not react
>> to mouse clicks, and selection happens with OS mouse pointer.  Paste
>> works rather slow (bad idea to paste large chunks of text), but
>> tolerable.
>>
>> Now, yesterday my daily master build got me xterm-mouse-mode enabled, so
>> I did some testing just out of curiosity.  Most of the things work,
>> including clicking and selection.  However, Command-C now just doesn't
>> copy text to OS clipboard.  And it's non-obvious that you should disable
>> xterm-mouse-mode to be able to copy.
>
> xterm-mouse-mode is supposed to be enabled only on terminals that load
> xterm.el, which means they are xterm-compatible.  Does Terminal.app
> load xterm.el on startup?

Terminal.app sets TERM=xterm-256color (this is configurable in "Settings
-> Profiles -> Advanced -> Declare terminal as", I doubt I ever changed
it), so xterm.el should be loaded, yes.

Other term-related vars are:

TERM_PROGRAM=Apple_Terminal
TERM_PROGRAM_VERSION=453
TERM_SESSION_ID=1251C872-8246-4380-A2AE-ED1F8B649878





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-13 16:52               ` Ship Mints
@ 2024-12-13 20:46                 ` Filipp Gunbin
  0 siblings, 0 replies; 51+ messages in thread
From: Filipp Gunbin @ 2024-12-13 20:46 UTC (permalink / raw)
  To: Ship Mints; +Cc: Eli Zaretskii, 74833

On 13/12/2024 11:52 -0500, Ship Mints wrote:

> Try experimenting with alternative terminals such as
> https://wezfurlong.org/wezterm/ which I've used and where I remap all of
> the keys to pass through to Emacs vs. letting the terminal application
> abscond with functions like Command-C. I can share my wezterm configuration
> off line if you're interested. I still remain mostly GUI on macOS but
> occasionally use the terminal, and especially useful for running Emacs via
> ssh on a remote computer (vs. tramp).

Thank you for the tips!  I'm certainly fine with xterm-mouse-mode off,
this bug is rather to let people know that the _default_ behavior
worsened, in default macOS terminal.





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-13 20:32               ` Filipp Gunbin
@ 2024-12-13 20:54                 ` Ship Mints
  2024-12-14  7:52                 ` Eli Zaretskii
  1 sibling, 0 replies; 51+ messages in thread
From: Ship Mints @ 2024-12-13 20:54 UTC (permalink / raw)
  To: Filipp Gunbin; +Cc: Eli Zaretskii, 74833

[-- Attachment #1: Type: text/plain, Size: 2649 bytes --]

I'm afraid to say that TERM indicates terminfo support, not whether
terminal.app provides full xterm compatibility which I believe it doesn't,
at least not without manual modifications to the key maps and I can't speak
to other xterm features. This will require some experimentation. Give
xterm.el a try and see how it goes. I would not load that by default
without conformance testing of some kind. I suppose it would already have
been by now if it was known to work.

Take a look at this page
https://dotat.at/@/2020-12-12-terminal-app-xterm-compatibiity.html someone
did some work in this regard. I might give some of this a try myself one
day.

On Fri, Dec 13, 2024 at 3:32 PM Filipp Gunbin <fgunbin@fastmail.fm> wrote:

> On 13/12/2024 18:49 +0200, Eli Zaretskii wrote:
>
> >> From: Filipp Gunbin <fgunbin@fastmail.fm>
> >> Cc: Ship Mints <shipmints@gmail.com>,  74833@debbugs.gnu.org
> >> Date: Fri, 13 Dec 2024 19:35:15 +0300
> >>
> >> On 13/12/2024 09:21 +0200, Eli Zaretskii wrote:
> >>
> >> > So why is this an Emacs bug?  It sounds like the OP expects something
> >> > to happen which shouldn't, because the xterm protocol for selections
> >> > and the clipboard are not supported by Terminal.app?  In that case,
> >> > this could be at best a feature request, not a bug.
> >>
> >> I'll try to explain differently.
> >>
> >> Without xterm-mouse-mode you can copy/paste from/into Terminal.app
> >> window, looks like Terminal.app gives this ability on its own.  This is
> >> not integration with Emacs kill ring, no.  Emacs cursor does not react
> >> to mouse clicks, and selection happens with OS mouse pointer.  Paste
> >> works rather slow (bad idea to paste large chunks of text), but
> >> tolerable.
> >>
> >> Now, yesterday my daily master build got me xterm-mouse-mode enabled, so
> >> I did some testing just out of curiosity.  Most of the things work,
> >> including clicking and selection.  However, Command-C now just doesn't
> >> copy text to OS clipboard.  And it's non-obvious that you should disable
> >> xterm-mouse-mode to be able to copy.
> >
> > xterm-mouse-mode is supposed to be enabled only on terminals that load
> > xterm.el, which means they are xterm-compatible.  Does Terminal.app
> > load xterm.el on startup?
>
> Terminal.app sets TERM=xterm-256color (this is configurable in "Settings
> -> Profiles -> Advanced -> Declare terminal as", I doubt I ever changed
> it), so xterm.el should be loaded, yes.
>
> Other term-related vars are:
>
> TERM_PROGRAM=Apple_Terminal
> TERM_PROGRAM_VERSION=453
> TERM_SESSION_ID=1251C872-8246-4380-A2AE-ED1F8B649878
>

[-- Attachment #2: Type: text/html, Size: 3742 bytes --]

^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-13 20:32               ` Filipp Gunbin
  2024-12-13 20:54                 ` Ship Mints
@ 2024-12-14  7:52                 ` Eli Zaretskii
  2024-12-14  9:40                   ` Gerd Möllmann
  1 sibling, 1 reply; 51+ messages in thread
From: Eli Zaretskii @ 2024-12-14  7:52 UTC (permalink / raw)
  To: Filipp Gunbin, Jared Finder; +Cc: 74833, shipmints

> From: Filipp Gunbin <fgunbin@fastmail.fm>
> Cc: shipmints@gmail.com,  74833@debbugs.gnu.org
> Date: Fri, 13 Dec 2024 23:32:39 +0300
> 
> On 13/12/2024 18:49 +0200, Eli Zaretskii wrote:
> 
> >> From: Filipp Gunbin <fgunbin@fastmail.fm>
> >> Cc: Ship Mints <shipmints@gmail.com>,  74833@debbugs.gnu.org
> >> Date: Fri, 13 Dec 2024 19:35:15 +0300
> >>
> >> On 13/12/2024 09:21 +0200, Eli Zaretskii wrote:
> >>
> >> > So why is this an Emacs bug?  It sounds like the OP expects something
> >> > to happen which shouldn't, because the xterm protocol for selections
> >> > and the clipboard are not supported by Terminal.app?  In that case,
> >> > this could be at best a feature request, not a bug.
> >>
> >> I'll try to explain differently.
> >>
> >> Without xterm-mouse-mode you can copy/paste from/into Terminal.app
> >> window, looks like Terminal.app gives this ability on its own.  This is
> >> not integration with Emacs kill ring, no.  Emacs cursor does not react
> >> to mouse clicks, and selection happens with OS mouse pointer.  Paste
> >> works rather slow (bad idea to paste large chunks of text), but
> >> tolerable.
> >>
> >> Now, yesterday my daily master build got me xterm-mouse-mode enabled, so
> >> I did some testing just out of curiosity.  Most of the things work,
> >> including clicking and selection.  However, Command-C now just doesn't
> >> copy text to OS clipboard.  And it's non-obvious that you should disable
> >> xterm-mouse-mode to be able to copy.
> >
> > xterm-mouse-mode is supposed to be enabled only on terminals that load
> > xterm.el, which means they are xterm-compatible.  Does Terminal.app
> > load xterm.el on startup?
> 
> Terminal.app sets TERM=xterm-256color (this is configurable in "Settings
> -> Profiles -> Advanced -> Declare terminal as", I doubt I ever changed
> it), so xterm.el should be loaded, yes.
> 
> Other term-related vars are:
> 
> TERM_PROGRAM=Apple_Terminal
> TERM_PROGRAM_VERSION=453
> TERM_SESSION_ID=1251C872-8246-4380-A2AE-ED1F8B649878

Then we should amend xterm.el to not allow xterm-mouse on this
terminal.  Jared, could you please add such a condition?

And I think the Terminal.app developers should be told that pretending
to be xterm without full support for all the xterm features is not
TRT, and they should stop.  Would someone please file an issue with
their issue tracker?





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-14  7:52                 ` Eli Zaretskii
@ 2024-12-14  9:40                   ` Gerd Möllmann
  2024-12-16 16:32                     ` Filipp Gunbin
  0 siblings, 1 reply; 51+ messages in thread
From: Gerd Möllmann @ 2024-12-14  9:40 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Jared Finder, 74833, Filipp Gunbin, shipmints

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Filipp Gunbin <fgunbin@fastmail.fm>
>> Cc: shipmints@gmail.com,  74833@debbugs.gnu.org
>> Date: Fri, 13 Dec 2024 23:32:39 +0300
>> 
>> On 13/12/2024 18:49 +0200, Eli Zaretskii wrote:
>> 
>> >> From: Filipp Gunbin <fgunbin@fastmail.fm>
>> >> Cc: Ship Mints <shipmints@gmail.com>,  74833@debbugs.gnu.org
>> >> Date: Fri, 13 Dec 2024 19:35:15 +0300
>> >>
>> >> On 13/12/2024 09:21 +0200, Eli Zaretskii wrote:
>> >>
>> >> > So why is this an Emacs bug?  It sounds like the OP expects something
>> >> > to happen which shouldn't, because the xterm protocol for selections
>> >> > and the clipboard are not supported by Terminal.app?  In that case,
>> >> > this could be at best a feature request, not a bug.
>> >>
>> >> I'll try to explain differently.
>> >>
>> >> Without xterm-mouse-mode you can copy/paste from/into Terminal.app
>> >> window, looks like Terminal.app gives this ability on its own.  This is
>> >> not integration with Emacs kill ring, no.  Emacs cursor does not react
>> >> to mouse clicks, and selection happens with OS mouse pointer.  Paste
>> >> works rather slow (bad idea to paste large chunks of text), but
>> >> tolerable.
>> >>
>> >> Now, yesterday my daily master build got me xterm-mouse-mode enabled, so
>> >> I did some testing just out of curiosity.  Most of the things work,
>> >> including clicking and selection.  However, Command-C now just doesn't
>> >> copy text to OS clipboard.  And it's non-obvious that you should disable
>> >> xterm-mouse-mode to be able to copy.
>> >
>> > xterm-mouse-mode is supposed to be enabled only on terminals that load
>> > xterm.el, which means they are xterm-compatible.  Does Terminal.app
>> > load xterm.el on startup?
>> 
>> Terminal.app sets TERM=xterm-256color (this is configurable in "Settings
>> -> Profiles -> Advanced -> Declare terminal as", I doubt I ever changed
>> it), so xterm.el should be loaded, yes.
>> 
>> Other term-related vars are:
>> 
>> TERM_PROGRAM=Apple_Terminal
>> TERM_PROGRAM_VERSION=453
>> TERM_SESSION_ID=1251C872-8246-4380-A2AE-ED1F8B649878
>
> Then we should amend xterm.el to not allow xterm-mouse on this
> terminal.  Jared, could you please add such a condition?
>
> And I think the Terminal.app developers should be told that pretending
> to be xterm without full support for all the xterm features is not
> TRT, and they should stop.  Would someone please file an issue with
> their issue tracker?

I still think that this is a cockpit error.

Terminal.app's Command-C can only copy a selection that the app knows
about. If the mouse is used by an app like Emacs (Terminal.app's
Settings/Report ....)) the user tells Terminal to let the app use the mouse.
I find it little surprising that when Terminal.app does that, it doesn't
use the mouse itself to make a selection it could then copy.

Do Command-A Command-C and see what happens.

Or use Command-R to toggle the mouse reporting setting on the fly.

Or use xclip in Emacs.

Please don't disable xterm-mouse for this.





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-12 17:54 bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled Filipp Gunbin
  2024-12-12 18:08 ` Ship Mints
  2024-12-12 19:15 ` Eli Zaretskii
@ 2024-12-16  1:41 ` Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-12-16  3:40   ` Gerd Möllmann
  2024-12-16 16:49   ` Filipp Gunbin
  2 siblings, 2 replies; 51+ messages in thread
From: Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-16  1:41 UTC (permalink / raw)
  To: Gerd Möllmann; +Cc: Eli Zaretskii, Filipp Gunbin, 74833, shipmints

On 2024-12-14 04:40, Gerd Möllmann wrote:
> Eli Zaretskii <eliz@gnu.org> writes:
> 
>>> From: Filipp Gunbin <fgunbin@fastmail.fm>
>>> Cc: shipmints@gmail.com,  74833@debbugs.gnu.org
>>> Date: Fri, 13 Dec 2024 23:32:39 +0300
>>> 
>>> On 13/12/2024 18:49 +0200, Eli Zaretskii wrote:
>>> 
>>> >> From: Filipp Gunbin <fgunbin@fastmail.fm>
>>> >> Cc: Ship Mints <shipmints@gmail.com>,  74833@debbugs.gnu.org
>>> >> Date: Fri, 13 Dec 2024 19:35:15 +0300
>>> >>
>>> >> On 13/12/2024 09:21 +0200, Eli Zaretskii wrote:
>>> >>
>>> >> > So why is this an Emacs bug?  It sounds like the OP expects something
>>> >> > to happen which shouldn't, because the xterm protocol for selections
>>> >> > and the clipboard are not supported by Terminal.app?  In that case,
>>> >> > this could be at best a feature request, not a bug.
>>> >>
>>> >> I'll try to explain differently.
>>> >>
>>> >> Without xterm-mouse-mode you can copy/paste from/into Terminal.app
>>> >> window, looks like Terminal.app gives this ability on its own.  This is
>>> >> not integration with Emacs kill ring, no.  Emacs cursor does not react
>>> >> to mouse clicks, and selection happens with OS mouse pointer.  Paste
>>> >> works rather slow (bad idea to paste large chunks of text), but
>>> >> tolerable.
>>> >>
>>> >> Now, yesterday my daily master build got me xterm-mouse-mode enabled, so
>>> >> I did some testing just out of curiosity.  Most of the things work,
>>> >> including clicking and selection.  However, Command-C now just doesn't
>>> >> copy text to OS clipboard.  And it's non-obvious that you should disable
>>> >> xterm-mouse-mode to be able to copy.
>>> >
>>> > xterm-mouse-mode is supposed to be enabled only on terminals that load
>>> > xterm.el, which means they are xterm-compatible.  Does Terminal.app
>>> > load xterm.el on startup?
>>> 
>>> Terminal.app sets TERM=xterm-256color (this is configurable in 
>>> "Settings
>>> -> Profiles -> Advanced -> Declare terminal as", I doubt I ever 
>>> changed
>>> it), so xterm.el should be loaded, yes.
>>> 
>>> Other term-related vars are:
>>> 
>>> TERM_PROGRAM=Apple_Terminal
>>> TERM_PROGRAM_VERSION=453
>>> TERM_SESSION_ID=1251C872-8246-4380-A2AE-ED1F8B649878
>> 
>> Then we should amend xterm.el to not allow xterm-mouse on this
>> terminal.  Jared, could you please add such a condition?
>> 
>> And I think the Terminal.app developers should be told that pretending
>> to be xterm without full support for all the xterm features is not
>> TRT, and they should stop.  Would someone please file an issue with
>> their issue tracker?
> 
> I still think that this is a cockpit error.

I agree. While in Emacs, with Emacs managing the selection, one should 
expect to use Emacs commands to manage the clipboard like C-w and M-w. 
Sadly, Terminal.app does not support OSC52 therefore the clipboard is 
shared only within Emacs. Terminal.app provides fn+mouse drag to select 
things that Command-C notices as well as Command-R to disable mouse 
reporting already for exactly this reason.

However, I'm sensitive that someone using Terminal.app is just using the 
MacOS default configuration for terminal and will think Emacs is broken 
here. Terminal.app is MacOS's default terminal emulator after all. Other 
popular MacOS terminal emulators like iTerm2 work fine because they 
support OSC52 (copy protocol).

What about adding a workaround that uses the command line tool pbcopy 
(Mac version of xclip)? The pbcopy program is distributed with MacOS by 
default. This won't work over SSH, but at that point I don't think 
there's anything that can be done. TERM_PROGRAM isn't sent to the server 
by default.

I also think I could make the news entry more detailed.


Paste works just fine in MacOS under Terminal.app for me.

   -- MJF





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-16  1:41 ` Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-12-16  3:40   ` Gerd Möllmann
  2024-12-16  5:16     ` Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-12-16 16:30     ` Eli Zaretskii
  2024-12-16 16:49   ` Filipp Gunbin
  1 sibling, 2 replies; 51+ messages in thread
From: Gerd Möllmann @ 2024-12-16  3:40 UTC (permalink / raw)
  To: Jared Finder; +Cc: Eli Zaretskii, Filipp Gunbin, 74833, shipmints

Jared Finder <jared@finder.org> writes:

> What about adding a workaround that uses the command line tool pbcopy
> (Mac version of xclip)? The pbcopy program is distributed with MacOS
> by default.

The Elpa package xclip uses that.

  ;; This package allows Emacs to copy to and paste from the GUI clipboard
  ;; when running in text terminal.
  ;;
  ;; It can use external command-line tools for that, which you may need
  ;; to install in order for the package to work.
  ;; More specifically, it can use the following tools:
  ;; - Under X11: `xclip' or `xsel' (https://xclip.sourceforge.net and
  ;;   https://www.vergenet.net/~conrad/software/xsel/ respectively).
  ;; - MacOS: `pbpaste/pbcopy'
  ;; - Cygwin: `getclip/putclip'
  ;; - Under Wayland: `wl-clipboard' (https://github.com/bugaevc/wl-clipboard)
  ;; - Termux: `termux-clipboard-get/set'
  ;; - Emacs: It can also use Emacs's built-in GUI support to talk to the GUI.
  ;;   This requires an Emacs built with GUI support.
  ;;   It uses `make-frame-on-display' which has been tested to work under X11,
  ;;   but it's not known whether it works under MacOS or Windows.







^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-16  3:40   ` Gerd Möllmann
@ 2024-12-16  5:16     ` Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-12-16 16:37       ` Eli Zaretskii
  2024-12-16 16:30     ` Eli Zaretskii
  1 sibling, 1 reply; 51+ messages in thread
From: Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-16  5:16 UTC (permalink / raw)
  To: Gerd Möllmann; +Cc: Eli Zaretskii, Filipp Gunbin, 74833, shipmints

On 2024-12-15 19:40, Gerd Möllmann wrote:
> Jared Finder <jared@finder.org> writes:
> 
>> What about adding a workaround that uses the command line tool pbcopy
>> (Mac version of xclip)? The pbcopy program is distributed with MacOS
>> by default.
> 
> The Elpa package xclip uses that.
> 
>   ;; This package allows Emacs to copy to and paste from the GUI 
> clipboard
>   ;; when running in text terminal.
>   ;;
>   ;; It can use external command-line tools for that, which you may 
> need
>   ;; to install in order for the package to work.

Thanks. I just tested xclip-mode from Elpa and it indeed works to get 
copy operations work with Terminal.app. I think the best path forward 
would be to just mention this package in the NEWS update as a workaround 
for folks using Terminal.app. We could also recommend using iTerm2 as a 
GPL'd alternative that properly supports copy. (Paste works fine because 
Terminal.app supports xterm bracketed pastes.)

Eli, does this sound good to you?

   -- MJF





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-16  3:40   ` Gerd Möllmann
  2024-12-16  5:16     ` Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-12-16 16:30     ` Eli Zaretskii
  1 sibling, 0 replies; 51+ messages in thread
From: Eli Zaretskii @ 2024-12-16 16:30 UTC (permalink / raw)
  To: Gerd Möllmann; +Cc: fgunbin, 74833, jared, shipmints

> From: Gerd Möllmann <gerd.moellmann@gmail.com>
> Cc: Eli Zaretskii <eliz@gnu.org>,  Filipp Gunbin <fgunbin@fastmail.fm>,
>   74833@debbugs.gnu.org,  shipmints@gmail.com
> Date: Mon, 16 Dec 2024 04:40:03 +0100
> 
> Jared Finder <jared@finder.org> writes:
> 
> > What about adding a workaround that uses the command line tool pbcopy
> > (Mac version of xclip)? The pbcopy program is distributed with MacOS
> > by default.
> 
> The Elpa package xclip uses that.
> 
>   ;; This package allows Emacs to copy to and paste from the GUI clipboard
>   ;; when running in text terminal.
>   ;;
>   ;; It can use external command-line tools for that, which you may need
>   ;; to install in order for the package to work.
>   ;; More specifically, it can use the following tools:
>   ;; - Under X11: `xclip' or `xsel' (https://xclip.sourceforge.net and
>   ;;   https://www.vergenet.net/~conrad/software/xsel/ respectively).
>   ;; - MacOS: `pbpaste/pbcopy'
>   ;; - Cygwin: `getclip/putclip'
>   ;; - Under Wayland: `wl-clipboard' (https://github.com/bugaevc/wl-clipboard)
>   ;; - Termux: `termux-clipboard-get/set'
>   ;; - Emacs: It can also use Emacs's built-in GUI support to talk to the GUI.
>   ;;   This requires an Emacs built with GUI support.
>   ;;   It uses `make-frame-on-display' which has been tested to work under X11,
>   ;;   but it's not known whether it works under MacOS or Windows.

It is not needed on Windows (at least the latest versions of it).





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-14  9:40                   ` Gerd Möllmann
@ 2024-12-16 16:32                     ` Filipp Gunbin
  2024-12-16 17:30                       ` Gerd Möllmann
  0 siblings, 1 reply; 51+ messages in thread
From: Filipp Gunbin @ 2024-12-16 16:32 UTC (permalink / raw)
  To: Gerd Möllmann; +Cc: Eli Zaretskii, Jared Finder, 74833, shipmints

On 14/12/2024 10:40 +0100, Gerd Möllmann wrote:

> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> From: Filipp Gunbin <fgunbin@fastmail.fm>
>>> Cc: shipmints@gmail.com,  74833@debbugs.gnu.org
>>> Date: Fri, 13 Dec 2024 23:32:39 +0300
>>> 
>>> On 13/12/2024 18:49 +0200, Eli Zaretskii wrote:
>>> 
>>> >> From: Filipp Gunbin <fgunbin@fastmail.fm>
>>> >> Cc: Ship Mints <shipmints@gmail.com>,  74833@debbugs.gnu.org
>>> >> Date: Fri, 13 Dec 2024 19:35:15 +0300
>>> >>
>>> >> On 13/12/2024 09:21 +0200, Eli Zaretskii wrote:
>>> >>
>>> >> > So why is this an Emacs bug?  It sounds like the OP expects something
>>> >> > to happen which shouldn't, because the xterm protocol for selections
>>> >> > and the clipboard are not supported by Terminal.app?  In that case,
>>> >> > this could be at best a feature request, not a bug.
>>> >>
>>> >> I'll try to explain differently.
>>> >>
>>> >> Without xterm-mouse-mode you can copy/paste from/into Terminal.app
>>> >> window, looks like Terminal.app gives this ability on its own.  This is
>>> >> not integration with Emacs kill ring, no.  Emacs cursor does not react
>>> >> to mouse clicks, and selection happens with OS mouse pointer.  Paste
>>> >> works rather slow (bad idea to paste large chunks of text), but
>>> >> tolerable.
>>> >>
>>> >> Now, yesterday my daily master build got me xterm-mouse-mode enabled, so
>>> >> I did some testing just out of curiosity.  Most of the things work,
>>> >> including clicking and selection.  However, Command-C now just doesn't
>>> >> copy text to OS clipboard.  And it's non-obvious that you should disable
>>> >> xterm-mouse-mode to be able to copy.
>>> >
>>> > xterm-mouse-mode is supposed to be enabled only on terminals that load
>>> > xterm.el, which means they are xterm-compatible.  Does Terminal.app
>>> > load xterm.el on startup?
>>> 
>>> Terminal.app sets TERM=xterm-256color (this is configurable in "Settings
>>> -> Profiles -> Advanced -> Declare terminal as", I doubt I ever changed
>>> it), so xterm.el should be loaded, yes.
>>> 
>>> Other term-related vars are:
>>> 
>>> TERM_PROGRAM=Apple_Terminal
>>> TERM_PROGRAM_VERSION=453
>>> TERM_SESSION_ID=1251C872-8246-4380-A2AE-ED1F8B649878
>>
>> Then we should amend xterm.el to not allow xterm-mouse on this
>> terminal.  Jared, could you please add such a condition?
>>
>> And I think the Terminal.app developers should be told that pretending
>> to be xterm without full support for all the xterm features is not
>> TRT, and they should stop.  Would someone please file an issue with
>> their issue tracker?
>
> I still think that this is a cockpit error.
>
> Terminal.app's Command-C can only copy a selection that the app knows
> about.

Not really - with xterm-mouse-mode disabled (and with "Allow mouse
reporting" ticked in Terminal.app menu), mouse selection in Terminal.app
is not related to Emacs selection, and copy / paste works.

> If the mouse is used by an app like Emacs (Terminal.app's
> Settings/Report ....)) the user tells Terminal to let the app use the mouse.
> I find it little surprising that when Terminal.app does that, it doesn't
> use the mouse itself to make a selection it could then copy.

It does, although that's Terminal.app's "own" selection, not Emacs's.

> Do Command-A Command-C and see what happens.
>
> Or use Command-R to toggle the mouse reporting setting on the fly.
>
> Or use xclip in Emacs.
>
> Please don't disable xterm-mouse for this.

Again, it turns out that the new default leads to copy not working at
all, while with previous default you could make selection in
Terminal.app (it's not reflected in Emacs) and then copy.  Paste works
in both cases.  It still looks to me that the old default is better.  If
you enable xterm-mouse-mode, then perhaps you should also use xclip, not
just the mode itself.





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-16  5:16     ` Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-12-16 16:37       ` Eli Zaretskii
  2024-12-16 16:47         ` Ship Mints
  2024-12-16 17:36         ` Gerd Möllmann
  0 siblings, 2 replies; 51+ messages in thread
From: Eli Zaretskii @ 2024-12-16 16:37 UTC (permalink / raw)
  To: Jared Finder; +Cc: gerd.moellmann, 74833, fgunbin, shipmints

> Date: Sun, 15 Dec 2024 21:16:16 -0800
> From: Jared Finder <jared@finder.org>
> Cc: Eli Zaretskii <eliz@gnu.org>, Filipp Gunbin <fgunbin@fastmail.fm>,
>  74833@debbugs.gnu.org, shipmints@gmail.com
> 
> On 2024-12-15 19:40, Gerd Möllmann wrote:
> > Jared Finder <jared@finder.org> writes:
> > 
> >> What about adding a workaround that uses the command line tool pbcopy
> >> (Mac version of xclip)? The pbcopy program is distributed with MacOS
> >> by default.
> > 
> > The Elpa package xclip uses that.
> > 
> >   ;; This package allows Emacs to copy to and paste from the GUI 
> > clipboard
> >   ;; when running in text terminal.
> >   ;;
> >   ;; It can use external command-line tools for that, which you may 
> > need
> >   ;; to install in order for the package to work.
> 
> Thanks. I just tested xclip-mode from Elpa and it indeed works to get 
> copy operations work with Terminal.app. I think the best path forward 
> would be to just mention this package in the NEWS update as a workaround 
> for folks using Terminal.app. We could also recommend using iTerm2 as a 
> GPL'd alternative that properly supports copy. (Paste works fine because 
> Terminal.app supports xterm bracketed pastes.)
> 
> Eli, does this sound good to you?

It does (I think it should also be in PROBLEMS), but I wonder whether
we should disable xterm-mouse on Terminal.app (assuming we can detect
it).  It sounds like more people could bump into this tricky issue,
and relying on all of them read NEWS is too optimistic.

What are the downsides of turning this off for Terminal.app?  That's
what Emacs before 31 had, so it cannot be too bad.





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-16 16:37       ` Eli Zaretskii
@ 2024-12-16 16:47         ` Ship Mints
  2024-12-16 17:36         ` Gerd Möllmann
  1 sibling, 0 replies; 51+ messages in thread
From: Ship Mints @ 2024-12-16 16:47 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gerd.moellmann, fgunbin, 74833, Jared Finder

[-- Attachment #1: Type: text/plain, Size: 2425 bytes --]

I use xterm-mouse under Terminal.app just fine as I rely only on Emacs
pasteboard integration via xclip. (I use clipetty when terminals support
osc52--there's no easy programmatic test for that which I'm aware of so I
set that up "by hand.") I don't think it is a good idea to blanket disable
xterm-mouse for macOS users.

FWIW, one can detect it via getenv "TERM_PROGRAM" when set to "Apple_Terminal".
I'd suggest this is an exercise for the user. In my configuration, I have
various things I configure based on if macOS and the terminal program; one
being Apple's Terminal.app, another being WezTerm, etc.

On Mon, Dec 16, 2024 at 11:37 AM Eli Zaretskii <eliz@gnu.org> wrote:

> > Date: Sun, 15 Dec 2024 21:16:16 -0800
> > From: Jared Finder <jared@finder.org>
> > Cc: Eli Zaretskii <eliz@gnu.org>, Filipp Gunbin <fgunbin@fastmail.fm>,
> >  74833@debbugs.gnu.org, shipmints@gmail.com
> >
> > On 2024-12-15 19:40, Gerd Möllmann wrote:
> > > Jared Finder <jared@finder.org> writes:
> > >
> > >> What about adding a workaround that uses the command line tool pbcopy
> > >> (Mac version of xclip)? The pbcopy program is distributed with MacOS
> > >> by default.
> > >
> > > The Elpa package xclip uses that.
> > >
> > >   ;; This package allows Emacs to copy to and paste from the GUI
> > > clipboard
> > >   ;; when running in text terminal.
> > >   ;;
> > >   ;; It can use external command-line tools for that, which you may
> > > need
> > >   ;; to install in order for the package to work.
> >
> > Thanks. I just tested xclip-mode from Elpa and it indeed works to get
> > copy operations work with Terminal.app. I think the best path forward
> > would be to just mention this package in the NEWS update as a workaround
> > for folks using Terminal.app. We could also recommend using iTerm2 as a
> > GPL'd alternative that properly supports copy. (Paste works fine because
> > Terminal.app supports xterm bracketed pastes.)
> >
> > Eli, does this sound good to you?
>
> It does (I think it should also be in PROBLEMS), but I wonder whether
> we should disable xterm-mouse on Terminal.app (assuming we can detect
> it).  It sounds like more people could bump into this tricky issue,
> and relying on all of them read NEWS is too optimistic.
>
> What are the downsides of turning this off for Terminal.app?  That's
> what Emacs before 31 had, so it cannot be too bad.
>

[-- Attachment #2: Type: text/html, Size: 3632 bytes --]

^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-16  1:41 ` Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-12-16  3:40   ` Gerd Möllmann
@ 2024-12-16 16:49   ` Filipp Gunbin
  1 sibling, 0 replies; 51+ messages in thread
From: Filipp Gunbin @ 2024-12-16 16:49 UTC (permalink / raw)
  To: Jared Finder; +Cc: Gerd Möllmann, Eli Zaretskii, 74833, shipmints

On 15/12/2024 17:41 -0800, Jared Finder wrote:

> On 2024-12-14 04:40, Gerd Möllmann wrote:
>> Eli Zaretskii <eliz@gnu.org> writes:
>> 
>>>> From: Filipp Gunbin <fgunbin@fastmail.fm>
>>>> Cc: shipmints@gmail.com,  74833@debbugs.gnu.org
>>>> Date: Fri, 13 Dec 2024 23:32:39 +0300
>>>> On 13/12/2024 18:49 +0200, Eli Zaretskii wrote:
>>>>  >> From: Filipp Gunbin <fgunbin@fastmail.fm>
>>>> >> Cc: Ship Mints <shipmints@gmail.com>,  74833@debbugs.gnu.org
>>>> >> Date: Fri, 13 Dec 2024 19:35:15 +0300
>>>> >>
>>>> >> On 13/12/2024 09:21 +0200, Eli Zaretskii wrote:
>>>> >>
>>>> >> > So why is this an Emacs bug?  It sounds like the OP expects something
>>>> >> > to happen which shouldn't, because the xterm protocol for selections
>>>> >> > and the clipboard are not supported by Terminal.app?  In that case,
>>>> >> > this could be at best a feature request, not a bug.
>>>> >>
>>>> >> I'll try to explain differently.
>>>> >>
>>>> >> Without xterm-mouse-mode you can copy/paste from/into Terminal.app
>>>> >> window, looks like Terminal.app gives this ability on its own.  This is
>>>> >> not integration with Emacs kill ring, no.  Emacs cursor does not react
>>>> >> to mouse clicks, and selection happens with OS mouse pointer.  Paste
>>>> >> works rather slow (bad idea to paste large chunks of text), but
>>>> >> tolerable.
>>>> >>
>>>> >> Now, yesterday my daily master build got me xterm-mouse-mode enabled, so
>>>> >> I did some testing just out of curiosity.  Most of the things work,
>>>> >> including clicking and selection.  However, Command-C now just doesn't
>>>> >> copy text to OS clipboard.  And it's non-obvious that you should disable
>>>> >> xterm-mouse-mode to be able to copy.
>>>> >
>>>> > xterm-mouse-mode is supposed to be enabled only on terminals that load
>>>> > xterm.el, which means they are xterm-compatible.  Does Terminal.app
>>>> > load xterm.el on startup?
>>>> Terminal.app sets TERM=xterm-256color (this is configurable in
>>>> "Settings
>>>> -> Profiles -> Advanced -> Declare terminal as", I doubt I ever
>>>> changed
>>>> it), so xterm.el should be loaded, yes.
>>>> Other term-related vars are:
>>>> TERM_PROGRAM=Apple_Terminal
>>>> TERM_PROGRAM_VERSION=453
>>>> TERM_SESSION_ID=1251C872-8246-4380-A2AE-ED1F8B649878
>>> Then we should amend xterm.el to not allow xterm-mouse on this
>>> terminal.  Jared, could you please add such a condition?
>>> And I think the Terminal.app developers should be told that
>>> pretending
>>> to be xterm without full support for all the xterm features is not
>>> TRT, and they should stop.  Would someone please file an issue with
>>> their issue tracker?
>> I still think that this is a cockpit error.
>
> I agree. While in Emacs, with Emacs managing the selection, one should
> expect to use Emacs commands to manage the clipboard like C-w and
> M-w. Sadly, Terminal.app does not support OSC52 therefore the
> clipboard is shared only within Emacs. Terminal.app provides fn+mouse
> drag to select things that Command-C notices as well as Command-R to
> disable mouse reporting already for exactly this reason.

I didn't know about fn + mouse drag, thanks!

> However, I'm sensitive that someone using Terminal.app is just using
> the MacOS default configuration for terminal and will think Emacs is
> broken here. Terminal.app is MacOS's default terminal emulator after
> all.

That's my point, yes.

> Other popular MacOS terminal emulators like iTerm2 work fine
> because they support OSC52 (copy protocol).
>
> What about adding a workaround that uses the command line tool pbcopy
> (Mac version of xclip)? The pbcopy program is distributed with MacOS
> by default. This won't work over SSH, but at that point I don't think
> there's anything that can be done. TERM_PROGRAM isn't sent to the
> server by default.

Having thing like that in Emacs, without a need for installing a
package, would be best from my POV.

> I also think I could make the news entry more detailed.
>
>
> Paste works just fine in MacOS under Terminal.app for me.

For me too.





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-16 16:32                     ` Filipp Gunbin
@ 2024-12-16 17:30                       ` Gerd Möllmann
  2024-12-16 17:42                         ` Eli Zaretskii
  2024-12-16 19:09                         ` Filipp Gunbin
  0 siblings, 2 replies; 51+ messages in thread
From: Gerd Möllmann @ 2024-12-16 17:30 UTC (permalink / raw)
  To: Filipp Gunbin; +Cc: Eli Zaretskii, Jared Finder, 74833, shipmints

Filipp Gunbin <fgunbin@fastmail.fm> writes:

>> Terminal.app's Command-C can only copy a selection that the app knows
>> about.
>
> Not really - with xterm-mouse-mode disabled (and with "Allow mouse
> reporting" ticked in Terminal.app menu), mouse selection in Terminal.app
> is not related to Emacs selection, and copy / paste works.

What I meant with my sentence is that the selection Emacs shows and the
selection Terminal.app shows and uses are not related to each other.
Maybe that's a cause of confusion, I don't know.

>
>> If the mouse is used by an app like Emacs (Terminal.app's
>> Settings/Report ....)) the user tells Terminal to let the app use the mouse.
>> I find it little surprising that when Terminal.app does that, it doesn't
>> use the mouse itself to make a selection it could then copy.
>
> It does, although that's Terminal.app's "own" selection, not Emacs's.
>
>> Do Command-A Command-C and see what happens.
>>
>> Or use Command-R to toggle the mouse reporting setting on the fly.
>>
>> Or use xclip in Emacs.
>>
>> Please don't disable xterm-mouse for this.
>
> Again, it turns out that the new default leads to copy not working at
> all, while with previous default you could make selection in
> Terminal.app (it's not reflected in Emacs) and then copy.  Paste works
> in both cases.  It still looks to me that the old default is better.  If
> you enable xterm-mouse-mode, then perhaps you should also use xclip, not
> just the mode itself.

Mouse support by default is an important feature, IMO. It makes the menu
bar usable, or in a future Emacs containing tty child frames tooltips
can be shown. Not to mention setting point and what else.

What's the positive effect of turning mouse support off by default?
Command-C works for users who haven't set up terminal Emacs well enough
that they could use M-w, plus in addition don't know Terminal.app well
enough to know about Command-R or Fn + mouse.

I think it's best if we simply agree to disagree. 





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-16 16:37       ` Eli Zaretskii
  2024-12-16 16:47         ` Ship Mints
@ 2024-12-16 17:36         ` Gerd Möllmann
  1 sibling, 0 replies; 51+ messages in thread
From: Gerd Möllmann @ 2024-12-16 17:36 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: fgunbin, 74833, Jared Finder, shipmints

Eli Zaretskii <eliz@gnu.org> writes:

>> Date: Sun, 15 Dec 2024 21:16:16 -0800
>> From: Jared Finder <jared@finder.org>
>> Cc: Eli Zaretskii <eliz@gnu.org>, Filipp Gunbin <fgunbin@fastmail.fm>,
>>  74833@debbugs.gnu.org, shipmints@gmail.com
>> 
>> On 2024-12-15 19:40, Gerd Möllmann wrote:
>> > Jared Finder <jared@finder.org> writes:
>> > 
>> >> What about adding a workaround that uses the command line tool pbcopy
>> >> (Mac version of xclip)? The pbcopy program is distributed with MacOS
>> >> by default.
>> > 
>> > The Elpa package xclip uses that.
>> > 
>> >   ;; This package allows Emacs to copy to and paste from the GUI 
>> > clipboard
>> >   ;; when running in text terminal.
>> >   ;;
>> >   ;; It can use external command-line tools for that, which you may 
>> > need
>> >   ;; to install in order for the package to work.
>> 
>> Thanks. I just tested xclip-mode from Elpa and it indeed works to get 
>> copy operations work with Terminal.app. I think the best path forward 
>> would be to just mention this package in the NEWS update as a workaround 
>> for folks using Terminal.app. We could also recommend using iTerm2 as a 
>> GPL'd alternative that properly supports copy. (Paste works fine because 
>> Terminal.app supports xterm bracketed pastes.)
>> 
>> Eli, does this sound good to you?
>
> It does (I think it should also be in PROBLEMS), but I wonder whether
> we should disable xterm-mouse on Terminal.app (assuming we can detect
> it).  It sounds like more people could bump into this tricky issue,
> and relying on all of them read NEWS is too optimistic.
>
> What are the downsides of turning this off for Terminal.app?  That's
> what Emacs before 31 had, so it cannot be too bad.

In my last reply to the OP I wrote 

  Mouse support by default is an important feature, IMO. It makes the menu
  bar usable, or in a future Emacs containing tty child frames tooltips
  can be shown. Not to mention setting point and what else.

  What's the positive effect of turning mouse support off by default?
  Command-C works for users who haven't set up terminal Emacs well enough
  that they could use M-w, plus in addition don't know Terminal.app well
  enough to know about Command-R or Fn + mouse.







^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-16 17:30                       ` Gerd Möllmann
@ 2024-12-16 17:42                         ` Eli Zaretskii
  2024-12-16 17:53                           ` Gerd Möllmann
  2024-12-16 19:09                         ` Filipp Gunbin
  1 sibling, 1 reply; 51+ messages in thread
From: Eli Zaretskii @ 2024-12-16 17:42 UTC (permalink / raw)
  To: Gerd Möllmann; +Cc: jared, 74833, fgunbin, shipmints

> From: Gerd Möllmann <gerd.moellmann@gmail.com>
> Cc: Eli Zaretskii <eliz@gnu.org>,  Jared Finder <jared@finder.org>,
>   74833@debbugs.gnu.org,  shipmints@gmail.com
> Date: Mon, 16 Dec 2024 18:30:30 +0100
> 
> Mouse support by default is an important feature, IMO. It makes the menu
> bar usable, or in a future Emacs containing tty child frames tooltips
> can be shown. Not to mention setting point and what else.

I agree that mouse support is an important feature -- if it works well
and doesn't cause regressions.  Here it seems like at least some
people could see some breakage.

It is easy to turn on xterm-mouse-mode for those who want it and don't
get anything broken due to it.  Turning it on by default is only TRT
if there are no significant downsides.  IOW, we shouldn't force users
to turn off some feature that is turned on by default because the
default doesn't work or breaks something.

So I still think it is safer to turn this off on Terminal.app, if we
can detect it.





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-16 17:42                         ` Eli Zaretskii
@ 2024-12-16 17:53                           ` Gerd Möllmann
  0 siblings, 0 replies; 51+ messages in thread
From: Gerd Möllmann @ 2024-12-16 17:53 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: jared, 74833, fgunbin, shipmints

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Gerd Möllmann <gerd.moellmann@gmail.com>
>> Cc: Eli Zaretskii <eliz@gnu.org>,  Jared Finder <jared@finder.org>,
>>   74833@debbugs.gnu.org,  shipmints@gmail.com
>> Date: Mon, 16 Dec 2024 18:30:30 +0100
>> 
>> Mouse support by default is an important feature, IMO. It makes the menu
>> bar usable, or in a future Emacs containing tty child frames tooltips
>> can be shown. Not to mention setting point and what else.
>
> I agree that mouse support is an important feature -- if it works well
> and doesn't cause regressions.  Here it seems like at least some
> people could see some breakage.
>
> It is easy to turn on xterm-mouse-mode for those who want it and don't
> get anything broken due to it.  Turning it on by default is only TRT
> if there are no significant downsides.  IOW, we shouldn't force users
> to turn off some feature that is turned on by default because the
> default doesn't work or breaks something.

You left out the part where I said for whom it breaks something :-).





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-16 17:30                       ` Gerd Möllmann
  2024-12-16 17:42                         ` Eli Zaretskii
@ 2024-12-16 19:09                         ` Filipp Gunbin
  2024-12-16 19:20                           ` Ship Mints
  2024-12-16 19:53                           ` Gerd Möllmann
  1 sibling, 2 replies; 51+ messages in thread
From: Filipp Gunbin @ 2024-12-16 19:09 UTC (permalink / raw)
  To: Gerd Möllmann; +Cc: Eli Zaretskii, Jared Finder, 74833, shipmints

On 16/12/2024 18:30 +0100, Gerd Möllmann wrote:

> Filipp Gunbin <fgunbin@fastmail.fm> writes:
>
>>> Terminal.app's Command-C can only copy a selection that the app knows
>>> about.
>>
>> Not really - with xterm-mouse-mode disabled (and with "Allow mouse
>> reporting" ticked in Terminal.app menu), mouse selection in Terminal.app
>> is not related to Emacs selection, and copy / paste works.
>
> What I meant with my sentence is that the selection Emacs shows and the
> selection Terminal.app shows and uses are not related to each other.
> Maybe that's a cause of confusion, I don't know.
>
>>
>>> If the mouse is used by an app like Emacs (Terminal.app's
>>> Settings/Report ....)) the user tells Terminal to let the app use the mouse.
>>> I find it little surprising that when Terminal.app does that, it doesn't
>>> use the mouse itself to make a selection it could then copy.
>>
>> It does, although that's Terminal.app's "own" selection, not Emacs's.
>>
>>> Do Command-A Command-C and see what happens.
>>>
>>> Or use Command-R to toggle the mouse reporting setting on the fly.
>>>
>>> Or use xclip in Emacs.
>>>
>>> Please don't disable xterm-mouse for this.
>>
>> Again, it turns out that the new default leads to copy not working at
>> all, while with previous default you could make selection in
>> Terminal.app (it's not reflected in Emacs) and then copy.  Paste works
>> in both cases.  It still looks to me that the old default is better.  If
>> you enable xterm-mouse-mode, then perhaps you should also use xclip, not
>> just the mode itself.
>
> Mouse support by default is an important feature, IMO. It makes the menu
> bar usable, or in a future Emacs containing tty child frames tooltips
> can be shown. Not to mention setting point and what else.
>
> What's the positive effect of turning mouse support off by default?
> Command-C works for users who haven't set up terminal Emacs well enough
> that they could use M-w, plus in addition don't know Terminal.app well
> enough to know about Command-R or Fn + mouse.

My point is exactly that Command-C _doesn't work_ for them, with current
defaults (xterm-mouse-mode on in Emacs; "Allow mouse reporting" ticked -
which is the default for a new Terminal.app tab, at least here).

> I think it's best if we simply agree to disagree.

I don't think we disagree much, I see the value of xterm-mouse-mode
(although I like "just text" on tty, no menus etc.), the only thing
which concerns me (and is the reason for this bug) are "half-broken"
defaults.  We're discussing whether to disable xterm-mouse-mode only in
Terminal.app, not everywhere.





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-16 19:09                         ` Filipp Gunbin
@ 2024-12-16 19:20                           ` Ship Mints
  2024-12-16 19:57                             ` Gerd Möllmann
  2024-12-16 19:58                             ` Eli Zaretskii
  2024-12-16 19:53                           ` Gerd Möllmann
  1 sibling, 2 replies; 51+ messages in thread
From: Ship Mints @ 2024-12-16 19:20 UTC (permalink / raw)
  To: Filipp Gunbin; +Cc: Gerd Möllmann, Eli Zaretskii, Jared Finder, 74833

[-- Attachment #1: Type: text/plain, Size: 3946 bytes --]

I think about it like this: if Terminal.app successfully passed through all
its keys (which it can be configured to do), Command-C would appear in
Emacs as M-c but it doesn't. Does it surprise you that Command-P offers the
print dialog when Emacs is running in the terminal? This is no different
than Command-C. That Terminal.app supersedes Emacs is not an Emacs problem,
it's Terminal's problem. This feels like documentation issue not something
to cure with default Emacs configuration.

Other terminal applications like iTerm or WezTerm can be programmed
similarly to pass through all keys that you want them to with modifiers,
but by default, they don't. These can't be Emacs's problem either. Same
with Emacs run via ssh with tmux on the other side. That's a "default" set
of features offered on many systems and their configuration is not Emacs's
problem.

This issue sounds like an "impedance mismatch" to my ears, even if it
surprises some users and requires some configuration depending on your
specific goals and should perhaps be better documented.

On Mon, Dec 16, 2024 at 2:09 PM Filipp Gunbin <fgunbin@fastmail.fm> wrote:

> On 16/12/2024 18:30 +0100, Gerd Möllmann wrote:
>
> > Filipp Gunbin <fgunbin@fastmail.fm> writes:
> >
> >>> Terminal.app's Command-C can only copy a selection that the app knows
> >>> about.
> >>
> >> Not really - with xterm-mouse-mode disabled (and with "Allow mouse
> >> reporting" ticked in Terminal.app menu), mouse selection in Terminal.app
> >> is not related to Emacs selection, and copy / paste works.
> >
> > What I meant with my sentence is that the selection Emacs shows and the
> > selection Terminal.app shows and uses are not related to each other.
> > Maybe that's a cause of confusion, I don't know.
> >
> >>
> >>> If the mouse is used by an app like Emacs (Terminal.app's
> >>> Settings/Report ....)) the user tells Terminal to let the app use the
> mouse.
> >>> I find it little surprising that when Terminal.app does that, it
> doesn't
> >>> use the mouse itself to make a selection it could then copy.
> >>
> >> It does, although that's Terminal.app's "own" selection, not Emacs's.
> >>
> >>> Do Command-A Command-C and see what happens.
> >>>
> >>> Or use Command-R to toggle the mouse reporting setting on the fly.
> >>>
> >>> Or use xclip in Emacs.
> >>>
> >>> Please don't disable xterm-mouse for this.
> >>
> >> Again, it turns out that the new default leads to copy not working at
> >> all, while with previous default you could make selection in
> >> Terminal.app (it's not reflected in Emacs) and then copy.  Paste works
> >> in both cases.  It still looks to me that the old default is better.  If
> >> you enable xterm-mouse-mode, then perhaps you should also use xclip, not
> >> just the mode itself.
> >
> > Mouse support by default is an important feature, IMO. It makes the menu
> > bar usable, or in a future Emacs containing tty child frames tooltips
> > can be shown. Not to mention setting point and what else.
> >
> > What's the positive effect of turning mouse support off by default?
> > Command-C works for users who haven't set up terminal Emacs well enough
> > that they could use M-w, plus in addition don't know Terminal.app well
> > enough to know about Command-R or Fn + mouse.
>
> My point is exactly that Command-C _doesn't work_ for them, with current
> defaults (xterm-mouse-mode on in Emacs; "Allow mouse reporting" ticked -
> which is the default for a new Terminal.app tab, at least here).
>
> > I think it's best if we simply agree to disagree.
>
> I don't think we disagree much, I see the value of xterm-mouse-mode
> (although I like "just text" on tty, no menus etc.), the only thing
> which concerns me (and is the reason for this bug) are "half-broken"
> defaults.  We're discussing whether to disable xterm-mouse-mode only in
> Terminal.app, not everywhere.
>

[-- Attachment #2: Type: text/html, Size: 5151 bytes --]

^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-16 19:09                         ` Filipp Gunbin
  2024-12-16 19:20                           ` Ship Mints
@ 2024-12-16 19:53                           ` Gerd Möllmann
  2024-12-16 20:25                             ` Filipp Gunbin
  1 sibling, 1 reply; 51+ messages in thread
From: Gerd Möllmann @ 2024-12-16 19:53 UTC (permalink / raw)
  To: Filipp Gunbin; +Cc: Eli Zaretskii, Jared Finder, 74833, shipmints

Filipp Gunbin <fgunbin@fastmail.fm> writes:

>> I think it's best if we simply agree to disagree.
>
> I don't think we disagree much, I see the value of xterm-mouse-mode
> (although I like "just text" on tty, no menus etc.), the only thing
> which concerns me (and is the reason for this bug) are "half-broken"
> defaults.  
  
I disagree completely :-). I don't see "half-broken" defaults.

> We're discussing whether to disable xterm-mouse-mode only in
> Terminal.app, not everywhere.

I don't think it's proven that only Terminal.app behaves the way it
does. At least iTerm can be configured in a way that it behaves almost
the same. And Alacritty as well.

Without seeing Command-C in Emacs, and then doing something to bring
Emacs' selection to the pasteboard, it's pretty difficult for a terminal
emulator to know what's going on in the app. It would have to be a
clairvoyant.






^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-16 19:20                           ` Ship Mints
@ 2024-12-16 19:57                             ` Gerd Möllmann
  2024-12-16 19:58                             ` Eli Zaretskii
  1 sibling, 0 replies; 51+ messages in thread
From: Gerd Möllmann @ 2024-12-16 19:57 UTC (permalink / raw)
  To: Ship Mints; +Cc: Jared Finder, Eli Zaretskii, Filipp Gunbin, 74833

Ship Mints <shipmints@gmail.com> writes:

> Other terminal applications like iTerm or WezTerm can be programmed
> similarly to pass through all keys that you want them to with
> modifiers, but by default, they don't.

Right. It's the support for the Kitty Keyboard Protocol, which allows
this. Which Emacs doesn't support OOTB, only through the kkp package.





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-16 19:20                           ` Ship Mints
  2024-12-16 19:57                             ` Gerd Möllmann
@ 2024-12-16 19:58                             ` Eli Zaretskii
  2024-12-16 20:07                               ` Ship Mints
  1 sibling, 1 reply; 51+ messages in thread
From: Eli Zaretskii @ 2024-12-16 19:58 UTC (permalink / raw)
  To: Ship Mints; +Cc: gerd.moellmann, jared, 74833, fgunbin

> From: Ship Mints <shipmints@gmail.com>
> Date: Mon, 16 Dec 2024 14:20:40 -0500
> Cc: Gerd Möllmann <gerd.moellmann@gmail.com>, 
> 	Eli Zaretskii <eliz@gnu.org>, Jared Finder <jared@finder.org>, 74833@debbugs.gnu.org
> 
> I think about it like this: if Terminal.app successfully passed through all its keys (which it can be configured to
> do), Command-C would appear in Emacs as M-c but it doesn't. Does it surprise you that Command-P offers
> the print dialog when Emacs is running in the terminal? This is no different than Command-C. That
> Terminal.app supersedes Emacs is not an Emacs problem, it's Terminal's problem. This feels like
> documentation issue not something to cure with default Emacs configuration.
> 
> Other terminal applications like iTerm or WezTerm can be programmed similarly to pass through all keys
> that you want them to with modifiers, but by default, they don't. These can't be Emacs's problem either.
> Same with Emacs run via ssh with tmux on the other side. That's a "default" set of features offered on many
> systems and their configuration is not Emacs's problem.

I see your points, but the fact remains that our enabling of
xterm-mouse-mode triggered these problems where previously there were
none.

> This issue sounds like an "impedance mismatch" to my ears, even if it surprises some users and requires
> some configuration depending on your specific goals and should perhaps be better documented.

If a default behavior needs documentation to explain it, it is usually
a sign of a not-very-good default, IME.





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-16 19:58                             ` Eli Zaretskii
@ 2024-12-16 20:07                               ` Ship Mints
  2024-12-16 20:19                                 ` Eli Zaretskii
  0 siblings, 1 reply; 51+ messages in thread
From: Ship Mints @ 2024-12-16 20:07 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gerd.moellmann, jared, 74833, fgunbin

[-- Attachment #1: Type: text/plain, Size: 2111 bytes --]

Now I see the recent change to master (Dec 9). I'd add that pretty much
every other "curses" based app that supports mouse activity defaults to
mouse on, though. Not sure why Emacs's recent default to on should be
surprising. People would be surprised that the mouse doesn't work. That
Terminal.app also steals command keys from those apps is also not a
surprise.

On Mon, Dec 16, 2024 at 2:58 PM Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Ship Mints <shipmints@gmail.com>
> > Date: Mon, 16 Dec 2024 14:20:40 -0500
> > Cc: Gerd Möllmann <gerd.moellmann@gmail.com>,
> >       Eli Zaretskii <eliz@gnu.org>, Jared Finder <jared@finder.org>,
> 74833@debbugs.gnu.org
> >
> > I think about it like this: if Terminal.app successfully passed through
> all its keys (which it can be configured to
> > do), Command-C would appear in Emacs as M-c but it doesn't. Does it
> surprise you that Command-P offers
> > the print dialog when Emacs is running in the terminal? This is no
> different than Command-C. That
> > Terminal.app supersedes Emacs is not an Emacs problem, it's Terminal's
> problem. This feels like
> > documentation issue not something to cure with default Emacs
> configuration.
> >
> > Other terminal applications like iTerm or WezTerm can be programmed
> similarly to pass through all keys
> > that you want them to with modifiers, but by default, they don't. These
> can't be Emacs's problem either.
> > Same with Emacs run via ssh with tmux on the other side. That's a
> "default" set of features offered on many
> > systems and their configuration is not Emacs's problem.
>
> I see your points, but the fact remains that our enabling of
> xterm-mouse-mode triggered these problems where previously there were
> none.
>
> > This issue sounds like an "impedance mismatch" to my ears, even if it
> surprises some users and requires
> > some configuration depending on your specific goals and should perhaps
> be better documented.
>
> If a default behavior needs documentation to explain it, it is usually
> a sign of a not-very-good default, IME.
>

[-- Attachment #2: Type: text/html, Size: 2916 bytes --]

^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-16 20:07                               ` Ship Mints
@ 2024-12-16 20:19                                 ` Eli Zaretskii
  2024-12-17  3:32                                   ` Gerd Möllmann
  0 siblings, 1 reply; 51+ messages in thread
From: Eli Zaretskii @ 2024-12-16 20:19 UTC (permalink / raw)
  To: Ship Mints; +Cc: gerd.moellmann, jared, 74833, fgunbin

> From: Ship Mints <shipmints@gmail.com>
> Date: Mon, 16 Dec 2024 15:07:25 -0500
> Cc: fgunbin@fastmail.fm, gerd.moellmann@gmail.com, jared@finder.org, 
> 	74833@debbugs.gnu.org
> 
> Now I see the recent change to master (Dec 9). I'd add that pretty much every other "curses" based app
> that supports mouse activity defaults to mouse on, though. Not sure why Emacs's recent default to on should
> be surprising. People would be surprised that the mouse doesn't work. That Terminal.app also steals
> command keys from those apps is also not a surprise.

First, xt-mouse is not about curses, it's about xterm-specific mouse
protocol.

And second, the issue here, at least for me, is not the user surprise
that the mouse works, it's that features which used to work in Emacs
when running on Terminal.app before that change cease to work, at
least in some situations, now.





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-16 19:53                           ` Gerd Möllmann
@ 2024-12-16 20:25                             ` Filipp Gunbin
  2024-12-16 20:29                               ` Ship Mints
  0 siblings, 1 reply; 51+ messages in thread
From: Filipp Gunbin @ 2024-12-16 20:25 UTC (permalink / raw)
  To: Gerd Möllmann; +Cc: Eli Zaretskii, Jared Finder, 74833, shipmints

On 16/12/2024 20:53 +0100, Gerd Möllmann wrote:

> Filipp Gunbin <fgunbin@fastmail.fm> writes:
>
>>> I think it's best if we simply agree to disagree.
>>
>> I don't think we disagree much, I see the value of xterm-mouse-mode
>> (although I like "just text" on tty, no menus etc.), the only thing
>> which concerns me (and is the reason for this bug) are "half-broken"
>> defaults.  
>   
> I disagree completely :-). I don't see "half-broken" defaults.

What is the default value of "Allow mouse reporting" if you open a new
Terminal.app tab?  If it's ticked, like here, then you see them :-)
Because then you get by default that half-way setup which I'm
complaining about.

>> We're discussing whether to disable xterm-mouse-mode only in
>> Terminal.app, not everywhere.
>
> I don't think it's proven that only Terminal.app behaves the way it
> does. At least iTerm can be configured in a way that it behaves almost
> the same. And Alacritty as well.

Terminal.app is the default terminal on macOS, so it's a bit more
important in this context than others, I think.  And we're talking about
what Terminal.app does by default.





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-16 20:25                             ` Filipp Gunbin
@ 2024-12-16 20:29                               ` Ship Mints
  0 siblings, 0 replies; 51+ messages in thread
From: Ship Mints @ 2024-12-16 20:29 UTC (permalink / raw)
  To: Filipp Gunbin; +Cc: Gerd Möllmann, Eli Zaretskii, Jared Finder, 74833

[-- Attachment #1: Type: text/plain, Size: 1527 bytes --]

On mac, mouse reporting defaults to on and I think always has. "By default,
each new Terminal window has the Allow Mouse Reporting option selected."
Via
https://support.apple.com/guide/terminal/turn-on-mouse-reporting-trmlc69728a5/mac

On Mon, Dec 16, 2024 at 3:25 PM Filipp Gunbin <fgunbin@fastmail.fm> wrote:

> On 16/12/2024 20:53 +0100, Gerd Möllmann wrote:
>
> > Filipp Gunbin <fgunbin@fastmail.fm> writes:
> >
> >>> I think it's best if we simply agree to disagree.
> >>
> >> I don't think we disagree much, I see the value of xterm-mouse-mode
> >> (although I like "just text" on tty, no menus etc.), the only thing
> >> which concerns me (and is the reason for this bug) are "half-broken"
> >> defaults.
> >
> > I disagree completely :-). I don't see "half-broken" defaults.
>
> What is the default value of "Allow mouse reporting" if you open a new
> Terminal.app tab?  If it's ticked, like here, then you see them :-)
> Because then you get by default that half-way setup which I'm
> complaining about.
>
> >> We're discussing whether to disable xterm-mouse-mode only in
> >> Terminal.app, not everywhere.
> >
> > I don't think it's proven that only Terminal.app behaves the way it
> > does. At least iTerm can be configured in a way that it behaves almost
> > the same. And Alacritty as well.
>
> Terminal.app is the default terminal on macOS, so it's a bit more
> important in this context than others, I think.  And we're talking about
> what Terminal.app does by default.
>

[-- Attachment #2: Type: text/html, Size: 2276 bytes --]

^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-16 20:19                                 ` Eli Zaretskii
@ 2024-12-17  3:32                                   ` Gerd Möllmann
  2024-12-17 12:32                                     ` Eli Zaretskii
  0 siblings, 1 reply; 51+ messages in thread
From: Gerd Möllmann @ 2024-12-17  3:32 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: jared, 74833, fgunbin, Ship Mints

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Ship Mints <shipmints@gmail.com>
>> Date: Mon, 16 Dec 2024 15:07:25 -0500
>> Cc: fgunbin@fastmail.fm, gerd.moellmann@gmail.com, jared@finder.org, 
>> 	74833@debbugs.gnu.org
>> 
>> Now I see the recent change to master (Dec 9). I'd add that pretty much every other "curses" based app
>> that supports mouse activity defaults to mouse on, though. Not sure
>> why Emacs's recent default to on should
>> be surprising. People would be surprised that the mouse doesn't work. That Terminal.app also steals
>> command keys from those apps is also not a surprise.
>
> First, xt-mouse is not about curses, it's about xterm-specific mouse
> protocol.

Replace "curses" which he put in quotes with terminal application and
what Ship Mints says is true.

> And second, the issue here, at least for me, is not the user surprise
> that the mouse works, it's that features which used to work in Emacs
> when running on Terminal.app before that change cease to work, at
> least in some situations, now.

I really don't know what you are talking about when you write "feature
in Emacs". There is no feature _in_ Emacs that is broken. Emacs doesn't
even get a keyboard event for Command-C, it has no idea what is going
on.

It's Terminal.app that behaves differently. And Terminal.app has
previsions for that (Command-R, Fn-mouse).






^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-17  3:32                                   ` Gerd Möllmann
@ 2024-12-17 12:32                                     ` Eli Zaretskii
  2024-12-18 17:50                                       ` Ship Mints
  0 siblings, 1 reply; 51+ messages in thread
From: Eli Zaretskii @ 2024-12-17 12:32 UTC (permalink / raw)
  To: Gerd Möllmann; +Cc: jared, 74833, fgunbin, shipmints

> From: Gerd Möllmann <gerd.moellmann@gmail.com>
> Cc: Ship Mints <shipmints@gmail.com>,  fgunbin@fastmail.fm,
>   jared@finder.org,  74833@debbugs.gnu.org
> Date: Tue, 17 Dec 2024 04:32:20 +0100
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > And second, the issue here, at least for me, is not the user surprise
> > that the mouse works, it's that features which used to work in Emacs
> > when running on Terminal.app before that change cease to work, at
> > least in some situations, now.
> 
> I really don't know what you are talking about when you write "feature
> in Emacs". There is no feature _in_ Emacs that is broken. Emacs doesn't
> even get a keyboard event for Command-C, it has no idea what is going
> on.
> 
> It's Terminal.app that behaves differently. And Terminal.app has
> previsions for that (Command-R, Fn-mouse).

I don't see how this distinction (which I have no doubt is accurate)
is important to the decision we should make here.  Simply put,
"something" that worked on Terminal.app before we turned on xt-moude
doesn't work in some cases after we turned it on.  That's my bother.





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-17 12:32                                     ` Eli Zaretskii
@ 2024-12-18 17:50                                       ` Ship Mints
  2024-12-19  5:16                                         ` Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 51+ messages in thread
From: Ship Mints @ 2024-12-18 17:50 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Gerd Möllmann, jared, 74833, fgunbin

[-- Attachment #1: Type: text/plain, Size: 1696 bytes --]

I see your point, Eli, for sure. Since this is on master, and presumably
destined for Emacs 31, there seems to be sufficient time for people to read
NEWS and PROBLEMS and accommodate their configurations while Emacs is
brought one step forward into behaving, by default, like other terminal
apps on macOS.

I think someone suggested bringing xclip (seems properly licensed) into the
core and now might be a good time to consider that.

On Tue, Dec 17, 2024 at 1:32 PM Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Gerd Möllmann <gerd.moellmann@gmail.com>
> > Cc: Ship Mints <shipmints@gmail.com>,  fgunbin@fastmail.fm,
> >   jared@finder.org,  74833@debbugs.gnu.org
> > Date: Tue, 17 Dec 2024 04:32:20 +0100
> >
> > Eli Zaretskii <eliz@gnu.org> writes:
> >
> > > And second, the issue here, at least for me, is not the user surprise
> > > that the mouse works, it's that features which used to work in Emacs
> > > when running on Terminal.app before that change cease to work, at
> > > least in some situations, now.
> >
> > I really don't know what you are talking about when you write "feature
> > in Emacs". There is no feature _in_ Emacs that is broken. Emacs doesn't
> > even get a keyboard event for Command-C, it has no idea what is going
> > on.
> >
> > It's Terminal.app that behaves differently. And Terminal.app has
> > previsions for that (Command-R, Fn-mouse).
>
> I don't see how this distinction (which I have no doubt is accurate)
> is important to the decision we should make here.  Simply put,
> "something" that worked on Terminal.app before we turned on xt-moude
> doesn't work in some cases after we turned it on.  That's my bother.
>

[-- Attachment #2: Type: text/html, Size: 2700 bytes --]

^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-18 17:50                                       ` Ship Mints
@ 2024-12-19  5:16                                         ` Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-12-19 17:23                                           ` Ship Mints
  0 siblings, 1 reply; 51+ messages in thread
From: Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-19  5:16 UTC (permalink / raw)
  To: Ship Mints; +Cc: Gerd Möllmann, Eli Zaretskii, fgunbin, 74833

On 2024-12-18 09:50, Ship Mints wrote:
> On Tue, Dec 17, 2024 at 1:32 PM Eli Zaretskii <eliz@gnu.org> wrote:
>> I don't see how this distinction (which I have no doubt is accurate)
>> is important to the decision we should make here.  Simply put,
>> "something" that worked on Terminal.app before we turned on xt-moude
>> doesn't work in some cases after we turned it on.  That's my bother.
> I see your point, Eli, for sure. Since this is on master, and 
> presumably destined for Emacs 31, there seems to be sufficient time for 
> people to read NEWS and PROBLEMS and accommodate their configurations 
> while Emacs is brought one step forward into behaving, by default, like 
> other terminal apps on macOS.
> 
> 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).

   -- MJF





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-19  5:16                                         ` Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-12-19 17:23                                           ` Ship Mints
  2024-12-20 18:48                                             ` Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-12-22  4:49                                             ` Richard Stallman
  0 siblings, 2 replies; 51+ messages in thread
From: Ship Mints @ 2024-12-19 17:23 UTC (permalink / raw)
  To: Jared Finder; +Cc: Gerd Möllmann, Eli Zaretskii, fgunbin, 74833

[-- Attachment #1: Type: text/plain, Size: 2372 bytes --]

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.

As far as the proposed user option goes, "fallback" doesn't really convey
any meaning to me. I know eglot adopted the convention "stay out of" to
control that minor mode's enabling other minor modes. Perhaps a user option
called xterm-stay-out-of-xclip, if that's a convention that people would
like, or xterm-inhibit-enabling-xclip following long-standing Emacs inhibit
conventions. This is moot until xclip becomes part of Emacs.



On Thu, Dec 19, 2024 at 6:16 AM Jared Finder <jared@finder.org> wrote:

> On 2024-12-18 09:50, Ship Mints wrote:
> > On Tue, Dec 17, 2024 at 1:32 PM Eli Zaretskii <eliz@gnu.org> wrote:
> >> I don't see how this distinction (which I have no doubt is accurate)
> >> is important to the decision we should make here.  Simply put,
> >> "something" that worked on Terminal.app before we turned on xt-moude
> >> doesn't work in some cases after we turned it on.  That's my bother.
> > I see your point, Eli, for sure. Since this is on master, and
> > presumably destined for Emacs 31, there seems to be sufficient time for
> > people to read NEWS and PROBLEMS and accommodate their configurations
> > while Emacs is brought one step forward into behaving, by default, like
> > other terminal apps on macOS.
> >
> > 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).
>
>    -- MJF
>

[-- Attachment #2: Type: text/html, Size: 3242 bytes --]

^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-19 17:23                                           ` Ship Mints
@ 2024-12-20 18:48                                             ` Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-12-22  4:49                                             ` Richard Stallman
  1 sibling, 0 replies; 51+ messages in thread
From: Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-20 18:48 UTC (permalink / raw)
  To: Ship Mints; +Cc: Gerd Möllmann, Eli Zaretskii, fgunbin, 74833

On 2024-12-19 09:23, Ship Mints wrote:
> On Thu, Dec 19, 2024 at 6:16 AM Jared Finder <jared@finder.org> 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





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-19 17:23                                           ` Ship Mints
  2024-12-20 18:48                                             ` Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-12-22  4:49                                             ` Richard Stallman
  2024-12-22  6:12                                               ` Gerd Möllmann
  2024-12-22  7:46                                               ` Eli Zaretskii
  1 sibling, 2 replies; 51+ messages in thread
From: Richard Stallman @ 2024-12-22  4:49 UTC (permalink / raw)
  To: Ship Mints; +Cc: gerd.moellmann, fgunbin, eliz, jared, 74833

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > 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,

Merging the application program xclip into Emacs seems like doing
things the roundabout way.  Doesn't Emacs already have access to the X
clipboard and selections?  If it doesn't have all the desirable
features in that area, we can implement the missing ones simply
like the already-implemened ones.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)







^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-22  4:49                                             ` Richard Stallman
@ 2024-12-22  6:12                                               ` Gerd Möllmann
  2024-12-22  7:46                                               ` Eli Zaretskii
  1 sibling, 0 replies; 51+ messages in thread
From: Gerd Möllmann @ 2024-12-22  6:12 UTC (permalink / raw)
  To: Richard Stallman; +Cc: 74833, fgunbin, eliz, jared, Ship Mints

Richard Stallman <rms@gnu.org> writes:

> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
>   > 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,
>
> Merging the application program xclip into Emacs seems like doing
> things the roundabout way.  Doesn't Emacs already have access to the X
> clipboard and selections?  If it doesn't have all the desirable
> features in that area, we can implement the missing ones simply
> like the already-implemened ones.

The 'xclip' meant here is the ELPA package

  https://elpa.gnu.org/packages/xclip.html





^ permalink raw reply	[flat|nested] 51+ messages in thread

* bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled
  2024-12-22  4:49                                             ` Richard Stallman
  2024-12-22  6:12                                               ` Gerd Möllmann
@ 2024-12-22  7:46                                               ` Eli Zaretskii
  1 sibling, 0 replies; 51+ messages in thread
From: Eli Zaretskii @ 2024-12-22  7:46 UTC (permalink / raw)
  To: rms; +Cc: gerd.moellmann, fgunbin, 74833, jared, shipmints

> From: Richard Stallman <rms@gnu.org>
> Cc: jared@finder.org, gerd.moellmann@gmail.com, eliz@gnu.org,
> 	fgunbin@fastmail.fm, 74833@debbugs.gnu.org
> Date: Sat, 21 Dec 2024 23:49:28 -0500
> 
>   > 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,
> 
> Merging the application program xclip into Emacs seems like doing
> things the roundabout way.  Doesn't Emacs already have access to the X
> clipboard and selections?  If it doesn't have all the desirable
> features in that area, we can implement the missing ones simply
> like the already-implemened ones.

The xclip package is about allowing Emacs to access the clipboard and
selection from text-only frames.  That is supported on xterm and on
some other text terminals, but not universally.  This package is
supposed to fill the gaps by using external programs.





^ permalink raw reply	[flat|nested] 51+ messages in thread

end of thread, other threads:[~2024-12-22  7:46 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-12 17:54 bug#74833: 31.0.50; Copy to OS clipboard doesn't work in macOS Terminal.app with xterm-mouse-mode enabled Filipp Gunbin
2024-12-12 18:08 ` Ship Mints
2024-12-12 18:18   ` Filipp Gunbin
2024-12-12 18:20     ` Ship Mints
2024-12-12 19:15 ` Eli Zaretskii
2024-12-12 19:18   ` Ship Mints
2024-12-12 19:32     ` Eli Zaretskii
2024-12-12 20:07       ` Gerd Möllmann
2024-12-12 20:31       ` Ship Mints
2024-12-13  7:21         ` Eli Zaretskii
2024-12-13 14:46           ` Ship Mints
2024-12-13 16:35           ` Filipp Gunbin
2024-12-13 16:42             ` Ship Mints
2024-12-13 16:52               ` Ship Mints
2024-12-13 20:46                 ` Filipp Gunbin
2024-12-13 16:49             ` Eli Zaretskii
2024-12-13 20:32               ` Filipp Gunbin
2024-12-13 20:54                 ` Ship Mints
2024-12-14  7:52                 ` Eli Zaretskii
2024-12-14  9:40                   ` Gerd Möllmann
2024-12-16 16:32                     ` Filipp Gunbin
2024-12-16 17:30                       ` Gerd Möllmann
2024-12-16 17:42                         ` Eli Zaretskii
2024-12-16 17:53                           ` Gerd Möllmann
2024-12-16 19:09                         ` Filipp Gunbin
2024-12-16 19:20                           ` Ship Mints
2024-12-16 19:57                             ` Gerd Möllmann
2024-12-16 19:58                             ` Eli Zaretskii
2024-12-16 20:07                               ` Ship Mints
2024-12-16 20:19                                 ` Eli Zaretskii
2024-12-17  3:32                                   ` Gerd Möllmann
2024-12-17 12:32                                     ` Eli Zaretskii
2024-12-18 17:50                                       ` Ship Mints
2024-12-19  5:16                                         ` Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-19 17:23                                           ` Ship Mints
2024-12-20 18:48                                             ` Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-22  4:49                                             ` Richard Stallman
2024-12-22  6:12                                               ` Gerd Möllmann
2024-12-22  7:46                                               ` Eli Zaretskii
2024-12-16 19:53                           ` Gerd Möllmann
2024-12-16 20:25                             ` Filipp Gunbin
2024-12-16 20:29                               ` Ship Mints
2024-12-12 19:55   ` Gerd Möllmann
2024-12-16  1:41 ` Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-16  3:40   ` Gerd Möllmann
2024-12-16  5:16     ` Jared Finder via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-16 16:37       ` Eli Zaretskii
2024-12-16 16:47         ` Ship Mints
2024-12-16 17:36         ` Gerd Möllmann
2024-12-16 16:30     ` Eli Zaretskii
2024-12-16 16:49   ` Filipp Gunbin

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).