From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: kill-region without modifying the kill ring Date: Fri, 25 Sep 2015 18:40:34 +0200 Message-ID: <87eghm78ql.fsf@web.de> References: <8272bab2-aa15-479f-b838-0b60fb11c5bb@googlegroups.com> <7a656389-cff3-4afd-a237-1142a1ba7daa@googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1443199283 20468 80.91.229.3 (25 Sep 2015 16:41:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 25 Sep 2015 16:41:23 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Sep 25 18:41:16 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZfW3c-0004KJ-Ex for geh-help-gnu-emacs@m.gmane.org; Fri, 25 Sep 2015 18:41:12 +0200 Original-Received: from localhost ([::1]:48976 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfW3W-0003qt-VI for geh-help-gnu-emacs@m.gmane.org; Fri, 25 Sep 2015 12:41:06 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47810) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfW3J-0003q1-AU for help-gnu-emacs@gnu.org; Fri, 25 Sep 2015 12:40:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfW3E-0001m8-7r for help-gnu-emacs@gnu.org; Fri, 25 Sep 2015 12:40:53 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:45682) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfW3D-0001lU-Jp for help-gnu-emacs@gnu.org; Fri, 25 Sep 2015 12:40:48 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZfW3B-0003ob-C5 for help-gnu-emacs@gnu.org; Fri, 25 Sep 2015 18:40:45 +0200 Original-Received: from ip-90-186-3-175.web.vodafone.de ([90.186.3.175]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 25 Sep 2015 18:40:45 +0200 Original-Received: from michael_heerdegen by ip-90-186-3-175.web.vodafone.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 25 Sep 2015 18:40:45 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 67 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ip-90-186-3-175.web.vodafone.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) Cancel-Lock: sha1:NMHbvy4q6ceqla8jYxFRbaLA40o= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:107348 Archived-At: Jim Newton 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.