emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: `y-or-n-p' does not wait for input - assumes `n'


From: Luc Teirlinck
Subject: Re: `y-or-n-p' does not wait for input - assumes `n'
Date: Tue, 25 Jan 2005 21:59:02 -0600 (CST)

Richard Stallman wrote:

   In that case, I am stumped.  Can you figure out what is really happening?

I believe I did.

I replaced Drew's function with:

(defun custom-foobar (widget)
  (if (progn (input-pending-p) (read-event) (y-or-n-p "foo: "))
      (progn (message "Yes")(sit-for 1))
    (message "No")(sit-for 1)))

Then I edebugged that.  `input-pending' was t and `read-event' returned
a mouse-motion event.  The problem is that the function is executed
with the variable track-mouse bound to t.

There are two ways to interpret this.  The first way (which to me
looks far fetched) would be that functions used in
`custom-variable-menu' should bind track-mouse themselves to nil if
they want to read input that does not track the mouse.  That is,
Drew's function should be:

(defun custom-foobar (widget)
  (if (let (track-mouse) (y-or-n-p "foo: "))
      (progn (message "Yes")(sit-for 1))
    (message "No")(sit-for 1)))

This indeed fixes the bug.

The second way to interpret it is that the functions in
`custom-variable-menu' should be executed with track-mouse bound to
nil, and if they need to track the mouse, they have to simply rebind
it to t once more.  This is implemented by the following patch, which
I could install if desired.  It fixes the bug.  It is an incompatible
change and I am not 100% sure that it does not break something else,
although I would be surprised.

===File ~/wid-edit-diff=====================================
*** wid-edit.el 27 Dec 2004 15:02:40 -0600      1.134
--- wid-edit.el 25 Jan 2005 21:20:06 -0600      
***************
*** 939,945 ****
                          ;; its action function.
                          (when (and pos
                                     (eq (get-char-property pos 'button) 
button))
!                           (widget-apply-action button event))))
                    (overlay-put overlay 'face face)
                    (overlay-put overlay 'mouse-face mouse-face))))
  
--- 939,946 ----
                          ;; its action function.
                          (when (and pos
                                     (eq (get-char-property pos 'button) 
button))
!                           (let (track-mouse)
!                             (widget-apply-action button event)))))
                    (overlay-put overlay 'face face)
                    (overlay-put overlay 'mouse-face mouse-face))))
  
============================================================




reply via email to

[Prev in Thread] Current Thread [Next in Thread]