all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* artist-mouse-choose-operation
@ 2009-10-31 11:51 Eli Zaretskii
  2009-11-09 22:22 ` artist-mouse-choose-operation Tomas Abrahamsson
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2009-10-31 11:51 UTC (permalink / raw)
  To: Tomas Abrahamsson; +Cc: emacs-devel

The function in the Subject calls x-popup-menu, evidently under the
assumption that if Emacs can use a mouse, it also supports menus.  But
that assumption is false: Emacs configured --without-x can have mouse
support, e.g. via gpm-mouse, but does not have x-popup-menu.




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

* Re: artist-mouse-choose-operation
  2009-10-31 11:51 artist-mouse-choose-operation Eli Zaretskii
@ 2009-11-09 22:22 ` Tomas Abrahamsson
  2009-11-10 17:20   ` artist-mouse-choose-operation Stefan Monnier
  2009-11-13 10:34   ` artist-mouse-choose-operation Eli Zaretskii
  0 siblings, 2 replies; 8+ messages in thread
From: Tomas Abrahamsson @ 2009-11-09 22:22 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> The function in the Subject calls x-popup-menu, evidently under the
> assumption that if Emacs can use a mouse, it also supports menus.  But
> that assumption is false: Emacs configured --without-x can have mouse
> support, e.g. via gpm-mouse, but does not have x-popup-menu.

Yes, I agree this is a bug. Below is a patch for fixing the bug and a
proposal for a ChangeLog entry.

	* textmodes/artist.el (artist-mouse-choose-operation) call
	`tmm-prompt' instead of `x-popup-menu' if we cannot popup
	menus. Bug noticed by Eli Zaretskii <eliz@gnu.org>.

	* textmodes/artist.el (artist-mouse-choose-operation)
	(artist-down-mouse-1): call (new) function
	`artist-compute-up-event-key'.

The patch is against the latest from the git/cvs repository as of
yesterday (Sunday).  The patch is made by me.

BRs
Tomas



diff --git a/lisp/textmodes/artist.el b/lisp/textmodes/artist.el
index c69e3bc..03cb77b 100644
--- a/lisp/textmodes/artist.el
+++ b/lisp/textmodes/artist.el
@@ -4750,6 +4750,15 @@ If optional argument STATE is positive, turn borders on."
   "Function that does nothing."
   (interactive))
 
+(defun artist-compute-up-event-key (ev)
+  "Compute the corresponding up key sequence for event EV."
+ (let* ((basic (event-basic-type ev))
+	(unshifted basic)
+	(shifted (make-symbol (concat "S-" (symbol-name basic)))))
+   (if (artist-event-is-shifted ev)
+       (make-vector 1 shifted)
+     (make-vector 1 unshifted))))
+
 (defun artist-down-mouse-1 (ev)
   "Perform drawing action for event EV."
   (interactive "@e")
@@ -4761,15 +4770,10 @@ If optional argument STATE is positive, turn borders on."
 	 (orig-draw-region-min-y artist-draw-region-min-y)
 	 (orig-draw-region-max-y artist-draw-region-max-y)
 	 (orig-pointer-shape (if (eq window-system 'x) x-pointer-shape nil))
-	 (echo-keystrokes 10000)	; a lot of seconds
+	 (echoq-keystrokes 10000)	; a lot of seconds
 	 ;; Remember original binding for the button-up event to this
 	 ;; button-down event.
-	 (key (let* ((basic (event-basic-type ev))
-		     (unshifted basic)
-		     (shifted (make-symbol (concat "S-" (symbol-name basic)))))
-		(if (artist-event-is-shifted ev)
-		    (make-vector 1 shifted)
-		  (make-vector 1 unshifted))))
+	 (key (artist-compute-up-event-key ev))
 	 (orig-button-up-binding (lookup-key (current-global-map) key)))
 
     (unwind-protect
@@ -4835,7 +4839,21 @@ If optional argument STATE is positive, turn borders on."
    (progn
      (select-window (posn-window (event-start last-input-event)))
      (list last-input-event
-           (x-popup-menu last-nonmenu-event artist-popup-menu-table))))
+	   (if (display-popup-menus-p)
+	       (x-popup-menu last-nonmenu-event artist-popup-menu-table)
+	     'no-popup-menus))))
+
+  (if (eq op 'no-popup-menus)
+      ;; No popup menus. Call `tmm-prompt' instead, but with the
+      ;; up-mouse-button, if any, temporarily disabled, otherwise
+      ;; it'll interfere.
+      (let* ((key (artist-compute-up-event-key ev))
+	     (orig-button-up-binding (lookup-key (current-global-map) key)))
+	(unwind-protect
+	    (define-key (current-global-map) key 'artist-do-nothing)
+	    (setq op (tmm-prompt artist-popup-menu-table))
+	  (if orig-button-up-binding
+	      (define-key (current-global-map) key orig-button-up-binding)))))
 
   (let ((draw-fn (artist-go-get-draw-fn-from-symbol (car op)))
 	(set-fn (artist-fc-get-fn-from-symbol (car op))))




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

* Re: artist-mouse-choose-operation
  2009-11-09 22:22 ` artist-mouse-choose-operation Tomas Abrahamsson
@ 2009-11-10 17:20   ` Stefan Monnier
  2009-11-10 19:09     ` artist-mouse-choose-operation Eli Zaretskii
  2009-11-10 21:06     ` artist-mouse-choose-operation Tomas Abrahamsson
  2009-11-13 10:34   ` artist-mouse-choose-operation Eli Zaretskii
  1 sibling, 2 replies; 8+ messages in thread
From: Stefan Monnier @ 2009-11-10 17:20 UTC (permalink / raw)
  To: Tomas Abrahamsson; +Cc: Eli Zaretskii, emacs-devel

>> The function in the Subject calls x-popup-menu, evidently under the
>> assumption that if Emacs can use a mouse, it also supports menus.  But
>> that assumption is false: Emacs configured --without-x can have mouse
>> support, e.g. via gpm-mouse, but does not have x-popup-menu.

> Yes, I agree this is a bug. Below is a patch for fixing the bug and a
> proposal for a ChangeLog entry.

Makes me wonder: is it really the only place where this kind of problem
shows up?  I think not.  Maybe we should fix it more globally by making
x-popup-menu work on ttys as well (e.g. by using tmm-prompt).


        Stefan





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

* Re: artist-mouse-choose-operation
  2009-11-10 17:20   ` artist-mouse-choose-operation Stefan Monnier
@ 2009-11-10 19:09     ` Eli Zaretskii
  2009-11-10 19:31       ` artist-mouse-choose-operation Stefan Monnier
  2009-11-10 21:06     ` artist-mouse-choose-operation Tomas Abrahamsson
  1 sibling, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2009-11-10 19:09 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: tab, emacs-devel

> From: Stefan Monnier <monnier@IRO.UMontreal.CA>
> Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
> Date: Tue, 10 Nov 2009 12:20:09 -0500
> 
> Maybe we should fix it more globally by making x-popup-menu work on
> ttys as well (e.g. by using tmm-prompt).

That'd be good if (a) we call it popup-menu and not x-popup-menu, and
(b) check not for tty but for display-popup-menus-p.




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

* Re: artist-mouse-choose-operation
  2009-11-10 19:09     ` artist-mouse-choose-operation Eli Zaretskii
@ 2009-11-10 19:31       ` Stefan Monnier
  2009-11-10 21:32         ` artist-mouse-choose-operation tomas
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2009-11-10 19:31 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: tab, emacs-devel

>> Maybe we should fix it more globally by making x-popup-menu work on
>> ttys as well (e.g. by using tmm-prompt).
> That'd be good if (a) we call it popup-menu and not x-popup-menu,

Sadly `popup-menu' is already taken for something different (tho
closely related).

> and (b) check not for tty but for display-popup-menus-p.

The way I see it, `x-popup-menu' would become a "terminal primitive"
(e.g. with a corresponding hook in termhooks.h), so ms-dos and tty and
any other non-GUI backends could implement it any way they see fit.


        Stefan




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

* Re: artist-mouse-choose-operation
  2009-11-10 17:20   ` artist-mouse-choose-operation Stefan Monnier
  2009-11-10 19:09     ` artist-mouse-choose-operation Eli Zaretskii
@ 2009-11-10 21:06     ` Tomas Abrahamsson
  1 sibling, 0 replies; 8+ messages in thread
From: Tomas Abrahamsson @ 2009-11-10 21:06 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Eli Zaretskii, emacs-devel

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>>> The function in the Subject calls x-popup-menu, evidently under the
>>> assumption that if Emacs can use a mouse, it also supports menus.  But
>>> that assumption is false: Emacs configured --without-x can have mouse
>>> support, e.g. via gpm-mouse, but does not have x-popup-menu.
>
>> Yes, I agree this is a bug. Below is a patch for fixing the bug and a
>> proposal for a ChangeLog entry.
>
> Makes me wonder: is it really the only place where this kind of problem
> shows up?  I think not.

I grepped the sources briefly, and found only one call to tmm-prompt
outside of tmm.el, in cperl-mode.el.  I found 34 calls to x-popup-menu.

(I did: "find . -name \*.el | xargs egrep '\(x-popup-menu' | wc -l".)


BRs
Tomas




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

* Re: artist-mouse-choose-operation
  2009-11-10 19:31       ` artist-mouse-choose-operation Stefan Monnier
@ 2009-11-10 21:32         ` tomas
  0 siblings, 0 replies; 8+ messages in thread
From: tomas @ 2009-11-10 21:32 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Eli Zaretskii, tab, emacs-devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, Nov 10, 2009 at 02:31:45PM -0500, Stefan Monnier wrote:
> >> Maybe we should fix it more globally by making x-popup-menu work on
> >> ttys as well (e.g. by using tmm-prompt).
> > That'd be good if (a) we call it popup-menu and not x-popup-menu,
> 
> Sadly `popup-menu' is already taken for something different (tho
> closely related).

Still I think Eli has a point: x-popup-menu seems confusing for that.
Another name? Maybe generic-popup-menu?

Regards
- - tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFK+dvhBcgs9XrR2kYRApanAJ9DnerFQ9drcpula8wRsu4y9xSLVQCfeiTv
x9ORpMeUipH5tfMawe1kBSQ=
=j2/m
-----END PGP SIGNATURE-----




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

* Re: artist-mouse-choose-operation
  2009-11-09 22:22 ` artist-mouse-choose-operation Tomas Abrahamsson
  2009-11-10 17:20   ` artist-mouse-choose-operation Stefan Monnier
@ 2009-11-13 10:34   ` Eli Zaretskii
  1 sibling, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2009-11-13 10:34 UTC (permalink / raw)
  To: Tomas Abrahamsson; +Cc: emacs-devel

> From: Tomas Abrahamsson <tab@lysator.liu.se>
> Cc: emacs-devel@gnu.org
> Date: Mon, 09 Nov 2009 23:22:11 +0100
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > The function in the Subject calls x-popup-menu, evidently under the
> > assumption that if Emacs can use a mouse, it also supports menus.  But
> > that assumption is false: Emacs configured --without-x can have mouse
> > support, e.g. via gpm-mouse, but does not have x-popup-menu.
> 
> Yes, I agree this is a bug. Below is a patch for fixing the bug and a
> proposal for a ChangeLog entry.
> 
> 	* textmodes/artist.el (artist-mouse-choose-operation) call
> 	`tmm-prompt' instead of `x-popup-menu' if we cannot popup
> 	menus. Bug noticed by Eli Zaretskii <eliz@gnu.org>.
> 
> 	* textmodes/artist.el (artist-mouse-choose-operation)
> 	(artist-down-mouse-1): call (new) function
> 	`artist-compute-up-event-key'.
> 
> The patch is against the latest from the git/cvs repository as of
> yesterday (Sunday).  The patch is made by me.

Thanks, I installed this in CVS.




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

end of thread, other threads:[~2009-11-13 10:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-31 11:51 artist-mouse-choose-operation Eli Zaretskii
2009-11-09 22:22 ` artist-mouse-choose-operation Tomas Abrahamsson
2009-11-10 17:20   ` artist-mouse-choose-operation Stefan Monnier
2009-11-10 19:09     ` artist-mouse-choose-operation Eli Zaretskii
2009-11-10 19:31       ` artist-mouse-choose-operation Stefan Monnier
2009-11-10 21:32         ` artist-mouse-choose-operation tomas
2009-11-10 21:06     ` artist-mouse-choose-operation Tomas Abrahamsson
2009-11-13 10:34   ` artist-mouse-choose-operation Eli Zaretskii

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.