aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2006-11-25 13:29:40 +0000
committerEli Zaretskii2006-11-25 13:29:40 +0000
commit1d9a4930a5c2f414350a4e63a9a48f291bf7dc92 (patch)
treea8d8beef5933dd11a76dae3d8bbe132851f110c7
parentd86b05e72dc438e69d40653bdd2ae6be4ce47a92 (diff)
downloademacs-1d9a4930a5c2f414350a4e63a9a48f291bf7dc92.tar.gz
emacs-1d9a4930a5c2f414350a4e63a9a48f291bf7dc92.zip
(flymake-posn-at-point-as-event): New function.
(flymake-popup-menu): Use it instead of posn-at-point.
-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 dcd12fcafbb..2bd937a4ac9 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12006-11-25 Pavel Kobiakov <pk_at_work@yahoo.com>
2
3 * progmodes/flymake.el (flymake-posn-at-point-as-event): New
4 function.
5 (flymake-popup-menu): Use it instead of posn-at-point.
6
12006-11-25 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> 72006-11-25 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
2 8
3 * progmodes/cc-vars.el (c-backslash-column): Mention 9 * progmodes/cc-vars.el (c-backslash-column): Mention
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index b37be18188c..9f5031b0e63 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -2,8 +2,8 @@
2 2
3;; Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation 3;; Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation
4 4
5;; Author: Pavel Kobiakov <pk_at_work@yahoo.com> 5;; Author: Pavel Kobyakov <pk_at_work@yahoo.com>
6;; Maintainer: Pavel Kobiakov <pk_at_work@yahoo.com> 6;; Maintainer: Pavel Kobyakov <pk_at_work@yahoo.com>
7;; Version: 0.3 7;; Version: 0.3
8;; Keywords: c languages tools 8;; Keywords: c languages tools
9 9
@@ -117,6 +117,30 @@ Zero-length substrings at the beginning and end of the list are omitted."
117 'line-end-position 117 'line-end-position
118 (lambda (&optional arg) (save-excursion (end-of-line arg) (point))))) 118 (lambda (&optional arg) (save-excursion (end-of-line arg) (point)))))
119 119
120(defun flymake-posn-at-point-as-event (&optional position window dx dy)
121 "Return pixel position of top left corner of glyph at POSITION,
122relative to top left corner of WINDOW, as a mouse-1 click
123event (identical to the event that would be triggered by clicking
124mouse button 1 at the top left corner of the glyph).
125
126POSITION and WINDOW default to the position of point in the
127selected window.
128
129DX and DY specify optional offsets from the top left of the glyph."
130 (unless window (setq window (selected-window)))
131 (unless position (setq position (window-point window)))
132 (unless dx (setq dx 0))
133 (unless dy (setq dy 0))
134
135 (let* ((pos (posn-at-point position window))
136 (x-y (posn-x-y pos))
137 (edges (window-inside-pixel-edges window))
138 (win-x-y (window-pixel-edges window)))
139 ;; adjust for window edges
140 (setcar (nthcdr 2 pos)
141 (cons (+ (car x-y) (car edges) (- (car win-x-y)) dx)
142 (+ (cdr x-y) (cadr edges) (- (cadr win-x-y)) dy)))
143 (list 'mouse-1 pos)))
120 144
121(defun flymake-popup-menu (menu-data) 145(defun flymake-popup-menu (menu-data)
122 "Pop up the flymake menu at point, using the data MENU-DATA. 146 "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
134 (popup-menu (flymake-make-xemacs-menu menu-data) 158 (popup-menu (flymake-make-xemacs-menu menu-data)
135 (make-event 'button-press fake-event-props))) 159 (make-event 'button-press fake-event-props)))
136 (x-popup-menu (if (eval-when-compile (fboundp 'posn-at-point)) 160 (x-popup-menu (if (eval-when-compile (fboundp 'posn-at-point))
137 (posn-at-point) 161 (flymake-posn-at-point-as-event)
138 (list (flymake-get-point-pixel-pos) (selected-window))) 162 (list (flymake-get-point-pixel-pos) (selected-window)))
139 (flymake-make-emacs-menu menu-data)))) 163 (flymake-make-emacs-menu menu-data))))
140 164