From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.bugs Subject: bug#10165: [PATCH] Allow setting corner in mouse avoidance mode. Date: Mon, 05 Dec 2011 19:06:26 +0100 Message-ID: <871usilwpp.fsf@gmail.com> References: <877h2itald.fsf@gmail.com> <87pqgaj757.fsf@mail.jurta.org> <87liqxj401.fsf@gmail.com> <871uspy0e3.fsf@gmail.com> <87ipm0spfp.fsf@mail.jurta.org> <874nxj4ei8.fsf@gmail.com> <87zkfb2znw.fsf@gmail.com> <87y5uvb5x8.fsf@mail.jurta.org> <87wrafusgd.fsf@gmail.com> <87wraezyvf.fsf@mail.jurta.org> <874nxi7u70.fsf@gmail.com> <877h2eav6t.fsf@gmail.com> <87zkfaxaz2.fsf@gmail.com> <87d3c370j8.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1323108462 26652 80.91.229.12 (5 Dec 2011 18:07:42 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 5 Dec 2011 18:07:42 +0000 (UTC) Cc: 10165@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Dec 05 19:07:35 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RXcww-0004wR-Il for geb-bug-gnu-emacs@m.gmane.org; Mon, 05 Dec 2011 19:07:35 +0100 Original-Received: from localhost ([::1]:47840 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXcwv-0005sh-4Z for geb-bug-gnu-emacs@m.gmane.org; Mon, 05 Dec 2011 13:07:33 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:42921) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXcwr-0005oW-Tq for bug-gnu-emacs@gnu.org; Mon, 05 Dec 2011 13:07:30 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RXcwq-0006Kn-PN for bug-gnu-emacs@gnu.org; Mon, 05 Dec 2011 13:07:29 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:54161) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXcwq-0006Kj-Na for bug-gnu-emacs@gnu.org; Mon, 05 Dec 2011 13:07:28 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1RXcxN-0006MO-Ns for bug-gnu-emacs@gnu.org; Mon, 05 Dec 2011 13:08:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Thierry Volpiatto Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 05 Dec 2011 18:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10165 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 10165-submit@debbugs.gnu.org id=B10165.132310843024383 (code B ref 10165); Mon, 05 Dec 2011 18:08:01 +0000 Original-Received: (at 10165) by debbugs.gnu.org; 5 Dec 2011 18:07:10 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RXcwY-0006LE-19 for submit@debbugs.gnu.org; Mon, 05 Dec 2011 13:07:10 -0500 Original-Received: from mail-lpp01m010-f44.google.com ([209.85.215.44]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RXcwV-0006L6-JP for 10165@debbugs.gnu.org; Mon, 05 Dec 2011 13:07:08 -0500 Original-Received: by lagw12 with SMTP id w12so930301lag.3 for <10165@debbugs.gnu.org>; Mon, 05 Dec 2011 10:06:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=uXudG7HzJZATa8qoo4PZyOVUcUN1Xy+XPbnpU/PxGFs=; b=dXV5WMq2HMo+x/Vdsd7Vs9O7ljAVCv+i7uDJAef5IYYywYv1A1I7bgLGzdX5xNtsV+ MvGGHSznwSZHRIqDBe07kqNKsYRTJxCZy11wQif6V+hssIi197WzcWhmhgKER42Guo02 bbPl2lFMrl95Kc4caGkGXQK2Sy5nkwgN/3KEs= Original-Received: by 10.152.134.179 with SMTP id pl19mr6814269lab.13.1323108393510; Mon, 05 Dec 2011 10:06:33 -0800 (PST) Original-Received: from thierry-MM061 (109.78.88.79.rev.sfr.net. [79.88.78.109]) by mx.google.com with ESMTPS id no9sm18447624lab.0.2011.12.05.10.06.30 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 05 Dec 2011 10:06:31 -0800 (PST) In-Reply-To: <87d3c370j8.fsf@mail.jurta.org> (Juri Linkov's message of "Mon, 05 Dec 2011 12:52:59 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 05 Dec 2011 13:08:01 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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:54721 Archived-At: --=-=-= Content-Type: text/plain Juri Linkov writes: >> Use this, as there is an error in precedent patch (still using value of >> old variable), sorry. > > Thanks. I think names like `frame-or-window' and `top-or-bottom-pos' > are quite confusing. Yes, if you have better names tell me. Also here on last version of patch I am using symbol instead of sexp which is better. > But fortunately we could avoid them. Can you develop this? Find here the last version of patch for review, (more or less what you have actually) I will apply as soon Emacs is no more in feature freeze if no objections. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=Singlepatch-r118037ToTip.patch Content-Description: mouse avoidance banish ##Merge of all patches applied from revision 118117 ## patch-r118037: * lisp/avoid.el: Allow setting in which corner banish move the mouse. ## patch-r118084: * lisp/avoid.el (mouse-avoidance-banish-distance-from-edge): Allow banishing mouse in frame or window corner. ## patch-r118114: * lisp/avoid.el Allow specifying a vertical position when banishing mouse. ## diff --git a/lisp/avoid.el b/lisp/avoid.el --- a/lisp/avoid.el +++ b/lisp/avoid.el @@ -115,6 +115,23 @@ :type 'integer :group 'avoid) +(defcustom mouse-avoidance-banish-position '((frame-or-window . frame) + (side . right) + (side-pos . 3) + (top-or-bottom . top) + (top-or-bottom-pos . 0)) + "Position to which Mouse Avoidance mode `banish' moves the mouse. +An alist where keywords mean: +FRAME-OR-WINDOW: banish the mouse to corner of frame or window. +SIDE: banish the mouse on right or left corner of frame or window. +SIDE-POS: Distance from right or left edge of frame or window. +TOP-OR-BOTTOM: banish the mouse to top or bottom of frame or window. +TOP-OR-BOTTOM-POS: Distance from top or bottom edge of frame or window." + :group 'avoid + :type '(alist :key-type symbol :value-type symbol) + :options '(frame-or-window side (side-pos integer) + top-or-bottom (top-or-bottom-pos integer))) + ;; Internal variables (defvar mouse-avoidance-state nil) (defvar mouse-avoidance-pointer-shapes nil) @@ -183,13 +200,45 @@ (defun mouse-avoidance-banish-destination () "The position to which Mouse Avoidance mode `banish' moves the mouse. -You can redefine this if you want the mouse banished to a different corner." - (let* ((pos (window-edges))) - (cons (- (nth 2 pos) 2) - (nth 1 pos)))) + +If you want the mouse banished to a different corner set +`mouse-avoidance-banish-position' as you need." + (let* ((fra-or-win (assoc-default + 'frame-or-window + mouse-avoidance-banish-position 'eq)) + (list-values (case fra-or-win + (frame (list 0 0 (frame-width) (frame-height))) + (window (window-edges)))) + (alist (loop for v in list-values + for k in '(left top right bottom) + collect (cons k v))) + (side (assoc-default + 'side + mouse-avoidance-banish-position 'eq)) + (side-dist (assoc-default + 'side-pos + mouse-avoidance-banish-position 'eq)) + (top-or-bottom (assoc-default + 'top-or-bottom + mouse-avoidance-banish-position 'eq)) + (top-or-bottom-dist (assoc-default + 'top-or-bottom-pos + mouse-avoidance-banish-position 'eq)) + (side-fn (case side + (left '+) + (right '-))) + (top-or-bottom-fn (case top-or-bottom + (top '+) + (bottom '-)))) + (cons (funcall side-fn ; -/+ + (assoc-default side alist 'eq) ; right or left + side-dist) ; distance from side + (funcall top-or-bottom-fn ; -/+ + (assoc-default top-or-bottom alist 'eq) ; top/bottom + top-or-bottom-dist)))) ; distance from top/bottom (defun mouse-avoidance-banish-mouse () - ;; Put the mouse pointer in the upper-right corner of the current frame. + "Put the mouse pointer to `mouse-avoidance-banish-position'." (mouse-avoidance-set-mouse-position (mouse-avoidance-banish-destination))) (defsubst mouse-avoidance-delta (cur delta dist var min max) --=-=-= Content-Type: text/plain -- Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997 --=-=-=--