[MSLUG] 'meta-paste', take 2

Guillaume Germain germaing at iro.umontreal.ca
Thu Aug 19 17:09:19 EDT 2004


Hello again,

Stefan Monnier has sent me a much cleaner version of 'meta-paste' that 
I've attached to this e-mail.

Guillaume
-------------- next part --------------
;; author: Stefan Monnier <monnier at iro.umontreal.ca>
(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-selected-window
    (save-excursion
      (mouse-set-point event)
      (mark-sexp)
      (kill-ring-save (region-beginning) (region-end))))
  (cond
   ((not (memq (char-after) '(?\  ?\n ?\) nil)))
    (delete-region (point) 
		   (progn 
		     (forward-sexp 1) 
		     (point))))
   ((not (memq (char-before) '(?\  ?\n ?\( nil)))
    (insert " ")))
  (yank 1))


More information about the MSLUG mailing list