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, 10 Aug 2012 22:52:56 +0900 (JST) Organization: Red Hat Japan, Inc. Message-ID: <20120810.225256.926574222050311966.yamato@redhat.com> References: <20120728.183150.270114999187506774.yamato@redhat.com> <20120809.201312.1329961304666767845.yamato@redhat.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1344606790 30924 80.91.229.3 (10 Aug 2012 13:53:10 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 10 Aug 2012 13:53:10 +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 Aug 10 15:53:08 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 1SzpeE-0001sM-EX for ged-emacs-devel@m.gmane.org; Fri, 10 Aug 2012 15:53:06 +0200 Original-Received: from localhost ([::1]:51363 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SzpeD-0001GC-Ju for ged-emacs-devel@m.gmane.org; Fri, 10 Aug 2012 09:53:05 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:35939) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Szpe9-0001Ff-W4 for emacs-devel@gnu.org; Fri, 10 Aug 2012 09:53:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Szpe8-0001GS-FJ for emacs-devel@gnu.org; Fri, 10 Aug 2012 09:53:01 -0400 Original-Received: from mx1.redhat.com ([209.132.183.28]:22103) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Szpe8-0001Fg-6Z for emacs-devel@gnu.org; Fri, 10 Aug 2012 09:53:00 -0400 Original-Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q7ADqwRW003207 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 10 Aug 2012 09:52:58 -0400 Original-Received: from localhost (dhcp-193-19.nrt.redhat.com [10.64.193.19]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q7ADquQj013784; Fri, 10 Aug 2012 09:52:57 -0400 In-Reply-To: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 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:152410 Archived-At: Thanks. >> Hi, could you review this patch? > = > Yes, sorry for the delay. Installed, > = > = > Stefan > = > = >> http://lists.gnu.org/archive/html/emacs-devel/2012-07/msg00602.html >> --------------------------------------------------------------------= ----- >> Hi, > = >> About POSITION argument of popup-menu you suggested: > = >>> Maybe a better direction is to make popup-menu (and x-popup-menu, .= ..) >>> accept posn arguments, so you can just use things like (event-end >>> ) or (posn-at-point) to specify where to display it. The >>> docstring of popup-menu seems to indicate that an `event' can be us= ed, >>> but at least in my tests it doesn't seem to work. >>> = >>> Could you look at making a patch to do that (i.e. accept a posn, >>> or maybe an event)? > = >> I've revised the POSITION argument handling. >> Now `popup-menu-normalize-position' handles all POSITION variants. >> I have not touch `x-popup-menu' yet. > = >> Masatake YAMATO > = >> =3D=3D=3D modified file 'lisp/ChangeLog' >> --- lisp/ChangeLog 2012-07-27 16:42:19 +0000 >> +++ lisp/ChangeLog 2012-07-28 09:16:29 +0000 >> @@ -1,3 +1,13 @@ >> +2012-07-28 Masatake YAMATO >> + >> + * mouse.el (popup-menu-normalize-position): New function. >> + (popup-menu): Use `popup-menu-normalize-position' to normalize >> + the form for POSITION argument. >> + >> + * term/x-win.el (x-menu-bar-open): Use >> + the value returend from (posn-at-point) as position >> + passed to `popup-menu'. >> + >> 2012-07-27 Fabi=E1n Ezequiel Gallina > = >> Consistent completion in inferior python with emacs -nw. > = >> =3D=3D=3D modified file 'lisp/mouse.el' >> --- lisp/mouse.el 2012-07-26 08:32:25 +0000 >> +++ lisp/mouse.el 2012-07-28 09:18:46 +0000 >> @@ -101,11 +101,8 @@ >> "Popup the given menu and call the selected option. >> MENU can be a keymap, an easymenu-style menu or a list of keymaps a= s for >> `x-popup-menu'. >> - >> -POSITION can be a click event or ((XOFFSET YOFFSET) WINDOW) and >> -defaults to the current mouse position. If POSITION is the >> -symbol `point', the current point position is used. >> - >> +The menu is shown at the place where POSITION specifies. About >> +the form of POSITION, see `popup-menu-normalize-position'. >> PREFIX is the prefix argument (if any) to pass to the command." >> (let* ((map (cond >> ((keymapp menu) menu) >> @@ -114,18 +111,8 @@ >> (filter (when (symbolp map) >> (plist-get (get map 'menu-prop) :filter)))) >> (if filter (funcall filter (symbol-function map)) map))))) >> - event cmd) >> - (setq position >> - (cond >> - ((eq position 'point) >> - (let* ((pp (posn-at-point)) >> - (xy (posn-x-y pp))) >> - (list (list (car xy) (cdr xy)) (posn-window pp)))) >> - ((not position) >> - (let ((mp (mouse-pixel-position))) >> - (list (list (cadr mp) (cddr mp)) (car mp)))) >> - (t >> - position))) >> + event cmd >> + (position (popup-menu-normalize-position 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 >> @@ -163,6 +150,37 @@ >> ;; mouse-major-mode-menu was using `command-execute' instead.= >> (call-interactively cmd)))) > = >> +(defun popup-menu-normalize-position (position) >> + "Converts the POSITION to the form which `popup-menu' expects int= ernally. >> +POSITION can be nil, an click event, a posn- value, or a value havi= ng >> +form ((XOFFSET YOFFSET) WINDOW). >> +If nil, the current mouse position is used. >> +If an click event, the value returend from `event-end' is used." >> + (pcase position >> + ;; nil -> mouse cursor position >> + ;; this pattern must be before `eventp' because >> + ;; nil is an event. >> + (`nil >> + (let ((mp (mouse-pixel-position))) >> + (list (list (cadr mp) (cddr mp)) (car mp)))) >> + ;; value returned from (event-end (read-event)) or (posn-at-poi= nt) >> + ((or `(,window ,area-or-pos (,x . ,y) >> + ,timestamp ,object ,pos (,col . ,row) >> + ,image (,dx . ,dy) (,width . ,height)) >> + `(,window ,pos (0 . 0) 0)) >> + (let ((xy (posn-x-y position))) >> + (list (list (car xy) (cdr xy)) >> + (posn-window position)))) >> + ;; pattern expected by popup-menu >> + (`((,xoffset ,yoffset) ,window) >> + position) >> + ;; event >> + ((pred eventp) >> + (popup-menu-normalize-position (event-end position))) >> + ;; rejects >> + (t >> + (error "Unexpected position form")))) >> + >> (defun minor-mode-menu-from-indicator (indicator) >> "Show menu for minor mode specified by INDICATOR. >> Interactively, INDICATOR is read using completion. > = >> =3D=3D=3D modified file 'lisp/term/x-win.el' >> --- lisp/term/x-win.el 2012-07-20 11:32:30 +0000 >> +++ lisp/term/x-win.el 2012-07-28 05:08:48 +0000 >> @@ -1316,7 +1316,7 @@ >> (popup-menu (mouse-menu-bar-map) >> (if (listp last-nonmenu-event) >> nil >> - 'point))))) >> + (posn-at-point)))))) > = >> =0C >> ;;; Window system initialization. > = > = > =