From: "Drew Adams" <drew.adams@oracle.com>
To: "'Xah'" <xahlee@gmail.com>, <help-gnu-emacs@gnu.org>
Subject: RE: (insert ...) won't respect delete-selection-mode
Date: Tue, 7 Oct 2008 12:57:06 -0700 [thread overview]
Message-ID: <000601c928b6$e04a62a0$0200a8c0@us.oracle.com> (raw)
In-Reply-To: <cc880a3e-121e-412a-8073-41d2977c1927@b38g2000prf.googlegroups.com>
> 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)
next prev parent reply other threads:[~2008-10-07 19:57 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 [this message]
[not found] ` <mailman.495.1223409434.25473.help-gnu-emacs@gnu.org>
2008-10-07 21:08 ` Chetan
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='000601c928b6$e04a62a0$0200a8c0@us.oracle.com' \
--to=drew.adams@oracle.com \
--cc=help-gnu-emacs@gnu.org \
--cc=xahlee@gmail.com \
/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).