From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andrea Rossetti Newsgroups: gmane.emacs.bugs Subject: bug#17768: 24.3; problem with two ruler-mode windows Date: Sat, 14 Jun 2014 19:22:21 +0200 Message-ID: <8438f75rua.fsf@gmail.com> References: <84sin9n0kf.fsf@gmail.com> <539AA853.3050202@gmx.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1402766603 10909 80.91.229.3 (14 Jun 2014 17:23:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 14 Jun 2014 17:23:23 +0000 (UTC) Cc: 17768@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jun 14 19:23:17 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Wvrfg-0002Al-PN for geb-bug-gnu-emacs@m.gmane.org; Sat, 14 Jun 2014 19:23:17 +0200 Original-Received: from localhost ([::1]:36152 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wvrfg-0004Eu-CB for geb-bug-gnu-emacs@m.gmane.org; Sat, 14 Jun 2014 13:23:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58347) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WvrfX-0004Ds-Mi for bug-gnu-emacs@gnu.org; Sat, 14 Jun 2014 13:23:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WvrfS-0004sR-C3 for bug-gnu-emacs@gnu.org; Sat, 14 Jun 2014 13:23:07 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:56781) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WvrfS-0004sM-8K for bug-gnu-emacs@gnu.org; Sat, 14 Jun 2014 13:23:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WvrfR-0006yk-MF for bug-gnu-emacs@gnu.org; Sat, 14 Jun 2014 13:23:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andrea Rossetti Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 14 Jun 2014 17:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17768 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 17768-submit@debbugs.gnu.org id=B17768.140276655126773 (code B ref 17768); Sat, 14 Jun 2014 17:23:01 +0000 Original-Received: (at 17768) by debbugs.gnu.org; 14 Jun 2014 17:22:31 +0000 Original-Received: from localhost ([127.0.0.1]:47931 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wvrew-0006xk-Sa for submit@debbugs.gnu.org; Sat, 14 Jun 2014 13:22:31 -0400 Original-Received: from mail-we0-f169.google.com ([74.125.82.169]:52930) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wvreu-0006xQ-42 for 17768@debbugs.gnu.org; Sat, 14 Jun 2014 13:22:29 -0400 Original-Received: by mail-we0-f169.google.com with SMTP id t60so4089446wes.28 for <17768@debbugs.gnu.org>; Sat, 14 Jun 2014 10:22:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=XToIvoHkSf2Rrvih+KuJXBhepVr0mtptthOTbyqV+rA=; b=wZskZDM/cRsRcrmt4vpGuE7N1NaGIsnw/0moI0j+7+8pC7TTexFbWUIq05SKoB3WBN TLO00fsJbGi/SoaxxkWSTr8U6ItF29WDMyLVsblTqWCKFf41IbLFc6RagqNB0r4Zd8cF 408p1ggawgq++ARRKDjTD/S/Udf4Lsc/tL2+9/Ul9z5HsNpbFgJuRdmwoUZ+ycYlxmEy DAwHuIgSMTOC5zieYuJREK+3XNH/aIBuE10BMU3ybVIwvQGZ0nE7eqe0lezkHlrQ9Nmu 4ccahfS8VKxDkFMzWVcp/AfFizp5sKeykUOQ0mrnh9trN9qeDj6rMGXEhcTcYH9exAep KjMQ== X-Received: by 10.194.79.135 with SMTP id j7mr11961575wjx.56.1402766542407; Sat, 14 Jun 2014 10:22:22 -0700 (PDT) Original-Received: from LAPTOP-ANDREA.laptop-andrea.trieste.it (net-93-144-122-252.cust.dsl.teletu.it. [93.144.122.252]) by mx.google.com with ESMTPSA id j49sm20487054eew.32.2014.06.14.10.22.20 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 14 Jun 2014 10:22:21 -0700 (PDT) In-Reply-To: <539AA853.3050202@gmx.at> (martin rudalics's message of "Fri, 13 Jun 2014 09:29:23 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (windows-nt) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:90384 Archived-At: --=-=-= Content-Type: text/plain martin rudalics 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. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-lisp-ruler-mode.el-correct-offset-of-set-margin-and-.patch >From 88a4f9fb9d2eace74a737205a26b26f35cb21cf6 Mon Sep 17 00:00:00 2001 From: Andrea Rossetti 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 --=-=-= Content-Type: text/plain 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- 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. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0002-lisp-ruler-mode.el-fix-offset-for-mouse-dragging-bey.patch >From e521c93c296377d1733e8801832f3066e4cc4ede Mon Sep 17 00:00:00 2001 From: Andrea Rossetti 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 --=-=-= Content-Type: text/plain 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 --=-=-=--