[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (insert ...) won't respect delete-selection-mode
From: |
Xah |
Subject: |
Re: (insert ...) won't respect delete-selection-mode |
Date: |
Wed, 8 Oct 2008 00:20:03 -0700 (PDT) |
User-agent: |
G2/1.0 |
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/
☄
- (insert ...) won't respect delete-selection-mode, Xah, 2008/10/07
- RE: (insert ...) won't respect delete-selection-mode, Drew Adams, 2008/10/07
- Message not available
- Re: (insert ...) won't respect delete-selection-mode, Chetan, 2008/10/07
- Re: (insert ...) won't respect delete-selection-mode,
Xah <=
- Re: (insert ...) won't respect delete-selection-mode, Andreas Politz, 2008/10/08
- Re: (insert ...) won't respect delete-selection-mode, Xah, 2008/10/08
- Re: (insert ...) won't respect delete-selection-mode, Andreas Politz, 2008/10/08
- Re: (insert ...) won't respect delete-selection-mode, Lennart Borgman (gmail), 2008/10/08
- Message not available
- Re: (insert ...) won't respect delete-selection-mode, Xah, 2008/10/09