Is emacs broken?

Hey, I just managed to reproduce your error.

I notice the same, its only text lines with faces (ie: color) that have spaces to the end. Text w/o faces or color copy and pastes normally.

I tried xterm and urxvt, and a few terminal types. It is consistent. Emacs may have an issue with spaces when it's coloring text.

If I start xterm with the "trimSelection: true" configuration, I no longer get space.

xterm -xrm 'XTerm*trimSelection: true'

Or place that in your ~/.Xdefaults.
 
It absolutely makes a difference.
Okay, if it "absolutely" makes a difference, then would you please be so kind and tell us spefically what difference it does exactly make concerning this issue?
Because ...

The terminal type can change how Emacs and other TUI applications send data to the screen, and impact your paste. It can also impact how the terminal program interprets what it receives.

I'd suggest trying vt100, vt102, xterm and your xterm-256color and see if the behavior changes.
... I tried all this right at the beginning already, and didn't find a difference concerning that specific issue.

Some terminals vary in how they handle spaces to edge of screen. Ever had issues with line wrapping, or used alt-drag to select a box of text? This could be Emacs exposing a bug in the terminal program just as easily as it could be an Emacs bug.
As I think I mentioned somewhere before, it is a complex scenario, and pinpointing the issue to emacs is based on these two facts:
  1. in syntax highlighting mode emacs presents some lines in a way that trailing spaces get added, and other lines in a way that no trailing spaces are added. So obviousely emacs coding could be changed so that all the lines are presented in the same way, and
  2. not only xterm, but many of the well-known terminal emulators show that same behaviour. Therefore it is very unlikely that the problem is with xterm.
Have you tried different terminal emulators, or only xterm?
Just read above.
 

xterm has a toggle to trim whitespace off the end of a copy...
Ahh, now this one is indeed helpful!

This is not a solution, it is a workaround. Because, if you actually have trailing spaces written in your textfile (for whatever reason, as usually this is not wanted), then the X copy&paste is so accurate that it does actually copy such trailing spaces as-is! (This works with vi, it does not work with emacs)
And obviousely such really existing trailing space will also be removed by the trimSelection setting.

But when mainly emacs is used, this is now the best workaround so far.
 
Hey, I just managed to reproduce your error.

I notice the same, its only text lines with faces (ie: color) that have spaces to the end. Text w/o faces or color copy and pastes normally.
Yes, and only if the faces extend to EOL. (An end-of-comment in C will not show the effect).
Or, if you set-background-color, then you have it in every line.
 
Yes, and only if the faces extend to EOL. (An end-of-comment in C will not show the effect).
Or, if you set-background-color, then you have it in every line.
I found quite a few reports of other applications with similar issues, including Vim. The issue isn't just with Emacs.

I hope the trimSelection option solves the problem for you.
 

This seems to indicate that Vi(m) can have the same issue. I think the key here is full screen TUI apps may reasonably expect to control every character on the screen, and may have to fill them with spaces for presentation. That could break terminal copy/paste unless you trim the selection.

I'm glad the trimSelection helped! Happy Emacsing.
 
Back
Top