Subject: Re: bug#25145: 25.1; clipboard-yank and associated functions are broken

From: Stephane Chauveau <[email-masked]>
Date: Fri, 9 Dec 2016 14:53:49 +0100

On 12/09/2016 02:10 PM, Eli Zaretskii wrote:
>> From: Stephane Chauveau <[email-masked]>
>> Date: Fri, 9 Dec 2016 09:43:09 +0100
>>
>>
>> I noticed that the functions clipboard-yank, clipboard-kill-ring-save
>> and clipboard-kill-region are not accessing the gui clipboard as they
>> use to.
>>
>> In previous version those 3 functions were setting
>> x-select-enable-clipbard to enable the clipboard.
>>
>> They are now setting gui-select-enable-clipboard.
>>
>> The problem is likely related to the recent renaming of
>> x-select-enable-clibboard into select-enable-clipboard (so without a
>> gui- prefix).
>>
>> The variable gui-select-enable-clipboard is set in a few other places
>> but, as far as I can tell, it is never used for anything.
> Thank you for your report.  However, I don't think I understand what
> is it that doesn't work in Emacs 25.1 as you expect.  What you
> describe are simply indications of some redesign and reimplementation
> in this area, but the functionality definitely works for me.
>
> Could you perhaps give a recipe, starting from "emacs -Q", which
> reproduces the problems you are seeing, and describe the expected
> behavior and the actual one?  That would allow us to analyze the
> problems you see.

Here is the recipe.

This involved CLIPBOARD and PRIMARY buffer so on Linux X11

(1) Fill the CLIPBOARD and PRIMARY buffers with their respective name.
I use xsel but any other method should do

echo -n CLIPBOARD | xsel -b
echo -n PRIMARY | xsel -p

(2) Using emacs 24.3.1

emacs24 -Q --eval "(progn (setq x-select-enable-clipboard nil) (setq 
x-select-enable-primary nil)  (yank) )"

==> empty window as expected since PRIMARY and CLIPBOARD are both disabled

emacs24 -Q --eval "(progn (setq x-select-enable-clipboard nil) (setq 
x-select-enable-primary nil)  (clipboard-yank) )"

==> the content of CLIPBOARD is added to the scratch buffer

(3) The same commands using emacs 25.1.1 will always produce  an empty 
window.

As I tried to explain in my first email, the problem is that 
(clipboard-yank) is attempting to enable the clipboard by setting the 
variable gui-select-enable-clipboard:

(defun clipboard-yank ()
   "Insert the clipboard contents, or the last stretch of killed text."
   (interactive "*")
   (let ((gui-select-enable-clipboard t))
     (yank)))

However, this variable does not control the clipboard.
The proper variable name is select-enable-clipboard  or 
x-select-enable-clipboard