GNU bug report logs - #41156
margins interfere with xterm-mouse-mode

Previous Next

Package: emacs;

Reported by: Neil Okamoto <neil.okamoto <at> gmail.com>

Date: Sat, 9 May 2020 18:23:01 UTC

Severity: normal

Tags: confirmed

Found in version 26.3

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 41156 in the body.
You can then email your comments to 41156 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#41156; Package emacs. (Sat, 09 May 2020 18:23:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Neil Okamoto <neil.okamoto <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 09 May 2020 18:23:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Neil Okamoto <neil.okamoto <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.3; 27.0.91; linum-mode interferes with xterm-mouse-mode
Date: Sat, 9 May 2020 11:21:40 -0700
You cannot drag the vertical boundary between windows to the right, if the righthand window has linum-mode active. I’ve confirmed this on Emacs 26.3 and 27.0.91. I have not tried earlier builds.

Steps to reproduce:

$ emacs -nw -q
    M-x xterm-mouse-mode
    C-x b *scratch*
    C-x 3

    Use the mouse to drag the vertical divider right and left? Succeeds.

Now enable linum-mode:

    M-x linum-mode

    Use the mouse to drag the vertical divider left? Succeeds.
    Use the mouse to drag the vertical divider right?
    Fails with the message "<left-margin> <mouse-movement> is undefined"


Thank you-



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41156; Package emacs. (Mon, 11 May 2020 17:15:02 GMT) Full text and rfc822 format available.

Message #8 received at 41156 <at> debbugs.gnu.org (full text, mbox):

From: Neil Okamoto <neil.okamoto <at> gmail.com>
To: 41156 <at> debbugs.gnu.org
Subject: Updated description
Date: Mon, 11 May 2020 10:14:45 -0700
After further testing, I wanted to clarify that this occurs even without linum-mode.  It occurs whenever there are window margins to either side of the vertical divider.

So, e.g. 

$ emacs -nw -q
    M-x xterm-mouse-mode
    C-x b *scratch*
    C-x 3

    Use the mouse to drag the vertical divider right and left? Succeeds.

Now set a right margin on the left window:

    (set-window-margins (selected-window) 0 2)

    Use the mouse to drag the vertical divider to the left?
    Fails with the message “<right-margin> <mouse-movement> is undefined”

    (set-window-margins (selected-window) 0 0)

    And mouse-movement is permitted again.

Similarly, setting a left margin on the right window:

    (set-window-margins (selected-window) 2 0)

    Use the mouse to drag the vertical divider to the right?
    Fails with the message “<left-margin> <mouse-movement> is undefined”

    (set-window-margins (selected-window) 0 0)

    And mouse-movement is permitted again.






Changed bug title to 'margins interfere with xterm-mouse-mode' from '26.3; 27.0.91; linum-mode interferes with xterm-mouse-mode' Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 25 May 2020 14:40:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41156; Package emacs. (Sun, 13 Jun 2021 12:11:02 GMT) Full text and rfc822 format available.

Message #13 received at 41156 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Neil Okamoto <neil.okamoto <at> gmail.com>
Cc: 41156 <at> debbugs.gnu.org
Subject: Re: bug#41156: margins interfere with xterm-mouse-mode
Date: Sun, 13 Jun 2021 14:10:38 +0200
Neil Okamoto <neil.okamoto <at> gmail.com> writes:

> After further testing, I wanted to clarify that this occurs even
> without linum-mode.  It occurs whenever there are window margins to
> either side of the vertical divider.
>
> So, e.g. 
>
> $ emacs -nw -q
>     M-x xterm-mouse-mode
>     C-x b *scratch*
>     C-x 3
>
>     Use the mouse to drag the vertical divider right and left? Succeeds.
>
> Now set a right margin on the left window:
>
>     (set-window-margins (selected-window) 0 2)
>
>     Use the mouse to drag the vertical divider to the left?
>     Fails with the message “<right-margin> <mouse-movement> is undefined”

(I'm going through old bug reports that unfortunately got no response at
the time.)

Testing this in Emacs 28, I do not get any errors (but I can reproduce
the issue in Emacs 27.1.)  However -- it still doesn't work: When
dragging the divider to the left, nothing happens.  (Dragging to the
right works fine.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) confirmed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 13 Jun 2021 12:11:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41156; Package emacs. (Sun, 13 Jun 2021 14:53:02 GMT) Full text and rfc822 format available.

Message #18 received at 41156 <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Lars Ingebrigtsen <larsi <at> gnus.org>, Neil Okamoto <neil.okamoto <at> gmail.com>
Cc: 41156 <at> debbugs.gnu.org
Subject: Re: bug#41156: margins interfere with xterm-mouse-mode
Date: Sun, 13 Jun 2021 16:52:06 +0200
> Testing this in Emacs 28, I do not get any errors (but I can reproduce
> the issue in Emacs 27.1.)  However -- it still doesn't work: When
> dragging the divider to the left, nothing happens.  (Dragging to the
> right works fine.

Unless you do

(set-window-margins (selected-window) 2 0)

in the window at right.

> )

martin




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41156; Package emacs. (Mon, 14 Jun 2021 12:47:01 GMT) Full text and rfc822 format available.

Message #21 received at 41156 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 41156 <at> debbugs.gnu.org, Neil Okamoto <neil.okamoto <at> gmail.com>
Subject: Re: bug#41156: margins interfere with xterm-mouse-mode
Date: Mon, 14 Jun 2021 14:46:22 +0200
martin rudalics <rudalics <at> gmx.at> writes:

> Unless you do
>
> (set-window-margins (selected-window) 2 0)
>
> in the window at right.

Right, so I guess xterm-mouse-mode needs to define a key binding in the
margin area for these mouse commands?

Hm...  Well, I took a quick peek at xt-mouse.el for the first time in my
life, and that doesn't seem to be how that mode works at all.  Is
anybody familiar enough with xt-mouse that it's obvious to them what's
going wrong in this case?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41156; Package emacs. (Mon, 14 Jun 2021 12:57:02 GMT) Full text and rfc822 format available.

Message #24 received at 41156 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>, Jared Finder <jared <at> finder.org>
Cc: rudalics <at> gmx.at, 41156 <at> debbugs.gnu.org, neil.okamoto <at> gmail.com
Subject: Re: bug#41156: margins interfere with xterm-mouse-mode
Date: Mon, 14 Jun 2021 15:56:33 +0300
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Date: Mon, 14 Jun 2021 14:46:22 +0200
> Cc: 41156 <at> debbugs.gnu.org, Neil Okamoto <neil.okamoto <at> gmail.com>
> 
> martin rudalics <rudalics <at> gmx.at> writes:
> 
> > Unless you do
> >
> > (set-window-margins (selected-window) 2 0)
> >
> > in the window at right.
> 
> Right, so I guess xterm-mouse-mode needs to define a key binding in the
> margin area for these mouse commands?
> 
> Hm...  Well, I took a quick peek at xt-mouse.el for the first time in my
> life, and that doesn't seem to be how that mode works at all.  Is
> anybody familiar enough with xt-mouse that it's obvious to them what's
> going wrong in this case?

Jared, can you help us out here, please?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41156; Package emacs. (Tue, 15 Jun 2021 03:52:01 GMT) Full text and rfc822 format available.

Message #27 received at 41156 <at> debbugs.gnu.org (full text, mbox):

From: Jared Finder <jared <at> finder.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: rudalics <at> gmx.at, Lars Ingebrigtsen <larsi <at> gnus.org>, 41156 <at> debbugs.gnu.org,
 neil.okamoto <at> gmail.com
Subject: Re: bug#41156: margins interfere with xterm-mouse-mode
Date: Mon, 14 Jun 2021 20:51:33 -0700
On 2021-06-14 5:56 am, Eli Zaretskii wrote:
>> From: Lars Ingebrigtsen <larsi <at> gnus.org>
>> Date: Mon, 14 Jun 2021 14:46:22 +0200
>> Cc: 41156 <at> debbugs.gnu.org, Neil Okamoto <neil.okamoto <at> gmail.com>
>> 
>> martin rudalics <rudalics <at> gmx.at> writes:
>> 
>> > Unless you do
>> >
>> > (set-window-margins (selected-window) 2 0)
>> >
>> > in the window at right.
>> 
>> Right, so I guess xterm-mouse-mode needs to define a key binding in 
>> the
>> margin area for these mouse commands?
>> 
>> Hm...  Well, I took a quick peek at xt-mouse.el for the first time in 
>> my
>> life, and that doesn't seem to be how that mode works at all.  Is
>> anybody familiar enough with xt-mouse that it's obvious to them what's
>> going wrong in this case?
> 
> Jared, can you help us out here, please?

xterm-mouse-mode is running fine, it is correctly generating 
mouse-motion events with proper X,Y coordinates.

The actual drag keybinding is handled in mouse-drag-line in mouse.el.  
The following patch mostly works for me, though I see issues when 
dragging to the left and the left buffer has a margin of width greater 
than 1.  I think there's some incorrect logic in how the temporarily 
bound move function is converting calculating positions:

@@ -494,9 +494,12 @@ mouse-drag-line
 	       (define-key map [header-line] map)
 	       (define-key map [vertical-line] map)
 	       ;; ... and some maybe even with a right- or bottom-divider
-	       ;; prefix.
+	       ;; prefix ...
 	       (define-key map [right-divider] map)
 	       (define-key map [bottom-divider] map)
+               ;; ... and the margins too.
+               (define-key map [left-margin] map)
+               (define-key map [right-margin] map)
 	       map)
 	     t (lambda () (setq track-mouse old-track-mouse)))))))

I'll investigate a bit more later.

  -- MJF




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41156; Package emacs. (Tue, 15 Jun 2021 05:30:02 GMT) Full text and rfc822 format available.

Message #30 received at 41156 <at> debbugs.gnu.org (full text, mbox):

From: Jared Finder <jared <at> finder.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: rudalics <at> gmx.at, Lars Ingebrigtsen <larsi <at> gnus.org>, 41156 <at> debbugs.gnu.org,
 neil.okamoto <at> gmail.com
Subject: Re: bug#41156: margins interfere with xterm-mouse-mode
Date: Mon, 14 Jun 2021 22:29:36 -0700
On 2021-06-14 8:51 pm, Jared Finder wrote:
> On 2021-06-14 5:56 am, Eli Zaretskii wrote:
>>> From: Lars Ingebrigtsen <larsi <at> gnus.org>
>>> Date: Mon, 14 Jun 2021 14:46:22 +0200
>>> Cc: 41156 <at> debbugs.gnu.org, Neil Okamoto <neil.okamoto <at> gmail.com>
>>> 
>>> martin rudalics <rudalics <at> gmx.at> writes:
>>> 
>>> > Unless you do
>>> >
>>> > (set-window-margins (selected-window) 2 0)
>>> >
>>> > in the window at right.
>>> 
>>> Right, so I guess xterm-mouse-mode needs to define a key binding in 
>>> the
>>> margin area for these mouse commands?
>>> 
>>> Hm...  Well, I took a quick peek at xt-mouse.el for the first time in 
>>> my
>>> life, and that doesn't seem to be how that mode works at all.  Is
>>> anybody familiar enough with xt-mouse that it's obvious to them 
>>> what's
>>> going wrong in this case?
>> 
>> Jared, can you help us out here, please?
> 
> xterm-mouse-mode is running fine, it is correctly generating
> mouse-motion events with proper X,Y coordinates.
> 
> The actual drag keybinding is handled in mouse-drag-line in mouse.el.
> The following patch mostly works for me, though I see issues when
> dragging to the left and the left buffer has a margin of width greater
> than 1.  I think there's some incorrect logic in how the temporarily
> bound move function is converting calculating positions:
> 

And I'm fairly certain this is the proper fix.  If a window is live, 
then the AREA-OR-POS made by posn-at-x-y should never be nil, I believe:

--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -415,7 +415,7 @@ mouse-drag-line
 		(when (window-live-p (setq posn-window (posn-window start)))
 		  ;; Add left edge of `posn-window' to `position'.
 		  (setq position (+ (window-pixel-left posn-window) position))
-		  (unless (nth 1 start)
+		  (unless (posn-area start)
 		    ;; Add width of objects on the left of the text area to
 		    ;; `position'.
 		    (when (eq (window-current-scroll-bars posn-window) 'left)
@@ -494,9 +494,11 @@ mouse-drag-line
 	       (define-key map [header-line] map)
 	       (define-key map [vertical-line] map)
 	       ;; ... and some maybe even with a right- or bottom-divider
-	       ;; prefix.
+	       ;; or left- or right-margin prefix ...
 	       (define-key map [right-divider] map)
 	       (define-key map [bottom-divider] map)
+	       (define-key map [left-margin] map)
+	       (define-key map [right-margin] map)
 	       map)
 	     t (lambda () (setq track-mouse old-track-mouse)))))))

  -- MJF




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41156; Package emacs. (Tue, 15 Jun 2021 07:51:01 GMT) Full text and rfc822 format available.

Message #33 received at 41156 <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Jared Finder <jared <at> finder.org>, Eli Zaretskii <eliz <at> gnu.org>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 41156 <at> debbugs.gnu.org,
 neil.okamoto <at> gmail.com
Subject: Re: bug#41156: margins interfere with xterm-mouse-mode
Date: Tue, 15 Jun 2021 09:50:31 +0200
> And I'm fairly certain this is the proper fix.  If a window is live,
> then the AREA-OR-POS made by posn-at-x-y should never be nil, I
> believe:

Looks good to me.

Thanks, martin




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41156; Package emacs. (Tue, 15 Jun 2021 11:20:01 GMT) Full text and rfc822 format available.

Message #36 received at 41156 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Jared Finder <jared <at> finder.org>
Cc: rudalics <at> gmx.at, larsi <at> gnus.org, 41156 <at> debbugs.gnu.org,
 neil.okamoto <at> gmail.com
Subject: Re: bug#41156: margins interfere with xterm-mouse-mode
Date: Tue, 15 Jun 2021 14:19:01 +0300
> Date: Mon, 14 Jun 2021 22:29:36 -0700
> From: Jared Finder <jared <at> finder.org>
> Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, rudalics <at> gmx.at,
>  41156 <at> debbugs.gnu.org, neil.okamoto <at> gmail.com
> 
> >> Jared, can you help us out here, please?
> > 
> > xterm-mouse-mode is running fine, it is correctly generating
> > mouse-motion events with proper X,Y coordinates.
> > 
> > The actual drag keybinding is handled in mouse-drag-line in mouse.el.
> > The following patch mostly works for me, though I see issues when
> > dragging to the left and the left buffer has a margin of width greater
> > than 1.  I think there's some incorrect logic in how the temporarily
> > bound move function is converting calculating positions:
> > 
> 
> And I'm fairly certain this is the proper fix.  If a window is live, 
> then the AREA-OR-POS made by posn-at-x-y should never be nil, I believe:

Thanks, Jared.

Lars, feel free to install, unless you have comments.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41156; Package emacs. (Tue, 15 Jun 2021 13:55:02 GMT) Full text and rfc822 format available.

Message #39 received at 41156 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Jared Finder <jared <at> finder.org>
Cc: rudalics <at> gmx.at, Eli Zaretskii <eliz <at> gnu.org>, 41156 <at> debbugs.gnu.org,
 neil.okamoto <at> gmail.com
Subject: Re: bug#41156: margins interfere with xterm-mouse-mode
Date: Tue, 15 Jun 2021 15:54:40 +0200
Jared Finder <jared <at> finder.org> writes:

> And I'm fairly certain this is the proper fix.  If a window is live,
> then the AREA-OR-POS made by posn-at-x-y should never be nil, I
> believe:

Looks good to me, and it fixes the reported test case for me, so I've
now pushed it to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 28.1, send any further explanations to 41156 <at> debbugs.gnu.org and Neil Okamoto <neil.okamoto <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 15 Jun 2021 13:55:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 14 Jul 2021 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 286 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.