unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* `mouse-save-then-kill' changes
@ 2010-11-05 17:49 Drew Adams
  2010-11-07 19:01 ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Drew Adams @ 2010-11-05 17:49 UTC (permalink / raw)
  To: emacs-devel

`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.)




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-11-08  9:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-05 17:49 `mouse-save-then-kill' changes Drew Adams
2010-11-07 19:01 ` 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

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).