GNU bug report logs - #17768
24.3; problem with two ruler-mode windows

Previous Next

Package: emacs;

Reported by: Andrea Rossetti <andrea.rossetti <at> gmail.com>

Date: Thu, 12 Jun 2014 23:59:02 UTC

Severity: normal

Found in version 24.3

Done: Andrea Rossetti <andrea.rossetti <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


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

From: Andrea Rossetti <andrea.rossetti <at> gmail.com>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 17768 <at> debbugs.gnu.org
Subject: Re: bug#17768: 24.3; problem with two ruler-mode windows
Date: Sat, 14 Jun 2014 19:22:21 +0200
[Message part 1 (text/plain, inline)]
martin rudalics <rudalics <at> gmx.at> writes:
> Could you try testing it
> with three and more side-by-side windows and all sorts of clicks ruler
> mode can handle and possibly post a corresponding patch?
>

Hi, here's my tentative patches. I checked out from
http://git.savannah.gnu.org/cgit/emacs.git, last
commit was 6449128a5ab4a47a281de6117b86661dcc05b599, and
made two patches.

  First patch applies the changes that we supposed could
solve the problem of the wrong offset.

[0001-lisp-ruler-mode.el-correct-offset-of-set-margin-and-.patch (text/x-patch, inline)]
From 88a4f9fb9d2eace74a737205a26b26f35cb21cf6 Mon Sep 17 00:00:00 2001
From: Andrea Rossetti <andrear1979 <at> hotmail.com>
Date: Sat, 14 Jun 2014 17:26:49 +0200
Subject: [PATCH 1/2] lisp/ruler-mode.el: correct offset of "set margin" and
 "drag column" mouse operations

---
 lisp/ruler-mode.el | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lisp/ruler-mode.el b/lisp/ruler-mode.el
index 9e32a2f..238754e 100644
--- a/lisp/ruler-mode.el
+++ b/lisp/ruler-mode.el
@@ -306,7 +306,6 @@ or remove a tab stop.  \\[ruler-mode-toggle-show-tab-stops] or
   "Return a column number relative to the selected window.
 N is a column number relative to selected frame."
   (- n
-     (car (window-edges))
      (or (car (window-margins)) 0)
      (fringe-columns 'left)
      (scroll-bar-columns 'left)))
@@ -321,7 +320,7 @@ START-EVENT is the mouse click event."
     (when (eq start end) ;; mouse click
       (save-selected-window
         (select-window (posn-window start))
-        (setq col (- (car (posn-col-row start)) (car (window-edges))
+        (setq col (- (car (posn-col-row start))
                      (scroll-bar-columns 'left))
               w   (- (ruler-mode-full-window-width)
                      (scroll-bar-columns 'left)
@@ -343,7 +342,7 @@ START-EVENT is the mouse click event."
     (when (eq start end) ;; mouse click
       (save-selected-window
         (select-window (posn-window start))
-        (setq col (- (car (posn-col-row start)) (car (window-edges))
+        (setq col (- (car (posn-col-row start))
                      (scroll-bar-columns 'left))
               w   (- (ruler-mode-full-window-width)
                      (scroll-bar-columns 'left)
-- 
1.8.1.msysgit.1

[Message part 3 (text/plain, inline)]
 I tested patch1 somewhat randomly, opening 4/5 windows horizontally,
1/2 windows vertically, and did also some attempt splitting windows
in two frames. Played also a bit on the text-only Emacs (using MSYS shell).

  Everything worked fine with patch1, except for an unexpected small
and non-blocking issue (let's call it "diagonal-drag" issue) that
can be reproduced as follows:

- C-x 3 M-x ruler-mode (you should see two windows with ruler)
- click S-<mouse-1> on the ruler of the rightmost window, this will set
  a left margin, choose a width of around 10~20 chars
- drag "diagonally" a column, for example moving down-left the
  fill-column, until the cursor goes a few pixels below the ruler area
- you will see that the dragged column will "jump" innaturally to the
  left of around 10~20 chars

  Tentative diagnosys: function `ruler-mode-window-col' returns a
different column value depending if you are inside or outside the 
ruler area. The actual problem is probably inherited from `posn-col-row',
but I could not clarify any better.

  I wrote patch 2, that worked for me to solve the "diagonal-drag" issue.

[0002-lisp-ruler-mode.el-fix-offset-for-mouse-dragging-bey.patch (text/x-patch, inline)]
From e521c93c296377d1733e8801832f3066e4cc4ede Mon Sep 17 00:00:00 2001
From: Andrea Rossetti <andrear1979 <at> hotmail.com>
Date: Sat, 14 Jun 2014 17:32:03 +0200
Subject: [PATCH 2/2] lisp/ruler-mode.el: fix offset for mouse dragging beyond
 header line

---
 lisp/ruler-mode.el | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/lisp/ruler-mode.el b/lisp/ruler-mode.el
index 238754e..097a13e 100644
--- a/lisp/ruler-mode.el
+++ b/lisp/ruler-mode.el
@@ -302,12 +302,17 @@ or remove a tab stop.  \\[ruler-mode-toggle-show-tab-stops] or
   (let ((edges (window-edges)))
     (- (nth 2 edges) (nth 0 edges))))
 
-(defsubst ruler-mode-window-col (n)
+(defsubst ruler-mode-window-col (start-or-end-event)
   "Return a column number relative to the selected window.
-N is a column number relative to selected frame."
-  (- n
-     (or (car (window-margins)) 0)
-     (fringe-columns 'left)
+START-OR-END-EVENT is the start point or end point
+of a mouse click or mouse drag event.
+
+See also: `event-start', `event-end', `posn-col-row', `posn-area'.
+"
+  (- (car (posn-col-row start-or-end-event))
+     (if (eq (posn-area start) 'header-line)
+         (+ (or (car (window-margins)) 0) (fringe-columns 'left))
+       0)
      (scroll-bar-columns 'left)))
 
 (defun ruler-mode-mouse-set-left-margin (start-event)
@@ -371,7 +376,7 @@ dragging.  See also the variable `ruler-mode-dragged-symbol'."
          col newc oldc)
     (save-selected-window
       (select-window (posn-window start))
-      (setq col  (ruler-mode-window-col (car (posn-col-row start)))
+      (setq col  (ruler-mode-window-col start)
             newc (+ col (window-hscroll)))
       (and
        (>= col 0) (< col (window-width))
@@ -454,7 +459,7 @@ Called on each mouse motion event START-EVENT."
          col newc)
     (save-selected-window
       (select-window (posn-window start))
-      (setq col  (ruler-mode-window-col (car (posn-col-row end)))
+      (setq col  (ruler-mode-window-col end)
             newc (+ col (window-hscroll)))
       (when (and (>= col 0) (< col (window-width)))
         (set ruler-mode-dragged-symbol newc)))))
@@ -470,7 +475,7 @@ START-EVENT is the mouse click event."
       (when (eq start end) ;; mouse click
         (save-selected-window
           (select-window (posn-window start))
-          (setq col (ruler-mode-window-col (car (posn-col-row start)))
+          (setq col (ruler-mode-window-col start)
                 ts  (+ col (window-hscroll)))
           (and (>= col 0) (< col (window-width))
                (not (member ts tab-stop-list))
@@ -490,7 +495,7 @@ START-EVENT is the mouse click event."
       (when (eq start end) ;; mouse click
         (save-selected-window
           (select-window (posn-window start))
-          (setq col (ruler-mode-window-col (car (posn-col-row start)))
+          (setq col (ruler-mode-window-col start)
                 ts  (+ col (window-hscroll)))
           (and (>= col 0) (< col (window-width))
                (member ts tab-stop-list)
-- 
1.8.1.msysgit.1

[Message part 5 (text/plain, inline)]
  And finally: I noticed another independent bug ("text-scale issue"),
i.e. most ruler's mouse operation have wrong offset if you adjust
text scale (C-x C-+).

  If anyone reading is interested to help, here's a proposed action plan:

- may you please try to play with patch1, and give advice if it could be
  acceptable for a commit 

- I guess that patch2 is unacceptable (BTW it changes the definition of
  ruler-mode-window-col, I assumed that ruler-mode.el is the only
  program calling it) but it's the best I could squeeze out of my head...
  any help or constructive criticism is welcome :)

- be aware of the "text-scale" issue but don't test for it; it seems
  a totally independent issue so I'd rather send another bug report for it

  Thanks for your attention, kindest regards.

  Andrea

This bug report was last modified 11 years and 36 days ago.

Previous Next


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