[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
`mouse-save-then-kill' changes
From: |
Drew Adams |
Subject: |
`mouse-save-then-kill' changes |
Date: |
Fri, 5 Nov 2010 10:49:37 -0700 |
`mouse-save-then-kill' has been changed quite a bit for Emacs 24.
I'm trying to adjust my code to the changes.
Until now, it called `mouse-save-then-kill-delete-region' to kill/delete the
text when you click the same spot. (`mouse-secondary-save-then-kill' still does
this.)
This made it possible to simply flet-bind `mouse-save-then-kill-delete-region'
in order to get an alternative behavior to the killing/deleting part.
In my case, in *Completions* I flet-bind it to a command `foobar' that picks up
the selected candidates and saves them to a list for special processing. That
is, in *Completions* I bind `mouse-3' to a command that does this:
(defun foo (&optional arg)
(interactive "e\nP")
(flet ((mouse-save-then-kill-delete-region (beg end)
(foobar nil arg)))
(mouse-save-then-kill click))
(setq this-command 'mouse-save-then-kill))
Now (Emacs 24) I have to (a) duplicate all of the code of
`mouse-save-then-kill', (b) replace the 3 lines that delete or kill the region
by a call to `foobar', and (c) change references to `mouse-save-then-kill'
within the new command to the new command name - e.g. places where the code
checks `(eq last-command 'mouse-save-then-kill)'.
That's quite ugly, for something that used to be simple. Any chance of your
moving the 3 kill/delete lines out of `mouse-save-then-kill' into a function,
like this?
(defun mouse-kill/delete-region (pt)
"Kill or delete region, according to `mouse-drag-copy-region'."
(if mouse-drag-copy-region
(delete-region (mark t) (point))
(kill-region (mark t) (point))))
(You cannot name this function `mouse-save-then-kill-delete-region' since that
function still exists and is used for the secondary selection.)
- `mouse-save-then-kill' changes,
Drew Adams <=