unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Harald Hanche-Olsen <hanche@math.ntnu.no>
Subject: Re: Ctrl-Y is pasting from the clipboard
Date: Tue, 19 Dec 2006 10:50:13 +0100	[thread overview]
Message-ID: <pco1wmwmcyy.fsf@shuttle.math.ntnu.no> (raw)
In-Reply-To: em7uff$j18$1@wildfire.prairienet.org

+ Dan Bensen <randomgeek@cyberspace.net>:

| Harald Hanche-Olsen wrote:
|> Nope.  We don't do telepathy here.
| Sometimes experience and insight are adequate substitutes.
|
|> Tell us what your code looks like, and maybe we can begin to guess
|> what happened.
| Here's the code in .emacs:
| (global-set-key "\C-xcy" 'clipboard-yank)
| (global-set-key "\C-xck" 'clipboard-kill-region)
| (global-set-key "\C-xcc" 'clipboard-kill-ring-save)
|
| I restarted both emacs and X, and it's still working.

Surely, restarting X was overkill.

| I can copy text from Firefox or a pdf file and paste it into emacs
| with either Ctrl-y or Ctrl-x c y.  I thought the emacs kill ring was
| different from the X clipboard.

Ah, now I get what you're driving at.  Yeah, they're different, but
there's magic in them thar functions.  Consider C-y, which is bound to
the command yank, defined in simple.el.  If you look at the definition
(easy: just C-h k C-y and click on the _simple_ link in the help
window) you will find that yank calls current-kill to get what it is
yanking, and current-kill in its turn will funcall
interprogram-paste-function, which is a variable that typically (on X)
has the value x-cut-buffer-or-selection-value.  And that function is
described as follows in x-win.el:

;;; Return the value of the current X selection.
;;; Consult the selection, and the cut buffer.  Treat empty strings
;;; as if they were unset.
;;; If this function is called twice and finds the same text,
;;; it returns nil the second time.  This is so that a single
;;; selection won't be added to the kill ring over and over.

In summary, if you set interprogram-paste-function to nil then I think
you have completely severed the connection between the kill ring and
the X selection, and then you will always have to make a conscious
choice between the two.  But that seems to be what you want.  Try it,
and see if it does what you want.  Heck, I may want to try it myself.

(No apology for the lengthy answer with such a brief solution.  I try
to educate people, teach them how to find answers on their own, rather
than just telling them the answer.  Occupational hazard.)

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
  when there is no ground whatsoever for supposing it is true.
  -- Bertrand Russell

  reply	other threads:[~2006-12-19  9:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-18 18:16 Ctrl-Y is pasting from the clipboard Dan Bensen
2006-12-18 18:51 ` Harald Hanche-Olsen
2006-12-19  5:52   ` Dan Bensen
2006-12-19  9:50     ` Harald Hanche-Olsen [this message]
2006-12-22  5:26       ` Dan Bensen
2006-12-19 11:16     ` Johan Bockgård
2006-12-22  5:37       ` Dan Bensen
2006-12-22 13:00         ` Dieter Wilhelm
     [not found]         ` <mailman.2217.1166792441.2155.help-gnu-emacs@gnu.org>
2006-12-22 14:46           ` Dan Bensen

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=pco1wmwmcyy.fsf@shuttle.math.ntnu.no \
    --to=hanche@math.ntnu.no \
    /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.
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).