all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tassilo Horn <tassilo@member.fsf.org>
To: "Drew Adams" <drew.adams@oracle.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: when deleting in minibuffer, don't change kill-ring
Date: Fri, 28 Oct 2011 08:53:04 +0200	[thread overview]
Message-ID: <877h3pli9b.fsf@thinkpad.tsdh.de> (raw)
In-Reply-To: <2E5FB92AF4854B6CB7774F5D671C3320@us.oracle.com> (Drew Adams's message of "Thu, 27 Oct 2011 14:53:31 -0700")

"Drew Adams" <drew.adams@oracle.com> writes:

>> I guess the OP means `backward-kill-word' (<M-backspace>) and
>> friends.  I'm also interested in something like that.  I want to use
>> the word, line, and region editing commands in the minibuffer, but I
>> don't want to have the killed text in the global kill-ring.
>
> I think you need deleting (non-killing) commands to remap the killing
> commands to:

Yes, that would be a possibility.

>> What I'd really like to have is a separate kill-ring for the
>> minibuffers.  I've tried
>> (dolist (b (buffer-list))
>>   (when (minibufferp b)
>>     (set-buffer b)
>>     (make-local-variable 'kill-ring)))
>> or entering a recursive edit
>>   M-: M-: (make-local-variable 'kill-ring) RET C-g,
>> but that doesn't have an effect. 
>
> Try doing it on `minibuffer-setup-hook' instead.
>
> (add-hook 'minibuffer-setup-hook
>           (lambda ()
>             (make-local-variable 'kill-ring)))

It doesn't work completely.  The good thing is that the kills I make in
the minibuffer are not in the global kill-ring anymore.  But when
reentering the minibuffer again, its value is again the global
kill-ring.

That looks to me as if on entering the minibuffer
`minibuffer-setup-hook' makes kill-ring buffer-local, but when the
minibuffer is left again, the buffer local variable is killed.

And in fact, advising `kill-all-local-variables' like so

--8<---------------cut here---------------start------------->8---
  (defadvice kill-all-local-variables (before bla activate)
    (message "killing all local vars of %s" (current-buffer)))
--8<---------------cut here---------------end--------------->8---

I get

  killing all local vars of  *Minibuf-1*
  killing all local vars of  *Minibuf-0*
  killing all local vars of  *Minibuf-1*

when leaving the minibuffer.

Using this advice, I think I finally got the intended behavior:

--8<---------------cut here---------------start------------->8---
(defadvice kill-all-local-variables (around th-keep-minibuffer-kill-ring activate)
  (let ((b (current-buffer)))
    (when (minibufferp b)
      (let ((kr kill-ring))
	ad-do-it
	(set (make-local-variable 'kill-ring) kr)))))
--8<---------------cut here---------------end--------------->8---

Now, when reentering the minibuffer I can yank the stuff I killed in
previous minibuffer sessions, and those kills don't show up in the
global kill-ring.

But why are the buffer-local variables of minibuffers forcefully killed,
anyway?

Bye,
Tassilo



  reply	other threads:[~2011-10-28  6:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-27 16:35 when deleting in minibuffer, don't change kill-ring filebat Mark
2011-10-27 16:52 ` Drew Adams
2011-10-27 18:23   ` Tassilo Horn
2011-10-27 18:38     ` Peter Dyballa
2011-10-27 19:08       ` Tassilo Horn
2011-10-27 21:53     ` Drew Adams
2011-10-28  6:53       ` Tassilo Horn [this message]
2011-10-28  7:10         ` Tassilo Horn

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

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

  git send-email \
    --in-reply-to=877h3pli9b.fsf@thinkpad.tsdh.de \
    --to=tassilo@member.fsf.org \
    --cc=drew.adams@oracle.com \
    --cc=help-gnu-emacs@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.