How to generate a mouse event programmatically?

There are two very useful features in SLIME: slime-copy-or-inspect-presentation-at-mouseand slime-presentation-menu. But they must be called with an event argument. In order to generate even I would need a lot of logistics (calculating the area occupied by the printed representation of the object that the mouse points to, the rows and columns are something that I really do not want to do because, of course, there is something in Emacs- something that already computes all of this.

So, is there an easy way to generate a "fake" mouse event? Because using the mouse for only two things in the editor, which otherwise does not require a mouse, feels ... well, not very smart. :)

EDIT

Here is what I tried:

(define-key lisp-mode-map (kbd "C-x ?")
  #'(lambda ()
      (interactive)
      (message "called")
      (slime-copy-or-inspect-presentation-at-mouse
       `(mouse-2 ;; button
     (,(selected-window) ;; window
      ,(point) ;; position
      (0 . 0) ;; window-relative pixel
      0 ;; timestamp
      nil ;; object
      ,(point) ;; text position 
      (,(current-column) . ;; column
       ,(line-number-at-pos (point))) ;; line
      nil ;; image
      (0 . 0) ;; object-relative pixel
      (1 . 1))))))
(define-key lisp-mode-map (kbd "C-x SPC")
  #'(lambda ()
      (interactive)
      (message "called")
      (slime-presentation-menu
       `(mouse-3 ;; button
     (,(selected-window) ;; window
      ,(point) ;; position
      (0 . 0) ;; window-relative pixel
      0 ;; timestamp
      nil ;; object
      ,(point) ;; text position 
      (,(current-column) . ;; column
       ,(line-number-at-pos (point))) ;; line
      nil ;; image
      (0 . 0) ;; object-relative pixel
      (1 . 1))))))

, , slime-presentation-menu , , - , "" , .: (

EDIT2

, - x-popup-menu, , ... arrrrrgh.

+5
2

, , . , , , , .. . 21.7.4 "" "Elisp" .

, :

(mwheel-scroll `(mouse-5 ;; button
                 (,(selected-window) ;; window
                  ,(point) ;; position
                  (0 . 0) ;; window-relative pixel
                  0 ;; timestamp
                  nil ;; object
                  ,(point) ;; text position 
                  (,(current-column) . ;; column
                   ,(line-number-at-pos (point))) ;; line
                  nil ;; image
                  (0 . 0) ;; object-relative pixel
                  (1 . 1)))) ;; object size

:

'(mouse-4
  (#<window 374 on *scratch*>
   120
   (6 . 10)
   1301935153
   nil
   120
   (0 . 0)
   nil
   (6 . 10)
   (7 . 15)))
+4

posn-at-point . :

(defun my/test-posn (e)
  (interactive "e")
  (message "%S\n%S" e `(down-mouse-3 ,(posn-at-point))))

(global-set-key [down-mouse-3] #'my/test-posn)

:

(down-mouse-3 (#<window 73 on blah> 3152 (0 . 594) 145393072 nil 3152 (0 . 33) nil (1 . 4) (8 . 18)))
(down-mouse-3 (#<window 73 on blah> 3152 (0 . 594) 0         nil 3152 (0 . 33) nil (0 . 0) (8 . 18)))
0

All Articles