all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Xah Lee <xahlee@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: can a command specify overwrite selection behavior?
Date: Wed, 1 Sep 2010 01:11:51 -0700 (PDT)	[thread overview]
Message-ID: <05a87fbb-31a7-40c3-a890-6c7aacaefac3@t5g2000prd.googlegroups.com> (raw)
In-Reply-To: 33ac6984-0a0c-4db8-8ea1-50ec5c271a25@x18g2000pro.googlegroups.com

On Aug 31, 10:33 pm, Xah Lee <xah...@gmail.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.
> ...

work around:

(defun insert-date ()
  "Insert current date."
  (interactive)
  (when (region-active-p)
    (delete-region (region-beginning) (region-end) )
    )
  (insert (format-time-string "%Y-%m-%d"))
  )


  reply	other threads:[~2010-09-01  8:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-01  5:33 can a command specify overwrite selection behavior? Xah Lee
2010-09-01  8:11 ` Xah Lee [this message]
2010-12-10 23:37   ` Drew Adams
     [not found]   ` <mailman.4.1292024249.16140.help-gnu-emacs@gnu.org>
2010-12-12 15:16     ` Xah Lee
2010-12-13 17:16       ` Drew Adams
     [not found]       ` <mailman.1.1292262212.1009.help-gnu-emacs@gnu.org>
2010-12-22 14:49         ` Xah Lee
2010-12-22 17:12           ` Drew Adams
     [not found]           ` <mailman.0.1293037975.895.help-gnu-emacs@gnu.org>
2010-12-23  2:33             ` Xah Lee
2010-12-25  0:17             ` Ilya Zakharevich
2010-12-25 17:00               ` Drew Adams
     [not found]               ` <mailman.8.1293296501.5624.help-gnu-emacs@gnu.org>
2010-12-25 18:54                 ` Ilya Zakharevich
2010-12-26  0:32                   ` Drew Adams
2010-12-26  2:20                 ` Xah Lee
2010-12-26 16:19                   ` Drew Adams
2010-12-28  2:46                 ` Stefan Monnier
2010-12-28  5:34                   ` Drew Adams
2010-12-28 14:18                     ` Stefan Monnier

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=05a87fbb-31a7-40c3-a890-6c7aacaefac3@t5g2000prd.googlegroups.com \
    --to=xahlee@gmail.com \
    --cc=help-gnu-emacs@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.