[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: kill-region without modifying the kill ring
From: |
Michael Heerdegen |
Subject: |
Re: kill-region without modifying the kill ring |
Date: |
Sat, 26 Sep 2015 06:35:31 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
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.
- Re: kill-region without modifying the kill ring, (continued)
Message not available
Re: kill-region without modifying the kill ring, Jorge A. Alfaro-Murillo, 2015/09/25
Message not available
Re: kill-region without modifying the kill ring, Javier, 2015/09/25
Re: kill-region without modifying the kill ring, Yuri Khan, 2015/09/25
Message not available
Re: kill-region without modifying the kill ring, Emanuel Berg, 2015/09/25