From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: William Xu Newsgroups: gmane.emacs.devel Subject: Re: Xref completion Date: Sun, 06 Dec 2020 15:00:53 +0100 Organization: the Church of Emacs Message-ID: 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 Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7796"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (darwin) To: emacs-devel@gnu.org Cancel-Lock: sha1:qOzIuhTfiqQ1to0gGarRNzSoo+o= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Dec 06 15:03:03 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 1klucw-0001sp-UR for ged-emacs-devel@m.gmane-mx.org; Sun, 06 Dec 2020 15:03:02 +0100 Original-Received: from localhost ([::1]:50390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1klucw-0008H2-0C for ged-emacs-devel@m.gmane-mx.org; Sun, 06 Dec 2020 09:03:02 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1klub5-0007RF-Pq for emacs-devel@gnu.org; Sun, 06 Dec 2020 09:01:08 -0500 Original-Received: from static.214.254.202.116.clients.your-server.de ([116.202.254.214]:57272 helo=ciao.gmane.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kluaz-0004yi-KE for emacs-devel@gnu.org; Sun, 06 Dec 2020 09:01:03 -0500 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1kluav-000AAX-Re for emacs-devel@gnu.org; Sun, 06 Dec 2020 15:00:57 +0100 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=ged-emacs-devel@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NML_ADSP_CUSTOM_MED=0.9, 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:260443 Archived-At: 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. > 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". 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<------------------------------------- -- William