I get a weird bug and I am struggling to fix it.
The problem occur only when writing files over 2900 characters through ssh with tramp. The file is correctly sent in remote machine, but tramp-perl-decode-with-module hangs after saving the file. Here is the message where it hangs:
Decoding remote file '/plink:Session1:/home/user1/file' using 'tramp_perl_decode_with_module >%s'
It's strange because opening a file over 2900 characters is working fine (which use the same tramp-perl-decode-with-module method). and the file is correctly updated when I check it with on the remote machine. The only difference I noted is that the file lost is +x flag. I guess the problem occur at this stage.
That "2900" is so arbitrary precise that it should be a key of the answer. Apparently there was a bug in emacs when writing files with lines over 2900 characters, maybe there is a problem with windows changing the encoding and the newline characters are changed. But I checked with different encoding utf8-xxx and the problem still occurs. I don't know what else to do.
Tramp default method is set to plink, and use the session set in putty. I tried to use ssh since I have the binaries with no success unfortunately, it can't even connect to the remote machine.
If you know a workaround within emacs, what I do is saving file, chmod +x in remote then opening again in emacs. Or just use vim in remote machine. But it messing my workflow quite a bit. Having to deal with 2900 characters limitation for scripts is somewhat cool, but it's quite frustrating as well.
M-x tramp-bug
.