aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog19
-rw-r--r--lisp/mouse.el52
-rw-r--r--lisp/term/x-win.el2
3 files changed, 50 insertions, 23 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index fef050e6d02..dc0efcf7563 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12012-08-10 Masatake YAMATO <yamato@redhat.com>
2
3 * mouse.el (popup-menu-normalize-position): New function.
4 (popup-menu): Use `popup-menu-normalize-position' to normalize
5 the form for POSITION argument.
6
7 * term/x-win.el (x-menu-bar-open):
8 Use the value returend from (posn-at-point) as position
9 passed to `popup-menu'.
10
12012-08-09 Jay Belanger <jay.p.belanger@gmail.com> 112012-08-09 Jay Belanger <jay.p.belanger@gmail.com>
2 12
3 * calc/calccomp.el (math-compose-expr): Add extra argument 13 * calc/calccomp.el (math-compose-expr): Add extra argument
@@ -35,8 +45,8 @@
35 * progmodes/python.el: Enhancements to forward-sexp. 45 * progmodes/python.el: Enhancements to forward-sexp.
36 (python-nav-forward-sexp): Rename from 46 (python-nav-forward-sexp): Rename from
37 python-nav-forward-sexp-function. 47 python-nav-forward-sexp-function.
38 (python-nav--forward-sexp, python-nav--backward-sexp): New 48 (python-nav--forward-sexp, python-nav--backward-sexp):
39 functions. 49 New functions.
40 50
412012-08-09 Jay Belanger <jay.p.belanger@gmail.com> 512012-08-09 Jay Belanger <jay.p.belanger@gmail.com>
42 52
@@ -489,9 +499,8 @@
489 499
490 * register.el (copy-to-register, copy-rectangle-to-register): 500 * register.el (copy-to-register, copy-rectangle-to-register):
491 Deactivate the mark, and use indicate-copied-region (Bug#10056). 501 Deactivate the mark, and use indicate-copied-region (Bug#10056).
492 (append-to-register, prepend-to-register): Call 502 (append-to-register, prepend-to-register):
493 503 Call 2012-07-29 Juri Linkov <juri@jurta.org>
4942012-07-29 Juri Linkov <juri@jurta.org>
495 504
496 * simple.el (async-shell-command-buffer): New defcustom. 505 * simple.el (async-shell-command-buffer): New defcustom.
497 (shell-command): Use it. (Bug#4719) 506 (shell-command): Use it. (Bug#4719)
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 71336c08ee3..1506c3f5a84 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -101,11 +101,8 @@ point at the click position."
101 "Popup the given menu and call the selected option. 101 "Popup the given menu and call the selected option.
102MENU can be a keymap, an easymenu-style menu or a list of keymaps as for 102MENU can be a keymap, an easymenu-style menu or a list of keymaps as for
103`x-popup-menu'. 103`x-popup-menu'.
104 104The menu is shown at the place where POSITION specifies. About
105POSITION can be a click event or ((XOFFSET YOFFSET) WINDOW) and 105the form of POSITION, see `popup-menu-normalize-position'.
106defaults to the current mouse position. If POSITION is the
107symbol `point', the current point position is used.
108
109PREFIX is the prefix argument (if any) to pass to the command." 106PREFIX is the prefix argument (if any) to pass to the command."
110 (let* ((map (cond 107 (let* ((map (cond
111 ((keymapp menu) menu) 108 ((keymapp menu) menu)
@@ -114,18 +111,8 @@ PREFIX is the prefix argument (if any) to pass to the command."
114 (filter (when (symbolp map) 111 (filter (when (symbolp map)
115 (plist-get (get map 'menu-prop) :filter)))) 112 (plist-get (get map 'menu-prop) :filter))))
116 (if filter (funcall filter (symbol-function map)) map))))) 113 (if filter (funcall filter (symbol-function map)) map)))))
117 event cmd) 114 event cmd
118 (setq position 115 (position (popup-menu-normalize-position position)))
119 (cond
120 ((eq position 'point)
121 (let* ((pp (posn-at-point))
122 (xy (posn-x-y pp)))
123 (list (list (car xy) (cdr xy)) (posn-window pp))))
124 ((not position)
125 (let ((mp (mouse-pixel-position)))
126 (list (list (cadr mp) (cddr mp)) (car mp))))
127 (t
128 position)))
129 ;; The looping behavior was taken from lmenu's popup-menu-popup 116 ;; The looping behavior was taken from lmenu's popup-menu-popup
130 (while (and map (setq event 117 (while (and map (setq event
131 ;; map could be a prefix key, in which case 118 ;; 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."
163 ;; mouse-major-mode-menu was using `command-execute' instead. 150 ;; mouse-major-mode-menu was using `command-execute' instead.
164 (call-interactively cmd)))) 151 (call-interactively cmd))))
165 152
153(defun popup-menu-normalize-position (position)
154 "Converts the POSITION to the form which `popup-menu' expects internally.
155POSITION can be nil, an click event, a posn- value, or a value having
156form ((XOFFSET YOFFSET) WINDOW).
157If nil, the current mouse position is used.
158If an click event, the value returend from `event-end' is used."
159 (pcase position
160 ;; nil -> mouse cursor position
161 ;; this pattern must be before `eventp' because
162 ;; nil is an event.
163 (`nil
164 (let ((mp (mouse-pixel-position)))
165 (list (list (cadr mp) (cddr mp)) (car mp))))
166 ;; value returned from (event-end (read-event)) or (posn-at-point)
167 ((or `(,window ,area-or-pos (,x . ,y)
168 ,timestamp ,object ,pos (,col . ,row)
169 ,image (,dx . ,dy) (,width . ,height))
170 `(,window ,pos (0 . 0) 0))
171 (let ((xy (posn-x-y position)))
172 (list (list (car xy) (cdr xy))
173 (posn-window position))))
174 ;; pattern expected by popup-menu
175 (`((,xoffset ,yoffset) ,window)
176 position)
177 ;; event
178 ((pred eventp)
179 (popup-menu-normalize-position (event-end position)))
180 ;; rejects
181 (t
182 (error "Unexpected position form"))))
183
166(defun minor-mode-menu-from-indicator (indicator) 184(defun minor-mode-menu-from-indicator (indicator)
167 "Show menu for minor mode specified by INDICATOR. 185 "Show menu for minor mode specified by INDICATOR.
168Interactively, INDICATOR is read using completion. 186Interactively, INDICATOR is read using completion.
diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el
index fb7389b856c..3f58614eb64 100644
--- a/lisp/term/x-win.el
+++ b/lisp/term/x-win.el
@@ -1316,7 +1316,7 @@ Request data types in the order specified by `x-select-request-type'."
1316 (popup-menu (mouse-menu-bar-map) 1316 (popup-menu (mouse-menu-bar-map)
1317 (if (listp last-nonmenu-event) 1317 (if (listp last-nonmenu-event)
1318 nil 1318 nil
1319 'point))))) 1319 (posn-at-point))))))
1320 1320
1321 1321
1322;;; Window system initialization. 1322;;; Window system initialization.