FS#49864 - [emacs] Cut and paste to and from emacs buffers in virtual consoles (without X11) no longer works

Attached to Project: Arch Linux
Opened by Mike Dowling (mdowling) - Monday, 27 June 2016, 07:20 GMT
Last edited by Jürgen Hötzel (juergen) - Monday, 10 December 2018, 16:07 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Jürgen Hötzel (juergen)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

In virtual consoles WITHOUT X11 or graphics, the mouse can no longer be used to cut and paste to and from emacs buffers. Typically, I would use the mouse to cut and paste from the command line or other virtual consoles into an emacs buffer but this no longer works. instead, one sees the message: "x selection is unavailable for this frame", o, indeed for any other frame.

I have tested this with "emacs -q", thereby demonstrating that the problem does not lie with my .emacs init-file. But just to make sure, I created a new user with no configuration files at all, and I get the same response.

I have used a recursive zgrep on all .el.gz files in /use/share/emace/24.5 to find an elisp file containing that message but found none. I also attempted a grep on the output from "strings /usr/bin/emacs" but found no match.

The message is upsetting as it referrs to "x selection" although I am in a virtual (text) console without X11. This used to work! I don't kno when it stopped working.

Cut and paste with the mouse works fine using xterms and X11. Of course, for virtual consoles, gpm must be running. Cut and paste using the mouse works fine when
cutting and pasting to and from anything except emacs buffers.

Additional info:
* package version(s) emacs-24.5.1
* config and/or log files etc.
No log output; the problem is reproducible without any config files, emacs or otherwise.
The *Messages* buffer contains no extra information.

Steps to reproduce:
You can start without a .emacs file or with emacs -q in a text mode virtual console (no X11, no graphics). Enter
$ emacs
on the command line and you will see the emacs welcome page. Double click on any word, and paste with mouse-2. The paste will not work. Instead you will see the message "x selection is unavailable for this frame"

You get the same message regardless of the buffer, and regardles as to where you try to cut from.


I have checked with the emacs docs and can find no reference to the problem.

This might be an unfortunate feature where the emacs developers proceed on the assumption that nobody in their right mind these days would ever want to work without graphics mode. In which case, I would just have to accept the sad reality. But a mere confirmation of the problem by somebody would be of some benefit to me.
This task depends upon

Closed by  Jürgen Hötzel (juergen)
Monday, 10 December 2018, 16:07 GMT
Reason for closing:  Not a bug
Comment by Alif (alive4ever) - Thursday, 30 June 2016, 04:31 GMT
Works for me. (i3-wm, st terminal)

To enable mouse in tty (emacs -nw), one has to issue M-x 'xterm-mouse-mode'.
Then select the text using mouse and M-w to copy. Switch to buffer C-x b *scratch* and C-y to insert the copied text.
Comment by Alif (alive4ever) - Saturday, 02 July 2016, 06:01 GMT
Pardon my previous comment. I didn't pay attention to 'console without X' statement.

I've tried opening a virtual console on tty2 ( ctrl+alt+F2 ). Then I started gpm.service (via systemctl) to enable mouse movement in virtual console.

The result, I can select text on emacs (emacs -q -nw), killing some text (ctrl-w), copying text (M-w), and yanking from kill-buffer (C-y). Everything works as expected. I didn't enable 'xterm-mouse-mode' since the mouse is already works. Note that copying and pasting is done via keyboard. Using mouse click doesn't work at all.

About pasting into *GNU Emacs* buffer, it doesn't work because the buffer is 'read only'. Pasting into other non read-only buffer from killed text works fine, though (e.g. *scratch*).


Comment by Mike Dowling (mdowling) - Monday, 04 July 2016, 18:41 GMT
I have done some more research on this. I downloaded to emacs source code, and compiled it. In the emacs-24.5/src/xselect.c there are two places where "X selection unavailable in the frame' occurs, and it is the second on on line 2008 that is responsible for the error. Commenting this, however, results in segmentation faults when attempting a cut-and-paste. This code segment first appears in version 24. I did not actually install my self compiled emacs; it sufficed merely to call the binary in the src subdirectory.

Yes, killing text and yanking it again works. Mouse can be used withing virtual consoles; this has been possible from 1980s. It works on the consoles themselves, and for the vi editor, and pretty much anything capable of editing, except emacs.

Now for something strange; for a while starting emacs hung for quite a while. Eventually, it would start. This problem can occur in X11 and virtual consoles. I noted that some elisp files were read-only for root; I fixed that, and it appeared to solve the problem. But it has not. Sometimes emacs will start quickly, and at other time it can take a minute or so. The problem also occurs with 'emacs -q'. Using strace, I could see that emacs was waiting for some resource, but wich resource, I could not determine.

The connection? When it hangs and I am impatient, Ctrl-G. When I do that, prest, cut and paste works once again in virtual consoles! Also, when I interrupt whatever emacs is doing on a vconsole, I cannot use the mouse to operate the scroll-bar; if I wait patiently, then even the scroll-bar works in the vconsole. Just now cut-and-paste.

Finally, the error message itself I find unsettling. Why "X selection" in a vconsole? Worse, vconsoles don't have frames; frames only exist in graphics modes. For me, it looks like an emacs bug but I could be wrong. It is strange that you cannot reproduce this.
Comment by Alif (alive4ever) - Monday, 04 July 2016, 20:40 GMT
With TERM=xterm on virtual console, Emacs (emacs -q -nw) starts slowly. Emacs kill buffer doesn't work with mouse selection, but right click (gpm) when selecting text pastes the selected text into cursor position. I think mouse selection doesn't intercepted by Emacs when TERM=xterm in linux virtual console. I didn't see 'X selection unavailable' message, though. I only found 'The mark is not set now, so there is no region' when attempting to put selected text in killbuffer (M-w).

When I reset the virtual console TERM variable to 'linux' (TERM=linux; reset), Emacs (emacs -q -nw) started fast and there was no bug with emacs kill buffer with mouse selection. The only thing I encounter is the right mouse button (gpm) doesn't paste the selected text, but I think it's okay since the text selection is affecting cursor/mark position. M-w and C-y is needed to put selected text into emacs killbuffer and pasting the killbuffer into cursor/mark position.

Have you checked any of shell startup files (.bashrc, .profile, .zshrc, etc) that forces TERM variable to be set to some value?
Comment by Mike Dowling (mdowling) - Tuesday, 05 July 2016, 09:45 GMT
I created a new user "Joe" and gave him no configuration files at all. No .bashrc, no .profile nor .emacs. What is more I have never applied system wide configurations like /etc/Rashrc. Yet "joe" also cannot cut and paste to and from an emacs buffer on a vconsole.

I increasingly suspect a bug in emacs. The error message appears to refer to X11 properties ("X selection", "frams") when no X11 is running. Moreover, traditionally there were two modes of selection: PRIMARY and SECONDARY, but as of emacs version 24 a third one has been created, namely CLIPBOARD that is suppoed to work more intuitively with desktop software.

Since I get the problem with a freshly compiled version, I deduce that this is probably not an Arch problem. But it is so strange that I can reproduce this error in so many ways, with and without .emacs, or configured environment variables (beyond those that are automatically defined by Arch) and yet nobody else can reproduce it.
Comment by Alif (alive4ever) - Saturday, 09 July 2016, 06:06 GMT
I created a new archlinux disk image containing 'base base-devel gcc-multilib grub emacs', booted it via qemu without kvm. Created a standard user. Started the gpm service. Mouse worked fine without any additional tweaks. I didn't encounter 'X selection unavailable' crap.

This is just my effort to reproduce the problem. I don't know if mdowling can reproduce the problem inside a qemu/virtualbox vm.
Comment by Mike Dowling (mdowling) - Saturday, 09 July 2016, 14:41 GMT
OK, it look as if I'll have to re-install Arch. Thanks very much for your support. I'll be away from the Internet over the next 6 weeks anyways, so please close this ticket. (Yes, Really! No Internet for 6 weeks!) When I get back, I'll re-install Arch Linux and will probably find that it all works as it should.

Thanks again,
Mike Dowling
Comment by Mike Dowling (mdowling) - Saturday, 09 July 2016, 14:47 GMT
OK, it look as if I'll have to re-install Arch. Thanks very much for your support. I'll be away from the Internet over the next 6 weeks anyway, so please close this ticket. (Yes, Really! No Internet for 6 weeks!) When I get back, I'll re-install Arch Linux and will probably find that it all works as it should.

Thanks again,
Mike Dowling
Comment by Mike Dowling (mdowling) - Sunday, 28 August 2016, 09:32 GMT
Well, the problem did not lie with the emacs binary. That much I do know. What is more, I can avoid the problem even though I don't understand it.

I compute between Braunschweig an Hamburg, and have Arch Linux computers in both cities, each acting ad a backup og the other. In Braunschweig, I had installed some elisp packages. My site-lisp directory had therefore been altered in Braunschweig. Starting emacs with the -q flag ought not to use the site-lisp directory, surely? But in Braunschweig I still had the problems. I compile my own emacs, still the problems. Go to Hamburg, no problem. Rename the Hamburg site-lisp, and unpack my Braunschweig version, and bingo; the same problem as Braunschweig.

So, successively delete the new packages until only the older ones were left; still the problem. Change tactic; restore the Hamburg site-lisp, and successively add the new packages. Strangely, no problems.

I do not understand this, but the problems have gone away.

Thanks again for the help. (I feel somewhat silly after all this.)

Cheers,
Mike Dowling
Comment by Jürgen Hötzel (juergen) - Sunday, 18 September 2016, 14:52 GMT
Could you reevaluate using the emacs 25.1-1 release?
Comment by Stefan Husmann (stefanhusmann) - Saturday, 08 December 2018, 17:54 GMT
As far as I understood this bgreport, the problem has been solved for the OP by reinstalling Arch. So IMHO this can be closed as "Not a bug", please.

Loading...