From 7cbe5aedb2e80c000172bbe37ad3c887c694ce86 Mon Sep 17 00:00:00 2001
From: jason bonthron <6798494+bonthron@users.noreply.github.com>
Date: Wed, 7 Feb 2024 20:20:15 -0500
Subject: [PATCH] new
---
README.md | 13 +++++++++++++
view-kill.el | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+)
create mode 100644 README.md
create mode 100644 view-kill.el
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..1889aa8
--- /dev/null
+++ b/README.md
@@ -0,0 +1,13 @@
+# view-kill
+
+Very simple but extemely useful emacs script for viewing your kill ring.
+
+view-kill \
+Displays the entire kill ring as a single menu of numbered items. \
+Select a number to insert that item into your current buffer. \
+Use <SPACE> to scroll. \
+Note: the length of your kill ring is controlled by the variable 'kill-ring-max'.
+
+Just copy to your .emacs file.
+
+https://www.emacswiki.org/emacs/view-kill.el
diff --git a/view-kill.el b/view-kill.el
new file mode 100644
index 0000000..b7ced73
--- /dev/null
+++ b/view-kill.el
@@ -0,0 +1,50 @@
+;; VIEW-KILL
+
+;; Displays the entire kill ring as a single page of numbered items.
+;; Select a number to insert that item into your current buffer.
+;; Use to scroll.
+;; The length of the kill ring is controlled by the variable `kill-ring-max';
+
+
+(defun view-kill ()
+ (interactive)
+ (save-excursion
+ (save-window-excursion
+ (let ((working-buffer (current-buffer))
+ (new-buffer (get-buffer-create "kill-ring-view"))
+ (count 0)
+ (custom-map (copy-keymap minibuffer-local-map))
+ (selection nil)
+ )
+ (unwind-protect
+ (progn
+ (define-key custom-map " " 'scroll-other-window)
+
+ (switch-to-buffer new-buffer t)
+ (delete-other-windows)
+
+ (dolist (x kill-ring)
+ (insert (concat "----- "
+ (number-to-string count)
+ " -----"))
+ (newline)
+ (insert x)
+ (newline)
+ (newline)
+ (setq count (+ count 1))
+ )
+ (goto-char (point-min))
+
+ (let ((choice (read-from-minibuffer "choose: " nil custom-map t nil "x")))
+ (and (numberp choice)
+ (< choice count)
+ (progn
+ (set-buffer working-buffer)
+ (insert (nth choice kill-ring))
+ (setq selection choice)
+ ))
+ ))
+ (kill-buffer new-buffer) ; unwind-protect clean-up form
+ )
+ selection
+ ))))
--
2.45.2