help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ctrl-Y is pasting from the clipboard


From: Harald Hanche-Olsen
Subject: Re: Ctrl-Y is pasting from the clipboard
Date: Tue, 19 Dec 2006 10:50:13 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.0 (berkeley-unix)

+ Dan Bensen <address@hidden>:

| 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 via email to

[Prev in Thread] Current Thread [Next in Thread]