I use GNU emacs-24.
I make button like this:
(defun go-click (button)
(print (button-get button 'point))
(let ((win (get-buffer-window (button-get button 'buffer))))
(if win
(progn
(select-window win)
(goto-char (button-get button 'point)))
(message "open a window with the location"))))
(let ((p (point)) (buf (current-buffer)))
(with-current-buffer (get-buffer "yyy")
(insert-button "go" 'action #'go-click
'follow-link t
'point p
'buffer buf)))
I have this code in *scratch* buffer in onw window and another window with bufffer yyy. I eval-current-buffer while the point is, say on #’go-click position. And the button go in yyy appears.
If I now click on the button, it prints the number, as expected, makes *scratch* active, as supposed, but doesn’t move the point on #’go-click position.
But if I position point on the go button by cursor keys, and hit enter, it works as expected (moves point to #’go-click positoin, no matter, where I left it in *scratch* previously) .
How to make it work for both keyboard-enter and mouse-click scenario?
Here is the little patch: