From: Andrea Rossetti <andrea.rossetti@gmail.com>
To: martin rudalics <rudalics@gmx.at>
Cc: 17768@debbugs.gnu.org
Subject: bug#17768: 24.3; problem with two ruler-mode windows
Date: Sat, 14 Jun 2014 19:22:21 +0200 [thread overview]
Message-ID: <8438f75rua.fsf@gmail.com> (raw)
In-Reply-To: <539AA853.3050202@gmx.at> (martin rudalics's message of "Fri, 13 Jun 2014 09:29:23 +0200")
[-- Attachment #1: Type: text/plain, Size: 479 bytes --]
martin rudalics <rudalics@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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-ruler-mode.el-correct-offset-of-set-margin-and-.patch --]
[-- Type: text/x-patch, Size: 1723 bytes --]
From 88a4f9fb9d2eace74a737205a26b26f35cb21cf6 Mon Sep 17 00:00:00 2001
From: Andrea Rossetti <andrear1979@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
[-- Attachment #3: Type: text/plain, Size: 1124 bytes --]
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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0002-lisp-ruler-mode.el-fix-offset-for-mouse-dragging-bey.patch --]
[-- Type: text/x-patch, Size: 3069 bytes --]
From e521c93c296377d1733e8801832f3066e4cc4ede Mon Sep 17 00:00:00 2001
From: Andrea Rossetti <andrear1979@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)))
\f
(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
[-- Attachment #5: Type: text/plain, Size: 802 bytes --]
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
next prev parent reply other threads:[~2014-06-14 17:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-12 23:57 bug#17768: 24.3; problem with two ruler-mode windows Andrea Rossetti
2014-06-13 7:29 ` martin rudalics
2014-06-14 16:45 ` Eli Zaretskii
2014-06-15 15:09 ` martin rudalics
2014-06-15 16:17 ` Eli Zaretskii
2014-06-16 21:05 ` Stefan Monnier
2014-06-14 17:22 ` Andrea Rossetti [this message]
2014-06-15 15:09 ` martin rudalics
2014-06-15 18:06 ` Andrea Rossetti
2014-06-15 23:22 ` Andrea Rossetti
2014-06-16 7:10 ` martin rudalics
2014-06-16 7:10 ` martin rudalics
2014-06-16 8:45 ` bug#17768: Andrea Rossetti
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8438f75rua.fsf@gmail.com \
--to=andrea.rossetti@gmail.com \
--cc=17768@debbugs.gnu.org \
--cc=rudalics@gmx.at \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.