unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
@ 2011-11-30  5:58 Thierry Volpiatto
  2011-11-30  6:05 ` Thierry Volpiatto
  2011-11-30  9:32 ` Juri Linkov
  0 siblings, 2 replies; 27+ messages in thread
From: Thierry Volpiatto @ 2011-11-30  5:58 UTC (permalink / raw)
  To: 10165

[-- Attachment #1: Type: text/plain, Size: 387 bytes --]


> Hi all,
> there was nothing except modifying function
> `mouse-avoidance-banish-destination' to set in which corner mouse is
> banish.
> This patch allow setting this through
> `mouse-avoidance-banish-destination' user variable like this:
> (left . top) or (right . bottom) etc...

Thanks.  We're in feature freeze---please file this in the bug database
so it doesn't get forgotten.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: mouse-avoidance-banish-destination --]
[-- Type: text/x-diff, Size: 1894 bytes --]

# HG changeset patch
# User Thierry Volpiatto <thierry.volpiatto@gmail.com>
# Date 1322632617 -3600
# Node ID 885228e9f341f392fc6886bf2855a66c5bdba6c5
# Parent  c511f9c3f7a2cab8b3684b2f1ea4782176988ac6
* lisp/avoid.el:  Allow setting in which corner banish move the mouse.
(mouse-avoidance-banish-destination): New user variable, a cons pair to specify banish corner position.
(mouse-avoidance-banish-destination): Set destination according to mouse-avoidance-banish-destination value.

diff --git a/lisp/avoid.el b/lisp/avoid.el
--- a/lisp/avoid.el
+++ b/lisp/avoid.el
@@ -115,6 +115,11 @@
   :type 'integer
   :group 'avoid)
 
+(defcustom mouse-avoidance-banish-destination '(left . top)
+  "Set the position to which Mouse Avoidance mode `banish' moves the mouse."
+  :group 'avoid
+  :type 'list)
+
 ;; Internal variables
 (defvar mouse-avoidance-state nil)
 (defvar mouse-avoidance-pointer-shapes nil)
@@ -183,10 +188,18 @@
 
 (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' as you need."
+  (let* ((pos     (loop for v in (window-edges)
+                        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) 2)
+	  (assoc-default up-down pos))))
 
 (defun mouse-avoidance-banish-mouse ()
   ;; Put the mouse pointer in the upper-right corner of the current frame.

[-- Attachment #3: Type: text/plain, Size: 83 bytes --]


-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 

^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2011-11-30  5:58 bug#10165: [PATCH] Allow setting corner in mouse avoidance mode Thierry Volpiatto
@ 2011-11-30  6:05 ` Thierry Volpiatto
  2011-11-30  9:32 ` Juri Linkov
  1 sibling, 0 replies; 27+ messages in thread
From: Thierry Volpiatto @ 2011-11-30  6:05 UTC (permalink / raw)
  To: 10165

As a reminder, I will have to put back the original behavior in
defcustom, that is to move the mouse by default in the 
top right corner i.e 
(defcustom mouse-avoidance-banish-destination '(right . top)
 
Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:

>> Hi all,
>> there was nothing except modifying function
>> `mouse-avoidance-banish-destination' to set in which corner mouse is
>> banish.
>> This patch allow setting this through
>> `mouse-avoidance-banish-destination' user variable like this:
>> (left . top) or (right . bottom) etc...
>
> Thanks.  We're in feature freeze---please file this in the bug database
> so it doesn't get forgotten.
>
>
> # HG changeset patch
> # User Thierry Volpiatto <thierry.volpiatto@gmail.com>
> # Date 1322632617 -3600
> # Node ID 885228e9f341f392fc6886bf2855a66c5bdba6c5
> # Parent  c511f9c3f7a2cab8b3684b2f1ea4782176988ac6
> * lisp/avoid.el:  Allow setting in which corner banish move the mouse.
> (mouse-avoidance-banish-destination): New user variable, a cons pair to specify banish corner position.
> (mouse-avoidance-banish-destination): Set destination according to mouse-avoidance-banish-destination value.
>
> diff --git a/lisp/avoid.el b/lisp/avoid.el
> --- a/lisp/avoid.el
> +++ b/lisp/avoid.el
> @@ -115,6 +115,11 @@
>    :type 'integer
>    :group 'avoid)
>  
> +(defcustom mouse-avoidance-banish-destination '(left . top)
> +  "Set the position to which Mouse Avoidance mode `banish' moves the mouse."
> +  :group 'avoid
> +  :type 'list)
> +
>  ;; Internal variables
>  (defvar mouse-avoidance-state nil)
>  (defvar mouse-avoidance-pointer-shapes nil)
> @@ -183,10 +188,18 @@
>  
>  (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' as you need."
> +  (let* ((pos     (loop for v in (window-edges)
> +                        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) 2)
> +	  (assoc-default up-down pos))))
>  
>  (defun mouse-avoidance-banish-mouse ()
>    ;; Put the mouse pointer in the upper-right corner of the current frame.

-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 






^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2011-11-30  5:58 bug#10165: [PATCH] Allow setting corner in mouse avoidance mode Thierry Volpiatto
  2011-11-30  6:05 ` Thierry Volpiatto
@ 2011-11-30  9:32 ` Juri Linkov
  2011-11-30 10:31   ` Thierry Volpiatto
  1 sibling, 1 reply; 27+ messages in thread
From: Juri Linkov @ 2011-11-30  9:32 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: 10165

>> there was nothing except modifying function
>> `mouse-avoidance-banish-destination' to set in which corner mouse is
>> banish.
>> This patch allow setting this through
>> `mouse-avoidance-banish-destination' user variable like this:
>> (left . top) or (right . bottom) etc...

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.





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2011-11-30  9:32 ` Juri Linkov
@ 2011-11-30 10:31   ` Thierry Volpiatto
  2011-11-30 17:40     ` Thierry Volpiatto
  0 siblings, 1 reply; 27+ messages in thread
From: Thierry Volpiatto @ 2011-11-30 10:31 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 10165

Juri Linkov <juri@jurta.org> writes:

>>> there was nothing except modifying function
>>> `mouse-avoidance-banish-destination' to set in which corner mouse is
>>> banish.
>>> This patch allow setting this through
>>> `mouse-avoidance-banish-destination' user variable like this:
>>> (left . top) or (right . bottom) etc...
>
> 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.

-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2011-11-30 10:31   ` Thierry Volpiatto
@ 2011-11-30 17:40     ` Thierry Volpiatto
  2011-12-01  7:48       ` Juri Linkov
  0 siblings, 1 reply; 27+ messages in thread
From: Thierry Volpiatto @ 2011-11-30 17:40 UTC (permalink / raw)
  To: 10165

Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:

> Juri Linkov <juri@jurta.org> writes:
>
>>>> there was nothing except modifying function
>>>> `mouse-avoidance-banish-destination' to set in which corner mouse is
>>>> banish.
>>>> This patch allow setting this through
>>>> `mouse-avoidance-banish-destination' user variable like this:
>>>> (left . top) or (right . bottom) etc...
>>
>> 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)

-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 






^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2011-11-30 17:40     ` Thierry Volpiatto
@ 2011-12-01  7:48       ` Juri Linkov
  2011-12-01  8:45         ` Thierry Volpiatto
  2011-12-02  7:30         ` Thierry Volpiatto
  0 siblings, 2 replies; 27+ messages in thread
From: Juri Linkov @ 2011-12-01  7:48 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: 10165

>>> 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?





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2011-12-01  7:48       ` Juri Linkov
@ 2011-12-01  8:45         ` Thierry Volpiatto
  2011-12-02  7:30         ` Thierry Volpiatto
  1 sibling, 0 replies; 27+ messages in thread
From: Thierry Volpiatto @ 2011-12-01  8:45 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 10165

Juri Linkov <juri@jurta.org> 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 





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2011-12-01  7:48       ` Juri Linkov
  2011-12-01  8:45         ` Thierry Volpiatto
@ 2011-12-02  7:30         ` Thierry Volpiatto
  2011-12-02  7:36           ` Thierry Volpiatto
  1 sibling, 1 reply; 27+ messages in thread
From: Thierry Volpiatto @ 2011-12-02  7:30 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 10165

[-- Attachment #1: Type: text/plain, Size: 1221 bytes --]

Juri Linkov <juri@jurta.org> 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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: mouse avoidance banish --]
[-- Type: text/x-diff, Size: 2450 bytes --]

##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.

[-- Attachment #3: Type: text/plain, Size: 83 bytes --]


-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 

^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2011-12-02  7:30         ` Thierry Volpiatto
@ 2011-12-02  7:36           ` Thierry Volpiatto
  2011-12-02 10:52             ` Juri Linkov
  0 siblings, 1 reply; 27+ messages in thread
From: Thierry Volpiatto @ 2011-12-02  7:36 UTC (permalink / raw)
  To: 10165

Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:

> +(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)

I used same default value as it is actually, but i think using 
'(frame . 2) as Juri does is much better.

-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 






^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2011-12-02  7:36           ` Thierry Volpiatto
@ 2011-12-02 10:52             ` Juri Linkov
  2011-12-02 11:24               ` Thierry Volpiatto
  0 siblings, 1 reply; 27+ messages in thread
From: Juri Linkov @ 2011-12-02 10:52 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: 10165

>> +(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)
>
> I used same default value as it is actually, but i think using
> '(frame . 2) as Juri does is much better.

Thanks.  What do you think about using the same syntax as for the
geometry specification?  Like (info "(emacs) Window Size X") describes:

  {+-}XOFFSET{+-}YOFFSET





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2011-12-02 10:52             ` Juri Linkov
@ 2011-12-02 11:24               ` Thierry Volpiatto
  2011-12-02 17:07                 ` Juri Linkov
  0 siblings, 1 reply; 27+ messages in thread
From: Thierry Volpiatto @ 2011-12-02 11:24 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 10165

Juri Linkov <juri@jurta.org> writes:

>>> +(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)
>>
>> I used same default value as it is actually, but i think using
>> '(frame . 2) as Juri does is much better.
>
> Thanks.  What do you think about using the same syntax as for the
> geometry specification?  

You mean using something like:
'(frame . "X+Y")

> Like (info "(emacs) Window Size X") describes:
>
>   {+-}XOFFSET{+-}YOFFSET

-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2011-12-02 11:24               ` Thierry Volpiatto
@ 2011-12-02 17:07                 ` Juri Linkov
  2011-12-02 17:35                   ` Thierry Volpiatto
  0 siblings, 1 reply; 27+ messages in thread
From: Juri Linkov @ 2011-12-02 17:07 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: 10165

> You mean using something like:
> '(frame . "X+Y")

Yes, but we also need an edge specification too, like:

  '(frame top +2 right -1)

  '(window bottom -2 left +3)





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2011-12-02 17:07                 ` Juri Linkov
@ 2011-12-02 17:35                   ` Thierry Volpiatto
  2011-12-03  8:58                     ` Thierry Volpiatto
  0 siblings, 1 reply; 27+ messages in thread
From: Thierry Volpiatto @ 2011-12-02 17:35 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 10165

Juri Linkov <juri@jurta.org> writes:

>> You mean using something like:
>> '(frame . "X+Y")
>
> Yes, but we also need an edge specification too, like:
>
>   '(frame top +2 right -1)
>
>   '(window bottom -2 left +3)
IIUC we would need only one defcustom, right?

We are seriously going out of the corner now. ;-)

Such settings maybe interesting for not popping up xfce toolbar at
bottom of screen when using Emacs in fullscreen for example.

I will try to rework my patch then.

Thanks.

-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2011-12-02 17:35                   ` Thierry Volpiatto
@ 2011-12-03  8:58                     ` Thierry Volpiatto
  2011-12-03  9:26                       ` Thierry Volpiatto
  0 siblings, 1 reply; 27+ messages in thread
From: Thierry Volpiatto @ 2011-12-03  8:58 UTC (permalink / raw)
  To: 10165

[-- Attachment #1: Type: text/plain, Size: 679 bytes --]

Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:

> I will try to rework my patch then.

I use only one user variable now:

--8<---------------cut here---------------start------------->8---
(defcustom mouse-avoidance-banish-position '((frame-or-window . frame)
                                             (side . right)
                                             (side-pos . 3)
                                             (top-or-bottom . top)
                                             (top-or-bottom-pos . 0))
--8<---------------cut here---------------end--------------->8---

Which allow to set also the vertical position (top-or-bottom-pos).
See attached patch.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: mouse avoidance banish --]
[-- Type: text/x-diff, Size: 3809 bytes --]

##Merge of all patches applied from revision 118111
## 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 sexp :value-type sexp)
+  :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,10 +200,40 @@
 
 (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))
+         (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
+                   ;; distance from side
+                   (cdr mouse-avoidance-banish-distance-from-edge))
+	  (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.

[-- Attachment #3: Type: text/plain, Size: 83 bytes --]


-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 

^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2011-12-03  8:58                     ` Thierry Volpiatto
@ 2011-12-03  9:26                       ` Thierry Volpiatto
  2011-12-05 10:52                         ` Juri Linkov
  0 siblings, 1 reply; 27+ messages in thread
From: Thierry Volpiatto @ 2011-12-03  9:26 UTC (permalink / raw)
  To: 10165

Use this, as there is an error in precedent patch (still using value of
old variable), sorry.

--8<---------------cut here---------------start------------->8---
(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-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
--8<---------------cut here---------------end--------------->8---



-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 






^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2011-12-03  9:26                       ` Thierry Volpiatto
@ 2011-12-05 10:52                         ` Juri Linkov
  2011-12-05 18:06                           ` Thierry Volpiatto
  0 siblings, 1 reply; 27+ messages in thread
From: Juri Linkov @ 2011-12-05 10:52 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: 10165

> 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.  But fortunately we could avoid them.





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2011-12-05 10:52                         ` Juri Linkov
@ 2011-12-05 18:06                           ` Thierry Volpiatto
  2011-12-07 17:30                             ` Juri Linkov
  0 siblings, 1 reply; 27+ messages in thread
From: Thierry Volpiatto @ 2011-12-05 18:06 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 10165

[-- Attachment #1: Type: text/plain, Size: 586 bytes --]

Juri Linkov <juri@jurta.org> 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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: mouse avoidance banish --]
[-- Type: text/x-diff, Size: 4136 bytes --]

##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)

[-- Attachment #3: Type: text/plain, Size: 83 bytes --]


-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 

^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2011-12-05 18:06                           ` Thierry Volpiatto
@ 2011-12-07 17:30                             ` Juri Linkov
  2011-12-07 18:04                               ` Thierry Volpiatto
  0 siblings, 1 reply; 27+ messages in thread
From: Juri Linkov @ 2011-12-07 17:30 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: 10165

>> Thanks.  I think names like `frame-or-window' and `top-or-bottom-pos'
>> are quite confusing.
>
> Yes, if you have better names tell me.

I think better names would be similar to geometry specification
like in (info "(emacs) Window Size X").

Then we could have such names (with possible values):

  x-side     `left' or `right'
  y-side     `top' or `bottom'
  x-offset   integer (positive, negative or zero)
  y-offset   integer (positive, negative or zero)

So for example it would be possible to customize
`mouse-avoidance-banish-position' to the following setting:

  '((frame-or-window . frame)
    (x-side          . right)
    (x-offset        . 3)
    (y-side          . bottom)
    (y-offset        . -1))

Also `frame-or-window' is too long name, but currently I have no idea
what a shorter name would be better.

>> But fortunately we could avoid them.
>
> Can you develop this?

I think that instead of an alist it would be simpler to use a list
with the fixed meaning of each list element.  I mean something like:

(defcustom mouse-avoidance-banish-position '(frame right 3 bottom -1)
  :type '(list (choice (const frame :tag "Relative to frame coordinates")
                       (const window :tag "Relative to window coordinates"))
               (choice (const left :tag "Relative to left edge")
                       (const right :tag "Relative to right edge"))
               (integer :tag "Horizontal offset")
               (choice (const top :tag "Relative to top edge")
                       (const bottom :tag "Relative to bottom edge"))
               (integer :tag "Vertical offset")))





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2011-12-07 17:30                             ` Juri Linkov
@ 2011-12-07 18:04                               ` Thierry Volpiatto
  2011-12-07 19:52                                 ` Juri Linkov
  0 siblings, 1 reply; 27+ messages in thread
From: Thierry Volpiatto @ 2011-12-07 18:04 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 10165

Juri Linkov <juri@jurta.org> writes:

>>> Thanks.  I think names like `frame-or-window' and `top-or-bottom-pos'
>>> are quite confusing.
>>
>> Yes, if you have better names tell me.
>
> I think better names would be similar to geometry specification
> like in (info "(emacs) Window Size X").
>
> Then we could have such names (with possible values):
>
>   x-side     `left' or `right'
>   y-side     `top' or `bottom'
>   x-offset   integer (positive, negative or zero)
>   y-offset   integer (positive, negative or zero)

Note that the code I wrote don't require negative arguments.
You just set the distance from one edge with a positive argument,
doesn't matter if it is right, left top or bottom.

> So for example it would be possible to customize
> `mouse-avoidance-banish-position' to the following setting:
>
>   '((frame-or-window . frame)
>     (x-side          . right)
>     (x-offset        . 3)
>     (y-side          . bottom)
>     (y-offset        . -1))

Ok for this, except for negative integers.

> Also `frame-or-window' is too long name, but currently I have no idea
> what a shorter name would be better.
>
>>> But fortunately we could avoid them.
>>
>> Can you develop this?
>
> I think that instead of an alist it would be simpler to use a list
> with the fixed meaning of each list element.  I mean something like:
>
> (defcustom mouse-avoidance-banish-position '(frame right 3 bottom -1)
>   :type '(list (choice (const frame :tag "Relative to frame coordinates")
>                        (const window :tag "Relative to window coordinates"))
>                (choice (const left :tag "Relative to left edge")
>                        (const right :tag "Relative to right edge"))
>                (integer :tag "Horizontal offset")
>                (choice (const top :tag "Relative to top edge")
>                        (const bottom :tag "Relative to bottom edge"))
>                (integer :tag "Vertical offset")))

I prefer an alist, it is easier to understand.


-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2011-12-07 18:04                               ` Thierry Volpiatto
@ 2011-12-07 19:52                                 ` Juri Linkov
  2011-12-08  6:33                                   ` Thierry Volpiatto
  0 siblings, 1 reply; 27+ messages in thread
From: Juri Linkov @ 2011-12-07 19:52 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: 10165

>>   x-side     `left' or `right'
>>   y-side     `top' or `bottom'
>>   x-offset   integer (positive, negative or zero)
>>   y-offset   integer (positive, negative or zero)
>
> Note that the code I wrote don't require negative arguments.
> You just set the distance from one edge with a positive argument,
> doesn't matter if it is right, left top or bottom.

Sorry, I don't understand.  Could you please demonstrate how it would be
possible to represent the following setting:

  (defun mouse-avoidance-banish-destination ()
    (cons (+ 3 (frame-width)) (- (frame-height) 1)))

with only positive integer values in `mouse-avoidance-banish-position'?





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2011-12-07 19:52                                 ` Juri Linkov
@ 2011-12-08  6:33                                   ` Thierry Volpiatto
  2011-12-08 20:20                                     ` Stefan Monnier
  2012-04-12 20:04                                     ` Lars Magne Ingebrigtsen
  0 siblings, 2 replies; 27+ messages in thread
From: Thierry Volpiatto @ 2011-12-08  6:33 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 10165

Juri Linkov <juri@jurta.org> writes:

>>>   x-side     `left' or `right'
>>>   y-side     `top' or `bottom'
>>>   x-offset   integer (positive, negative or zero)
>>>   y-offset   integer (positive, negative or zero)
>>
>> Note that the code I wrote don't require negative arguments.
>> You just set the distance from one edge with a positive argument,
>> doesn't matter if it is right, left top or bottom.
>
> Sorry, I don't understand.  Could you please demonstrate how it would be
> possible to represent the following setting:
>
>   (defun mouse-avoidance-banish-destination ()
>     (cons (+ 3 (frame-width)) (- (frame-height) 1)))
>
> with only positive integer values in `mouse-avoidance-banish-position'?

Yes you are right, sorry, need to use negative values for such setting.

-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2011-12-08  6:33                                   ` Thierry Volpiatto
@ 2011-12-08 20:20                                     ` Stefan Monnier
  2012-04-12 20:04                                     ` Lars Magne Ingebrigtsen
  1 sibling, 0 replies; 27+ messages in thread
From: Stefan Monnier @ 2011-12-08 20:20 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: 10165

> Yes you are right, sorry, need to use negative values for such setting.

I see no problem with that, by the way,


        Stefan





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2011-12-08  6:33                                   ` Thierry Volpiatto
  2011-12-08 20:20                                     ` Stefan Monnier
@ 2012-04-12 20:04                                     ` Lars Magne Ingebrigtsen
  2012-04-12 21:12                                       ` Thierry Volpiatto
  2012-04-13 15:19                                       ` Thierry Volpiatto
  1 sibling, 2 replies; 27+ messages in thread
From: Lars Magne Ingebrigtsen @ 2012-04-12 20:04 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: 10165

Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:

> Yes you are right, sorry, need to use negative values for such setting.

There were lots of different versions of the patch, but we're now in
Emacs 24.2 land, so installing this now would be OK.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2012-04-12 20:04                                     ` Lars Magne Ingebrigtsen
@ 2012-04-12 21:12                                       ` Thierry Volpiatto
  2012-04-13 15:19                                       ` Thierry Volpiatto
  1 sibling, 0 replies; 27+ messages in thread
From: Thierry Volpiatto @ 2012-04-12 21:12 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: 10165

[-- Attachment #1: Type: text/plain, Size: 345 bytes --]

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
>
>> Yes you are right, sorry, need to use negative values for such setting.
>
> There were lots of different versions of the patch, but we're now in
> Emacs 24.2 land, so installing this now would be OK.
Ok I will install it tomorrow.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: banish mouse --]
[-- Type: text/x-diff, Size: 4201 bytes --]

# HG changeset patch
# User Thierry Volpiatto <thierry.volpiatto@gmail.com>
# Date 1334264470 -7200
# Node ID 3348d7d9ee32577461067f83f3df8f5c9f2106c7
# Parent  6535056f09a7e69005c3ea1402fec39eaa754e5f
* lisp/avoid.el Allow customizing position of mouse when banishing.
(mouse-avoidance-banish-position): New user variable.
(mouse-avoidance-banish-destination): Place mouse pointer according to `mouse-avoidance-banish-position'.

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)

[-- Attachment #3: Type: text/plain, Size: 83 bytes --]


-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 

^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2012-04-12 20:04                                     ` Lars Magne Ingebrigtsen
  2012-04-12 21:12                                       ` Thierry Volpiatto
@ 2012-04-13 15:19                                       ` Thierry Volpiatto
  2012-04-13 21:13                                         ` Lars Ingebrigtsen
  1 sibling, 1 reply; 27+ messages in thread
From: Thierry Volpiatto @ 2012-04-13 15:19 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: 10165

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
>
>> Yes you are right, sorry, need to use negative values for such setting.
>
> There were lots of different versions of the patch, but we're now in
> Emacs 24.2 land, so installing this now would be OK.
Please install the patch I am unable to use bzr, just give up.

-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2012-04-13 15:19                                       ` Thierry Volpiatto
@ 2012-04-13 21:13                                         ` Lars Ingebrigtsen
  2012-04-14  5:14                                           ` Thierry Volpiatto
  0 siblings, 1 reply; 27+ messages in thread
From: Lars Ingebrigtsen @ 2012-04-13 21:13 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: 10165

Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:

> Please install the patch I am unable to use bzr, just give up.

Ok; applied.

But what's the problem?  vc mode in Emacs means that you never have to
understand the underlying VC.  :-)

-- 
(domestic pets only, the antidote for overdose, milk.)
  http://lars.ingebrigtsen.no  *  Sent from my Rome





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#10165: [PATCH] Allow setting corner in mouse avoidance mode.
  2012-04-13 21:13                                         ` Lars Ingebrigtsen
@ 2012-04-14  5:14                                           ` Thierry Volpiatto
  0 siblings, 0 replies; 27+ messages in thread
From: Thierry Volpiatto @ 2012-04-14  5:14 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 10165

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
>
>> Please install the patch I am unable to use bzr, just give up.
>
> Ok; applied.
Thanks.

> But what's the problem?  vc mode in Emacs means that you never have to
> understand the underlying VC.  :-)

-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 





^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2012-04-14  5:14 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-30  5:58 bug#10165: [PATCH] Allow setting corner in mouse avoidance mode Thierry Volpiatto
2011-11-30  6:05 ` Thierry Volpiatto
2011-11-30  9:32 ` Juri Linkov
2011-11-30 10:31   ` Thierry Volpiatto
2011-11-30 17:40     ` Thierry Volpiatto
2011-12-01  7:48       ` Juri Linkov
2011-12-01  8:45         ` Thierry Volpiatto
2011-12-02  7:30         ` Thierry Volpiatto
2011-12-02  7:36           ` Thierry Volpiatto
2011-12-02 10:52             ` Juri Linkov
2011-12-02 11:24               ` Thierry Volpiatto
2011-12-02 17:07                 ` Juri Linkov
2011-12-02 17:35                   ` Thierry Volpiatto
2011-12-03  8:58                     ` Thierry Volpiatto
2011-12-03  9:26                       ` Thierry Volpiatto
2011-12-05 10:52                         ` Juri Linkov
2011-12-05 18:06                           ` Thierry Volpiatto
2011-12-07 17:30                             ` Juri Linkov
2011-12-07 18:04                               ` Thierry Volpiatto
2011-12-07 19:52                                 ` Juri Linkov
2011-12-08  6:33                                   ` Thierry Volpiatto
2011-12-08 20:20                                     ` Stefan Monnier
2012-04-12 20:04                                     ` Lars Magne Ingebrigtsen
2012-04-12 21:12                                       ` Thierry Volpiatto
2012-04-13 15:19                                       ` Thierry Volpiatto
2012-04-13 21:13                                         ` Lars Ingebrigtsen
2012-04-14  5:14                                           ` Thierry Volpiatto

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).