Vladimir Sedach

Have Emacs - Will Hack

January 16, 2011

Mouse-copy for GNU Emacs

Topic: Emacs

Zmacs, Macintosh Common Lisp's FRED, and the Lispworks editor all contain a very nice time-saving feature absent from GNU Emacs called mouse-copy. Rainer Joswig wrote a good description of mouse-copy; in brief it can be summarized as "hold down Ctrl and click on an s-exp to copy it to the current point." This works when copying across windows as well.

I first found out about mouse copy from working with Jedi, the JazzScheme IDE, and ever since I have wanted it for my GNU Emacs setup.

Michael Weber's redshank extensions to Paredit/SLIME include mouse-copy, but it only works in Paredit mode buffers.

Fortunately there is a simple way to get generic mouse-copy in GNU Emacs. Unfortunately it does not do the right thing when it comes to spaces. This is easy to fix by borrowing a couple of lines from redshank. This is the mouse-copy I use right now, and it seems to work pretty well.

As you might suspect there are more time-saving things you can do with the mouse. For example, in redshank M-S-mouse-1 generates a skeleton for a make-instance when you click on a defclass definition. Looking at TI Explorer ZWEI sources, Lisp Machines had an entire modifier-key-and-mouse-button-chord convention that really made s-exp manipulation easy and direct. It would be nice to have something like that for GNU Emacs.

If you have tips on better ways of using GNU Emacs for editing Lisp, consider sharing them on the CLiki Emacs tips page.