Subject: bug#29357: Cut and paste problems on Linux on a text virtual console no longer works

From: Stefan Kangas <[email-masked]>
Date: Fri, 14 Aug 2020 16:16:57 -0700

[Please use "Reply to all" so the discussion is in the bug tracker.]

Hi Michael,

Thanks for replying back with details.  I'm hoping that the information
you have provided will help someone who knows more about this stuff
investigate this.

Best regards,
Stefan Kangas

"Dr. Michael L. Dowling" <[email-masked]> writes:

> Hello Stefan!
>
> Thanks for  replying.  This  is an  old bug  report but  is nevertheless
> still valid.
>
> On Mon, Aug 10, 2020 at 09:14:36AM -0700, Stefan Kangas wrote:
>> "Dr. Michael L. Dowling" <[email-masked]> writes:
>
>> > The Report:
>> >
>> > If I  use X-windows, there is  no problem with cutting  and pasting from
>> > outside an emacs  buffer into an emacs buffer and  vice versa.  But this
>> > no  longer works  when  in a  text  console.  When  on  a Linux  virtual
>> > console, pasting into an emacs buffer results in the message:
>> >
>> > "No selection available"
>
> This continues to be the case to this day.
>
>> > Conversely, marking text in  an emacs buffer and pasting  into a virtual
>> > console yields no error, but it does not paste.
>
> This has apparently been fixed.  It now works.
>
> Of  course, cut-and-paste  never worked  when it's  from an  xterm to  a
> virtual console, and vice versa, and I have never expected it to.
>
>> How do you cut and paste in the Linux virtual console?  Are you using
>> gpm?
>
> Yes, I use gpm.
>
>> Could you please provide a recipe for reproducing this?
>
> Simple!
>
> /usr/lib/systemd/system$grep gpm *
> gpm.service:ExecStart=/usr/bin/gpm -m /dev/input/mice -t imps2
>
> However  I mark  that text,  for example,  with a  depressed left  mouse
> button on the '/'  of '/usr', and dragging the mouse  to '2' of 'imps2',
> and then  releasing the left button,  with a right button  click in this
> text as I write, I get that error.  The same goes for any other means of
> cutting and pasting, for example, simply  double clicking on a word, and
> pasting with a single right button click, the same error.
>
> (I copied this text using emacs; start a shell process in emacs, and cut
> and  paste using  emacs, works.   This  doesn't use  the mouse,  though,
> namely with the set-mark-command (C-SPC) and append-next-kill (M-C-w).)
>
>> >
>> > My tests were as follows:
>> >
>> >   1. Try emacs -q -- still does not work.
>> >   2. Set up a new user with no special  environment, just out of the box.  No .emacs file, and
>> >      no bash init files.  Same behaviour.
>> >   3. Now  the strange bit: login  using my normal userid  "mike" and change user  to the newly
>> >      created user "joe", and cut and paste works for joe.  ("su - joe" was used for that.)
>> >   4. Logout, and log back in again as joe (no su -; joe logs in from the
>> >      text terminal), cut and paste no longer works for joe, But change user user
>> >      using "su - mike", and it works for mike!
>
> I had forgotten about this.  So I made some more tests.
>
> Login from a virtual console as  "joe", and cut-and-paste does not work.
> (Joe  has  a  completely  empty  home  directory;  no  .bash*  except  a
> .bash_logout that deletes everything except .bash_logout)
>
> Login as "mike" and "su - joe" and it does work.
>
> Login as "mike" and "su - mike" and it doesn't work.
>
> Login as "joe" and "su - mike", and cut-and-paste works!!!
>
> Give "joe"  with ksh as  login shell  and login as  "joe", cut-and-paste
> doesn't work.
>
> It doesn't work for  root either when root logs in as  root on a virtual
> console.
>
> Weird!
>
> BTW, this  computer is not  one year old and  has a completely  new ARCH
> installation.
>
>> >   5. Is it a shell problem?  Change shell to zsh, same behaviour.
>> >   6. Login as mike  or joe, and call the bash  again.  Now I'm not in a  login shell, but same
>> >      behaviour, no cut and paste.
>> >
>> > I cannot say for sure that this is an emacs  problem.  It could be a Linux problem, or an Arch
>> > Linux problem.   It might even  be a shell  problem, although with  the above tests  that seem
>> > unlikely.
>>
>> Are you seeing this outside of Emacs?
>
> No!   Cut-and-paste  works  fine  everywhere else,  within  and  between
> virtual consoles, from virtual consoles to postgresql (psql), to python,
> etc, etc.  The (frustrating) odd man out is emacs.
>
> As I recall,  at the time cut-and-paste ceased to  work for emacs, there
> had been a major upgrade of emacs.
>
> There  is  something   about  that  initial  login   that  affects  that
> cut-and-paste.
>
> My Linux boots to text-mode virtual  consoles.  I manually start X using
> startx.  This might be one reason  why cut-and-paste works in X, just as
> it works when first logging in as another and changing user works.
>
> Cheers,
>
> Mike