From: "Drew Adams" <drew.adams@oracle.com>
To: "'Samuel Wales'" <samologist@gmail.com>,
"'Stefan Monnier'" <monnier@iro.umontreal.ca>
Cc: help-gnu-emacs@gnu.org
Subject: RE: how to get subsequent text copies to emacs kill ring?
Date: Thu, 16 May 2013 22:00:34 -0700 [thread overview]
Message-ID: <24A033FA61ED474DBA3996584BAA4A96@us.oracle.com> (raw)
In-Reply-To: <CAJcAo8vSNqMdK-1BqCzMuY_HRkyjdk0zrZsuQ+Y05QX4e51fVQ@mail.gmail.com>
> (setq save-interprogram-paste-before-kill t)
Thanks for pointing this out, Samuel! It seems to do just what I requested.
Dunno how I missed it.
Stefan, what does your local patch do differently from what this option does?
---
I think the option name and doc for this are a bit misleading, however.
The Emacs manual, at (emacs) `Clipboard', is almost OK about this. But it
suggests that the problem, in which copied text gets "lost" or "replaced", is
that the clipboard text is overwritten by a kill or a copy to the kill ring:
When an Emacs kill command puts text in the clipboard, the
existing clipboard contents are normally lost.
^^^^^^^^^
The problem is not that the _clipboard_ gets overwritten by a kill. It is that
the Emacs `current-kill', copied automatically from the clipboard (good), is
overwritten (replaced) by an Emacs kill or copy to the kill ring. (When you
yank (`C-y') you get the `current-kill'.)
IOW, the problem is about the opposite of what the doc says. It does not matter
to Emacs behavior that the clipboard gets overwritten. What matters here is
that the "current kill", which came from the clipboard, gets replaced when you
kill text.
This problem has to do with the fact that the clipboard text was never copied to
the `kill-ring' (the list variable). It gets treated as the (zeroth)
`current-kill', so an immediate `C-y' yanks it, but though it is called "current
kill" and it can be yanked it is not really on the `kill-ring'.
That is quite different from the behavior provided by `kill-ring-save' or
`copy-region-as-kill' - they add the text to `kill-ring', as well as making it
the `current-kill'.
A non-nil value of this option effectively copies the clipboard text to the
`kill-ring', just as `kill-ring-save' and `copy-region-as-kill' do. And that's
all it does, I think.
The option should perhaps have been called something like
`clipboard-to-kill-ring', `copy-clipboard-as-kill', `copy-clipboard-before-kill'
or `kill-copies-clipboard-first'. The name should, above all, say that it
causes the clipboard text to be copied to the kill ring.
A problem with such a (better) name could be that some people might think that
the clipboard text already gets copied to the kill ring anyway, without the
option, because of the curious behavior of `current-kill'. You can yank the
clipboard text (provided you do so immediately), but it is not on the
`kill-ring'.
IOW, it might not be clear to everyone that what `C-y' yanks is the
`current-kill', which is not necessarily the first item (or any item) in the
`kill-ring'.
The Emacs doc, at (emacs) `Yanking', makes that clear:
Emacs effectively treats "cut" or "copy" clipboard operations
performed in other applications like Emacs kills, except that
^^^^^^^^^^^^^^^^
they are not recorded in the kill ring.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Regardless of this possible confusion, the most important thing the option name
could suggest is that it causes the clipboard text to be added to the
`kill-ring'. Currently, the name does not convey that.
The current option name is also misleading because it can suggest that it
controls "pasting" in Emacs. I'm guessing the name was taken from "interprogram
paste function", but as used here the word "paste" is misleading, even for those
who might happen to know about "interprogram paste function".
The name can unfortunately suggest that this is about saving a _paste_ from
another program (before a kill). There is no such paste here. And even if
there were, what does it mean to save a paste?
What happens is that before a kill (and before a copy to the kill ring, which is
also important), the clipboard text is copied to the `kill-ring'. The doc
string should just say that:
Non-nil means copy clipboard text to kill ring before text you kill.
That is, when you kill or copy text to the kill ring, as its first
item, the clipboard text is put on the ring as the second (older)
item. You can thus yank it using `C-y M-y'.
It could also say this, which might not be obvious though it follows from what
has already been said:
Whatever is on the clipboard when you kill or copy in Emacs gets added
to the kill ring. It does not matter how long ago it was cut or
copied to the clipboard or by which program.
The doc string can go on to point out what happens if the value is nil, and that
you can always yank the clipboard text immediately:
If nil, clipboard text is not added to the kill ring. Whether nil or
non-nil, you can yank the text using `C-y' immediately after it is
added to the clipboard. But if nil then a subsequent kill or copy to
the kill ring overwrites the text as the current kill, so it is no
longer available to be yanked.
The doc string should also, like Emacs doc generally, speak of yanking, not
pasting, when it talks about yanking text in Emacs. And whatever this doc
string says about yanking text (i.e., `C-y M-y') should be only secondary.
The point of the option is to make sure that the clipboard text gets copied
(really) to the kill ring. What you do with text on the kill ring is secondary
here to the effect of the option.
next prev parent reply other threads:[~2013-05-17 5:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-16 14:59 how to get subsequent text copies to emacs kill ring? Paul K
2013-05-16 15:05 ` Peter Dyballa
[not found] ` <mailman.25922.1368716751.855.help-gnu-emacs@gnu.org>
2013-05-16 19:18 ` Michael Heerdegen
2013-05-16 20:16 ` Drew Adams
2013-05-17 0:22 ` Stefan Monnier
2013-05-17 1:38 ` Samuel Wales
2013-05-17 5:00 ` Drew Adams [this message]
[not found] ` <mailman.25948.1368735385.855.help-gnu-emacs@gnu.org>
2013-05-16 23:06 ` Joost Kremers
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=24A033FA61ED474DBA3996584BAA4A96@us.oracle.com \
--to=drew.adams@oracle.com \
--cc=help-gnu-emacs@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=samologist@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 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.