mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-05 07:01:11 -08:00
* lisp/mouse.el (popup-menu-normalize-position): New function.
(popup-menu): Use `popup-menu-normalize-position' to normalize the form for POSITION argument. * lisp/term/x-win.el (x-menu-bar-open): Use the value returend from (posn-at-point) as position passed to `popup-menu'.
This commit is contained in:
parent
9ff736dc87
commit
c69f56a207
3 changed files with 50 additions and 23 deletions
|
|
@ -1,3 +1,13 @@
|
|||
2012-08-10 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-08-09 Jay Belanger <jay.p.belanger@gmail.com>
|
||||
|
||||
* calc/calccomp.el (math-compose-expr): Add extra argument
|
||||
|
|
@ -35,8 +45,8 @@
|
|||
* progmodes/python.el: Enhancements to forward-sexp.
|
||||
(python-nav-forward-sexp): Rename from
|
||||
python-nav-forward-sexp-function.
|
||||
(python-nav--forward-sexp, python-nav--backward-sexp): New
|
||||
functions.
|
||||
(python-nav--forward-sexp, python-nav--backward-sexp):
|
||||
New functions.
|
||||
|
||||
2012-08-09 Jay Belanger <jay.p.belanger@gmail.com>
|
||||
|
||||
|
|
@ -489,9 +499,8 @@
|
|||
|
||||
* register.el (copy-to-register, copy-rectangle-to-register):
|
||||
Deactivate the mark, and use indicate-copied-region (Bug#10056).
|
||||
(append-to-register, prepend-to-register): Call
|
||||
|
||||
2012-07-29 Juri Linkov <juri@jurta.org>
|
||||
(append-to-register, prepend-to-register):
|
||||
Call 2012-07-29 Juri Linkov <juri@jurta.org>
|
||||
|
||||
* simple.el (async-shell-command-buffer): New defcustom.
|
||||
(shell-command): Use it. (Bug#4719)
|
||||
|
|
|
|||
|
|
@ -101,11 +101,8 @@ point at the click position."
|
|||
"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 @@ PREFIX is the prefix argument (if any) to pass to the command."
|
|||
(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 @@ PREFIX is the prefix argument (if any) to pass to the command."
|
|||
;; 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.
|
||||
|
|
|
|||
|
|
@ -1316,7 +1316,7 @@ Request data types in the order specified by `x-select-request-type'."
|
|||
(popup-menu (mouse-menu-bar-map)
|
||||
(if (listp last-nonmenu-event)
|
||||
nil
|
||||
'point)))))
|
||||
(posn-at-point))))))
|
||||
|
||||
|
||||
;;; Window system initialization.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue