From: Chetan <Chetan.xspam@xspam.sbcglobal.net>
To: help-gnu-emacs@gnu.org
Subject: Re: (insert ...) won't respect delete-selection-mode
Date: Tue, 07 Oct 2008 14:08:09 -0700 [thread overview]
Message-ID: <uwsgk6rly.fsf@myhost.sbcglobal.net> (raw)
In-Reply-To: mailman.495.1223409434.25473.help-gnu-emacs@gnu.org
"Drew Adams" <drew.adams@oracle.com> writes:
>> i have a some 20 personal commands that insert some text. However, i
>> have delete-selection-mode on, meaning that when a region is active,
>> any typing should delete/override it.
>>
>> But when calling my insert text commands it will just insert at the
>> end of region. Here's a example:
>> (defun insert-date () "Insert current date." (interactive)
>> (insert (format-time-string "%Y-%m-%d")))
>>
>> Do i need to modify each commands to check on mark-active and delete-
>> selection-mode then call delete region first? Or, is there some
>> variable i can just set?
>
> See the Commentary at the beginning of `delsel.el':
>
> ;; Commands that delete the selection need a `delete-selection'
> ;; property on their symbols. Commands that insert text but do not
> ;; have this property do not delete the selection. The property can
> ;; be one of these values:
> ;; 'yank
> ;; For commands which do a yank; ensures the region about to be
> ;; deleted isn't yanked.
> ;; 'supersede
> ;; Delete the active region and ignore the current command,
> ;; i.e. the command will just delete the region.
> ;; 'kill
> ;; `kill-region' is used on the selection, rather than
> ;; `delete-region'. (Text selected with the mouse will typically
> ;; be yankable anyhow.)
> ;; non-nil
> ;; The normal case: delete the active region prior to executing
> ;; the command which will insert replacement text.
>
> Example:
>
> (put 'insert-date 'delete-selection t)
The command also needs to be activated with keyboard. M-x does not
do it.
Chetan
next prev parent reply other threads:[~2008-10-07 21:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-07 19:11 (insert ...) won't respect delete-selection-mode Xah
2008-10-07 19:57 ` Drew Adams
[not found] ` <mailman.495.1223409434.25473.help-gnu-emacs@gnu.org>
2008-10-07 21:08 ` Chetan [this message]
2008-10-08 7:20 ` Xah
2008-10-08 10:04 ` Andreas Politz
2008-10-08 16:48 ` Xah
2008-10-08 21:09 ` Andreas Politz
2008-10-08 21:46 ` Lennart Borgman (gmail)
[not found] ` <mailman.621.1223502455.25473.help-gnu-emacs@gnu.org>
2008-10-09 21:27 ` Xah
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=uwsgk6rly.fsf@myhost.sbcglobal.net \
--to=chetan.xspam@xspam.sbcglobal.net \
--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.
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).