unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Andreas Politz <politza@fh-trier.de>
To: help-gnu-emacs@gnu.org
Subject: Re: (insert ...) won't respect delete-selection-mode
Date: Wed, 08 Oct 2008 12:04:55 +0200	[thread overview]
Message-ID: <1223460628.620979@arno.fh-trier.de> (raw)
In-Reply-To: <df333b8d-9d5a-4f5c-bb92-e163247e98bc@a18g2000pra.googlegroups.com>

Xah wrote:
> On Oct 7, 2:08 pm, Chetan <Chetan.xs...@xspam.sbcglobal.net> wrote:
>> "Drew Adams" <drew.ad...@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.
> 
> Thank you both.
> 
> Why does it needs to be called from keyboard? Unfortunately most of my
> commands are used by calling a short alias.
> 
>   Xah
> ∑ http://xahlee.org/
> 
> ☄
> 


Because it't a different command.

(put 'execute-extended-command 'delete-selection t)

-ap


  reply	other threads:[~2008-10-08 10:04 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
2008-10-08  7:20     ` Xah
2008-10-08 10:04       ` Andreas Politz [this message]
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=1223460628.620979@arno.fh-trier.de \
    --to=politza@fh-trier.de \
    --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).