gnu-emacs-sources
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mouse-insert-sexp-at-point


From: Emilio Lopes
Subject: mouse-insert-sexp-at-point
Date: Sun, 28 May 2006 23:00:04 +0200
User-agent: Emacs Gnus

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]