From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: Xref completion Date: Sun, 6 Dec 2020 23:01:36 +0200 Message-ID: <11d0db3c-1fb4-9eca-850d-96e86387f676@yandex.ru> References: <873617ets1.fsf@ambrevar.xyz> <878sazzsw5.fsf@mail.linkov.net> <7593e751-cff0-7c1a-7d4c-f927a16c07c9@yandex.ru> <3b255b14-6494-99dc-1e78-9607e0d1fcd9@yandex.ru> <87tut351ea.fsf@mail.linkov.net> <9bbe9827-8e96-e45c-2e0f-23a4fb5aea33@yandex.ru> <87pn3q8ulz.fsf@mail.linkov.net> <7e7e6923-851f-c1c0-4816-d84debe6570b@yandex.ru> <4c25c3e2-4589-5036-9795-75d139e6b6cf@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26707"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 To: William Xu , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Dec 06 22:02:53 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 1km1BE-0006jB-IN for ged-emacs-devel@m.gmane-mx.org; Sun, 06 Dec 2020 22:02:52 +0100 Original-Received: from localhost ([::1]:56376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1km1BD-0000iM-KE for ged-emacs-devel@m.gmane-mx.org; Sun, 06 Dec 2020 16:02:51 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1km1A7-0000HB-Iv for emacs-devel@gnu.org; Sun, 06 Dec 2020 16:01:43 -0500 Original-Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]:45685) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1km1A5-00081F-FY for emacs-devel@gnu.org; Sun, 06 Dec 2020 16:01:43 -0500 Original-Received: by mail-ej1-x633.google.com with SMTP id qw4so16557005ejb.12 for ; Sun, 06 Dec 2020 13:01:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=xkCuMEXhPXvaAkhq+NBHMcFD0+WvT2oKBUB+gvQmAJQ=; b=O/HEEWJnRDICrarwwtJTMzReduwdcmOqn4YrV5HH7N+dmPrXozDdYZW09faKJIYQ1K LZdyq9h3aQY145AAmxshLEu4/5TTMrIT2DkNCi/X2LIq/KIaP7R5rIVeykd+HQw2pErV B5y24pK+OQQC05XOHpHRvpY3xmf+sJn0GjEIHLH1mWN0iH+DTdMTV+EZLylt/64xyyoi 6/LeJL4uxP+LtZauGtNv8vPhtmIAp/xeSqBP1VrFzMpw+OxJvUqMQB5lqsVEgulsvhJb XEzwKC7H4vsxRTdnhU/OFlYXT3pAEvs+7xNxhgresvTXT58m1+WAGapphFKv16vAFmGv 5KYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=xkCuMEXhPXvaAkhq+NBHMcFD0+WvT2oKBUB+gvQmAJQ=; b=Wzr41HVdP+laZ291l4D6zjPmVkYKM3aQaNyQyjakKFRmumz8eyy7k6n38+Ed5PUUK0 BP0/bIJiyKqSjWdrw/2dKH8uF8o18d59cdW3Tt4rix1ZrVdPffRCLufn7buJa63Oe7gv /2BZX7fuF5ukq+pSn8jy2wiiktbKLb8EfCxTONfhFezoTx1HwO5O11fH4l6egpVmHo6l ZQpuDLtWH4Xop/GkqYHswBS0wyoWmkvxP0tqqf0nvqiIGlPKHBZtwQhsZTRRHFuPzpGx VwpDbCz8uVFaHn8XCf4h0IcYgI6BoKviS1NXiHa77DyJTXjivhud3U2i9HUx6ZXPNIC0 Yl0g== X-Gm-Message-State: AOAM532Mb0fru/WXOc/9ScG/ysJXCjs2nyvGuZkfhY3OSm+a6VbiibsP GDLhIo5DP662OBYE2NkwNuKnO0LMxTv/Sg== X-Google-Smtp-Source: ABdhPJySggMkq8IH2SmRsDmOQ9hCjZe+CD9rdN3WXgZwK1uUIy0RrMBkzuD5KJ5Xu1c5G3JQcSKCuQ== X-Received: by 2002:a17:906:4705:: with SMTP id y5mr16261666ejq.112.1607288499291; Sun, 06 Dec 2020 13:01:39 -0800 (PST) Original-Received: from [192.168.0.4] ([66.205.71.3]) by smtp.googlemail.com with ESMTPSA id d9sm9777618edk.86.2020.12.06.13.01.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 06 Dec 2020 13:01:38 -0800 (PST) In-Reply-To: Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=raaahh@gmail.com; helo=mail-ej1-x633.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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:260457 Archived-At: On 06.12.2020 16:00, William Xu wrote: > Dmitry Gutov writes: > >> It could also be a limitation of the LSP protocol (looking at >> https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/#location, >> it doesn't have a field for "line text"). > > Would have been nicer if the protocol supports it, then one won't have > to look into the file manually. Someone should probably look into bringing that up to LSP folks, but even if successful, that's going to be a long process. >> But if so, maybe Eglot could visit the files preemptively and extract >> the line contents. Unlike some other operations, there's unlikely to >> be many results in that list, so it shouldn't take long. >> >> It seems to be trying to do something like this already: >> https://github.com/joaotavora/eglot/blob/master/eglot.el#L1927, maybe >> file a report for this particular case. > > Thanks for the info. My usecase is running the ccls via docker, so the > file path reported by ccls is inside the docker. No wonder Eglot fails > to find the file, thus falling back to so called "dumb strategy". IDK, if Eglot knows how to navigate to a file, it will know how to read a line from it. So it should be possible to add that behavior. What the performance is going to be, however, is something we'll only know after we try. > I could work around it by changing the file path: > > ---------------------------------8<------------------------------------- > (defun xwl-convert-to-docker-path (file) > (if (and (string-match "foo" (cdr (project-current))) > (string-match "^/usr/include/" file)) > (concat "/docker:foo:" file) > file)) > > (defun xwl-check-docker (orig-fun file &rest args) > (or (ignore-errors (apply orig-fun (cons file args))) > (apply orig-fun (cons (xwl-convert-to-docker-path file) args)))) > > (advice-add 'file-readable-p :around 'xwl-check-docker) > (advice-add 'insert-file-contents :around 'xwl-check-docker) > ---------------------------------8<------------------------------------- Advising these common functions looks suspicious to me. But hey, if it works, it works. You could also try editing the project via Tramp. Not sure if Eglot supports that (if it does not, adding support shouldn't be too hard), but apparently lsp-mode does.