0

How can I return back to point position after jumping by <down-mouse-1>?

Example: moving in the buffer for a while with C-pbfn, then use mouse for navigation, and press C-u C-<space> trying to return back, but last point not in mark-ring.

  • By C-pbfn I mean navigation via keyboard. And by <down-mouse-1> – mouse clicking. So when I reposition cursor by mouse, I want to be able to jump back where it was by C-u C-<space>, how I usually do while navigating via keyboard. Thank you. – Netsu Oct 20 '17 at 15:37
  • You mean clicking mouse-1, I guess. That does not set the mark. Are you asking how to make it set the mark? If so, that's easy to do, but if you use the mouse at all besides just clicking mouse-1 then that will interfere with what it normally does. Normally, mouse-1 sets point, not the mark. That lets you drag the mouse to select text or use mouse-3 to select text or double- or triple-click mouse-1 to select text. Better be sure of what you want first. ;-) Have you tried clicking mouse-1 followed by immediately clicking mouse-3? Does have the effect you're looking for? – Drew Oct 20 '17 at 20:34
  • Yes, put mark (without activating region, unless it activated explicitly) AND THAN set the new point. Thank you! – Netsu Oct 20 '17 at 20:52
1
(defun my-mouse-1 (event)
  "..."
  (interactive "e")
  (mouse-set-point event)
  (push-mark))

(global-set-key (kbd "<mouse-1>") 'my-mouse-1)

(Not that I really recommend doing this. You won't be able to take advantage of double and triple clicking mouse-1.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.