Someone at comp.lang.lisp recently praised the "mouse copy" command
available in the IDE of some proprietary Lisp implementations at also
in Genera.

Although I'm not the "mouse kind of person", I thought such a command
could be occasionally useful and implemented it for GNU Emacs.  Here
it is, although not thoroughly tested:

(defun mouse-insert-sexp-at-point (start-event)
  "Insert the sexp under the mouse cursor at point.
This command  must be bound to a mouse event."
  (interactive "*e")
  (let ((posn (event-start start-event)))
    (let ((sexp-at-mouse-pos
           (with-selected-window (posn-window posn)
             (save-excursion
               (goto-char (posn-point posn))
               (thing-at-point 'sexp)))))
      (if sexp-at-mouse-pos
          (insert sexp-at-mouse-pos)
        (error "Mouse not at a sexp")))))

;; (global-set-key (vector 'S-mouse-3) 'mouse-insert-sexp-at-point)

-- 
Emílio C. Lopes
Munich, Germany
_______________________________________________
gnu-emacs-sources mailing list
gnu-emacs-sources@gnu.org
http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources

Reply via email to