emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: kill-ring visualization


From: Juri Linkov
Subject: Re: kill-ring visualization
Date: Thu, 25 Mar 2010 19:29:57 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu)

> If you use a `substring' style completion, you're already closer (tho
> it's not a regexp-search).

Is the below what you mean?

I remember there were requests to reuse M-y to complete on the kill-ring
instead of signalling an error that the previous command was not a yank.

=== modified file 'lisp/simple.el'
--- lisp/simple.el      2010-03-23 23:25:12 +0000
+++ lisp/simple.el      2010-03-25 17:29:27 +0000
@@ -3216,9 +3216,21 @@ (defun yank-pop (&optional arg)
 When this command inserts killed text into the buffer, it honors
 `yank-excluded-properties' and `yank-handler' as described in the
 doc string for `insert-for-yank-1', which see."
-  (interactive "*p")
+  (interactive
+   (list
+    (if (not (eq last-command 'yank))
+       (let ((completion-styles '(substring)))
+         (completing-read "Yank from kill-ring: " kill-ring))
+      (barf-if-buffer-read-only)
+      current-prefix-arg)))
+
   (if (not (eq last-command 'yank))
-      (error "Previous command was not a yank"))
+      (yank (mod (abs (- (length (member arg kill-ring))
+                        (length kill-ring-yank-pointer)
+                        1))
+                (length kill-ring)))
+
+    ;; Otherwise, if last-command eq 'yank.
   (setq this-command 'yank)
   (unless arg (setq arg 1))
   (let ((inhibit-read-only t)
@@ -3238,7 +3250,8 @@ (defun yank-pop (&optional arg)
        ;; loop would deactivate the mark because we inserted text.
        (goto-char (prog1 (mark t)
                     (set-marker (mark-marker) (point) (current-buffer))))))
-  nil)
+    nil))
+
 
 (defun yank (&optional arg)
   "Reinsert (\"paste\") the last stretch of killed text.


PS: This patch is for the demonstration, not for installation.

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]