Emacs Init: Define Command for Mouse Click
Define a Command Act on Mouse Clicked Point
To make the command act on mouse clicked point, you need to write a wrapper command that sets the position, then call the command you want.
For example, suppose the command you want is describe-char on clicked point.
You write a wrapper, like this:
(defun xah-click-describe-char (Click) "Mouse click to `describe-char' at clicked point. URL `http://xahlee.info/emacs/emacs/emacs_mouse_wheel_config.html' Version: 2016-07-18" (interactive "e") (let ((xp (posn-point (event-start Click)))) (goto-char xp) (describe-char xp))) ;; make right button show char info on clicked point (global-set-key (kbd "<mouse-3>") 'xah-describe-char-on-click)
Define a Command for Cursor Point
When you bind a mouse button to a command, the command acts on the current cursor position, not clicked point.
;; make right button show char info (of current cursor position, not clicked point) (global-set-key (kbd "<mouse-3>") 'describe-char)