A quite simple standard way to browse and select the first couple of kill ring items is to use Edit → Paste from Kill Menu. In Emacs 24, F10 will open the menu bar, either the graphical one if the menu bar is enabled, or the textual one. Regardless of which one that opens you can navigate the first couple of kill ring items using your keyboard. – MaDa
Similar to browse-kill-ring – makes it easy to access and yank text from the kill ring:
(global-set-key "\C-cy" '(lambda () (interactive) (popup-menu 'yank-menu)))
browse-kill-ring.el – a package by ColinWalters, and later maintained by Nick Hurley. You can get it here:
apt-get install elpa-browse-kill-ring(DebianPackage:elpa-browse-kill-ring)
browse-kill-ring+.el – Enhancements to
‘kill-ring’— in particular, the
Helm has build-in support for browsing the kill-ring when `helm-mode` is enabled.
Icicles – You can clean up the ring selectively during completion, deleting entries on the fly. And you can sort completions in various ways. All Icicles completion features are available, including progressive completion. Two ways:
‘C-- C-y’yanks from the kill ring using completion.
‘M-y’at top level (i.e., not after a yank from either the kill ring or the
‘secondary-selection-ring’of second-sel.el) yanks from one of those rings using completion. It yanks a kill by default, but a secondary selection if you use a prefix argument.
KillRingSearch – incremental search of the kill ring
popup-kill-ring.el – interactively insert item from kill-ring
view-kill.el – Displays the entire kill ring as a menu.
wuxch-browse-kill-ring.el – key bindings, customization
(defun konix/kill-ring-insert () (interactive) (let ((to_insert (completing-read "Yank : " (delete-duplicates kill-ring :test #'equal)))) (when (and to_insert (region-active-p)) ;; the currently highlighted section is to be replaced by the yank (delete-region (region-beginning) (region-end))) (insert to_insert)))
Similar function with Anything, a candidate selection framework. Start with
‘M-x anything-show-kill-ring’, narrow the list by typing some patterns(multiple patterns are space-delimited string), select with up/down/pgup/pgdown/C-p/C-n/C-v/M-v, choose with enter to insert an element of
I can’t praise browse-kill-ring enough – I don’t use it all that much, but when I need it there’s no replacing it. – Anonymous
Someone once said “The easiest way to invoke kill-ring browsing is just to use
‘M-y’ without first using
‘C-y’”. But when I try that (with Emacs 22) I just get “Previous command was not a yank”.
To get the “M-y immediately pulls up the kill ring” behavior, you need to run M-x browse-kill-ring-default-keybindings. Or, to put this in .emacs
(require 'browse-kill-ring) (browse-kill-ring-default-keybindings)
Here’s a “poor man’s kill-ring-browser”:
(defun yank-browse (string) "Browse the `kill-ring' to choose which entry to yank." (interactive (minibuffer-with-setup-hook #'minibuffer-completion-help (let* ((kills (delete-dups (append kill-ring-yank-pointer kill-ring nil))) (entries (mapcar (lambda (string) (let ((pos 0)) ;; FIXME: Maybe we should start by removing ;; all properties. (setq string (copy-sequence string)) (while (string-match "\n" string pos) ;; FIXME: Maybe completion--insert-strings should ;; do that for us. (put-text-property (match-beginning 0) (match-end 0) 'display (eval-when-compile (propertize "\\n" 'face 'escape-glyph)) string) (setq pos (match-end 0))) ;; FIXME: We may use the window-width of the ;; wrong window. (when (>= (* 3 (string-width string)) (* 2 (window-width))) (let ((half (- (/ (window-width) 3) 1))) ;; FIXME: We're using char-counts rather than ;; width-count. (put-text-property half (- (length string) half) 'display (eval-when-compile (propertize "……" 'face 'escape-glyph)) string))) string)) kills)) (table (lambda (string pred action) (cond ((eq action 'metadata) '(metadata (category . kill-ring))) (t (complete-with-action action entries string pred)))))) ;; FIXME: We should return the entry from the kill-ring rather than ;; the entry from the completion-table. ;; FIXME: substring completion doesn't work well because it only matches ;; subtrings before the first \n. ;; FIXME: completion--insert-strings assumes that boundaries of ;; candidates are obvious enough, but with kill-ring entries this is not ;; true, so we'd probably want to display them with «...» around them. (list (completing-read "Yank: " table nil t))))) (setq this-command 'yank) (insert-for-yank string))
I adapted popup-kill-ring to replace a potential previous yank like the default M-y does (yank-pop).
diff --git a/libs/popup-kill-ring.el b/libs/popup-kill-ring.el --- a/libs/popup-kill-ring.el +++ b/libs/popup-kill-ring.el @@ -280,6 +280,8 @@ and `pos-tip.el'" :scroll-bar t :isearch popup-kill-ring-isearch)) (when item + (when (or (eq last-command 'cua--paste-rectangle) (eq last-command 'yank)) + (undo)) (setq num (popup-kill-ring-get-index item)) (when num (let ((kill-ring-item (nth num kill-ring)))