Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. (defun jump-to-cursor ()
  2. "Jump to the position under the mouse cursor if possible."
  3. (interactive)
  4. (when-let ((cursor-pos (mouse-position))
  5. (line (cddr cursor-pos))
  6. (col (cadr cursor-pos))
  7. (p (save-excursion
  8. (goto-char (window-start))
  9. (forward-line line)
  10. (if (> (- (line-end-position) (line-beginning-position)) col)
  11. (progn (move-to-column col) (1- (point)))
  12. nil))))
  13. (goto-char p)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement