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: Sat, 26 Sep 2015 06:35:31 +0200 Message-ID: <87d1x5lrvw.fsf@web.de> References: <8272bab2-aa15-479f-b838-0b60fb11c5bb@googlegroups.com> <7a656389-cff3-4afd-a237-1142a1ba7daa@googlegroups.com> <87eghm78ql.fsf@web.de> <20150926022718.GG25140@chitra.no-ip.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1443242170 8379 80.91.229.3 (26 Sep 2015 04:36:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 26 Sep 2015 04:36:10 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Sep 26 06:36:02 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 1ZfhDK-00005M-5J for geh-help-gnu-emacs@m.gmane.org; Sat, 26 Sep 2015 06:35:58 +0200 Original-Received: from localhost ([::1]:51875 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfhDI-0000gC-T8 for geh-help-gnu-emacs@m.gmane.org; Sat, 26 Sep 2015 00:35:56 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfhD6-0000g1-So for help-gnu-emacs@gnu.org; Sat, 26 Sep 2015 00:35:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZfhD3-0005Ro-Ly for help-gnu-emacs@gnu.org; Sat, 26 Sep 2015 00:35:44 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:50011) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZfhD3-0005Qj-Dp for help-gnu-emacs@gnu.org; Sat, 26 Sep 2015 00:35:41 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZfhD1-000841-J7 for help-gnu-emacs@gnu.org; Sat, 26 Sep 2015 06:35:39 +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 ; Sat, 26 Sep 2015 06:35:39 +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 ; Sat, 26 Sep 2015 06:35:39 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 43 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:90JSVjwIf1EhbNZifI1OMjiWYmM= 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:107364 Archived-At: Suvayu Ali 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.