From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tobias Rittweiler Newsgroups: gmane.emacs.bugs Subject: bug#45135: 28.0.50; [PATCH] Add option to print file names in *xref* buffer relative to project root Date: Sun, 27 Dec 2020 07:55:41 +0100 Message-ID: References: <6d6911b9-c604-1fca-3cd4-084a8880524f@yandex.ru> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000745c1905b76ca78c" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21134"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 45135@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 27 14:44:30 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1ktWLW-0005Oi-DS for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 27 Dec 2020 14:44:30 +0100 Original-Received: from localhost ([::1]:40690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ktWLV-0007Iy-Fv for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 27 Dec 2020 08:44:29 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ktWL4-0007Hf-FC for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2020 08:44:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48914) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ktWL4-0002p7-7X for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2020 08:44:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ktWL4-0007QX-38 for bug-gnu-emacs@gnu.org; Sun, 27 Dec 2020 08:44:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tobias Rittweiler Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Dec 2020 13:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45135 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 45135-submit@debbugs.gnu.org id=B45135.160907660128472 (code B ref 45135); Sun, 27 Dec 2020 13:44:02 +0000 Original-Received: (at 45135) by debbugs.gnu.org; 27 Dec 2020 13:43:21 +0000 Original-Received: from localhost ([127.0.0.1]:60458 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktWKO-0007P9-LA for submit@debbugs.gnu.org; Sun, 27 Dec 2020 08:43:21 -0500 Original-Received: from mail-qt1-f176.google.com ([209.85.160.176]:36826) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ktPyY-0005gh-Uz for 45135@debbugs.gnu.org; Sun, 27 Dec 2020 01:56:23 -0500 Original-Received: by mail-qt1-f176.google.com with SMTP id z20so5163223qtq.3 for <45135@debbugs.gnu.org>; Sat, 26 Dec 2020 22:56:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=e5QOcT9X7w9bFJJoDqSOe1tF5IN9LWw5C2kkT9PjKRU=; b=YI4oM0Rtv5t7hoGfPx8z7L5cDgdPYVR9RfKc5eYOAZ65RZVbbBniTfsBzvZMF+HW++ EFYnwQ1hEnZX8Tm+MUFSuKs/spu7SYirbhuppdX+24Q/fhVGK717JIvORwzDIHu58bZ+ ITQEaARun1TK6bIUm1RNaoUdp+cEUIDcYdr58Cqk1lktvqdgbiMIjVQ5ZUx2o9ARUJWe 9kQLYYmcIYWGsx/DLv/gtPyg2lPH517ToiFXV93JyBPPQ/jY4t75B3M+NGloncqBzCXx K+eQkImEBQq9FUeJImvepPk3buZpjlhEqJxlz7eikCZukBIb8aSYebiCv7tiG0RLIkNl Wxcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=e5QOcT9X7w9bFJJoDqSOe1tF5IN9LWw5C2kkT9PjKRU=; b=n53AZUadHOnN2nj5bqb7o0xwP2xGi9jZrNQa1CA1DF5fxBtt4O99LCqlx8V+Xg8Dtk FGrYskLgbOvusz1trgCOj+NOhgw5XLrKmaTFhChQYbniI130mEL+YFNqvN4nQRex2Ma6 cW/YZCdkT00g+iB3NZUcPHEcVSUJ9Em0WehLJz/NbWgmE7gVLRvuedFvoCfmRGlKX22A TqCusp/A8UcBpvnZSZ/lSkx/JJHFJ844UA2q5t66GzwyTCL39DB486u/ROfga57JpQqW +fqND3spAKsxTJClnkG5C48OtpTIMCpU7BaaM2giTbkWV2itfF1VXgj1QHgavUGH83Yi +6fg== X-Gm-Message-State: AOAM533cnP1YMD/P+G1uG2es+aZ5eCtjQ+RJ0nhcTivyuBnoTj6L6gR5 02FkDsNJimO8sgjzTfICePy/uSXCcWZUp/UHM+M= X-Google-Smtp-Source: ABdhPJxe/Y+r18lxgWYAYV4Nj+3ZuWmB9KTaklMkAda9oEkInnF1jJ0cTNRC/rV6j/+G8Qya87V1K/QiJaWx5Qvpg5M= X-Received: by 2002:ac8:6c2d:: with SMTP id k13mr39476265qtu.197.1609052177323; Sat, 26 Dec 2020 22:56:17 -0800 (PST) In-Reply-To: X-Mailman-Approved-At: Sun, 27 Dec 2020 08:43:18 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:196797 Archived-At: --000000000000745c1905b76ca78c Content-Type: text/plain; charset="UTF-8" On Sat, 26 Dec 2020 at 03:21, Dmitry Gutov wrote: > On 23.12.2020 04:16, Dmitry Gutov wrote: > > Re: patch 2, I have an idea that would make it a bit simpler and less > > coupled to project.el, but behave the same in the usual cases. Stay > tuned. > > Not as clean as I hoped, but here's something that should work just as > well, and a lot faster to boot (project-current lookup for every file > name is slow when there are a lot of matches, even if each individual > project-current call looks fast). > > We could remove the explicit dependency on the "current project" if it > was always passed in from the outside (e.g. by project-find-regexp's > setup), but we probably want this display mode to work with > xref-find-references as well. > > Also simplified the docstring a bit. > > Tobias, please try the attached patch. > Hi Dmitry, Thank you. I tested the patch and it works fine. Some comments on the patch itself: 1. 'xref--project-root' returns a project root if 'project-root' is fboundp. Otherwise it returns a *list* of roots. 2. And in the second case, 'xref-backend-references' conses that list of roots to the list of external roots. I.e. it constructs an improper list which it then passes to 'mapcan'. This is a bug, isn't it? 3. 'xref-expanded-seach-root` mispells "search" --000000000000745c1905b76ca78c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sat, 26 Dec 2020 at 03:21, Dmitry= Gutov <dgutov@yandex.ru> wro= te:
On 23.12.2020 04:16, Dmitry Gutov wrote:
> Re: patch 2, I have an idea that would make it a bit simpler and less =
> coupled to project.el, but behave the same in the usual cases. Stay tu= ned.

Not as clean as I hoped, but here's something that should work just as =
well, and a lot faster to boot (project-current lookup for every file
name is slow when there are a lot of matches, even if each individual
project-current call looks fast).

We could remove the explicit dependency on the "current project" = if it
was always passed in from the outside (e.g. by project-find-regexp's setup), but we probably want this display mode to work with
xref-find-references as well.

Also simplified the docstring a bit.

Tobias, please try the attached patch.

Hi Dm= itry,

Thank you. I tested the patch and it works fine.

Some comments on the patch itself:

1. 'xref--project-root' returns a project root if 'pro= ject-root' is fboundp.
=C2=A0 =C2=A0 Otherwise it returns a *list* o= f roots.

2. And in the second case, 'xref-backend-references'= ; conses that list
=C2=A0 =C2=A0 of roots to the list of external= roots. I.e. it constructs an improper list
=C2=A0 =C2=A0 which i= t then passes to 'mapcan'. This is a bug, isn't it?

3. 'xref-expanded-seach-root` mispells "search"=C2=A0<= /div>
--000000000000745c1905b76ca78c--