unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: 9406@debbugs.gnu.org
Cc: Thierry Volpiatto <thierry.volpiatto@gmail.com>
Subject: bug#9406: 24.0.50; Use M-p/M-n to navigate through the kill ring
Date: Thu, 01 Sep 2011 20:39:20 -0400	[thread overview]
Message-ID: <jwvfwkh61f0.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87zkiphcqw.fsf@gmail.com> (Thierry Volpiatto's message of "Wed,  31 Aug 2011 16:33:27 +0200")

>> Why "free" the M-y binding if it means jailing M-n and M-p?

You didn't read me right: I only pointed out that *if/when* M-p/M-n is
used as suggested, then M-y can be freed.

>> M-y does nothing useful unless preceded by C-y today, so in that
>> sense it's already "free".

That's true, except that the current implementation occupies the M-y
binding all the time.

> It's so convenient to have a kill-ring browser, i don't understand why
> Emacs have not one and continue cycling blindly to find something in
> kill-ring...

It's already been suggested, and I agree it's a good idea.
I.e. patches welcome for Emacs-24.2.  But most likely I'd only accept
such a patch if the "kill-ring browser" uses a more-or-less standard
"minibuffer with completion".  OTOH it'd be OK for that patch to include
some changes to minibuffer.el, if needed.  FWIW, here's the code I'm
using right now.


        Stefan


(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))





  parent reply	other threads:[~2011-09-02  0:39 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-30 11:39 bug#9406: 24.0.50; Use M-p/M-n to navigate through the kill ring Dani Moncayo
2011-08-30 12:08 ` Juri Linkov
2011-08-30 12:17   ` Dani Moncayo
2011-08-30 12:27     ` Juri Linkov
2011-08-30 18:13       ` Deniz Dogan
2011-08-30 18:48         ` Dani Moncayo
2011-08-31  6:22       ` Dani Moncayo
2011-08-31  9:51         ` Juri Linkov
2011-08-31 10:45           ` Dani Moncayo
2011-08-31 13:01         ` Stefan Monnier
2011-08-31 13:55           ` Deniz Dogan
2011-08-31 14:33             ` Thierry Volpiatto
2011-08-31 14:52               ` Deniz Dogan
2011-09-02  0:39               ` Stefan Monnier [this message]
2011-08-31 15:40             ` Dani Moncayo
2011-08-31 15:45               ` Deniz Dogan
2011-08-31 16:11               ` Drew Adams
2011-08-31 15:33           ` Dani Moncayo
2011-08-31 15:47           ` David De La Harpe Golden
2011-08-31 16:36             ` Juri Linkov
2011-08-31 21:18               ` Dani Moncayo
2011-09-01  8:42                 ` Juri Linkov
2011-09-01  9:13                   ` Dani Moncayo
2011-09-01  9:53                     ` Antoine Levitt
2011-09-01 10:28                       ` Dani Moncayo
2011-09-01 13:22                     ` Juri Linkov
2011-09-01 14:44                       ` Dani Moncayo
2011-09-01 19:59                         ` David De La Harpe Golden
2011-09-01 21:56                           ` Dani Moncayo
2011-09-02  1:24                             ` David De La Harpe Golden
2022-04-27 14:21   ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvfwkh61f0.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=9406@debbugs.gnu.org \
    --cc=thierry.volpiatto@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).