From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: kill-ring visualization Date: Thu, 25 Mar 2010 22:53:34 -0400 Message-ID: References: <87y6hib6vi.fsf@mail.jurta.org> <87aatwv12t.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1269572041 3588 80.91.229.12 (26 Mar 2010 02:54:01 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 26 Mar 2010 02:54:01 +0000 (UTC) Cc: Emacs development discussions To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 26 03:53:57 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1NuzgL-0008Uo-0S for ged-emacs-devel@m.gmane.org; Fri, 26 Mar 2010 03:53:57 +0100 Original-Received: from localhost ([127.0.0.1]:40089 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NuzgK-0002jq-E9 for ged-emacs-devel@m.gmane.org; Thu, 25 Mar 2010 22:53:56 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nuzg3-0002fe-3J for emacs-devel@gnu.org; Thu, 25 Mar 2010 22:53:39 -0400 Original-Received: from [140.186.70.92] (port=42309 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nuzg1-0002eq-LF for emacs-devel@gnu.org; Thu, 25 Mar 2010 22:53:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nuzfz-0004Gc-3l for emacs-devel@gnu.org; Thu, 25 Mar 2010 22:53:37 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.183]:16951 helo=ironport2-out.pppoe.ca) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nuzfz-0004GT-1U for emacs-devel@gnu.org; Thu, 25 Mar 2010 22:53:35 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAOK+q0tFpYrY/2dsb2JhbACbKXS+QoR9BIsd X-IronPort-AV: E=Sophos;i="4.51,311,1267419600"; d="scan'208";a="59083399" Original-Received: from 69-165-138-216.dsl.teksavvy.com (HELO pastel.home) ([69.165.138.216]) by ironport2-out.pppoe.ca with ESMTP; 25 Mar 2010 22:53:34 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 2315685F0; Thu, 25 Mar 2010 22:53:34 -0400 (EDT) In-Reply-To: <87aatwv12t.fsf@mail.jurta.org> (Juri Linkov's message of "Thu, 25 Mar 2010 19:29:57 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:122685 Archived-At: >> If you use a `substring' style completion, you're already closer (tho >> it's not a regexp-search). > Is the below what you mean? Yes. Here's my "not for installation" code, FWIW, Stefan --- lisp/simple.el 2010-02-16 14:40:45 +0000 +++ lisp/simple.el 2010-03-24 14:52:19 +0000 @@ -3115,7 +3197,7 @@ doc string for `insert-for-yank-1', which see." (interactive "*p") (if (not (eq last-command 'yank)) - (error "Previous command was not a yank")) + (call-interactively 'yank-browse) (setq this-command 'yank) (unless arg (setq arg 1)) (let ((inhibit-read-only t) @@ -3135,7 +3217,7 @@ ;; 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. @@ -3171,6 +3257,23 @@ (setq this-command 'yank)) nil) +(defun yank-browse () + "Browse the `kill-ring' to choose which entry to yank." + (interactive) + (minibuffer-with-setup-hook + (lambda () + (set (make-local-variable 'completion-styles) '(substring)) + ;; FIXME: use more separation between entries in *Completions*, + ;; somehow cleanup the \n in there as well. Maybe indent the + ;; entries a little bit. + (minibuffer-completion-help)) + (let* ((kills (delete-dups (append kill-ring-yank-pointer kill-ring))) + (entry (completing-read "Yank: " kills nil t)) + ) + (setq this-command 'yank) + (insert-for-yank entry)))) + + (defun rotate-yank-pointer (arg) "Rotate the yanking point in the kill ring. With ARG, rotate that many kills forward (or backward, if negative)."