unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Enabling Xterm-Mouse-Mode
@ 2024-12-06  8:51 Philip Kaludercic
  2024-12-06 11:40 ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Philip Kaludercic @ 2024-12-06  8:51 UTC (permalink / raw)
  To: Emacs-devel@gnu.org


Is there a reason that we do not enable `xterm-mouse-mode' in emacs -nw
by default?  Are there issues with the implementation that prevent the
change?



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

* Re: Enabling Xterm-Mouse-Mode
  2024-12-06  8:51 Enabling Xterm-Mouse-Mode Philip Kaludercic
@ 2024-12-06 11:40 ` Eli Zaretskii
  2024-12-06 11:50   ` Philip Kaludercic
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2024-12-06 11:40 UTC (permalink / raw)
  To: Philip Kaludercic, Jared Finder; +Cc: Emacs-devel

> From: Philip Kaludercic <philipk@posteo.net>
> Date: Fri, 06 Dec 2024 08:51:01 +0000
> 
> 
> Is there a reason that we do not enable `xterm-mouse-mode' in emacs -nw
> by default?  Are there issues with the implementation that prevent the
> change?

Users might not expect that?  Certain escape sequences might not
really be mouse-related?

I've added Jared to this discussion.



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

* Re: Enabling Xterm-Mouse-Mode
  2024-12-06 11:40 ` Eli Zaretskii
@ 2024-12-06 11:50   ` Philip Kaludercic
  2024-12-08  0:37     ` Jared Finder
  2024-12-08  5:17     ` Richard Stallman
  0 siblings, 2 replies; 12+ messages in thread
From: Philip Kaludercic @ 2024-12-06 11:50 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Jared Finder, Emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Philip Kaludercic <philipk@posteo.net>
>> Date: Fri, 06 Dec 2024 08:51:01 +0000
>> 
>> 
>> Is there a reason that we do not enable `xterm-mouse-mode' in emacs -nw
>> by default?  Are there issues with the implementation that prevent the
>> change?
>
> Users might not expect that?  Certain escape sequences might not
> really be mouse-related?

From observing people (often accidentally) using Emacs in my computer
labs, they do them to expect that.  Clicking to move the point is
something that people appear to do very intuitively, and the TUI menus
hint toward mouse-usage as well.

> I've added Jared to this discussion.



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

* Re: Enabling Xterm-Mouse-Mode
  2024-12-06 11:50   ` Philip Kaludercic
@ 2024-12-08  0:37     ` Jared Finder
  2024-12-08  6:07       ` Eli Zaretskii
  2024-12-08  5:17     ` Richard Stallman
  1 sibling, 1 reply; 12+ messages in thread
From: Jared Finder @ 2024-12-08  0:37 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Eli Zaretskii, Emacs-devel

On 2024-12-06 03:50, Philip Kaludercic wrote:
> Eli Zaretskii <eliz@gnu.org> writes:
> 
>>> From: Philip Kaludercic <philipk@posteo.net>
>>> Date: Fri, 06 Dec 2024 08:51:01 +0000
>>> 
>>> 
>>> Is there a reason that we do not enable `xterm-mouse-mode' in emacs 
>>> -nw
>>> by default?  Are there issues with the implementation that prevent 
>>> the
>>> change?
>> 
>> Users might not expect that?  Certain escape sequences might not
>> really be mouse-related?
> 
> From observing people (often accidentally) using Emacs in my computer
> labs, they do them to expect that.  Clicking to move the point is
> something that people appear to do very intuitively, and the TUI menus
> hint toward mouse-usage as well.
> 
>> I've added Jared to this discussion.

As long as we can defer actually sending the mouse tracking escape 
sequence until after init file load I think this is fine. All terminals 
I've worked with work fine with xterm-mouse-mode's defaults, but since 
there's so many different terminals I want to ensure user compatibility 
variables still work (currently just xterm-mouse-utf-8, I expect to 
create a new one for bug #73469).

Also, I expect this would only be done when the envvar TERM indicates 
the user is on an xterm-compatible terminal.

   -- MJF



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

* Re: Enabling Xterm-Mouse-Mode
  2024-12-06 11:50   ` Philip Kaludercic
  2024-12-08  0:37     ` Jared Finder
@ 2024-12-08  5:17     ` Richard Stallman
  2024-12-08  9:55       ` Philip Kaludercic
  1 sibling, 1 reply; 12+ messages in thread
From: Richard Stallman @ 2024-12-08  5:17 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: eliz, jared, Emacs-devel

[[[ 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 get the impression that Xterm Mouse mode is meant for running
Emacs in an exterm.

What happens if you enable it when using a Linux console?

-- 
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] 12+ messages in thread

* Re: Enabling Xterm-Mouse-Mode
  2024-12-08  0:37     ` Jared Finder
@ 2024-12-08  6:07       ` Eli Zaretskii
  2024-12-08 16:35         ` Jared Finder
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2024-12-08  6:07 UTC (permalink / raw)
  To: Jared Finder; +Cc: philipk, Emacs-devel

> Date: Sat, 07 Dec 2024 16:37:46 -0800
> From: Jared Finder <jared@finder.org>
> Cc: Eli Zaretskii <eliz@gnu.org>, Emacs-devel@gnu.org
> 
> On 2024-12-06 03:50, Philip Kaludercic wrote:
> > Eli Zaretskii <eliz@gnu.org> writes:
> > 
> >>> From: Philip Kaludercic <philipk@posteo.net>
> >>> Date: Fri, 06 Dec 2024 08:51:01 +0000
> >>> 
> >>> 
> >>> Is there a reason that we do not enable `xterm-mouse-mode' in emacs 
> >>> -nw
> >>> by default?  Are there issues with the implementation that prevent 
> >>> the
> >>> change?
> >> 
> >> Users might not expect that?  Certain escape sequences might not
> >> really be mouse-related?
> > 
> > From observing people (often accidentally) using Emacs in my computer
> > labs, they do them to expect that.  Clicking to move the point is
> > something that people appear to do very intuitively, and the TUI menus
> > hint toward mouse-usage as well.
> > 
> >> I've added Jared to this discussion.
> 
> As long as we can defer actually sending the mouse tracking escape 
> sequence until after init file load I think this is fine. All terminals 
> I've worked with work fine with xterm-mouse-mode's defaults, but since 
> there's so many different terminals I want to ensure user compatibility 
> variables still work (currently just xterm-mouse-utf-8, I expect to 
> create a new one for bug #73469).

So this would require some changes in the code, to make sure the
escape sequences are delayed?

> Also, I expect this would only be done when the envvar TERM indicates 
> the user is on an xterm-compatible terminal.

How do we know which ones are compatible?



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

* Re: Enabling Xterm-Mouse-Mode
  2024-12-08  5:17     ` Richard Stallman
@ 2024-12-08  9:55       ` Philip Kaludercic
  2024-12-08 16:40         ` Jared Finder
  0 siblings, 1 reply; 12+ messages in thread
From: Philip Kaludercic @ 2024-12-08  9:55 UTC (permalink / raw)
  To: Richard Stallman; +Cc: eliz, jared, Emacs-devel

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 get the impression that Xterm Mouse mode is meant for running
> Emacs in an exterm.

Not just Xterm, but most terminal emulators.  But I guess that is a given.

> What happens if you enable it when using a Linux console?

From some superficial testing, it doesn't appear to affect anything.  I
know that there are TTYs with some kind of mouse support, I can try and
see if I can get that running on my system to test it out.



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

* Re: Enabling Xterm-Mouse-Mode
  2024-12-08  6:07       ` Eli Zaretskii
@ 2024-12-08 16:35         ` Jared Finder
  2024-12-10  6:22           ` Jared Finder
  0 siblings, 1 reply; 12+ messages in thread
From: Jared Finder @ 2024-12-08 16:35 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: philipk, Emacs-devel

On 2024-12-07 22:07, Eli Zaretskii wrote:
>> Date: Sat, 07 Dec 2024 16:37:46 -0800
>> From: Jared Finder <jared@finder.org>
>> Cc: Eli Zaretskii <eliz@gnu.org>, Emacs-devel@gnu.org
>> 
>> As long as we can defer actually sending the mouse tracking escape
>> sequence until after init file load I think this is fine. All 
>> terminals
>> I've worked with work fine with xterm-mouse-mode's defaults, but since
>> there's so many different terminals I want to ensure user 
>> compatibility
>> variables still work (currently just xterm-mouse-utf-8, I expect to
>> create a new one for bug #73469).
> 
> So this would require some changes in the code, to make sure the
> escape sequences are delayed?

Yes, some changes, though they are straightforward.

>> Also, I expect this would only be done when the envvar TERM indicates
>> the user is on an xterm-compatible terminal.
> 
> How do we know which ones are compatible?

If Emacs decided to load term/xterm.el then the terminal advertised 
itself as xterm compatible and I think we could enable xterm-mouse-mode. 
There's no termcap entry for mouse support, sadly.

   -- MJF



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

* Re: Enabling Xterm-Mouse-Mode
  2024-12-08  9:55       ` Philip Kaludercic
@ 2024-12-08 16:40         ` Jared Finder
  2024-12-11  4:33           ` Richard Stallman
  0 siblings, 1 reply; 12+ messages in thread
From: Jared Finder @ 2024-12-08 16:40 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Richard Stallman, eliz, Emacs-devel

On 2024-12-08 01:55, Philip Kaludercic wrote:
> 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 get the impression that Xterm Mouse mode is meant for running
>> Emacs in an exterm.
> 
> Not just Xterm, but most terminal emulators.  But I guess that is a 
> given.
> 
>> What happens if you enable it when using a Linux console?
> 
> From some superficial testing, it doesn't appear to affect anything.  I
> know that there are TTYs with some kind of mouse support, I can try and
> see if I can get that running on my system to test it out.

Are you talking about GPM? That's what is used on Linux. In a pure Linux 
terminal ($TERM set to "linux"), xterm-mouse-mode doesn't appear to have 
any effect.

   -- MJF



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

* Re: Enabling Xterm-Mouse-Mode
  2024-12-08 16:35         ` Jared Finder
@ 2024-12-10  6:22           ` Jared Finder
  0 siblings, 0 replies; 12+ messages in thread
From: Jared Finder @ 2024-12-10  6:22 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: philipk, Emacs-devel

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

On 2024-12-08 08:35, Jared Finder wrote:
> On 2024-12-07 22:07, Eli Zaretskii wrote:
>>> Date: Sat, 07 Dec 2024 16:37:46 -0800
>>> From: Jared Finder <jared@finder.org>
>>> Cc: Eli Zaretskii <eliz@gnu.org>, Emacs-devel@gnu.org
>>> 
>>> As long as we can defer actually sending the mouse tracking escape
>>> sequence until after init file load I think this is fine. All 
>>> terminals
>>> I've worked with work fine with xterm-mouse-mode's defaults, but 
>>> since
>>> there's so many different terminals I want to ensure user 
>>> compatibility
>>> variables still work (currently just xterm-mouse-utf-8, I expect to
>>> create a new one for bug #73469).
>> 
>> So this would require some changes in the code, to make sure the
>> escape sequences are delayed?
> 
> Yes, some changes, though they are straightforward.
> 
>>> Also, I expect this would only be done when the envvar TERM indicates
>>> the user is on an xterm-compatible terminal.
>> 
>> How do we know which ones are compatible?
> 
> If Emacs decided to load term/xterm.el then the terminal advertised 
> itself as xterm compatible and I think we could enable 
> xterm-mouse-mode. There's no termcap entry for mouse support, sadly.

Relying on term/xterm.el being loaded made the patch very 
straightforward because it gets loaded after user init files.  Patch 
attached.

   -- MJF

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Enable-xterm-mouse-mode-by-default-in-xterm.patch --]
[-- Type: text/x-diff; name=0001-Enable-xterm-mouse-mode-by-default-in-xterm.patch, Size: 2057 bytes --]

From eecc931e8dc58487cd710ef158fe1e216da0a717 Mon Sep 17 00:00:00 2001
From: Jared Finder <jared@finder.org>
Date: Mon, 9 Dec 2024 22:16:40 -0800
Subject: [PATCH] Enable xterm-mouse-mode by default in xterm

* lisp/xt-mouse.el (xterm-mouse-mode): Change default value of
xterm-mouse-mode to t.
* lisp/term/xterm.el (xterm--init): Enable xterm-mouse-mode if
the default value is still set.
* etc/NEWS: Document new behavior.
---
 etc/NEWS           | 6 ++++++
 lisp/term/xterm.el | 2 ++
 lisp/xt-mouse.el   | 2 ++
 3 files changed, 10 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index 3efce149dbf..aebcf30d84a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -41,6 +41,12 @@ why the mark trace buffer is enabled by default.
 \f
 * Startup Changes in Emacs 31.1
 
+** When run inside xterm, 'xterm-mouse-mode' is turned on by default.
+This means that the mouse will work by default inside xterm terminals.
+If your terminal does not behave properly with xterm mouse tracking
+enabled, you can disable mouse tracking by putting '(xterm-mouse-mode
+-1)' in your init file.
+
 \f
 * Changes in Emacs 31.1
 
diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el
index 82f9a60b53b..c4f33cd0faa 100644
--- a/lisp/term/xterm.el
+++ b/lisp/term/xterm.el
@@ -907,6 +907,8 @@ xterm--init
 
   (when xterm-set-window-title
     (xterm--init-frame-title))
+  (when xterm-mouse-mode
+    (xterm-mouse-mode 1))
   ;; Unconditionally enable bracketed paste mode: terminals that don't
   ;; support it just ignore the sequence.
   (xterm--init-bracketed-paste-mode)
diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el
index 8cbb44ece14..c77d763702c 100644
--- a/lisp/xt-mouse.el
+++ b/lisp/xt-mouse.el
@@ -358,6 +358,8 @@ xterm-mouse-mode
 mouse functionality for such clicks is still available by holding
 down the SHIFT key while pressing the mouse button."
   :global t :group 'mouse
+  :init-value t
+  :version "31.1"
   (funcall (if xterm-mouse-mode 'add-hook 'remove-hook)
            'terminal-init-xterm-hook
            'turn-on-xterm-mouse-tracking-on-terminal)
-- 
2.39.5


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

* Re: Enabling Xterm-Mouse-Mode
  2024-12-08 16:40         ` Jared Finder
@ 2024-12-11  4:33           ` Richard Stallman
  2024-12-11  6:27             ` Jared Finder
  0 siblings, 1 reply; 12+ messages in thread
From: Richard Stallman @ 2024-12-11  4:33 UTC (permalink / raw)
  To: Jared Finder; +Cc: philipk, eliz, Emacs-devel

[[[ 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. ]]]

  > Are you talking about GPM? That's what is used on Linux.

I don't recognize the name GPM.  As far as I know, I am using the
default tty that I can get to by tyming Meta-F1, Meta-F2, and so on.

-- 
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] 12+ messages in thread

* Re: Enabling Xterm-Mouse-Mode
  2024-12-11  4:33           ` Richard Stallman
@ 2024-12-11  6:27             ` Jared Finder
  0 siblings, 0 replies; 12+ messages in thread
From: Jared Finder @ 2024-12-11  6:27 UTC (permalink / raw)
  To: rms; +Cc: philipk, eliz, Emacs-devel

On 2024-12-10 23:33, Richard Stallman wrote:
> [[[ 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. ]]]
> 
>   > Are you talking about GPM? That's what is used on Linux.
> 
> I don't recognize the name GPM.  As far as I know, I am using the
> default tty that I can get to by tyming Meta-F1, Meta-F2, and so on.

Those are terminals provided by the Linux kernel. They report themselves 
as TERM=linux and so Emacs loads term/linux.el at startup. This wouldn't 
be affected by enabling xterm-mouse-mode for xterm, which instead loads 
term/xterm.el.

   -- MJF



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

end of thread, other threads:[~2024-12-11  6:27 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-06  8:51 Enabling Xterm-Mouse-Mode Philip Kaludercic
2024-12-06 11:40 ` Eli Zaretskii
2024-12-06 11:50   ` Philip Kaludercic
2024-12-08  0:37     ` Jared Finder
2024-12-08  6:07       ` Eli Zaretskii
2024-12-08 16:35         ` Jared Finder
2024-12-10  6:22           ` Jared Finder
2024-12-08  5:17     ` Richard Stallman
2024-12-08  9:55       ` Philip Kaludercic
2024-12-08 16:40         ` Jared Finder
2024-12-11  4:33           ` Richard Stallman
2024-12-11  6:27             ` Jared Finder

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).