* (insert ...) won't respect delete-selection-mode
@ 2008-10-07 19:11 Xah
2008-10-07 19:57 ` Drew Adams
[not found] ` <mailman.495.1223409434.25473.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 9+ messages in thread
From: Xah @ 2008-10-07 19:11 UTC (permalink / raw
To: help-gnu-emacs
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?
Thanks.
Xah
∑ http://xahlee.org/
☄
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: (insert ...) won't respect delete-selection-mode
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>
1 sibling, 0 replies; 9+ messages in thread
From: Drew Adams @ 2008-10-07 19:57 UTC (permalink / raw
To: 'Xah', help-gnu-emacs
> 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)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: (insert ...) won't respect delete-selection-mode
[not found] ` <mailman.495.1223409434.25473.help-gnu-emacs@gnu.org>
@ 2008-10-07 21:08 ` Chetan
2008-10-08 7:20 ` Xah
0 siblings, 1 reply; 9+ messages in thread
From: Chetan @ 2008-10-07 21:08 UTC (permalink / raw
To: help-gnu-emacs
"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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: (insert ...) won't respect delete-selection-mode
2008-10-07 21:08 ` Chetan
@ 2008-10-08 7:20 ` Xah
2008-10-08 10:04 ` Andreas Politz
0 siblings, 1 reply; 9+ messages in thread
From: Xah @ 2008-10-08 7:20 UTC (permalink / raw
To: help-gnu-emacs
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/
☄
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: (insert ...) won't respect delete-selection-mode
2008-10-08 7:20 ` Xah
@ 2008-10-08 10:04 ` Andreas Politz
2008-10-08 16:48 ` Xah
0 siblings, 1 reply; 9+ messages in thread
From: Andreas Politz @ 2008-10-08 10:04 UTC (permalink / raw
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: (insert ...) won't respect delete-selection-mode
2008-10-08 10:04 ` Andreas Politz
@ 2008-10-08 16:48 ` Xah
2008-10-08 21:09 ` Andreas Politz
0 siblings, 1 reply; 9+ messages in thread
From: Xah @ 2008-10-08 16:48 UTC (permalink / raw
To: help-gnu-emacs
On Oct 8, 3:04 am, Andreas Politz <poli...@fh-trier.de> wrote:
> Xahwrote:
> > 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)
LOL. When i tried this, it'll just delete the region when you do M-x,
regardless what command you gonna call.
for a moment i was gonna say Thanks! Great solution!
Xah
∑ http://xahlee.org/
☄
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: (insert ...) won't respect delete-selection-mode
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>
0 siblings, 2 replies; 9+ messages in thread
From: Andreas Politz @ 2008-10-08 21:09 UTC (permalink / raw
To: help-gnu-emacs
Xah wrote:
> On Oct 8, 3:04 am, Andreas Politz <poli...@fh-trier.de> wrote:
>> Xahwrote:
>>> 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)
>
> LOL. When i tried this, it'll just delete the region when you do M-x,
> regardless what command you gonna call.
>
> for a moment i was gonna say Thanks! Great solution!
>
> Xah
> ∑ http://xahlee.org/
>
> ☄
>
Yes, but you get the idea.
-ap
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: (insert ...) won't respect delete-selection-mode
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>
1 sibling, 0 replies; 9+ messages in thread
From: Lennart Borgman (gmail) @ 2008-10-08 21:46 UTC (permalink / raw
Cc: help-gnu-emacs
>>>>>> 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)
>>
>> LOL. When i tried this, it'll just delete the region when you do M-x,
>> regardless what command you gonna call.
>>
>> for a moment i was gonna say Thanks! Great solution!
>>
>> Xah
>> ∑ http://xahlee.org/
>>
>> ☄
>>
>
> Yes, but you get the idea.
Doesn't this look like a delicate problem? Maybe a bug?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: (insert ...) won't respect delete-selection-mode
[not found] ` <mailman.621.1223502455.25473.help-gnu-emacs@gnu.org>
@ 2008-10-09 21:27 ` Xah
0 siblings, 0 replies; 9+ messages in thread
From: Xah @ 2008-10-09 21:27 UTC (permalink / raw
To: help-gnu-emacs
In this thread:
«(insert ...) won't respect delete-selection-mode Options»
«(put 'insert-date 'delete-selection t)»
«The command also needs to be activated with keyboard. M-x does not do
it.»
«Doesn't this look like a delicate problem? Maybe a bug?»
I reported this to FSF.
http://groups.google.com/group/gnu.emacs.bug/browse_frm/thread/ba8ab4a5223591b7
Richard M Stallman wrote:
«It's intentional. This feature implements expectations that users
have for single-character editing operations in other editors, where
those commands don't have names and there's nothing like M-x. So
there's no reason why M-x should delete the region. It is better for
M-x just to call the function.»
Xah Lee wrote:
«Interesting point.
For elisp programers who wish to write extentions where the command's
behaviors change depending on whether user has delete-selection-mode
on, what should they do? Check for mark-active and delete-selection-
mode before any call to the insert function?
also, the current behavior seems to introduce a complexity, where
command behaves differently depending on whether it is invoked by a
keybinding or by M-x.
»
Richard wrote:
«If you really want to make behavior depend on those variables, you
need to check them. Whether you check them before or after calling
`insert' is up to you.
But that seems like a strange thing to do.»
Doh! I failed humanity.
Xah
∑ http://xahlee.org/
☄
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-10-09 21:27 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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.