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.bugs Subject: bug#36967: 27.0.50; Duplicate lines in xref output Date: Thu, 3 Dec 2020 03:35:19 +0200 Message-ID: <20e61edd-9ee6-deab-7ff4-94b0ba527dc4@yandex.ru> References: <87ef1wod82.fsf@mail.linkov.net> <950a9da4-4081-fe80-598f-eeb3931e24ad@yandex.ru> <87wnxz6glx.fsf@mail.linkov.net> 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="38447"; 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 Cc: 36967@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 03 02:36:21 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 1kkdXg-0009uX-OD for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 03 Dec 2020 02:36:20 +0100 Original-Received: from localhost ([::1]:54096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kkdXf-0003Zc-4J for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 02 Dec 2020 20:36:19 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kkdXP-0003ZL-9e for bug-gnu-emacs@gnu.org; Wed, 02 Dec 2020 20:36:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54494) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kkdXN-0005PJ-UQ for bug-gnu-emacs@gnu.org; Wed, 02 Dec 2020 20:36:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kkdXN-00047J-Rm for bug-gnu-emacs@gnu.org; Wed, 02 Dec 2020 20:36:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 03 Dec 2020 01:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36967 X-GNU-PR-Package: emacs Original-Received: via spool by 36967-submit@debbugs.gnu.org id=B36967.160695933115787 (code B ref 36967); Thu, 03 Dec 2020 01:36:01 +0000 Original-Received: (at 36967) by debbugs.gnu.org; 3 Dec 2020 01:35:31 +0000 Original-Received: from localhost ([127.0.0.1]:37807 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kkdWs-00046Z-JZ for submit@debbugs.gnu.org; Wed, 02 Dec 2020 20:35:30 -0500 Original-Received: from mail-wr1-f43.google.com ([209.85.221.43]:38528) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kkdWr-00046L-1K for 36967@debbugs.gnu.org; Wed, 02 Dec 2020 20:35:29 -0500 Original-Received: by mail-wr1-f43.google.com with SMTP id p8so210984wrx.5 for <36967@debbugs.gnu.org>; Wed, 02 Dec 2020 17:35:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=ZGWUkX5pjwEUuzorbtLYK9KwsDiFFOD/cel7Fwmbz5U=; b=Gp9IJMhHDDXHmMECVGG4n5hNLjnNsKCwzHz0qsPkqRVQHtkXLF76fuh+Y6Ktv/PF0P W2CUstQG7uRpqbpzeVg6DhZHWJFamj5YiKdYR+F65OT9ODC0zM1JY5bsSaMGe6Sj6FaR 5EjTuFUoMCyXBJnv0ftJGy2M7K65/mTjxgoXR64vo3xglgVwFscCMVfXL2aKzlXlSkzU r1FJE+l9YLR8NAETFFsMqkzcqo5rb+F5SS1G63WLIt2WXtpdP58kLYupXw7sf0INrVG0 g7keR9bHhKhlew7orVQVj4Rjc6IkBQwL6DKpZ5eTj8rfqyqJ4IFcQzKPrJpjOAS1sfJd PleQ== 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:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ZGWUkX5pjwEUuzorbtLYK9KwsDiFFOD/cel7Fwmbz5U=; b=kZl7y4qu5zybCZ0NWXXNg1M1j1R0r3i15L3g/EC6MaTE2aWl8Qiekm8ckKIKov2i8b kBaB+rbVOZqYteekk/tvrF0ekFwoSkq9Y8Dlahxiljzsdp4tchEit24I6NV7p+glyStV EoyWF5BmbG2ak6/jT5C2RE0EWKMAlEQ97K/rHNu0amaQSV8g3XwimysL+J3hud1q/wDH iAnHQdEL8hdC3aVYoVTurcUAO/MLAE6BOYy3CvoVXAmL7w0l/r43KLYb99UDgVwYfPxi NV2A5ImTlMg38c7L7a7TC6Gag2SbSQdLXHZ4ELM5weELvCOzqbzmbK5QJ73MdT/APM6M N8lw== X-Gm-Message-State: AOAM530aTQaRLyzqt8VE2W6MuqQNmaXbjACCcD3tSyJCSliEAOV+VVec GJ+QgBB371Zi3+mn6/p/VEC5QtHPcyl5mQ== X-Google-Smtp-Source: ABdhPJxGd2I6yEUSpZr+bd9C3rdUginGldoWmlM8lxQWgalBvHmGkU46qc9+YcbWZzIhRQ+mBcvF2w== X-Received: by 2002:adf:f8d2:: with SMTP id f18mr816096wrq.379.1606959322638; Wed, 02 Dec 2020 17:35:22 -0800 (PST) Original-Received: from [192.168.0.4] ([66.205.71.3]) by smtp.googlemail.com with ESMTPSA id u26sm327252wmm.24.2020.12.02.17.35.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Dec 2020 17:35:21 -0800 (PST) In-Reply-To: <87wnxz6glx.fsf@mail.linkov.net> Content-Language: en-US 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:194841 Archived-At: On 02.12.2020 23:30, Juri Linkov wrote: >>> I tried to use project-find-regexp more often than rgrep, >>> but unfortunately xref still has a fundamental flaw: >>> 0. emacs -Q >>> 1. M-x project-find-regexp RET regexp RET >>> 2. The output buffer *xref* contains duplicate lines >>> when regexp is found on the same line several times, >>> each duplicate output line has separate highlighting >>> for every regexp occurrence. >> >> I don't know how "fundamental" it is, but indeed, it's somewhat of >> a drawback. Suggestions for improving it (API change and/or implementation >> change) are welcome. > > Here is the patch that makes the broken Pretty harsh there. > project-find-regexp usable: Okay, impressions: When the line has two matches, the new code only collects the first match. So 'matches' is always an list with one element (or nil). Upside: repetitions are not shown anymore, but the match highlighting is still applied. Downside: xref-query-replace-in-results won't work in those cases anymore; it will only replace one match. Because the list only contains one location, and not all of them. And that command is pretty nice to have. Here's an alternative proposal: Combine the lines inside the rendering code instead. So each xref will have a separate location, but then xref--insert-xrefs will see that xref-location-line value repeats across some consecutive locations, and will combine them into single line with some text property magic (basically, copying the summary from one of them, and then applying 'xref-item and 'face properties appropriately). This retains the xref item semantics (as opposed to, say, associating an xref item with multiple locations). And _hopefully_ the replace-related code won't need any changes. As a bonus, 'n' and 'p' should then automatically change behavior to jump between locations when they are on the same line.