unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Andrea Rossetti <andrea.rossetti@gmail.com>
To: Stephen Berman <stephen.berman@gmx.net>
Cc: 17788@debbugs.gnu.org
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	[thread overview]
Message-ID: <84zjhdixgw.fsf@gmail.com> (raw)
In-Reply-To: <87fvj5omej.fsf@rosalinde.fritz.box> (Stephen Berman's message of "Mon, 16 Jun 2014 00:09:24 +0200")

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


  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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-bug-17788-ruler-mode-indicators-hops-left.patch --]
[-- Type: text/x-patch, Size: 3305 bytes --]

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)))
 \f
 (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


[-- Attachment #3: Type: text/plain, Size: 49 bytes --]


  Thanks in advance, kindest regards.

  Andrea

  reply	other threads:[~2014-06-15 23:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-15 19:17 bug#17788: 24.3; ruler-mode: column indicators "hop" left if you drag them diagonally Andrea Rossetti
2014-06-15 22:09 ` Stephen Berman
2014-06-15 23:06   ` Andrea Rossetti [this message]
2014-06-15 23:14     ` Andrea Rossetti
2014-06-16  7:11     ` martin rudalics
2014-06-16 20:26       ` Andrea Rossetti
2014-06-16 21:34         ` Stephen Berman
2014-06-17 23:50         ` Andrea Rossetti
2014-06-16 10:16     ` Stephen Berman
2014-06-16 19:03       ` Andrea Rossetti
2014-06-16  7:11 ` martin rudalics
2020-09-09 11:47 ` Lars Ingebrigtsen
2022-02-22 14:23   ` Lars Ingebrigtsen

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=84zjhdixgw.fsf@gmail.com \
    --to=andrea.rossetti@gmail.com \
    --cc=17788@debbugs.gnu.org \
    --cc=stephen.berman@gmx.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).