From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.devel Subject: Re: Tramp and conversion of \r\n into \n Date: Thu, 12 Aug 2021 20:47:15 +0200 Message-ID: <87wnoqv6to.fsf@gmx.de> References: <193e76e900f64f01a39893b12cf7c4ff@3ds.com> <871rfw900w.fsf@gmx.de> <87sg8c7i5w.fsf@gmx.de> <4f2b42e36d924f83883e120e601d40f7@3ds.com> <87tuslzrw1.fsf@gmx.de> <7135a39a200c4f8397c8bddb9da8d3fc@3ds.com> <8736014u95.fsf@gmx.de> <3474731f-eada-8185-1a21-f337fd55b38b@thomasross.io> <87k0kzj3wr.fsf@gmx.de> <87a6lvhwpz.fsf@gmx.de> <875ywhicr4.fsf@gmx.de> <87r1f4rp29.fsf@gmx.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6530"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: APEL Martin , Thomas Ross , yyoncho , "emacs-devel@gnu.org" To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Aug 12 21:00:28 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mEFwK-0001Tj-GI for ged-emacs-devel@m.gmane-mx.org; Thu, 12 Aug 2021 21:00:28 +0200 Original-Received: from localhost ([::1]:53978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mEFl5-00019l-FN for ged-emacs-devel@m.gmane-mx.org; Thu, 12 Aug 2021 14:48:51 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mEFjr-0000SN-Pq for emacs-devel@gnu.org; Thu, 12 Aug 2021 14:47:35 -0400 Original-Received: from mout.gmx.net ([212.227.17.22]:50801) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mEFjp-0004gc-6B for emacs-devel@gnu.org; Thu, 12 Aug 2021 14:47:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1628794041; bh=UhyV7SyP77gtyeP4pTSIItfFB5ubRUVpioMRjY1FhvE=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=eVpw3968tFQruleLQfL+kRMzfcB/4kL22zO4T4Xza2W/mq0lQG1NqeCGQkgntdL1p +oqORIhHjUt2xvIccasbgrLIjQq2IQ9mmiH2PeUSR5Jm4pMDboUmevFScsjknxH0ST MLRBwEOMSUyYf0603O6V252zvYFEnXmZv+d/tABA= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from gandalf.gmx.de ([213.220.159.239]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MpDNf-1mtKpr1kCd-00qkVj; Thu, 12 Aug 2021 20:47:20 +0200 In-Reply-To: <87r1f4rp29.fsf@gmx.de> (Michael Albinus's message of "Sun, 08 Aug 2021 16:25:34 +0200") X-Provags-ID: V03:K1:K3xqtw5iL4LphaS+4veLsmMkm2xi7iLmeU0n/t0H38kjBAEEpCf wiOLYwC5UG0doi5VaKFCG+6y2o4LSlzVxg2+mo+aIXpP2qcerpk9qIuK5clBytAOxh68gqs TYMo6/6MXWFgmEfiuLghGm7itlnYBC3C+Lq4JqN3zY0Yefu65B4wAFDpmfjdYBWEB0vCmpj /xMlHi3fWBJwKLQFlD2cQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:vqU9AFBcxy4=:DKXNRRaf2v+eSL/PCIgK7r 93ZZOAjKdCypAbs65x7T09yazECWLzMLLlhAH9gmdqqTQds5RPosJOSpBt/j9T0Er9EhJ+QeM dWLrVdmY8El36EmWwYm8z1FGe07eISf85jr52pcTaU+45Y55zk8HLXB2GlHeDUFzQ8uQ2/sZw Ar+t1DkCrAPsfXmtxVvkJpS384ujAEVq++Jwcvd7VNx+SgPYs6eztSpr7jX1b+iFT9Hw1sPS7 G+KVBv39d14FJP74nhRIQSmMppZY15PLUybkj1Oz/xIvtIGfE7k9ULOPs82whZx3f1Dm2yCYm +9BwHYyLqBmnhr63X8cKtvKkQpXSViqk9GmZNb7+45W6Vf8gK+c4x7IfpURpGQRRQRZnBFmat NCtp2uRpTjUBTB05rHB5G2NswRxdx41NwkYr12JDwbJmyUbLk6XpCcyP1Ls2YwmgYmQO+yRCT oKka624Z5mJPWhf7so7JfW3PMVRddKtEOoa9bDypKbmpo2xHl9IW9AJKR/JBmJb7GlKARR5rk IG1MCZoDrcQynrRX0oDhQSxVOJR4daOyePkYZGoShdbFuZ0zKaqQIwyykOvg5NbxAv3uPg5hs cpY0k4aGsMI4uYiwlafI6QGF0LMc5fymaE3G5V2eqX8f8h+cHMnHNsG6U4VJHUdJyx8dSolPw R1pK48P1UbiBAPhfaQUXVkxIQPXukoSz/KjjygWHkpCuCsxuKZddq2RzjLPBDFFiYDKnjHFt0 qDaBas0dFOcjlReZxuU5/So9P8ChtFnZ8JBghH0KL1bIcXj57zwKvZ/4gnrr7xqi9g3Yby7K Received-SPF: pass client-ip=212.227.17.22; envelope-from=michael.albinus@gmx.de; helo=mout.gmx.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:272362 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable >> I guess if we wanted to more faithfully simulate a pipe, we'd have to >> send the process input via something like a base64 decoder and get the >> output via a base64 encoder: this way not only stdin/stdout is a pipe but >> we can protect ourselves from the way ttys can mess with some bytes (as >> seen in this thread) and also overcome some of the limits of some ttys >> when sending "large" amounts of data at a time (IIRC on some systems >> this can either freeze the tty or the tty may insert extra chars like >> ^A or some such; my memory says the macOS kernel was such a culprits >> some years ago). >> >> The cure way be worse than the disease, tho. > > Yes. > > Maybe we could play with "stty raw", when > (tramp-)process-connection-type is nil or 'pipe. It looks like "stty -icrnl" suppresses the \r\n conversion in a shell. I have adapted Tramp to send this command to a remote async process, when connection type is nil or 'pipe. The Tramp documentation has a new subsection now: --8<---------------cut here---------------start------------->8--- 6.5.7 Remote process connection type Asynchronous processes differ in the way, whether they use a pseudo tty, or not. This is controlled by the variable =E2=80=98process-connection-typ= e=E2=80=99, which can be =E2=80=98t=E2=80=99 or =E2=80=98pty=E2=80=99 (use a pseudo tty= ), or =E2=80=98nil=E2=80=99 or =E2=80=98pipe=E2=80=99 (don=E2=80=99t use it). TRAMP is based on running shells on the remote host, which require a pseudo tty. Therefore, it declares the variable =E2=80=98tramp-process-connection-type=E2=80=99, which carries this informa= tion for remote processes. Per default, its value is =E2=80=98t=E2=80=99. The name= of the remote pseudo tty is returned by the function =E2=80=98process-tty-name=E2= =80=99. If a remote process, started by =E2=80=98start-file-process=E2=80=99, sh= ouldn=E2=80=99t use a pseudo tty, this is emulated by let-binding this variable to =E2=80=98nil= =E2=80=99 or =E2=80=98pipe=E2=80=99. There is still a pseudo tty for the started proces= s, but some terminal properties are changed, like suppressing translation of carriage return characters into newline. The function =E2=80=98make-process=E2=80=99 allows an explicit setting b= y the =E2=80=98:connection-type=E2=80=99 keyword. If this keyword is not used, t= he value of =E2=80=98tramp-process-connection-type=E2=80=99 is applied instead. --8<---------------cut here---------------end--------------->8--- The Tramp test suite has been extended in order to test this, see tramp-test30-make-process. Committed to Emacs master, and will also be available with next Tramp 2.5.1.2 on GNU ELPA. Thomas, could you test this, again? I guess the following patch is all what's needed in lsp-mode: --=-=-= Content-Type: text/x-patch Content-Disposition: inline *** /home/albinus/.emacs.d/elpa/lsp-mode-20210802.619/lsp-mode.el.~1~ 2021-08-05 17:13:45.133161987 +0200 --- /home/albinus/.emacs.d/elpa/lsp-mode-20210802.619/lsp-mode.el 2021-08-12 20:41:28.232443184 +0200 *************** *** 6956,6962 **** (format "/tmp/%s-%s-stderr" name (cl-incf lsp--stderr-index)))))))) (process-environment ! (lsp--compute-process-environment environment-fn))) (let ((proc (start-file-process-shell-command process-name (format "*%s*" process-name) wrapped-command))) --- 6956,6963 ---- (format "/tmp/%s-%s-stderr" name (cl-incf lsp--stderr-index)))))))) (process-environment ! (lsp--compute-process-environment environment-fn)) ! (tramp-process-connection-type 'pipe)) (let ((proc (start-file-process-shell-command process-name (format "*%s*" process-name) wrapped-command))) --=-=-= Content-Type: text/plain Best regards, Michael. --=-=-=--