emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tramp and conversion of \r\n into \n


From: yyoncho
Subject: Re: Tramp and conversion of \r\n into \n
Date: Sat, 19 Dec 2020 11:18:42 +0200

Michael,

About the original issue: is it possible to avoid the issue using emacs 27.1(or older)? Asking the users to move to master branch is not very desirable since lsp-mode is used also by a lot of complete beginners. 

Thanks,
Ivan

On Thu, Dec 17, 2020 at 1:48 PM APEL Martin <Martin.APEL@3ds.com> wrote:
Hi Michael,

I built an Emacs version from the current master branch and tried it out:
lsp-mode works well with a remote clangd now. Unfortunately there are some other problems, which do not occur with Emacs 27.1 and which might be related to TRAMP:
- my remote compile setup does not work anymore. It seems that the arguments to the invoked compile command are lost on the way to the remote machine
- rgrep on a remote machine also does not work. It produces a list of files it intends to search instead of the grep output
- I also encountered an error message from TRAMP once. Unfortunately I restarted Emacs afterwards, so I don't have the exact error message. It was something about a recursive call detected and a sentinel was mentioned.

Best Regards,

Martin

> -----Original Message-----
> From: Michael Albinus <michael.albinus@gmx.de>
> Sent: 16 December 2020 16:35
> To: APEL Martin <Martin.APEL@3ds.com>
> Cc: emacs-devel@gnu.org
> Subject: Re: Tramp and conversion of \r\n into \n
>
>
> APEL Martin <Martin.APEL@3ds.com> 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":"GN
> U Emacs 28.0.50 (build 28, x86_64-pc-linux-gnu, GTK+ Version 3.24.23, cairo
> version 1.16.0)\n of 2020-12-
> 15"},"rootUri":"file:///home/albinus/tmp/minicpp","capabilities":{"workspac
> e":{"workspaceEdit":{"documentChanges":true,"resourceOperations":["crea
> te","rename","delete"]},"applyEdit":true,"symbol":{"symbolKind":{"valueSe
> t":[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]}},"exe
> cuteCommand":{"dynamicRegistration":false},"didChangeWatchedFiles":{"d
> ynamicRegistration":true},"workspaceFolders":true,"configuration":true},"te
> xtDocument":{"declaration":{"linkSupport":true},"definition":{"linkSupport":
> true},"implementation":{"linkSupport":true},"typeDefinition":{"linkSupport":
> true},"synchronization":{"willSave":true,"didSave":true,"willSaveWaitUntil":t
> rue},"documentSymbol":{"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,1
> 2,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hierarchicalDocumentSymbolS
> upport":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":
> {"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepar
> eSupport":true},"codeAction":{"dynamicRegistration":true,"isPreferredSupp
> ort":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","qui
> ckfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","sourc
> e","source.organizeImports"]}}},"completion":{"completionItem":{"snippetS
> upport":false,"documentationFormat":["markdown"],"resolveAdditionalTex
> tEditsSupport":true},"contextSupport":true},"signatureHelp":{"signatureInfo
> rmation":{"parameterInformation":{"labelOffsetSupport":true}}},"document
> Link":{"dynamicRegistration":true,"tooltipSupport":true},"hover":{"contentF
> ormat":["markdown","plaintext"]},"foldingRange":{"dynamicRegistration":tr
> ue},"callHierarchy":{"dynamicRegistration":false},"publishDiagnostics":{"relat
> edInformation":true,"tagSupport":{"valueSet":[1,2]},"versionSupport":true}}
> ,"window":{"workDoneProgress":true}},"initializationOptions":null,"workDo
> neToken":"1"},"id":1}
> --8<---------------cut here---------------end--------------->8---
>
> Both on the remote side, running "clangd --log=verbose", 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=verbose
> 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] <<<
>
> {"jsonrpc":"2.0","method":"initialize","params":{"processId":null,"rootPath":
> "/home/albinus/tmp/minicpp","clientInfo":{"name":"emacs","version":"GN
> U Emacs 28.0.50 (build 28, x86_64-pc-linux-gnu, GTK+ Version 3.24.23, cairo
> version 1.16.0)\n of 2020-12-
> 15"},"rootUri":"file:///home/albinus/tmp/minicpp","capabilities":{"workspac
> e":{"workspaceEdit":{"documentChanges":true,"resourceOperations":["crea
> te","rename","delete"]},"applyEdit":true,"symbol":{"symbolKind":{"valueSe
> t":[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]}},"exe
> cuteCommand":{"dynamicRegistration":false},"didChangeWatchedFiles":{"d
> ynamicRegistration":true},"workspaceFolders":true,"configuration":true},"te
> xtDocument":{"declaration":{"linkSupport":true},"definition":{"linkSupport":
> true},"implementation":{"linkSupport":true},"typeDefinition":{"linkSupport":
> true},"synchronization":{"willSave":true,"didSave":true,"willSaveWaitUntil":t
> rue},"documentSymbol":{"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,1
> 2,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hierarchicalDocumentSymbolS
> upport":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":
> {"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepar
> eSupport":true},"codeAction":{"dynamicRegistration":true,"isPreferredSupp
> ort":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","qui
> ckfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","sourc
> e","source.organizeImports"]}}},"completion":{"completionItem":{"snippetS
> upport":false,"documentationFormat":["markdown"],"resolveAdditionalTex
> tEditsSupport":true},"contextSupport":true},"signatureHelp":{"signatureInfo
> rmation":{"parameterInformation":{"labelOffsetSupport":true}}},"document
> Link":{"dynamicRegistration":true,"tooltipSupport":true},"hover":{"contentF
> ormat":["markdown","plaintext"]},"foldingRange":{"dynamicRegistration":tr
> ue},"callHierarchy":{"dynamicRegistration":false},"publishDiagnostics":{"relat
> edInformation":true,"tagSupport":{"valueSet":[1,2]},"versionSupport":true}}
> ,"window":{"workDoneProgress":true}},"initializationOptions":null,"workDo
> neToken":"1"},"id":1
>
> E[16:18:53.668] JSON parse error: [3:2132, byte=2134]: Expected , or } after
> 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 name))
>                                       (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.
This email and any attachments are intended solely for the use of the individual or entity to whom it is addressed and may be confidential and/or privileged.

If you are not one of the named recipients or have received this email in error,

(i) you should not read, disclose, or copy it,

(ii) please notify sender of your receipt by reply email and delete this email and all attachments,

(iii) Dassault Systèmes does not accept or assume any liability or responsibility for any use of or reliance on this email.


Please be informed that your personal data are processed according to our data privacy policy as described on our website. Should you have any questions related to personal data protection, please contact 3DS Data Protection Officer at 3DS.compliance-privacy@3ds.com<mailto:3DS.compliance-privacy@3ds.com>


For other languages, go to https://www.3ds.com/terms/email-disclaimer

reply via email to

[Prev in Thread] Current Thread [Next in Thread]