|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
artist-mouse-choose-operationThe 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. |
|
|
Re: artist-mouse-choose-operationEli Zaretskii <eliz@...> 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@...>. * 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)))) |
|
|
Re: artist-mouse-choose-operation>> 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 |
|
|
Re: artist-mouse-choose-operation> From: Stefan Monnier <monnier@...>
> Cc: Eli Zaretskii <eliz@...>, emacs-devel@... > 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. |
|
|
Re: artist-mouse-choose-operation>> 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 |
|
|
Re: artist-mouse-choose-operationStefan Monnier <monnier@...> 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 |
|
|
Re: artist-mouse-choose-operation-----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----- |
|
|
Re: artist-mouse-choose-operation> From: Tomas Abrahamsson <tab@...>
> Cc: emacs-devel@... > Date: Mon, 09 Nov 2009 23:22:11 +0100 > > Eli Zaretskii <eliz@...> 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@...>. > > * 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. |
| Free embeddable forum powered by Nabble | Forum Help |