From: "Drew Adams" <drew.adams@oracle.com>
To: <emacs-devel@gnu.org>
Subject: `mouse-save-then-kill' changes
Date: Fri, 5 Nov 2010 10:49:37 -0700 [thread overview]
Message-ID: <59B673DED28140FEBB895891578B6202@us.oracle.com> (raw)
`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.)
next reply other threads:[~2010-11-05 17:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-05 17:49 Drew Adams [this message]
2010-11-07 19:01 ` `mouse-save-then-kill' changes Stefan Monnier
2010-11-07 20:36 ` Drew Adams
2010-11-08 3:38 ` Stefan Monnier
2010-11-08 4:42 ` Drew Adams
2010-11-08 9:11 ` tomas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=59B673DED28140FEBB895891578B6202@us.oracle.com \
--to=drew.adams@oracle.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.