unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Masatake YAMATO <yamato@redhat.com>
To: monnier@iro.umontreal.ca
Cc: emacs-devel@gnu.org
Subject: Re: Where the menu should be appeared when C-mouse-3 is triggered
Date: Fri, 10 Aug 2012 22:52:56 +0900 (JST)	[thread overview]
Message-ID: <20120810.225256.926574222050311966.yamato@redhat.com> (raw)
In-Reply-To: <jwva9y4xmrn.fsf-monnier+emacs@gnu.org>

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
>>> <event>) or (posn-at-point) to specify where to display it.  The
>>> docstring of popup-menu seems to indicate that an `event' can be used,
>>> 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
> 
>> === 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  <yamato@redhat.com>
>> +
>> +	* 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án Ezequiel Gallina  <fgallina@cuca>
>  
>>  	Consistent completion in inferior python with emacs -nw.
> 
>> === 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 as 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 internally.
>> +POSITION can be nil, an click event, a posn- value, or a value having
>> +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-point)
>> +    ((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.
> 
>> === 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))))))
>  
>>  \f
>>  ;;; Window system initialization.
> 
> 
> 



  parent reply	other threads:[~2012-08-10 13:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-19 18:41 [patch] showing menu bar temporarily when f10 is pressed Masatake YAMATO
2012-06-19 20:31 ` Lluís
2012-06-19 21:42 ` Stefan Monnier
2012-06-20  6:17   ` [patch v2] " Masatake YAMATO
2012-07-18 11:29     ` [patch v3] " Masatake YAMATO
2012-07-19  6:54       ` Stefan Monnier
2012-07-19  8:32         ` Where the menu should be appeared when C-mouse-3 is triggered (Was: [patch v3] showing menu bar temporarily when f10 is pressed) Masatake YAMATO
2012-07-19  9:07           ` Where the menu should be appeared when C-mouse-3 is triggered Stefan Monnier
2012-07-20  4:55             ` Masatake YAMATO
2012-07-20 11:38               ` Stefan Monnier
2012-07-20 11:56                 ` Masatake YAMATO
2012-07-28  9:31                   ` Masatake YAMATO
2012-08-09 11:13                     ` Masatake YAMATO
2012-08-10 12:44                       ` Stefan Monnier
2012-08-10 13:21                         ` Drew Adams
2012-08-10 13:52                         ` Masatake YAMATO [this message]
2012-08-10 14:47                         ` Stefan Monnier
2012-07-20 12:48                 ` Masatake YAMATO

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120810.225256.926574222050311966.yamato@redhat.com \
    --to=yamato@redhat.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).