I looked at coding up mouse commands myself but just out of curiosity and gave up without even trying. But I am sure it would be doable.
It is very easy to do. Just bind mouse events like any other key chord.
down-mouse-1
mouse-1
-2 for middle and -3 for left button.
You can of course combine it with modifiers: C-M-mouse-1 = Control Meta left button click.
(local-set-key (kbd "C-M-<mouse-1>") (lambda () (interactive) (insert "Mice!")))
--
__Pascal J. Bourguignon__