From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tomas Abrahamsson Newsgroups: gmane.emacs.devel Subject: Re: artist-mouse-choose-operation Date: Mon, 09 Nov 2009 23:22:11 +0100 Message-ID: References: <834opfeq8a.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1257825464 30839 80.91.229.12 (10 Nov 2009 03:57:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 10 Nov 2009 03:57:44 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Nov 10 04:57:37 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1N7hrM-0002NK-D5 for ged-emacs-devel@m.gmane.org; Tue, 10 Nov 2009 04:57:36 +0100 Original-Received: from localhost ([127.0.0.1]:45534 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N7hrM-0008QK-27 for ged-emacs-devel@m.gmane.org; Mon, 09 Nov 2009 22:57:36 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N7ccx-0006xx-Sk for emacs-devel@gnu.org; Mon, 09 Nov 2009 17:22:24 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N7ccs-0006wF-Tl for emacs-devel@gnu.org; Mon, 09 Nov 2009 17:22:23 -0500 Original-Received: from [199.232.76.173] (port=53438 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N7ccs-0006w2-P5 for emacs-devel@gnu.org; Mon, 09 Nov 2009 17:22:18 -0500 Original-Received: from mail.lysator.liu.se ([130.236.254.3]:56340) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N7ccp-0004Io-RF; Mon, 09 Nov 2009 17:22:16 -0500 Original-Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id D44C74002F; Mon, 9 Nov 2009 23:21:15 +0100 (CET) Original-Received: by mail.lysator.liu.se (Postfix, from userid 1674) id C7FA04006D; Mon, 9 Nov 2009 23:21:15 +0100 (CET) Original-Received: from stalhein.lysator.liu.se (stalhein.lysator.liu.se [130.236.254.204]) by mail.lysator.liu.se (Postfix) with ESMTP id 7E5A14002F; Mon, 9 Nov 2009 23:21:15 +0100 (CET) In-Reply-To: <834opfeq8a.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 31 Oct 2009 13:51:17 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (usg-unix-v) X-Virus-Scanned: ClamAV using ClamSMTP X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-Mailman-Approved-At: Mon, 09 Nov 2009 22:56:43 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:116787 Archived-At: Eli Zaretskii 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 . * 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))))