Thank you, David, for this fix. I was hoping there would be a more elegant
solution to getting the position of point than moving the mouse
programmatically to point. However, I am sure that if there had been one,
you would have found it so I'll include your fix in the next release. 

- Paul


At 06:52 PM 3/19/01 +0100, David Ponce wrote:
>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)))

Reply via email to