bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#17788: 24.3; ruler-mode: column indicators "hop" left if you drag th


From: Andrea Rossetti
Subject: bug#17788: 24.3; ruler-mode: column indicators "hop" left if you drag them diagonally
Date: Mon, 16 Jun 2014 01:06:55 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (windows-nt)

  Thanks Stephen for having tested at your side.

> (1) I see # jump whenever the mouse pointer is moved off the ruler while
>     holding down mouse-2, regardless of which direction you drag in
>     ...

  Yes, (1) is the same for me.

> (2) If you don't set the left margin, I see # jump as follows:
>     - If you drag from # straight down (due south), # jumps three
>       columns to the left. 
>     - If you drag from # southeast by one character, # jumps two columns
>       to the left.
>     - If you drag from # southeast by two characters, # jumps one column
>       to the left.
>     - If you drag from # southeast by more than two characters, # does
>       not jump to the left.
>     - If you drag from # southwest, # slides (but doesn't jump) to
>       whatever column you stop the drag on.  Moreover, once you drag #
>       southwest, you can slide # anywhere while holding mouse-2 with the
>       mouse pointer in the text area, just like when it is on the rule.
>

  I can't replicate any of the cases in (2); I always get 1 column hop.

> (3) If you set the left margin, the the number of columns jumped by
>     dragging due south equals (margin width + 3), if I'm not mistaken.

  In my setup I see the indicator jumps left for (margin width + 1)
columns. I'm afraid some other window parameters may be involved,
for example:

  - if you have a leftside fringe (I have it)
  - if you have a leftside scrollbar (I only have it rightside)
  - (maybe?) if your window manager sets thick window borders
    (I have just 3-4 pixel borders)

  I wrote a (quite rough) patch that seems to resolve all "hop"
problems on my installation. May I please ask if anyone has time
and patience to try the patch and report if it provides some benefit.

>From a9e5f6508e0ef3f582b78d174ac173ac1c403585 Mon Sep 17 00:00:00 2001
From: Andrea Rossetti <andrea.rossetti@gmail.com>
Date: Mon, 16 Jun 2014 00:28:34 +0200
Subject: [PATCH]  bug#17788: ruler-mode indicators "hops" left

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

diff --git a/lisp/ruler-mode.el b/lisp/ruler-mode.el
index 9e32a2f..4cbcf63 100644
--- a/lisp/ruler-mode.el
+++ b/lisp/ruler-mode.el
@@ -302,13 +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
-     (car (window-edges))
-     (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)
@@ -372,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))
@@ -455,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)))))
@@ -471,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))
@@ -491,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

  Thanks in advance, kindest regards.

  Andrea

reply via email to

[Prev in Thread] Current Thread [Next in Thread]