;; author: Guillaume Germain (defun meta-paste (event) "Paste the sexp at mouse click position to the current cursor position, inserting the sexp if on whitespace or else replacing the current sexp." (interactive "e") (save-excursion (mouse-set-point event) (mark-sexp) (kill-ring-save (point) (mark))) (cond ((not (or (looking-at "\\s-") (eolp) (looking-at "[)]"))) (mark-sexp) (kill-region (point) (mark)) (yank 2)) (t (forward-char -1) (cond ((not (or (looking-at "\\s-") (eolp))) (forward-char 1) (insert " ")) (forward-char)) (yank 1)))) (global-set-key (kbd "M-S-") 'meta-paste)