Bug 1161786 - emacs-24.4 adds extra spaces on copy/paste (in text-mode)
Summary: emacs-24.4 adds extra spaces on copy/paste (in text-mode)
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: emacs
Version: 21
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Petr Hracek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-11-07 21:22 UTC by Satish Balay
Modified: 2016-05-11 16:34 UTC (History)
5 users (show)

Fixed In Version: emacs-24.5-1.fc21
Clone Of:
Environment:
Last Closed: 2015-04-22 07:54:08 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Satish Balay 2014-11-07 21:22:46 UTC
Description of problem:
emacs-24.4 adds extra spaces/formatting when copy/pasting text with leading spaces

Version-Release number of selected component (if applicable):

emacs-24.4-2.fc21.x86_64

How reproducible:

Always

Steps to Reproduce:
1. start 'emacs -nw foo.txt'

2. copy/paste some multi-line text with spaces in front of some lines - for eg - the following text from my terminal:

$ wc gmakefile makefile 
  213   833  8681 gmakefile
  556  2956 28521 makefile
  769  3789 37202 total


Actual results:

emacs formats the text in the following way.

$ wc gmakefile makefile
  213   833  8681 gmakefile
    556  2956 28521 makefile
      769  3789 37202 total


Expected results: no extra spaces/formatting by emacs. i.e

$ wc gmakefile makefile 
  213   833  8681 gmakefile
  556  2956 28521 makefile
  769  3789 37202 total

Additional info:

No such issue existed with emacs-24.3-27.fc21.x86_64

Comment 1 Michael Schwendt 2014-11-08 09:49:02 UTC
Confirmed, but just for the -nw/--no-window-system mode.

Comment 2 Parag Nemade 2014-11-17 03:12:48 UTC
Yes reproduced easily. I want to add same note (as described in this bug) here that that if you have say 3 lines starting from column 0 and you copy them and paste again in front of any one of these lines then there is no issues. The issue arises when in a copied text any single line starts from non-zero column.

Comment 3 Petr Hracek 2014-11-18 11:17:45 UTC
Do you have any settings in your .emacs or .emacs.d file?

Like (setq-default tab-width 4) 
or 

(setq tab-width 4)
(setq tab-stop-list '(4 8))
(setq indent-tabs-mode nil)

Comment 4 Petr Hracek 2014-11-18 11:19:31 UTC
Hmm,
I have reproduced the problem too and I do not have any .emacs file.

I am gonna to report the problem to upstream.

Comment 5 Petr Hracek 2014-11-18 11:23:45 UTC
Upstream bug report:
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19093

Comment 6 Satish Balay 2014-11-18 17:01:14 UTC
Feature? ok. I'll just disable electric-indent-mode in my .emacs

(electric-indent-mode 0)

Comment 7 Petr Hracek 2014-11-19 12:53:58 UTC
Upstream would like to no how did you do "copy/paste" and what terminal do you used during the action.
Any hint?

Comment 8 Petr Hracek 2014-11-19 12:55:59 UTC
Upstream did the change in 24.5
http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=bfc3079

I can try to backported.
But testers are welcome.

Comment 9 Satish Balay 2014-11-19 17:07:27 UTC
(In reply to Petr Hracek from comment #7)
> Upstream would like to no how did you do "copy/paste" and what terminal do
> you used during the action.
> Any hint?

$ echo $TERM
xterm

- login to gnome3 [on Fedora 21]
- start 2 gnome-terminals
- run "emacs -Q -nw foo.txt" in gnome-terminal-1
- run 'wc makefile gmakefile' in gnome-terminal-2
- copy text from gnome-terminal-2 using mouse [click - drag]
- paste text into gnome-terminal-1 [with emacs] using mouse middle-button.

Also - I see the same issue - if I use xterms - instead of gnome-terminals.

Note: my primary use case here is - I run "emacs -nw" as my e-mail editor [from alpine] - so I end up doing such copy/paste frequently.


(In reply to Petr Hracek from comment #8)
> Upstream did the change in 24.5
> http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=bfc3079
> 
> I can try to backported.
> But testers are welcome.

Sure - I can test [either from updates-testing - or a koji scratch build..]

Or you could consider defaulting 24.4 to use (electric-indent-mode 0). Presumably that was the default for 24.3?

Comment 10 Satish Balay 2014-11-20 21:58:46 UTC
I built emacs from git [both master branch - and emacs-24 branch with bfc3079 cherry picked] with options: --with-x-toolkit=no --with-xpm=no --with-gif=no

Both builds do not exhibit this copy paste issue.

Comment 11 Petr Hracek 2015-03-04 14:15:35 UTC
Hi Satin,

scratch build with backported patch is here:
http://koji.fedoraproject.org/koji/taskinfo?taskID=9136901

Could you please verify it?

Greetings
Petr

Comment 12 Satish Balay 2015-03-04 14:42:46 UTC
I don't see this problem with the scratch build.

Will continue to use it and see how it goes.

Comment 13 Satish Balay 2015-03-04 21:36:29 UTC
Now I see 'Ctrl-S' search - with a copy/paste string is misbehaving.

1. Ctrl-S

2. copy/paste some text to search.

3. Its inserted into the buffer - instead of into the 'search'/message bar

I've reverted back to emacs-24.4-3 with 

(electric-indent-mode 0)

Comment 14 Petr Hracek 2015-04-22 07:54:08 UTC
This should be solved in next emacs version 24.5.
If not please reopen bug again.

Comment 15 Satish Balay 2015-04-22 15:50:18 UTC
Here are my observations:

emacs-24.4-6.fc21.x86_64 (default)
- copy/paste spaces: fixed
- ctrl-s paste: broken

emacs-24.4-6.fc21.x86_64 (electric-indent-mode 0)
- copy/paste spaces: fixed
- ctrl-s paste: broken

[i.e the patch fixed 'copy/paste spaces' broke 'ctrl-s paste']

emacs-24.5-1.fc21.x86_64 (default)
- copy/paste spaces: broken
- ctrl-s paste: fixed

emacs-24.5-1.fc21.x86_64 (electric-indent-mode 0)
- copy/paste spaces: fixed
- ctrl-s paste: fixed

[i.e this was the state when I initially reported this issue with emacs-24.4-2.fc21.x86_64 - so the patch didn't get into emacs-24.5-1.fc21.x86_64?]

I'm happy enough with the current state [where both modes work with the option (electric-indent-mode 0) - so I'll leave this issue closed.

Comment 16 Galder Zamarreño 2015-04-24 15:50:33 UTC
Not only does this happen when copy/pasting stuff, but also when getting Emacs to auto-complete code for you. Very annoying default behaviour. See my post in http://emacs.stackexchange.com/questions/10896/avoid-extra-tabs-when-generating-haskell-code-with-ghc-mod

Comment 17 Satish Balay 2016-05-11 16:34:43 UTC
(In reply to Satish Balay from comment #15)
> Here are my observations:
> 
> emacs-24.4-6.fc21.x86_64 (default)
> - copy/paste spaces: fixed
> - ctrl-s paste: broken
> 
> emacs-24.4-6.fc21.x86_64 (electric-indent-mode 0)
> - copy/paste spaces: fixed
> - ctrl-s paste: broken
> 
> [i.e the patch fixed 'copy/paste spaces' broke 'ctrl-s paste']
> 
> emacs-24.5-1.fc21.x86_64 (default)
> - copy/paste spaces: broken
> - ctrl-s paste: fixed
> 
> emacs-24.5-1.fc21.x86_64 (electric-indent-mode 0)
> - copy/paste spaces: fixed
> - ctrl-s paste: fixed
> 
> [i.e this was the state when I initially reported this issue with
> emacs-24.4-2.fc21.x86_64 - so the patch didn't get into
> emacs-24.5-1.fc21.x86_64?]
> 
> I'm happy enough with the current state [where both modes work with the
> option (electric-indent-mode 0) - so I'll leave this issue closed.

Looks like this patch got its way into emacs-25.0.93-2.fc24.x86_64 and I see the broken 'ctrl-s' paste behavior.

Refiled the issue at: https://bugzilla.redhat.com/show_bug.cgi?id=1335247


Note You need to log in before you can comment on or make changes to this bug.