+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
* 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>
* 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)
"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)
(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
;; 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.