The kill ring is a nice thing to have. Only the navigation is a bit to uncomfortable (I am refering to doing C-y again and again until the to desired element is found). So this is what I came up with to feel more ‚comfy‘:
(defun pre-process-kill-ring-element (element)
(replace-regexp-in-string "^[[:space:]]+" ""
(replace-regexp-in-string "[[:space:]]+$" "" (substring-no-properties element))))
(defun preprocess-kill-ring ()
(let ((result nil)
(element nil))
(dolist (element kill-ring)
(progn
(setq element (pre-process-kill-ring-element element))
(when (not (or
(eq 0 (length element))
(string-match-p "[\r\n]+" element)))
(setq result (cons element result)))))
(reverse result)))
(defun browse-kill-ring ()
(interactive)
(insert (completing-read "Pick an element: "
(preprocess-kill-ring))))
(global-set-key (kbd "C-M-y") 'browse-kill-ring)
Interesting idea. I assume that once an element was selected from the `kill-ring`, it would also be inserted, like:
(defun browse-and-yank-kill-ring (contents)
(interactive
(list
(ido-completing-read „Yank: “
(preprocess-kill-ring))))
(insert contents))
(global-set-key (kbd „C-M-y“) ‚browse-and-yank-kill-ring)
Good point. I have picked it up.
functionality already existing in the helm package and probably in other similar packages too.
helm-show-kill-ring
Check it out:
https://tuhdo.github.io/helm-intro.html#orgheadline6
Hi Deus Max,
Thanks for the hint. Will give it a try!
I’ve been using helm-show-kill-ring for something similar. =) There’s also a browse-kill-ring package, which you might like. Have fun!