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: Thu, 01 Dec 2011 09:45:09 +0100 Message-ID: <87ty5ksmsq.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: text/plain X-Trace: dough.gmane.org 1322729180 17453 80.91.229.12 (1 Dec 2011 08:46:20 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 1 Dec 2011 08:46:20 +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 Thu Dec 01 09:46:10 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 1RW2HS-0002iM-8X for geb-bug-gnu-emacs@m.gmane.org; Thu, 01 Dec 2011 09:46:10 +0100 Original-Received: from localhost ([::1]:43889 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RW2HR-0007VS-Ex for geb-bug-gnu-emacs@m.gmane.org; Thu, 01 Dec 2011 03:46:09 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:45989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RW2HL-0007UF-Io for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2011 03:46:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RW2HC-0002Qx-MJ for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2011 03:46:03 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:46803) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RW2HC-0002Qj-Kk for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2011 03:45:54 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1RW2HJ-0001mA-Tj for bug-gnu-emacs@gnu.org; Thu, 01 Dec 2011 03:46: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: Thu, 01 Dec 2011 08:46: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.13227291256784 (code B ref 10165); Thu, 01 Dec 2011 08:46:01 +0000 Original-Received: (at 10165) by debbugs.gnu.org; 1 Dec 2011 08:45:25 +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 1RW2Gi-0001lN-Ty for submit@debbugs.gnu.org; Thu, 01 Dec 2011 03:45:25 -0500 Original-Received: from mail-ee0-f44.google.com ([74.125.83.44]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RW2Gh-0001lD-3P for 10165@debbugs.gnu.org; Thu, 01 Dec 2011 03:45:23 -0500 Original-Received: by eear51 with SMTP id r51so1041850eea.3 for <10165@debbugs.gnu.org>; Thu, 01 Dec 2011 00:45:14 -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=txG51UmPJ32gkZZuBLtqZPSKhyEl3MTljjh/hCziOhQ=; b=AkcBUuKdfbaRC/JbQ3IMt0maLmRq8tXQ55Fy9cKABeKz6OL8xL12wdms/WVm72ZulV X0LI/MFXrLaGZDwYXh08iOhhscNoPjwyVweS+hJPDkdRJo5mnrzE9ViC4BXMT0nIZoIF TIFC1iwXM8qLemsNDkVLUXSjMDFEmaPKJG4h0= Original-Received: by 10.14.12.141 with SMTP id 13mr801277eez.37.1322729114213; Thu, 01 Dec 2011 00:45:14 -0800 (PST) Original-Received: from thierry-MM061 (52.78.88.79.rev.sfr.net. [79.88.78.52]) by mx.google.com with ESMTPS id 58sm10514412eet.11.2011.12.01.00.45.12 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 01 Dec 2011 00:45:13 -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: Thu, 01 Dec 2011 03:46: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:54532 Archived-At: 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? Try this: #+BEGIN_SRC lisp (defun mouse-avoidance-banish-destination () "The position to which Mouse Avoidance mode `banish' moves the mouse. If you want the mouse banished to a different corner set `mouse-avoidance-banish-destination' 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) (cdr mouse-avoidance-banish-distance-from-edge)) (assoc-default up-down pos)))) (defcustom mouse-avoidance-banish-destination '(right . top) "Set the position to which Mouse Avoidance mode `banish' moves the mouse." :group 'avoid :type 'list) (defcustom mouse-avoidance-banish-distance-from-edge '(window . 3) "Set the distance from edge of window in Mouse Avoidance mode `banish'." :group 'avoid :type 'list) #+END_SRC And to fit your settings: (setq mouse-avoidance-banish-destination '(right . bottom)) (setq mouse-avoidance-banish-distance-from-edge '(frame . 3)) -- Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997