* kill-region without modifying the kill ring
@ 2015-09-25 8:32 Jim Newton
2015-09-25 12:15 ` tomas
` (5 more replies)
0 siblings, 6 replies; 20+ messages in thread
From: Jim Newton @ 2015-09-25 8:32 UTC (permalink / raw)
To: help-gnu-emacs
is there a way or an idiom for killing a region without changing the kill ring.
I often want to cut several different regions by highlighting them, but then insert a particular thing with C-Y. If I use C-W to kill the region C-Y will yank back the string I just killed rather than the one I want.
It would be nice to have a version of C-W which does not effect the kill-ring.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: kill-region without modifying the kill ring
2015-09-25 8:32 kill-region without modifying the kill ring Jim Newton
@ 2015-09-25 12:15 ` tomas
[not found] ` <mailman.1800.1443183340.19560.help-gnu-emacs@gnu.org>
` (4 subsequent siblings)
5 siblings, 0 replies; 20+ messages in thread
From: tomas @ 2015-09-25 12:15 UTC (permalink / raw)
To: Jim Newton; +Cc: help-gnu-emacs
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Fri, Sep 25, 2015 at 01:32:14AM -0700, Jim Newton wrote:
> is there a way or an idiom for killing a region without changing the kill ring.
> I often want to cut several different regions by highlighting them, but then insert a particular thing with C-Y. If I use C-W to kill the region C-Y will yank back the string I just killed rather than the one I want.
delete-region is advertised to do that, but a quick test
in my case seems to do the same as kill. I haven't the time
now to debug that, might just be an idiosyncracy of my
less-than-organized .emacs
> It would be nice to have a version of C-W which does not effect the kill-ring.
Not an answer to your original request, but with M-y you can
replace the just-yanked text with previous kills, so perhaps
you might achieve the effect you're after by first yanking
with C-y, then with M-y (and with consecutive M-y you can
even "walk back" your kill history).
regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iEYEARECAAYFAlYFOtsACgkQBcgs9XrR2kbonwCePdzK5Uc++roPrA9nhgS/k886
QXgAn3wywDXBD0rgcinn7S3VVGmzCU5Y
=Xqp9
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: kill-region without modifying the kill ring
[not found] ` <mailman.1800.1443183340.19560.help-gnu-emacs@gnu.org>
@ 2015-09-25 12:47 ` Jim Newton
2015-09-25 12:49 ` Jim Newton
1 sibling, 0 replies; 20+ messages in thread
From: Jim Newton @ 2015-09-25 12:47 UTC (permalink / raw)
To: help-gnu-emacs
>
> Not an answer to your original request, but with M-y you can
> replace the just-yanked text with previous kills, so perhaps
> you might achieve the effect you're after by first yanking
> with C-y, then with M-y (and with consecutive M-y you can
> even "walk back" your kill history).
>
Yes, sometimes I do it that way. But after using C-w a second time, then to get back the yank, I must use C-y M-y M-y, and after C-w N times I have to C-y M-y N-1 times. Yes its do-able, which made me wonder whether theres a better way.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: kill-region without modifying the kill ring
[not found] ` <mailman.1800.1443183340.19560.help-gnu-emacs@gnu.org>
2015-09-25 12:47 ` Jim Newton
@ 2015-09-25 12:49 ` Jim Newton
2015-09-25 13:30 ` B. T. Raven
1 sibling, 1 reply; 20+ messages in thread
From: Jim Newton @ 2015-09-25 12:49 UTC (permalink / raw)
To: help-gnu-emacs
>
> delete-region is advertised to do that, but a quick test
> in my case seems to do the same as kill. I haven't the time
> now to debug that, might just be an idiosyncracy of my
> less-than-organized .emacs
>
After a quick test, it seems delete-region does what I want. It doesn't seem to have a standard bind key.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: kill-region without modifying the kill ring
2015-09-25 12:49 ` Jim Newton
@ 2015-09-25 13:30 ` B. T. Raven
2015-09-25 13:36 ` Jim Newton
0 siblings, 1 reply; 20+ messages in thread
From: B. T. Raven @ 2015-09-25 13:30 UTC (permalink / raw)
To: help-gnu-emacs
On 9/25/2015 7:49 AM, Jim Newton wrote:
>
>>
>> delete-region is advertised to do that, but a quick test
>> in my case seems to do the same as kill. I haven't the time
>> now to debug that, might just be an idiosyncracy of my
>> less-than-organized .emacs
>>
>
> After a quick test, it seems delete-region does what I want. It doesn't seem to have a standard bind key.
>
It would slow things down to have one, and waste a keychord. In order to
invoke delete-region you first need to define a region. Once that's
done, either the delete or backspace key will delete it. With a split
space keyboard the backspace key (left of split) is more accessible than
any key combo whatever.
Ed
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: kill-region without modifying the kill ring
2015-09-25 13:30 ` B. T. Raven
@ 2015-09-25 13:36 ` Jim Newton
2015-09-26 17:57 ` B. T. Raven
0 siblings, 1 reply; 20+ messages in thread
From: Jim Newton @ 2015-09-25 13:36 UTC (permalink / raw)
To: help-gnu-emacs
Hi Ed, not sure what you're suggesting. Are you suggesting that the delete or backspace key will delete without modifying the kill-ring?
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: kill-region without modifying the kill ring
2015-09-25 8:32 kill-region without modifying the kill ring Jim Newton
2015-09-25 12:15 ` tomas
[not found] ` <mailman.1800.1443183340.19560.help-gnu-emacs@gnu.org>
@ 2015-09-25 13:51 ` Jorge A. Alfaro-Murillo
[not found] ` <mailman.1805.1443189138.19560.help-gnu-emacs@gnu.org>
` (2 subsequent siblings)
5 siblings, 0 replies; 20+ messages in thread
From: Jorge A. Alfaro-Murillo @ 2015-09-25 13:51 UTC (permalink / raw)
To: help-gnu-emacs
Jim Newton writes:
> is there a way or an idiom for killing a region without changing
> the kill ring. I often want to cut several different regions by
> highlighting them, but then insert a particular thing with C-Y.
> If I use C-W to kill the region C-Y will yank back the string I
> just killed rather than the one I want.
>
> It would be nice to have a version of C-W which does not effect
> the kill-ring.
Doesn't selecting the text and using <backspace> do exactly that?
By the way, as Tomás suggested, I think that you are better off
always killing the region and then using M-y. You never know if
you will actually change your mind and use the text you deleted.
For an improved version of M-y, try:
https://github.com/browse-kill-ring/browse-kill-ring
Best,
--
Jorge.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: kill-region without modifying the kill ring
[not found] ` <mailman.1805.1443189138.19560.help-gnu-emacs@gnu.org>
@ 2015-09-25 14:30 ` Jim Newton
2015-09-25 15:47 ` Jorge A. Alfaro-Murillo
` (2 more replies)
2015-09-25 15:21 ` Barry Margolin
1 sibling, 3 replies; 20+ messages in thread
From: Jim Newton @ 2015-09-25 14:30 UTC (permalink / raw)
To: help-gnu-emacs
> Doesn't selecting the text and using <backspace> do exactly that?
> By the way, as Tomás suggested, I think that you are better off
> always killing the region and then using M-y. You never know if
> you will actually change your mind and use the text you deleted.
> For an improved version of M-y, try:
>
> https://github.com/browse-kill-ring/browse-kill-ring
The problem, as I described above is that every time I press C-w, then to get back the text I want to yank, I must press M-y N+1 times.
Here is the sequence. I copy the region I want to insert with M-w, then I start reading through the text in the buffer, every time I encounter a string I want to replace with C-y, I have to first delete what's there. So I select the first using M-space a few times, and press C-w C-y M-y, then continue to the text I want to remove and replace (maybe the same string again, or maybe one slightly different), and press M-space (a few times), then C-w C-y M-y M-y,
next time I have to press C-w C-y M-y M-y M-y
The 20th time I need to press
C-w C-y M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y
That's why the M-y suggestion does not work.
But the suggestion to use [delete] instead of C-w is a good one. I didn't know I could delete a region with the delete key, i've used C-w since 1988.
So to answer the original question:
Q: how can I delete a region without effecting the kill-ring
A: delete-forward-char which is bound by default to [delete] (making sure transient mark mode is active)
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: kill-region without modifying the kill ring
2015-09-25 8:32 kill-region without modifying the kill ring Jim Newton
` (3 preceding siblings ...)
[not found] ` <mailman.1805.1443189138.19560.help-gnu-emacs@gnu.org>
@ 2015-09-25 15:15 ` Yuri Khan
2015-09-26 2:07 ` Emanuel Berg
5 siblings, 0 replies; 20+ messages in thread
From: Yuri Khan @ 2015-09-25 15:15 UTC (permalink / raw)
To: Jim Newton; +Cc: help-gnu-emacs@gnu.org
On Fri, Sep 25, 2015 at 2:32 PM, Jim Newton <jimka.issy@gmail.com> wrote:
> is there a way or an idiom for killing a region without changing the kill ring.
> I often want to cut several different regions by highlighting them, but then insert a particular thing with C-Y. If I use C-W to kill the region C-Y will yank back the string I just killed rather than the one I want.
>
> It would be nice to have a version of C-W which does not effect the kill-ring.
I remember something posted on this very list not long ago. It was
called deleterious-mode.
https://lists.gnu.org/archive/html/help-gnu-emacs/2015-08/msg00152.html
(I don’t use it yet, but I do a very similar thing, rebinding all keys
which normally kill to delete instead. When I want something cut, I
cut it explicitly.)
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: kill-region without modifying the kill ring
[not found] ` <mailman.1805.1443189138.19560.help-gnu-emacs@gnu.org>
2015-09-25 14:30 ` Jim Newton
@ 2015-09-25 15:21 ` Barry Margolin
2015-09-25 15:37 ` Jorge A. Alfaro-Murillo
[not found] ` <mailman.1812.1443195492.19560.help-gnu-emacs@gnu.org>
1 sibling, 2 replies; 20+ messages in thread
From: Barry Margolin @ 2015-09-25 15:21 UTC (permalink / raw)
To: help-gnu-emacs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1368 bytes --]
In article <mailman.1805.1443189138.19560.help-gnu-emacs@gnu.org>,
jorge.alfaro-murillo@yale.edu (Jorge A. Alfaro-Murillo) wrote:
> Jim Newton writes:
>
> > is there a way or an idiom for killing a region without changing
> > the kill ring. I often want to cut several different regions by
> > highlighting them, but then insert a particular thing with C-Y.
> > If I use C-W to kill the region C-Y will yank back the string I
> > just killed rather than the one I want.
> >
> > It would be nice to have a version of C-W which does not effect
> > the kill-ring.
>
> Doesn't selecting the text and using <backspace> do exactly that?
I just tried it, and C-y recovered the deleted text. So it does put it
on the kill-ring.
> By the way, as Tomás suggested, I think that you are better off
> always killing the region and then using M-y. You never know if
> you will actually change your mind and use the text you deleted.
I've used delete-region when I've accidentally run a command in a shell
buffer that spews out thousands of lines of output. I know I'm not going
to want it back.
And back in the days of more limited memory, I would also turn off undo,
so that the deleted region wouldn't be saved in the undo-history.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: kill-region without modifying the kill ring
2015-09-25 15:21 ` Barry Margolin
@ 2015-09-25 15:37 ` Jorge A. Alfaro-Murillo
[not found] ` <mailman.1812.1443195492.19560.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 20+ messages in thread
From: Jorge A. Alfaro-Murillo @ 2015-09-25 15:37 UTC (permalink / raw)
To: help-gnu-emacs
Barry Margolin writes:
> Jorge A. Alfaro-Murillo writes:
>
>> Jim Newton writes:
>>
>> > is there a way or an idiom for killing a region without
>> > changing the kill ring. I often want to cut several
>> > different regions by highlighting them, but then insert a
>> > particular thing with C-Y. If I use C-W to kill the region
>> > C-Y will yank back the string I just killed rather than the
>> > one I want. It would be nice to have a version of C-W
>> > which does not effect the kill-ring.
>>
>> Doesn't selecting the text and using <backspace> do exactly
>> that?
>
> I just tried it, and C-y recovered the deleted text. So it does
> put it on the kill-ring.
No, I think you are wrong. delete-backward-char (bound to
<backspace>) doesn't put the text in the kill ring. At least not
by default, try it with emacs -Q
--
Jorge.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: kill-region without modifying the kill ring
2015-09-25 14:30 ` Jim Newton
@ 2015-09-25 15:47 ` Jorge A. Alfaro-Murillo
2015-09-26 0:41 ` Robert Thorpe
2015-09-25 16:40 ` Michael Heerdegen
2015-09-25 19:13 ` Javier
2 siblings, 1 reply; 20+ messages in thread
From: Jorge A. Alfaro-Murillo @ 2015-09-25 15:47 UTC (permalink / raw)
To: help-gnu-emacs
Jim Newton writes:
> Jorge A. Alfaro-Murillo writes:
>
>> Doesn't selecting the text and using <backspace> do exactly
>> that? By the way, as Tomás suggested, I think that you are
>> better off always killing the region and then using M-y. You
>> never know if you will actually change your mind and use the
>> text you deleted. For an improved version of M-y, try:
>>
>> https://github.com/browse-kill-ring/browse-kill-ring
>
> The problem, as I described above is that every time I press
> C-w, then to get back the text I want to yank, I must press M-y
> N+1 times.
>
> Here is the sequence. I copy the region I want to insert with
> M-w, then I start reading through the text in the buffer, every
> time I encounter a string I want to replace with C-y, I have to
> first delete what's there. So I select the first using M-space a
> few times, and press C-w C-y M-y, then continue to the text I
> want to remove and replace (maybe the same string again, or
> maybe one slightly different), and press M-space (a few times),
> then C-w C-y M-y M-y, next time I have to press C-w C-y M-y M-y
> M-y The 20th time I need to press C-w C-y M-y M-y M-y M-y M-y
> M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y
>
> That's why the M-y suggestion does not work.
I see now what you mean. I think registers are better for that
case. Select the region that you will yank a lot of times, do:
C-x r s 1 <enter>
That is copy-to-register, assigning a key, 1 in this example, to
the text.
Then every time that you want to insert the text do
insert-register:
C-x r i 1 <enter>
Then you can continue using C-w as much as you want.
If you will be yanking that text a lot, to save keystrokes record
a macro: F3 C-x r i 1 <enter> F4, and then use F4 from then on.
--
Jorge.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: kill-region without modifying the kill ring
[not found] ` <mailman.1812.1443195492.19560.help-gnu-emacs@gnu.org>
@ 2015-09-25 16:37 ` Barry Margolin
0 siblings, 0 replies; 20+ messages in thread
From: Barry Margolin @ 2015-09-25 16:37 UTC (permalink / raw)
To: help-gnu-emacs
In article <mailman.1812.1443195492.19560.help-gnu-emacs@gnu.org>,
jorge.alfaro-murillo@yale.edu (Jorge A. Alfaro-Murillo) wrote:
> Barry Margolin writes:
>
> > Jorge A. Alfaro-Murillo writes:
> >
> >> Jim Newton writes:
> >>
> >> > is there a way or an idiom for killing a region without
> >> > changing the kill ring. I often want to cut several
> >> > different regions by highlighting them, but then insert a
> >> > particular thing with C-Y. If I use C-W to kill the region
> >> > C-Y will yank back the string I just killed rather than the
> >> > one I want. It would be nice to have a version of C-W
> >> > which does not effect the kill-ring.
> >>
> >> Doesn't selecting the text and using <backspace> do exactly
> >> that?
> >
> > I just tried it, and C-y recovered the deleted text. So it does
> > put it on the kill-ring.
>
> No, I think you are wrong. delete-backward-char (bound to
> <backspace>) doesn't put the text in the kill ring. At least not
> by default, try it with emacs -Q
You're right, it was due to some customization, I had <backspace> bound
to a different function that sets killflag if there's a region.
Once I reverted the binding to normal, I also had to turn on
delete-selection-mode to make it delete the region rather than a single
character.
I use Carbon Emacs 22 on OS X, I'm not sure how I would start it with
options like -Q.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: kill-region without modifying the kill ring
2015-09-25 14:30 ` Jim Newton
2015-09-25 15:47 ` Jorge A. Alfaro-Murillo
@ 2015-09-25 16:40 ` Michael Heerdegen
2015-09-26 2:27 ` Suvayu Ali
2015-09-25 19:13 ` Javier
2 siblings, 1 reply; 20+ messages in thread
From: Michael Heerdegen @ 2015-09-25 16:40 UTC (permalink / raw)
To: help-gnu-emacs
Jim Newton <jimka.issy@gmail.com> writes:
> The problem, as I described above is that every time I press C-w, then
> to get back the text I want to yank, I must press M-y N+1 times.
>
> Here is the sequence. I copy the region I want to insert with M-w,
> then I start reading through the text in the buffer, every time I
> encounter a string I want to replace with C-y, I have to first delete
> what's there. So I select the first using M-space a few times, and
> press C-w C-y M-y, then continue to the text I want to remove and
> replace (maybe the same string again, or maybe one slightly
> different), and press M-space (a few times), then C-w C-y M-y M-y,
> next time I have to press C-w C-y M-y M-y M-y
> The 20th time I need to press
> C-w C-y M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y M-y
> M-y M-y M-y M-y M-y
>
> That's why the M-y suggestion does not work.
>
> But the suggestion to use [delete] instead of C-w is a good one. I
> didn't know I could delete a region with the delete key, i've used C-w
> since 1988.
I know that problem very well.
Some years ago, I also tried to solve this by using deletion instead of
killing. But I soon dismissed the idea, because
- there are a bunch of other killing commands (e.g. M-d, C-M-backspace,
C-k, etc.), and I would need to replace them all with deletion
commands.
- even if I did that, I sometimes _want_ to add to the kill ring.
That complicates the matter again.
But the underlying problem is not killing per se, but the design of the
kill/yank system. So I ended up by hacking the kill/yank system by
doing more or less the following:
- after a (persistent) yank, move the yanked piece of text to the
beginning of the kill ring, and let the yank pointer point to this
first element
- for more convenience, let M-y when hit not after a yank, instead of
raising an error, yank the second element of the kill ring
This implements a different concept of using the kill-ring, changing the
order of kills all of the time reflecting your recent yanks, instead of
the order in which the pieces were actually killed.
So, your workflow from above would become
kill text to yank
kill-command, M-y, move to next ocurrance, kill-command, M-y, ...
I used this for a while now and am happy with it. Of course, killing
still adds to the kill ring, but it doesn't disrupt the above work flow
anymore. Together with a tool like browse-kill-ring, it perfectly fits
my needs.
I can send you the code if interested.
Regards,
Michael.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: kill-region without modifying the kill ring
2015-09-25 14:30 ` Jim Newton
2015-09-25 15:47 ` Jorge A. Alfaro-Murillo
2015-09-25 16:40 ` Michael Heerdegen
@ 2015-09-25 19:13 ` Javier
2 siblings, 0 replies; 20+ messages in thread
From: Javier @ 2015-09-25 19:13 UTC (permalink / raw)
To: help-gnu-emacs
> But the suggestion to use [delete] instead of C-w is a good one. I
> didn't know I could delete a region with the delete key, i've used
> C-w since 1988.
I think that feature didn't exist until very recently, and it is
associated with transient-mark-mode. It must have appeared in emacs
23 when they made transient-mark-mode the default.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: kill-region without modifying the kill ring
2015-09-25 15:47 ` Jorge A. Alfaro-Murillo
@ 2015-09-26 0:41 ` Robert Thorpe
0 siblings, 0 replies; 20+ messages in thread
From: Robert Thorpe @ 2015-09-26 0:41 UTC (permalink / raw)
To: help-gnu-emacs
jorge.alfaro-murillo@yale.edu (Jorge A. Alfaro-Murillo) writes:
...
> If you will be yanking that text a lot, to save keystrokes record
> a macro: F3 C-x r i 1 <enter> F4, and then use F4 from then on.
That's what I would do. Another possibility is to do F3 M-x
delete-region RET F4. Then with F4 temporarily bound to delete region
use it for deletions. I think using registers is better though, because
it means you can use all of the usual forms of killing M-w, M-DEL, M-d,
C-k, etc.
In situations like this it's also useful to use registers for
navigation.
BR,
Robert Thorpe
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: kill-region without modifying the kill ring
2015-09-25 8:32 kill-region without modifying the kill ring Jim Newton
` (4 preceding siblings ...)
2015-09-25 15:15 ` Yuri Khan
@ 2015-09-26 2:07 ` Emanuel Berg
5 siblings, 0 replies; 20+ messages in thread
From: Emanuel Berg @ 2015-09-26 2:07 UTC (permalink / raw)
To: help-gnu-emacs
Jim Newton <jimka.issy@gmail.com> writes:
> It would be nice to have a version of C-W which does
> not effect the kill-ring.
You can do that but it is better to do first C-y
(`yank') and then M-y (`yank-pop').
Then you may like this as well:
(defun yank-pop-back (&optional arg)
(interactive "*p")
(yank-pop (if arg (* arg -1) -1)) )
from:
http://user.it.uu.se/~embe8573/conf/emacs-init/yank-my.el
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: kill-region without modifying the kill ring
2015-09-25 16:40 ` Michael Heerdegen
@ 2015-09-26 2:27 ` Suvayu Ali
2015-09-26 4:35 ` Michael Heerdegen
0 siblings, 1 reply; 20+ messages in thread
From: Suvayu Ali @ 2015-09-26 2:27 UTC (permalink / raw)
To: help-gnu-emacs
On Fri, Sep 25, 2015 at 06:40:34PM +0200, Michael Heerdegen wrote:
> So, your workflow from above would become
>
> kill text to yank
>
> kill-command, M-y, move to next ocurrance, kill-command, M-y, ...
>
> I used this for a while now and am happy with it. Of course, killing
> still adds to the kill ring, but it doesn't disrupt the above work flow
> anymore. Together with a tool like browse-kill-ring, it perfectly fits
> my needs.
>
> I can send you the code if interested.
This sounds amazing! I would love to use something like this.
:)
--
Suvayu
Open source is the future. It sets us free.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: kill-region without modifying the kill ring
2015-09-26 2:27 ` Suvayu Ali
@ 2015-09-26 4:35 ` Michael Heerdegen
0 siblings, 0 replies; 20+ messages in thread
From: Michael Heerdegen @ 2015-09-26 4:35 UTC (permalink / raw)
To: help-gnu-emacs
Suvayu Ali <fatkasuvayu+linux@gmail.com> writes:
> This sounds amazing! I would love to use something like this.
But note it's what I want, maybe this hack comes in your way in
situations where you like the original behavior more.
Anyway, here's the hack:
--8<---------------cut here---------------start------------->8---
(defun my-yank-reset-yank-pointer ()
(unless (eq last-command #'yank)
(setq kill-ring-yank-pointer kill-ring)))
(defun my-yank--before-ad (&rest _args)
"Before advice function for `yank'.
1. avoid persistent change of kill-ring-yank-pointer after
`yank-pop', and before next kill.
2. For yank-pop, move the really yanked text at the beg of the
kill ring."
(unless (eq kill-ring kill-ring-yank-pointer)
(let ((last-yank (car kill-ring-yank-pointer)))
(when last-yank
(setq kill-ring (cons last-yank (delete last-yank kill-ring)))
(my-yank-reset-yank-pointer)))))
(advice-add 'yank :before #'my-yank--before-ad)
(defun my-yank-pop ()
(interactive)
(if (eq last-command 'yank)
(call-interactively #'yank-pop)
(rotate-yank-pointer 1)
(yank)))
(global-set-key [(meta ?y)] #'my-yank-pop)
--8<---------------cut here---------------end--------------->8---
Regards,
Michael.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: kill-region without modifying the kill ring
2015-09-25 13:36 ` Jim Newton
@ 2015-09-26 17:57 ` B. T. Raven
0 siblings, 0 replies; 20+ messages in thread
From: B. T. Raven @ 2015-09-26 17:57 UTC (permalink / raw)
To: help-gnu-emacs
On 9/25/2015 8:36 AM, Jim Newton wrote:
> Hi Ed, not sure what you're suggesting. Are you suggesting that the
> delete or backspace key will delete without modifying the kill-ring?
>
Sorry, I read your note too fast. I thought delete-region was the same
as delete or backspace. Now I have:
(global-set-key [(shift backspace)] 'delete-region)
Which, indeed, does not affect the kill ring.
Ed
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2015-09-26 17:57 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-25 8:32 kill-region without modifying the kill ring Jim Newton
2015-09-25 12:15 ` tomas
[not found] ` <mailman.1800.1443183340.19560.help-gnu-emacs@gnu.org>
2015-09-25 12:47 ` Jim Newton
2015-09-25 12:49 ` Jim Newton
2015-09-25 13:30 ` B. T. Raven
2015-09-25 13:36 ` Jim Newton
2015-09-26 17:57 ` B. T. Raven
2015-09-25 13:51 ` Jorge A. Alfaro-Murillo
[not found] ` <mailman.1805.1443189138.19560.help-gnu-emacs@gnu.org>
2015-09-25 14:30 ` Jim Newton
2015-09-25 15:47 ` Jorge A. Alfaro-Murillo
2015-09-26 0:41 ` Robert Thorpe
2015-09-25 16:40 ` Michael Heerdegen
2015-09-26 2:27 ` Suvayu Ali
2015-09-26 4:35 ` Michael Heerdegen
2015-09-25 19:13 ` Javier
2015-09-25 15:21 ` Barry Margolin
2015-09-25 15:37 ` Jorge A. Alfaro-Murillo
[not found] ` <mailman.1812.1443195492.19560.help-gnu-emacs@gnu.org>
2015-09-25 16:37 ` Barry Margolin
2015-09-25 15:15 ` Yuri Khan
2015-09-26 2:07 ` Emanuel Berg
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).