unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Thomas Ross <thomasross@thomasross.io>
To: Michael Albinus <michael.albinus@gmx.de>, yyoncho <yyoncho@gmail.com>
Cc: APEL Martin <Martin.APEL@3ds.com>,
	"emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: Tramp and conversion of \r\n into \n
Date: Wed, 4 Aug 2021 21:46:02 -0400	[thread overview]
Message-ID: <3474731f-eada-8185-1a21-f337fd55b38b@thomasross.io> (raw)
In-Reply-To: <8736014u95.fsf@gmx.de>

Hi Michael,

> Understood. I will check, but I cannot promise anything. I still don't
> know, why the Content-Length line disappears with older Tramp. It is not
> (only) an eol conversion problem, I believe.

I looked into this a bit and it seems like this isn't a TRAMP-specific
issue.

Running this Elisp snippet (after evaling both these sexps, open the
"hexdump" buffer to see the output -- you may need to scroll up to
actually see it) shows you that the carriage return gets replaced with a
line feed by Emacs:

> (make-process :name "hexdump" :command '("hexdump" "-v" "-e" "/1 \"%02X\n\"") :buffer "hexdump")
> (process-send-string "hexdump" "abc\r\n")

on my system (Linux, Emacs 27.1):

> 61
> 62
> 63
> 0A
> 0A

Note that there's 61 ("a"), 62 ("b"), 62 ("c"), and two 0As (LF). The
first 0A should really be a 0D (CR). I believe this conversion is likely
done by the call to encode_coding_object inside send_process
(process.c), but I might be wrong. I would need to sit down and step
through the code with gdb to confirm.

In a previous email in this thread (2020-12-16), you wrote:

> That is, both the Content-Length header is missing as well as the final "}".

I don't think the Content-Length header is actually missing. I think
clangd doesn't print it (even with --log=verbose). If you use the
wrapper script that Martin provided, I think you will see it in the logs
for standard input. The actual issue is that instead of sending this to
the process (all literal newlines are for display only):

> Content-Length: 2134<CR><LF>
> <CR><LF>
> {<...JSON here...>}<LF>

Emacs replaces the CRs with LFs, which confuses clangd:

> Content-Length: 2134<LF><LF>
> <LF><LF>
> {<...JSON here...>}<LF>

I verified this by looking at the hexdump of /tmp/clangd-logs (which
contains the data lsp-mode passes to clangd over stdin using the wrapper
script Martin provided).

Let me know what you think. It would be awesome if we were able to track
this issue down and have this all work without the direct async
processes (since there are a bunch of limitations there).

Thanks,
Thomas.



  parent reply	other threads:[~2021-08-05  1:46 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11  7:46 Tramp and conversion of \r\n into \n APEL Martin
2020-12-11  9:15 ` Michael Albinus
2020-12-11  9:59   ` APEL Martin
2020-12-11 10:26     ` Michael Albinus
2020-12-11 11:29       ` APEL Martin
2020-12-11 11:52         ` Michael Albinus
2020-12-13 16:04           ` Michael Albinus
2020-12-15 11:37         ` Michael Albinus
2020-12-15 12:45           ` APEL Martin
2020-12-15 14:37             ` Michael Albinus
2020-12-15 18:45               ` Michael Albinus
2020-12-16  6:44                 ` APEL Martin
2020-12-16 15:34         ` Michael Albinus
2020-12-16 15:55           ` APEL Martin
2020-12-17 11:35           ` APEL Martin
2020-12-17 12:50             ` Michael Albinus
2020-12-18  7:48               ` APEL Martin
2020-12-18 12:35                 ` Michael Albinus
2020-12-18 12:56                   ` APEL Martin
2020-12-18 13:04                     ` Michael Albinus
2020-12-18 14:54                       ` APEL Martin
2020-12-18 15:00                         ` Michael Albinus
2020-12-18 15:10                           ` APEL Martin
2020-12-18 15:18                             ` Michael Albinus
2020-12-22 14:57                             ` Michael Albinus
2021-01-07 11:13                               ` APEL Martin
2020-12-19  9:18             ` yyoncho
2020-12-19 16:48               ` Michael Albinus
2020-12-20 14:03                 ` Michael Albinus
2021-08-05  1:46                 ` Thomas Ross [this message]
2021-08-05  6:16                   ` Eli Zaretskii
2021-08-07  2:08                     ` Thomas Ross
2021-08-05 14:10                   ` Stefan Monnier
2021-08-05 15:40                     ` Michael Albinus
2021-08-05 16:25                       ` Stefan Monnier
2021-08-06  7:13                         ` Michael Albinus
2021-08-06 14:46                           ` Stefan Monnier
2021-08-07 13:51                             ` Michael Albinus
2021-08-07 22:04                               ` Stefan Monnier
2021-08-08  6:13                                 ` PTYs vs. pipes for subprocesses [was: Tramp and conversion of \r\n into \n] tomas
2021-08-08 14:25                                 ` Tramp and conversion of \r\n into \n Michael Albinus
2021-08-12 18:47                                   ` Michael Albinus
2021-08-13 12:16                                     ` Michael Albinus
2021-08-07  2:07                     ` Thomas Ross
2021-08-07 13:54                       ` Michael Albinus
2021-08-08 14:29                         ` Michael Albinus
  -- strict thread matches above, loose matches on Subject: below --
2020-12-09  7:34 yyoncho
2020-12-10 13:44 ` Michael Albinus
2020-12-11 14:11   ` yyoncho

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3474731f-eada-8185-1a21-f337fd55b38b@thomasross.io \
    --to=thomasross@thomasross.io \
    --cc=Martin.APEL@3ds.com \
    --cc=emacs-devel@gnu.org \
    --cc=michael.albinus@gmx.de \
    --cc=yyoncho@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).