I need to replace the top killed string to another one. I can (yank) it and then (kill-region ...), but after that, there will be two strings: the old one, and my new. How to remove the old entry completely from the kill-ring?
It can be as simple as
(pop kill-ring)
-
-
This seems not to work very well, because it leaves
kill-ring-yank-pointer
. If the reason you want to delete the last entry is because it was e.g. a password and you don't want it hanging around in some variable, then @scottfrazer's answer (or thebrowse-kill-ring
package from MELPA) is better. – mbork Jan 11 at 14:58
I'm not sure why you think Oleg's answer is 'not a good style', but here is another way:
(when kill-ring
(setq kill-ring (cdr kill-ring)))
You might also want to adjust kill-ring-yank-pointer
:
(when kill-ring-yank-pointer
(setq kill-ring-yank-pointer kill-ring))
-
I meant, that Oleg's way is too low level, but the yours, certainly, outdid it. – Necto Oct 31 '12 at 17:24
M-y
or (browse-kill-ring)
to get into kill-ring-mode and then press 'h' for help. One of the entries is:
d browse-kill-ring-delete
so just press 'd' with cursor over the entry to remove.