unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Jared Finder <jared@finder.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: philipk@posteo.net, Emacs-devel@gnu.org
Subject: Re: Enabling Xterm-Mouse-Mode
Date: Mon, 09 Dec 2024 22:22:06 -0800	[thread overview]
Message-ID: <23bae57db2082aebd7f79064599c218f@finder.org> (raw)
In-Reply-To: <db15f34f07d5c22b354a99cb1dd0ef6c@finder.org>

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


  reply	other threads:[~2024-12-10  6:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=23bae57db2082aebd7f79064599c218f@finder.org \
    --to=jared@finder.org \
    --cc=Emacs-devel@gnu.org \
    --cc=eliz@gnu.org \
    --cc=philipk@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).