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: Wed, 16 Dec 2020 16:34:38 +0100 Message-ID: <87tuslzrw1.fsf@gmx.de> References: <193e76e900f64f01a39893b12cf7c4ff@3ds.com> <871rfw900w.fsf@gmx.de> <87sg8c7i5w.fsf@gmx.de> <4f2b42e36d924f83883e120e601d40f7@3ds.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14536"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: "emacs-devel@gnu.org" To: APEL Martin Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 16 16:37:51 2020 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 1kpYsA-0003gy-PU for ged-emacs-devel@m.gmane-mx.org; Wed, 16 Dec 2020 16:37:50 +0100 Original-Received: from localhost ([::1]:40794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kpYs9-0006ml-OV for ged-emacs-devel@m.gmane-mx.org; Wed, 16 Dec 2020 10:37:49 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpYpG-0004Fh-41 for emacs-devel@gnu.org; Wed, 16 Dec 2020 10:34:50 -0500 Original-Received: from mout.gmx.net ([212.227.15.18]:60615) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kpYpB-0001jy-AZ for emacs-devel@gnu.org; Wed, 16 Dec 2020 10:34:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1608132880; bh=lVV3Q74D2j9jg0MgyC4jzEQqPEknafmzU+X+hmK+eeI=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=j5SouMf7LGZZePNaR3ph4pTAE2Rax7hAstrN10N/QDOazzkobYzHMHTEKQhxU9UeV UcYALrVQKJjg7fSE6d0h0gRzEUIlMLMDQ+O6hFcKNS0CyK9tifX6imnlA0ox9K/YHF tbe/dFyX51DbKxuPIBc+Cq7xaiaQIctIXwLQbSE4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from gandalf.gmx.de ([79.140.118.184]) by mail.gmx.com (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MhlKs-1kC7Oq09MO-00dllf; Wed, 16 Dec 2020 16:34:40 +0100 In-Reply-To: <4f2b42e36d924f83883e120e601d40f7@3ds.com> (APEL Martin's message of "Fri, 11 Dec 2020 11:29:09 +0000") X-Provags-ID: V03:K1:euTOCXw9//g99ZThTmQm8bxLYqjceVwpacwv8/D/jn765dolISd SwlELoJx8wdqnrR4MWKCArmWaKqhkpYYboYZxtZ98mwQzPBsKm0TT+7REOpkeqskEq7fTOI K85bkoa1bY09/zgOhTcin9q5/aUMPfU79rbZ5fJuvzlhhbKoZuXNgoTatyz4dP4AmXV2CRp 1spz0pFwylTnXiMxuOj9Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:mVNem0g+Gic=:7DmqbqaG2q4IVNKCvqCqvQ ovdF6V8a9mej07PA6fUU/XsYk7QzHlLIKV6dcFrOiKSRo4IkS9V//gpT+Ul+z2dj+JRGlTvWJ 8Xoatn3kH/fRteisx3gpLtJAVGA84g8srGik8wJPFr18GvIkpzRNt0+v1HC9vstNy0VcG90Z+ ODm+a+XxDJruvk58vlRFjtfcPtfBMPrB/VlnjbXZGUnH03NMA7HaPeYuOgZ/vhd6pyJaJO2Sh uWK8w9/peLRd1nrwtHPux8Arv8M78HGoG0osDYEJH/hiS79GOaU0ZRzP54bk/pTJn6Ork7nZx wQGX0LSQCJmhT1yBUJYn7iWssmUzbnm47kvH/tfyZU7lEGrRJKtvUPoiT6+ZR9tDRTksRF1n+ Tg3TYDQNh+iaiRikrlnsX9nChcosZd/etPreqKbqoYViWRIzNuYskR5leBLSZFmNkArrM/9CY nQ/ipmrtTgi6mWlG0u50/fZR+UBp4tS9cdWdfMtOr1MTrroO0UDpN0vnP2VhmXlCPbj3NgcUe CdxGwbB388JH03op/aVzhy5voa1qVwuZB4pWhQwpaw824N86RQbGptQD9cENZrpD1ABuP5r4I zWWfRwtY76CLLECLkjJ/99Fxo2MqkJvAhnuKQ7M1Sibu1Pp5/dq+ENDkM9vc1eFbHXpEckEg1 gBkbV8StZ8AvwEKDQJ7U7vHHDq76zKWeFyzCJ8DAj0Kgh1u9KjFBvGDqTyUIbWcCefZeGfcUp bVaA/1PtUx6ncZB7KhbB5q9/XcLHDkxBqt4cPtfPEeWS4g4ScWyNzdLgtT3V6sKtvuTzfNg2 Received-SPF: pass client-ip=212.227.15.18; envelope-from=michael.albinus@gmx.de; helo=mout.gmx.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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:260998 Archived-At: APEL Martin writes: > Hi Michael, Hi Martin, > 6. Now try to open the main.cpp file on the remote machine in Emacs on > the local machine. This should trigger the start of clangd via > lsp-mode. If the error occurs, the modeline shows 'clangd starting' > forever. Well, I don't belive it is eol conversion. With some more stderr redirection, I could see that the local process sends --8<---------------cut here---------------start------------->8--- Content-Length: 2134 {"jsonrpc":"2.0","method":"initialize","params":{"processId":null,"rootPath= ":"/home/albinus/tmp/minicpp","clientInfo":{"name":"emacs","version":"GNU E= macs 28.0.50 (build 28, x86_64-pc-linux-gnu, GTK+ Version 3.24.23, cairo ve= rsion 1.16.0)\n of 2020-12-15"},"rootUri":"file:///home/albinus/tmp/minicpp= ","capabilities":{"workspace":{"workspaceEdit":{"documentChanges":true,"res= ourceOperations":["create","rename","delete"]},"applyEdit":true,"symbol":{"= symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20= ,21,22,23,24,25,26]}},"executeCommand":{"dynamicRegistration":false},"didCh= angeWatchedFiles":{"dynamicRegistration":true},"workspaceFolders":true,"con= figuration":true},"textDocument":{"declaration":{"linkSupport":true},"defin= ition":{"linkSupport":true},"implementation":{"linkSupport":true},"typeDefi= nition":{"linkSupport":true},"synchronization":{"willSave":true,"didSave":t= rue,"willSaveWaitUntil":true},"documentSymbol":{"symbolKind":{"valueSet":[1= ,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hier= archicalDocumentSymbolSupport":true},"formatting":{"dynamicRegistration":tr= ue},"rangeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegist= ration":true,"prepareSupport":true},"codeAction":{"dynamicRegistration":tru= e,"isPreferredSupport":true,"codeActionLiteralSupport":{"codeActionKind":{"= valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","r= efactor.rewrite","source","source.organizeImports"]}}},"completion":{"compl= etionItem":{"snippetSupport":false,"documentationFormat":["markdown"],"reso= lveAdditionalTextEditsSupport":true},"contextSupport":true},"signatureHelp"= :{"signatureInformation":{"parameterInformation":{"labelOffsetSupport":true= }}},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"hove= r":{"contentFormat":["markdown","plaintext"]},"foldingRange":{"dynamicRegis= tration":true},"callHierarchy":{"dynamicRegistration":false},"publishDiagno= stics":{"relatedInformation":true,"tagSupport":{"valueSet":[1,2]},"versionS= upport":true}},"window":{"workDoneProgress":true}},"initializationOptions":= null,"workDoneToken":"1"},"id":1} --8<---------------cut here---------------end--------------->8--- Both on the remote side, running "clangd --log=3Dverbose", we see only --8<---------------cut here---------------start------------->8--- I[16:18:53.667] Ubuntu clangd version 11.0.0-2 I[16:18:53.667] PID: 269465 I[16:18:53.667] Working directory: /home/albinus/tmp/minicpp I[16:18:53.667] argv[0]: clangd I[16:18:53.667] argv[1]: --log=3Dverbose V[16:18:53.667] User config file is /home/albinus/.config/clangd/config.yaml I[16:18:53.667] Starting LSP over stdin/stdout V[16:18:53.668] <<<=20 {"jsonrpc":"2.0","method":"initialize","params":{"processId":null,"rootPath= ":"/home/albinus/tmp/minicpp","clientInfo":{"name":"emacs","version":"GNU E= macs 28.0.50 (build 28, x86_64-pc-linux-gnu, GTK+ Version 3.24.23, cairo ve= rsion 1.16.0)\n of 2020-12-15"},"rootUri":"file:///home/albinus/tmp/minicpp= ","capabilities":{"workspace":{"workspaceEdit":{"documentChanges":true,"res= ourceOperations":["create","rename","delete"]},"applyEdit":true,"symbol":{"= symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20= ,21,22,23,24,25,26]}},"executeCommand":{"dynamicRegistration":false},"didCh= angeWatchedFiles":{"dynamicRegistration":true},"workspaceFolders":true,"con= figuration":true},"textDocument":{"declaration":{"linkSupport":true},"defin= ition":{"linkSupport":true},"implementation":{"linkSupport":true},"typeDefi= nition":{"linkSupport":true},"synchronization":{"willSave":true,"didSave":t= rue,"willSaveWaitUntil":true},"documentSymbol":{"symbolKind":{"valueSet":[1= ,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hier= archicalDocumentSymbolSupport":true},"formatting":{"dynamicRegistration":tr= ue},"rangeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegist= ration":true,"prepareSupport":true},"codeAction":{"dynamicRegistration":tru= e,"isPreferredSupport":true,"codeActionLiteralSupport":{"codeActionKind":{"= valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","r= efactor.rewrite","source","source.organizeImports"]}}},"completion":{"compl= etionItem":{"snippetSupport":false,"documentationFormat":["markdown"],"reso= lveAdditionalTextEditsSupport":true},"contextSupport":true},"signatureHelp"= :{"signatureInformation":{"parameterInformation":{"labelOffsetSupport":true= }}},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"hove= r":{"contentFormat":["markdown","plaintext"]},"foldingRange":{"dynamicRegis= tration":true},"callHierarchy":{"dynamicRegistration":false},"publishDiagno= stics":{"relatedInformation":true,"tagSupport":{"valueSet":[1,2]},"versionS= upport":true}},"window":{"workDoneProgress":true}},"initializationOptions":= null,"workDoneToken":"1"},"id":1 E[16:18:53.668] JSON parse error: [3:2132, byte=3D2134]: Expected , or } af= ter object property --8<---------------cut here---------------end--------------->8--- That is, both the Content-Length header is missing as well as the final "}". This is strange. I've tried to debug lsp-mode.el, but it is an 8200+ lines monster, and not documented well. However, lsp-tramp-connection uses start-file-process-shell-command, which means several shell calls in between. So I have rewritten this to the following code: --8<---------------cut here---------------start------------->8--- (defun lsp-tramp-connection (local-command &optional generate-error-file-fn) "Create LSP stdio connection named name. LOCAL-COMMAND is either list of strings, string or function which returns the command to execute." ;; Force a direct asynchronous process. (add-to-list 'tramp-connection-properties (list (regexp-quote (file-remote-p default-directory)) "direct-async-process" t)) (list :connect (lambda (filter sentinel name environment-fn) (let* ((final-command (lsp-resolve-final-function local-= command)) (_stderr (or (when generate-error-file-fn (funcall generate-error-file-fn nam= e)) (format "/tmp/%s-%s-stderr" name (cl-incf lsp--stderr-index)))) (process-name (generate-new-buffer-name name)) (process-environment (lsp--compute-process-environment environment-fn= )) (proc (make-process :name process-name :buffer (format "*%s*" process-name) :command final-command :connection-type 'pipe :coding 'no-conversion :noquery t :filter filter :sentinel sentinel :file-handler t))) (cons proc proc))) :test? (lambda () (-> local-command lsp-resolve-final-function lsp-= server-present?)))) --8<---------------cut here---------------end--------------->8--- With this, your test scenario works fine for me. Could you check how it fits in your environment? One disadvantage is, that direct asynch processes work only with the upcoming Tramp 2.5 (that's already in Emacs master), and it works only if the asynchronous process does not require password handling. The latter is true, if your ssh authentication is based on keys, or if you use Tramp's control master arguments (enabled by default). > Hope this helps, > > Martin Best regards, Michael.