aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorEli Zaretskii <[email protected]>2006-11-25 13:29:40 +0000
committerEli Zaretskii <[email protected]>2006-11-25 13:29:40 +0000
commit1d9a4930a5c2f414350a4e63a9a48f291bf7dc92 (patch)
treea8d8beef5933dd11a76dae3d8bbe132851f110c7 /lisp
parentd86b05e72dc438e69d40653bdd2ae6be4ce47a92 (diff)
(flymake-posn-at-point-as-event): New function.
(flymake-popup-menu): Use it instead of posn-at-point.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/progmodes/flymake.el30
2 files changed, 33 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index dcd12fcafb..2bd937a4ac 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2006-11-25 Pavel Kobiakov <[email protected]>
+
+ * progmodes/flymake.el (flymake-posn-at-point-as-event): New
+ function.
+ (flymake-popup-menu): Use it instead of posn-at-point.
+
2006-11-25 Jan Dj,Ad(Brv <[email protected]>
* progmodes/cc-vars.el (c-backslash-column): Mention
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index b37be18188..9f5031b0e6 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -2,8 +2,8 @@
;; Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation
-;; Author: Pavel Kobiakov <[email protected]>
-;; Maintainer: Pavel Kobiakov <[email protected]>
+;; Author: Pavel Kobyakov <[email protected]>
+;; Maintainer: Pavel Kobyakov <[email protected]>
;; Version: 0.3
;; Keywords: c languages tools
@@ -117,6 +117,30 @@ Zero-length substrings at the beginning and end of the list are omitted."
'line-end-position
(lambda (&optional arg) (save-excursion (end-of-line arg) (point)))))
+(defun flymake-posn-at-point-as-event (&optional position window dx dy)
+ "Return pixel position of top left corner of glyph at POSITION,
+relative to top left corner of WINDOW, as a mouse-1 click
+event (identical to the event that would be triggered by clicking
+mouse button 1 at the top left corner of the glyph).
+
+POSITION and WINDOW default to the position of point in the
+selected window.
+
+DX and DY specify optional offsets from the top left of the glyph."
+ (unless window (setq window (selected-window)))
+ (unless position (setq position (window-point window)))
+ (unless dx (setq dx 0))
+ (unless dy (setq dy 0))
+
+ (let* ((pos (posn-at-point position window))
+ (x-y (posn-x-y pos))
+ (edges (window-inside-pixel-edges window))
+ (win-x-y (window-pixel-edges window)))
+ ;; adjust for window edges
+ (setcar (nthcdr 2 pos)
+ (cons (+ (car x-y) (car edges) (- (car win-x-y)) dx)
+ (+ (cdr x-y) (cadr edges) (- (cadr win-x-y)) dy)))
+ (list 'mouse-1 pos)))
(defun flymake-popup-menu (menu-data)
"Pop up the flymake menu at point, using the data MENU-DATA.
@@ -134,7 +158,7 @@ MENU-DATA is a list of error and warning messages returned by
(popup-menu (flymake-make-xemacs-menu menu-data)
(make-event 'button-press fake-event-props)))
(x-popup-menu (if (eval-when-compile (fboundp 'posn-at-point))
- (posn-at-point)
+ (flymake-posn-at-point-as-event)
(list (flymake-get-point-pixel-pos) (selected-window)))
(flymake-make-emacs-menu menu-data))))