From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Masatake YAMATO Newsgroups: gmane.emacs.devel Subject: Re: Where the menu should be appeared when C-mouse-3 is triggered Date: Fri, 20 Jul 2012 13:55:34 +0900 (JST) Organization: Red Hat Japan, Inc. Message-ID: <20120720.135534.2139116803885399180.yamato@redhat.com> References: <20120719.173253.1324462371913652728.yamato@redhat.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1342760152 1519 80.91.229.3 (20 Jul 2012 04:55:52 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 20 Jul 2012 04:55:52 +0000 (UTC) Cc: emacs-devel@gnu.org To: monnier@IRO.UMontreal.CA Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 20 06:55:51 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ss5Fh-00031h-N3 for ged-emacs-devel@m.gmane.org; Fri, 20 Jul 2012 06:55:45 +0200 Original-Received: from localhost ([::1]:52048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ss5Fh-0003MS-1f for ged-emacs-devel@m.gmane.org; Fri, 20 Jul 2012 00:55:45 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:53633) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ss5Fe-0003M7-1P for emacs-devel@gnu.org; Fri, 20 Jul 2012 00:55:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ss5Fc-0002rD-2C for emacs-devel@gnu.org; Fri, 20 Jul 2012 00:55:41 -0400 Original-Received: from mx1.redhat.com ([209.132.183.28]:54540) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ss5Fb-0002r7-Ps for emacs-devel@gnu.org; Fri, 20 Jul 2012 00:55:39 -0400 Original-Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6K4tcou019242 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 20 Jul 2012 00:55:38 -0400 Original-Received: from localhost (dhcp-193-19.nrt.redhat.com [10.64.193.19]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q6K4tZ1P025759; Fri, 20 Jul 2012 00:55:36 -0400 In-Reply-To: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:151772 Archived-At: Hi, >> I don't this is easy to fix. > >> For KEYBOARD USER it is nice to popped up at point. >> Howto, it is not nice for MOUSE USER. > > We can easily check what kind of event was used to run the command and > then decide whether to popup near point or near the mouse. > > Such distinction is already used to decide whether to use a dialog-ox or > the minibuffer to read a file-name. > Thank you for suggestion. Please, see the patch. Do I understand what you wrote? >> Emacs has many useful commands(mouse oriented commands) which are >> expected to be triggered from MOUSE. Some of them, including >> C-mouse-3, are not suitable for keyboard operatoin. > > It's currently unsuitable, but we can make it suitable. YES! With the patch f10 can show the same menu items as C-mouse-3 shows. The menu is shows at point or mouse cursor; last-nonmenu-event is referred to decide the postion. The menu items reflects (current-buffer) when the menu is shown at point. I think a function showing menu at point may be useful other elisp program, so I introduced `point-pixel-position' and 'point' constant for POSITION parameter of `popup-menu'. If this one is acceptable, I'd like to withdraw the original f10 patch. Masatake YAMATO === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2012-07-19 14:38:01 +0000 +++ lisp/ChangeLog 2012-07-20 03:57:05 +0000 @@ -1,3 +1,15 @@ +2012-07-20 Masatake YAMATO + + * term/x-win.el (x-menu-bar-open): Use `frame-parameter' + to check whether menu-bar is shown or not. If not shown, + show the menu-bar as a popup menu instead of using tmm. + + * subr.el (point-pixel-position): New function. + + * mouse.el (popup-menu): Use the value returned from + `point-pixel-position' as POSITION if POSITION is + `point' when `popup-menu' is invoked. + 2012-07-19 Sam Steingold * vc/vc-dispatcher.el (vc-compilation-mode): Add, based on === modified file 'lisp/mouse.el' --- lisp/mouse.el 2012-07-08 08:26:21 +0000 +++ lisp/mouse.el 2012-07-20 03:43:27 +0000 @@ -102,7 +102,8 @@ MENU can be a keymap, an easymenu-style menu or a list of keymaps as for `x-popup-menu'. POSITION can be a click event or ((XOFFSET YOFFSET) WINDOW) and defaults to - the current mouse position. + the current mouse position. If POSITION is a symbol, `point' the current point +position is used. PREFIX is the prefix argument (if any) to pass to the command." (let* ((map (cond ((keymapp menu) menu) @@ -112,9 +113,16 @@ (plist-get (get map 'menu-prop) :filter)))) (if filter (funcall filter (symbol-function map)) map))))) event cmd) - (unless position - (let ((mp (mouse-pixel-position))) - (setq position (list (list (cadr mp) (cddr mp)) (car mp))))) + (setq position + (cond + ((eq position 'point) + (let ((pp (point-pixel-position))) + (list (list (cadr pp) (cddr pp)) (car pp)))) + ((not position) + (let ((mp (mouse-pixel-position))) + (list (list (cadr mp) (cddr mp)) (car mp)))) + (t + position))) ;; The looping behavior was taken from lmenu's popup-menu-popup (while (and map (setq event ;; map could be a prefix key, in which case === modified file 'lisp/subr.el' --- lisp/subr.el 2012-07-19 06:24:04 +0000 +++ lisp/subr.el 2012-07-20 01:28:19 +0000 @@ -1148,6 +1148,12 @@ be a list of the form returned by `event-start' and `event-end'." (nth 9 position)) +(defun point-pixel-position (&optional pos window) + "Return the pxiel position of point as (WINDOW X . Y). +Analogous to `mouse-pixel-position'." + (let ((pp (posn-at-point pos window))) + (cons (posn-window pp) (posn-x-y pp)))) + ;;;; Obsolescent names for functions. === modified file 'lisp/term/x-win.el' --- lisp/term/x-win.el 2012-04-27 05:40:46 +0000 +++ lisp/term/x-win.el 2012-07-20 03:39:48 +0000 @@ -1305,12 +1305,18 @@ (declare-function accelerate-menu "xmenu.c" (&optional frame) t) (defun x-menu-bar-open (&optional frame) - "Open the menu bar if `menu-bar-mode' is on, otherwise call `tmm-menubar'." + "Open the menu bar if it is shown. +`popup-menu' is used if it is off " (interactive "i") - (if (and menu-bar-mode - (fboundp 'accelerate-menu)) - (accelerate-menu frame) - (tmm-menubar))) + (cond + ((and (not (zerop (or (frame-parameter nil 'menu-bar-lines) 0))) + (fboundp 'accelerate-menu)) + (accelerate-menu frame)) + (t + (popup-menu (mouse-menu-bar-map) + (if (listp last-nonmenu-event) + nil + 'point))))) ;;; Window system initialization.