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: Xah Lee
Subject: Re: can a command specify overwrite selection behavior?
Date: Sun, 12 Dec 2010 07:16:00 -0800 (PST)
User-agent: G2/1.0

On Dec 10, 3:37 pm, "Drew Adams" <drew.ad...@oracle.com> wrote:
> > > 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)

thanks Drew for this tip. I didn't know about it.

btw, why the distinction on how the command is called?

all i recall about this issue is that i entered a bug report and
Richard Stallman specifically don't consider it a bug.

 Xah


reply via email to

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