help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: can a command specify overwrite selection behavior?


From: Drew Adams
Subject: RE: can a command specify overwrite selection behavior?
Date: Fri, 10 Dec 2010 15:37:10 -0800

> > i have this code that inserts date.
> >
> > (defun insert-date ()
> >   "Insert current date."
> >   (interactive)
> >   (insert (format-time-string "%Y-%m-%d")))
> >
> > (put 'insert-date 'delete-selection t)
> >
> > the last line is to make sure that if i have a text selection, just
> > overwrite it. but it doesn't work.

Actually, it does work, Xah.

If you just try `M-x insert-date' then you won't see that it works.  That's true
also of any other command with a `delete-selection' property.  That has to do
with the region being deactivated when you exit the minibuffer.

To see that it works, bind it to a key and then use the key:
(global-set-key [insert] 'insert-date)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]