Hello All,
Following is an improved version of latest JDE's function
`jde-cursor-posn-as-event'.
This function converts the cursor position (point) into an event so the
completion menu can pop up at point.
This implementation works in XEmacs too :-) and also move the mouse to
the cursor position, that is to the popup menu :-)
Any feedback will be welcome.
Sincerely,
David
(defun jde-cursor-posn-as-event()
"Returns the text cursor position as an event.
Also move the mouse pointer to the cursor position."
(let* ((w (get-buffer-window (current-buffer)))
(x (mod (- (current-column) (window-hscroll))
(window-width)))
(y (save-excursion
(save-restriction
(widen)
(narrow-to-region (window-start) (point))
(goto-char (point-min))
(1+ (vertical-motion (buffer-size))))))
)
(if (featurep 'xemacs)
(let* ((at (progn (set-mouse-position w x (1- y))
(cdr (mouse-pixel-position))))
(x (car at))
(y (cdr at)))
(make-event 'button-press
(list 'button 3
'modifiers nil
'x x
'y y)))
(set-mouse-pixel-position (window-frame w)
(* x (frame-char-width))
(* y (frame-char-height)))
;;(list (list x y) window)
t)))