* Make <delete> save the deleted text into the killing ring
@ 2022-12-13 11:12 aitor
2022-12-14 11:23 ` aitor
` (2 more replies)
0 siblings, 3 replies; 16+ messages in thread
From: aitor @ 2022-12-13 11:12 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
<delete> char is bound to `delete-forward-char` which does not save the
deleted text into the kill ring by default. How can I change this
behavior and make <delete> actually save the killed text into the ring?
--
aitor
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Make <delete> save the deleted text into the killing ring
2022-12-13 11:12 Make <delete> save the deleted text into the killing ring aitor
@ 2022-12-14 11:23 ` aitor
2022-12-14 17:44 ` Emanuel Berg
2022-12-14 20:17 ` Gregory Heytings
2022-12-15 6:14 ` Eli Zaretskii
2 siblings, 1 reply; 16+ messages in thread
From: aitor @ 2022-12-14 11:23 UTC (permalink / raw)
To: help-gnu-emacs
> <delete> char is bound to `delete-forward-char` which does not save the
> deleted text into the kill ring by default. How can I change this
> behavior and make <delete> actually save the killed text into the ring?
So I've tried stuff like:
(global-set-key [delete]
(lambda (n)
(interactive "p")
(delete-forward-char n t)))
but no luck, the deleted does not appear in the kill ring.
best,
aitor
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Make <delete> save the deleted text into the killing ring
2022-12-14 11:23 ` aitor
@ 2022-12-14 17:44 ` Emanuel Berg
2022-12-14 19:52 ` John Haman
0 siblings, 1 reply; 16+ messages in thread
From: Emanuel Berg @ 2022-12-14 17:44 UTC (permalink / raw)
To: help-gnu-emacs
aitor wrote:
>> <delete> char is bound to `delete-forward-char` which does
>> not save the deleted text into the kill ring by default.
>> How can I change this behavior and make <delete> actually
>> save the killed text into the ring?
>
> So I've tried stuff like:
>
> (global-set-key [delete]
> (lambda (n)
> (interactive "p")
> (delete-forward-char n t)))
>
> but no luck, the deleted does not appear in the kill ring.
Is this a good idea? Why?
But if you want it, make a command, i.e. an interactive defun
that does it, when it works, bind it to a key ...
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Make <delete> save the deleted text into the killing ring
2022-12-14 17:44 ` Emanuel Berg
@ 2022-12-14 19:52 ` John Haman
2022-12-14 19:58 ` Emanuel Berg
0 siblings, 1 reply; 16+ messages in thread
From: John Haman @ 2022-12-14 19:52 UTC (permalink / raw)
To: help-gnu-emacs
The function `delete-forward-char' takes an optional argument, killflag.
Maybe OP could use something like
```emacs-lisp
(define-key global-map (kbd "<delete>") #'(lambda ()
(interactive)
(delete-forward-char 1 t)))
```
--
Dr. John Haman
Maryland, USA
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Make <delete> save the deleted text into the killing ring
2022-12-14 19:52 ` John Haman
@ 2022-12-14 19:58 ` Emanuel Berg
0 siblings, 0 replies; 16+ messages in thread
From: Emanuel Berg @ 2022-12-14 19:58 UTC (permalink / raw)
To: help-gnu-emacs
John Haman wrote:
> The function `delete-forward-char' takes an optional
> argument, killflag. Maybe OP could use something like
>
> (define-key global-map (kbd "<delete>") #'(lambda ()
> (interactive)
> (delete-forward-char 1 t)))
Yes, but then you brake the interface, in particular the
N argument which is now hardcoded to 1, so it's better with
a wrapper function which offers a transparent interface - i.e.
the same, except it defaults to t instead for KILLFLAG ...
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Make <delete> save the deleted text into the killing ring
2022-12-13 11:12 Make <delete> save the deleted text into the killing ring aitor
2022-12-14 11:23 ` aitor
@ 2022-12-14 20:17 ` Gregory Heytings
2022-12-14 20:43 ` Emanuel Berg
2022-12-15 8:40 ` aitor
2022-12-15 6:14 ` Eli Zaretskii
2 siblings, 2 replies; 16+ messages in thread
From: Gregory Heytings @ 2022-12-14 20:17 UTC (permalink / raw)
To: aitor; +Cc: help-gnu-emacs
>
> <delete> char is bound to `delete-forward-char` which does not save the
> deleted text into the kill ring by default. How can I change this
> behavior and make <delete> actually save the killed text into the ring?
>
(defun kill-forward-char (n)
(interactive "p")
(let ((delete-active-region 'kill))
(delete-forward-char n t)))
(global-set-key [delete] #'kill-forward-char)
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Make <delete> save the deleted text into the killing ring
2022-12-14 20:17 ` Gregory Heytings
@ 2022-12-14 20:43 ` Emanuel Berg
2022-12-15 8:40 ` aitor
1 sibling, 0 replies; 16+ messages in thread
From: Emanuel Berg @ 2022-12-14 20:43 UTC (permalink / raw)
To: help-gnu-emacs
Gregory Heytings wrote:
>> <delete> char is bound to `delete-forward-char` which does
>> not save the deleted text into the kill ring by default.
>> How can I change this behavior and make <delete> actually
>> save the killed text into the ring?
>
> (defun kill-forward-char (n)
> (interactive "p")
> (let ((delete-active-region 'kill))
> (delete-forward-char n t)))
>
> (global-set-key [delete] #'kill-forward-char)
Yes, correct method 100% ...
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Make <delete> save the deleted text into the killing ring
2022-12-14 20:17 ` Gregory Heytings
2022-12-14 20:43 ` Emanuel Berg
@ 2022-12-15 8:40 ` aitor
2022-12-15 8:48 ` Emanuel Berg
1 sibling, 1 reply; 16+ messages in thread
From: aitor @ 2022-12-15 8:40 UTC (permalink / raw)
To: Gregory Heytings; +Cc: help-gnu-emacs
On Wed, Dec 14, 2022 at 08:17:45PM +0000, Gregory Heytings wrote:
>
> >
> > <delete> char is bound to `delete-forward-char` which does not save the
> > deleted text into the kill ring by default. How can I change this
> > behavior and make <delete> actually save the killed text into the ring?
> >
>
> (defun kill-forward-char (n)
> (interactive "p")
> (let ((delete-active-region 'kill))
> (delete-forward-char n t)))
>
> (global-set-key [delete] #'kill-forward-char)
This works like a charm. Thank you!
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Make <delete> save the deleted text into the killing ring
2022-12-15 8:40 ` aitor
@ 2022-12-15 8:48 ` Emanuel Berg
0 siblings, 0 replies; 16+ messages in thread
From: Emanuel Berg @ 2022-12-15 8:48 UTC (permalink / raw)
To: help-gnu-emacs
aitor wrote:
>>> <delete> char is bound to `delete-forward-char` which does
>>> not save the deleted text into the kill ring by default.
>>> How can I change this behavior and make <delete> actually
>>> save the killed text into the ring?
>>
>> (defun kill-forward-char (n)
>> (interactive "p")
>> (let ((delete-active-region 'kill))
>> (delete-forward-char n t)))
>>
>> (global-set-key [delete] #'kill-forward-char)
>
> This works like a charm. Thank you!
*char
The method ... it's done like that.
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Make <delete> save the deleted text into the killing ring
2022-12-13 11:12 Make <delete> save the deleted text into the killing ring aitor
2022-12-14 11:23 ` aitor
2022-12-14 20:17 ` Gregory Heytings
@ 2022-12-15 6:14 ` Eli Zaretskii
2022-12-15 6:15 ` Emanuel Berg
2022-12-15 8:31 ` aitor
2 siblings, 2 replies; 16+ messages in thread
From: Eli Zaretskii @ 2022-12-15 6:14 UTC (permalink / raw)
To: help-gnu-emacs
> From: aitor <a.soroa@gmail.com>
> Date: Tue, 13 Dec 2022 12:12:15 +0100
>
> <delete> char is bound to `delete-forward-char` which does not save the
> deleted text into the kill ring by default. How can I change this
> behavior and make <delete> actually save the killed text into the ring?
Any reason why you think you need that? Doing so will fill the
kill-ring with meaningless single-character entries. You have 'undo',
which can undelete the deleted text, so why do you want to put every
single character you delete in the kill-ring?
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Make <delete> save the deleted text into the killing ring
2022-12-15 6:14 ` Eli Zaretskii
@ 2022-12-15 6:15 ` Emanuel Berg
2022-12-15 8:31 ` aitor
1 sibling, 0 replies; 16+ messages in thread
From: Emanuel Berg @ 2022-12-15 6:15 UTC (permalink / raw)
To: help-gnu-emacs
Eli Zaretskii wrote:
>> <delete> char is bound to `delete-forward-char` which does
>> not save the deleted text into the kill ring by default.
>> How can I change this behavior and make <delete> actually
>> save the killed text into the ring?
>
> Any reason why you think you need that? Doing so will fill
> the kill-ring with meaningless single-character entries.
> You have 'undo', which can undelete the deleted text, so why
> do you want to put every single character you delete in the
> kill-ring?
So he can verify it's a bad idea ...
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Make <delete> save the deleted text into the killing ring
2022-12-15 6:14 ` Eli Zaretskii
2022-12-15 6:15 ` Emanuel Berg
@ 2022-12-15 8:31 ` aitor
2022-12-15 9:04 ` Eli Zaretskii
1 sibling, 1 reply; 16+ messages in thread
From: aitor @ 2022-12-15 8:31 UTC (permalink / raw)
To: help-gnu-emacs
On Thu, Dec 15, 2022 at 08:14:21AM +0200, Eli Zaretskii wrote:
> > <delete> char is bound to `delete-forward-char` which does not save the
> > deleted text into the kill ring by default. How can I change this
> > behavior and make <delete> actually save the killed text into the ring?
>
> Any reason why you think you need that? Doing so will fill the
> kill-ring with meaningless single-character entries. You have 'undo',
> which can undelete the deleted text, so why do you want to put every
> single character you delete in the kill-ring?
I usually select portions of text using shift+arrow keys, and then
delete them by pressing <delete>. Often, I find myself wanting to yank
the deleted text into another place (using C-y or shift-insert), but as
said 'delete-forward-char' doesn't save it in the kill ring.
I know that I can kill the selected text with C-w instead of <delete>,
thus saving the text into the ring, but my muscle memory is somehow used
to the <delete> key.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Make <delete> save the deleted text into the killing ring
2022-12-15 8:31 ` aitor
@ 2022-12-15 9:04 ` Eli Zaretskii
2022-12-15 10:18 ` Thibaut Verron
0 siblings, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2022-12-15 9:04 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Thu, 15 Dec 2022 09:31:43 +0100
> From: aitor <aitors2005@gmail.com>
>
> > Any reason why you think you need that? Doing so will fill the
> > kill-ring with meaningless single-character entries. You have 'undo',
> > which can undelete the deleted text, so why do you want to put every
> > single character you delete in the kill-ring?
>
> I usually select portions of text using shift+arrow keys, and then
> delete them by pressing <delete>.
Then press "C-u <delete>" instead. That will allow you to control
when the deleted text goes to the kill-ring and when not. Doing that
by default makes little sense, because <delete> is also used to delete
single characters or very short stretches of text.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Make <delete> save the deleted text into the killing ring
2022-12-15 9:04 ` Eli Zaretskii
@ 2022-12-15 10:18 ` Thibaut Verron
2022-12-15 10:24 ` Gregory Heytings
0 siblings, 1 reply; 16+ messages in thread
From: Thibaut Verron @ 2022-12-15 10:18 UTC (permalink / raw)
To: Eli Zaretskii, help-gnu-emacs
On 15/12/2022 10:04, Eli Zaretskii wrote:
>> Date: Thu, 15 Dec 2022 09:31:43 +0100
>> From: aitor <aitors2005@gmail.com>
>>
>>> Any reason why you think you need that? Doing so will fill the
>>> kill-ring with meaningless single-character entries. You have 'undo',
>>> which can undelete the deleted text, so why do you want to put every
>>> single character you delete in the kill-ring?
>> I usually select portions of text using shift+arrow keys, and then
>> delete them by pressing <delete>.
> Then press "C-u <delete>" instead. That will allow you to control
> when the deleted text goes to the kill-ring and when not. Doing that
> by default makes little sense, because <delete> is also used to delete
> single characters or very short stretches of text.
One could also have a delete function which saves to the kill ring only
when the region is active. This should keep most short deletions out.
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2022-12-15 10:46 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-13 11:12 Make <delete> save the deleted text into the killing ring aitor
2022-12-14 11:23 ` aitor
2022-12-14 17:44 ` Emanuel Berg
2022-12-14 19:52 ` John Haman
2022-12-14 19:58 ` Emanuel Berg
2022-12-14 20:17 ` Gregory Heytings
2022-12-14 20:43 ` Emanuel Berg
2022-12-15 8:40 ` aitor
2022-12-15 8:48 ` Emanuel Berg
2022-12-15 6:14 ` Eli Zaretskii
2022-12-15 6:15 ` Emanuel Berg
2022-12-15 8:31 ` aitor
2022-12-15 9:04 ` Eli Zaretskii
2022-12-15 10:18 ` Thibaut Verron
2022-12-15 10:24 ` Gregory Heytings
2022-12-15 10:46 ` Emanuel Berg
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.