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: Fri, 02 Dec 2011 08:30:23 +0100 Message-ID: <874nxj4ei8.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> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1322811061 23333 80.91.229.12 (2 Dec 2011 07:31:01 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 2 Dec 2011 07:31:01 +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 Fri Dec 02 08:30:56 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 1RWNaB-000583-KF for geb-bug-gnu-emacs@m.gmane.org; Fri, 02 Dec 2011 08:30:55 +0100 Original-Received: from localhost ([::1]:48535 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWNaB-0004Lt-4E for geb-bug-gnu-emacs@m.gmane.org; Fri, 02 Dec 2011 02:30:55 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:53855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWNa7-0004Ln-Sf for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2011 02:30:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RWNa5-0002wz-Co for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2011 02:30:51 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:48400) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWNa5-0002wm-B4 for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2011 02:30:49 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1RWNaH-0001zv-Us for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2011 02:31:02 -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: Fri, 02 Dec 2011 07:31: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.13228110447654 (code B ref 10165); Fri, 02 Dec 2011 07:31:01 +0000 Original-Received: (at 10165) by debbugs.gnu.org; 2 Dec 2011 07:30:44 +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 1RWNZz-0001zO-UO for submit@debbugs.gnu.org; Fri, 02 Dec 2011 02:30:44 -0500 Original-Received: from mail-ww0-f42.google.com ([74.125.82.42]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RWNZx-0001zH-VQ for 10165@debbugs.gnu.org; Fri, 02 Dec 2011 02:30:43 -0500 Original-Received: by wgbds13 with SMTP id ds13so503023wgb.3 for <10165@debbugs.gnu.org>; Thu, 01 Dec 2011 23:30:27 -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=p393ChDRZE6TSxUNKlQIhd+zBI03jaBQ6kYhaOyVEUI=; b=eCYYQoAXthAc4n8IZ68pv80R8DxYB5tFW60voXuxMxF6UsiorUvW3FhUC48ZJWK81r Qd1fuYd0iWlUaaC2OwQImvfeztzad7HnUhqAXY9Grc7y7HQSS+8ClAjfbXUG2WoK7pz6 7pw+2A5QmM9EaVmsF9yiiYYEvpT/WjLlCxTyw= Original-Received: by 10.180.18.165 with SMTP id x5mr7829085wid.24.1322811027823; Thu, 01 Dec 2011 23:30:27 -0800 (PST) Original-Received: from thierry-MM061 (40.78.88.79.rev.sfr.net. [79.88.78.40]) by mx.google.com with ESMTPS id ca18sm2630896wib.13.2011.12.01.23.30.25 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 01 Dec 2011 23:30:26 -0800 (PST) In-Reply-To: <87ipm0spfp.fsf@mail.jurta.org> (Juri Linkov's message of "Thu, 01 Dec 2011 09:48:10 +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: Fri, 02 Dec 2011 02:31: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:54588 Archived-At: --=-=-= Content-Type: text/plain Juri Linkov writes: >>>> FWIW, I have in my .emacs: >>>> >>>> ;; Move the mouse to the screen corner on any keypress. >>>> (when (and (display-mouse-p) (require 'avoid nil t)) >>>> ;; Move the mouse to the lower-right corner instead of default upper-right >>>> (defun mouse-avoidance-banish-destination () >>>> (cons (+ 3 (frame-width)) (- (frame-height) 1))) >>>> (mouse-avoidance-mode 'banish)) >>>> >>>> It would be better to allow users to replace such code with customization. >>> Yes, it is what my patch does: >>> Instead of your code you can just say: >>> (setq mouse-avoidance-banish-destination '(right . bottom)) >>> or of course setting that through customize interface. >> >> Also, I have added a new user variable to this patch that allow setting >> the distance from window's edge: >> >> (defcustom mouse-avoidance-banish-distance-from-edge 2 >> "Set the distance from edge of window in Mouse Avoidance mode `banish'." >> :group 'avoid >> :type 'integer) > > Thanks, but in my settings the distance is relative to frame's edge > instead of window's edge. Is it possible to express this setting > with a user variable? Here the improved version of the patch: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=Singlepatch-r118037ToTip.patch Content-Description: mouse avoidance banish ##Merge of all patches applied from revision 118094 ## 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. ## 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-destination '(right . top) + "Position to which Mouse Avoidance mode `banish' moves the mouse. + +Valid possible values can be: +\'(right . top\), \'(left . top\), \'(right . bottom\) or \'(left . bottom\)." + :group 'avoid + :type 'list) + +(defcustom mouse-avoidance-banish-distance-from-edge '(window . 2) + "Distance from edge of window or frame in Mouse Avoidance mode `banish'. + +It is a cons cell where the car can be 'window or 'frame +and the cdr and integer representing the distance +from edge of window or frame." + :group 'avoid + :type 'list) + ;; Internal variables (defvar mouse-avoidance-state nil) (defvar mouse-avoidance-pointer-shapes nil) @@ -183,10 +200,24 @@ (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-destination' and +`mouse-avoidance-banish-distance-from-edge' as you need." + (let* ((fra-or-win (case (car mouse-avoidance-banish-distance-from-edge) + (frame (list 0 0 (frame-width) (frame-height))) + (window (window-edges)))) + (pos (loop for v in fra-or-win + for k in '(left top right bottom) + collect (cons k v))) + (side (car mouse-avoidance-banish-destination)) + (up-down (cdr mouse-avoidance-banish-destination)) + (fn (case side + (left '+) + (right '-)))) + (cons (funcall fn (assoc-default side pos 'eq) + (cdr mouse-avoidance-banish-distance-from-edge)) + (assoc-default up-down pos 'eq)))) (defun mouse-avoidance-banish-mouse () ;; Put the mouse pointer in the upper-right corner of the current frame. --=-=-= Content-Type: text/plain -- Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997 --=-=-=--