From: Michael Heerdegen <michael_heerdegen@web.de>
To: help-gnu-emacs@gnu.org
Subject: Re: kill-region without modifying the kill ring
Date: Fri, 25 Sep 2015 18:40:34 +0200 [thread overview]
Message-ID: <87eghm78ql.fsf@web.de> (raw)
In-Reply-To: 7a656389-cff3-4afd-a237-1142a1ba7daa@googlegroups.com
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.
next prev parent reply other threads:[~2015-09-25 16:40 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
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
2015-09-25 15:15 ` Yuri Khan
[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 [this message]
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-26 2:07 ` Emanuel Berg
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87eghm78ql.fsf@web.de \
--to=michael_heerdegen@web.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.
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.