[lug] silly emacs

David dajo at frii.com
Sun Aug 12 08:08:07 MDT 2001


> I'm no lisp guru- so silly emacs question. How can I get emacs to NOT 
> automatically copy a selection when I select something with the mouse? I 
> hate that!

I have re-read this thread this morning and now, having looked into it
a little, I understand this original question 8-)  I should hate it
too!

I have looked at the code in mouse.el and it looks as though the
person who wrote it thought that incorporating the copy would be a
really good idea.  Below I describe what you can do to deal with it;
on the face of it, it is a simple (ha ha!) fix.

The code that I posted yesterday may be adequate for you; it does not
prevent the copy, but it removes it when it happens.  If you load that
code as described you should be able to highlight a region with the
mouse, then highlight a second region, then replace the second with
the first by using C-v.

If you want to eliminate the copy you can do it by getting mouse.el
(this is an Emacs lisp file that may be on your machine, I can send
you a copy if you want) and making your own private version.  Then you
load this version from your .emacs and the load will over-write the
standard functionality.  You can byte-compile the file if you feel the
need to do so.

There are three places in the file to change, you can search for them.

    (let (this-command last-command deactivate-mark)
      (copy-region-as-kill (mark) (point)))

    (let (deactivate-mark)
      (copy-region-as-kill (point) (mark t)))

    (let (deactivate-mark)
      (copy-region-as-kill (overlay-start mouse-secondary-overlay)
                           (overlay-end mouse-secondary-overlay)))))

Comment out the first two entirely, modify the third:

;;;    (let (this-command last-command deactivate-mark)
;;;      (copy-region-as-kill (mark) (point)))

;;;    (let (deactivate-mark)
;;;      (copy-region-as-kill (point) (mark t)))

;;;    (let (deactivate-mark)
;;;      (copy-region-as-kill (overlay-start mouse-secondary-overlay)
;;;                           (overlay-end mouse-secondary-overlay)))))
))  ; these terminate other code

Try it, you might like it!

The real solution is to have this code guarded by a User Option.  If
you try the above and it works well, please let me know and I shall
send a bug/suggestion report to FSF.  It is clear to me that your
question is not silly, but there is some silly code design.

dajo



More information about the LUG mailing list