From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#32034: 26.1; [PACTH] better xref-location-marker for imperfect file locations Date: Wed, 4 Jul 2018 17:33:42 +0300 Message-ID: <54af7707-12a6-4d89-de8d-b07ac626c898@yandex.ru> References: <87y3etsqb7.fsf@gmail.com> <5ab17038-c13d-3dde-2db9-4bc9a1042235@yandex.ru> <8736wzf7f0.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1530714727 21448 195.159.176.226 (4 Jul 2018 14:32:07 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 4 Jul 2018 14:32:07 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 Cc: 32034@debbugs.gnu.org To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 04 16:32:03 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1faip6-0005Nl-Kk for geb-bug-gnu-emacs@m.gmane.org; Wed, 04 Jul 2018 16:32:00 +0200 Original-Received: from localhost ([::1]:47500 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fairD-0004x6-Hs for geb-bug-gnu-emacs@m.gmane.org; Wed, 04 Jul 2018 10:34:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40973) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fair7-0004wy-AB for bug-gnu-emacs@gnu.org; Wed, 04 Jul 2018 10:34:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fair4-0000Cw-3G for bug-gnu-emacs@gnu.org; Wed, 04 Jul 2018 10:34:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:38928) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fair3-0000Cq-Ug for bug-gnu-emacs@gnu.org; Wed, 04 Jul 2018 10:34:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fair3-0007Lo-JU for bug-gnu-emacs@gnu.org; Wed, 04 Jul 2018 10:34:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 04 Jul 2018 14:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32034 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 32034-submit@debbugs.gnu.org id=B32034.153071483428242 (code B ref 32034); Wed, 04 Jul 2018 14:34:01 +0000 Original-Received: (at 32034) by debbugs.gnu.org; 4 Jul 2018 14:33:54 +0000 Original-Received: from localhost ([127.0.0.1]:46825 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1faiqv-0007LS-TB for submit@debbugs.gnu.org; Wed, 04 Jul 2018 10:33:54 -0400 Original-Received: from mail-ed1-f47.google.com ([209.85.208.47]:39538) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1faiqu-0007LF-7k for 32034@debbugs.gnu.org; Wed, 04 Jul 2018 10:33:52 -0400 Original-Received: by mail-ed1-f47.google.com with SMTP id w14-v6so4206467eds.6 for <32034@debbugs.gnu.org>; Wed, 04 Jul 2018 07:33:52 -0700 (PDT) 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=4XZ3SjtZOnexdAtKFZTmvDvFw/vNw4xEb+uITWKyPhw=; b=OV6nKhR5L9KN0me+ndSV9jq/rVJtikImPEsdtDOO+T8h2t6KfvR7aWdMAx6MmqslVl 63KlHU9NejQdTM5wu3Ts+FhR0B+UQdy0WqERri48DphvMmna71oyFz5ob00lKS5xBzSx YcC3Pwyon/6FoM6w9EWmRRY2NbnIT9uA+uoVZC1bKIqikWmJu5fKeRyn3XgE/dZuzf56 LPPndqjM0hN2H+apzqEZBGgQWW25Qdz6dBep3VrFEK2a2T6aOGXbPj/V7+SS6Uc8VBvP c0i+NEuWeHzUsMbIDxakxqvmKUmV82Gg92L+Y1jPawCNT8D5X3dzLIMYo5tqrnDMjHOO cLJA== 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=4XZ3SjtZOnexdAtKFZTmvDvFw/vNw4xEb+uITWKyPhw=; b=K5/mQPBiTPIZh8dKRbpRISBaXcb99XFt1evge4KKgnlvV74AJ8QaAGZDHySSv6kI7W 7dmX0M0tpCRS3wBXvFk0yzRfc9bIRkBY+DvEVmS9ljOOuJ0LUllRkMRnbaN2in9U32BR 7GccD+JN16FMKSV6nyzsShvA3/8j2Vi6yu+qKSXsCE1VnV4BGUiTA4SI7zT+SNIi+IcB Hv9sEHeRpG9CV3FMUl/QaJ3buMZJl0p3uN8xOFygeF2MGcEHKUxuZnx28Zb1aN+k3gUj /7LxpLuxe/wn1PT0+tSXiQocyojMx0XwbglC11WsFjC28qb0LwT/IAcNQKEPtfxBt1P1 L+zA== X-Gm-Message-State: APt69E1OJHCIIKqKrdZvdFfWzDjMpuhkt3OFjXq/OLDuYEOeYqQ6kC8J Td+gF7IEu8slhGms4BAjaciZU+7Q X-Google-Smtp-Source: AAOMgpdvLR9NMsX9JtVxOp7C3EG+ZLMYhPSILd7mMRbjxzL85SwLxjsIy3dlaGwii5V73xHvxfDwug== X-Received: by 2002:a50:b613:: with SMTP id b19-v6mr3006127ede.255.1530714826145; Wed, 04 Jul 2018 07:33:46 -0700 (PDT) Original-Received: from [192.168.0.200] ([109.110.245.170]) by smtp.googlemail.com with ESMTPSA id c21-v6sm1838714edr.78.2018.07.04.07.33.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Jul 2018 07:33:45 -0700 (PDT) In-Reply-To: <8736wzf7f0.fsf@gmail.com> Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:148185 Archived-At: On 7/4/18 4:37 PM, João Távora wrote: > Still better than failing randomly. Especially if you hint that the > match was approximate (much like the way diff tell you about "fuzz"). The problem is it will "break" correct navigations sometimes. > Anyway, those totally hypothetic future users of the class could well > and polish the default behaviour if they decided it's worth it. Suppose we use a new class. If the hint argument is mandatory, then there should be no problem: the backend explicitly asked for this behavior. Similarly if xref-file-location grows a new optional field which defaults to nil. >> It can certainly become outdated if the user has added or deleted a >> couple of lines there. > > But then, in that case, isn't it much better to find an actual match > (and perhaps warn) than to land the user in nowhereland? Yes. And in Grep results, it might be beneficial to use the new behavior. The code creating the locations will pass line's contents as the "hint" (and maybe we should make the hint a regexp, to be able to use the line-beginning and line-ending anchors). In that use case, though, it would be better to error out if the hint is not found. I'm somewhat worried about what will happen if a hint misdetects a match anyway, and we're in many-automatic-edits land (such as xref-query-replace-in-results), but on the balance, it'll probably be better than the current behavior anyway. Except for, err... lines with several matches on them. Not sure what to do about those. A special class, probably. > Because I want something with some default behaviour. Behaviour that is > admittely half-decent, but nevertheless better than current behaviour. > But since you showed that xref-location-marker is used by your grep > substitute, I don't want to cause any regressions in its existing, > broken behaviour, whatever that may be exactly. > >> It might be shorter implementation-wise, too. > > This is how I imagine the implementation: > > (defclass xref-hinted-location (xref-file-location) > ((hint :initarg :hint)))) > > (cl-defmethod xref-location-marker :around ((l xref-hinted-location)) > <...code to search around...>) > > Compared to the "add optional field" approach, there would be about 1 extra line, > the defclass one. If we use an optional field, we could call ignore-errors around forward-char if that field is present (your proposal number 1).