From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#32034: 26.1; [PACTH] better xref-location-marker for imperfect file locations Date: Wed, 04 Jul 2018 15:53:35 +0100 Message-ID: <87po03dpcg.fsf@gmail.com> References: <87y3etsqb7.fsf@gmail.com> <5ab17038-c13d-3dde-2db9-4bc9a1042235@yandex.ru> <8736wzf7f0.fsf@gmail.com> <54af7707-12a6-4d89-de8d-b07ac626c898@yandex.ru> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1530715928 19438 195.159.176.226 (4 Jul 2018 14:52:08 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 4 Jul 2018 14:52:08 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 32034@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 04 16:52:04 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 1faj8W-0004v5-5N for geb-bug-gnu-emacs@m.gmane.org; Wed, 04 Jul 2018 16:52:04 +0200 Original-Received: from localhost ([::1]:47596 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fajAd-00070D-EZ for geb-bug-gnu-emacs@m.gmane.org; Wed, 04 Jul 2018 10:54:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46117) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fajAS-0006yU-T7 for bug-gnu-emacs@gnu.org; Wed, 04 Jul 2018 10:54:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fajAQ-0002Gb-6x for bug-gnu-emacs@gnu.org; Wed, 04 Jul 2018 10:54:04 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:38935) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fajAQ-0002GX-1N for bug-gnu-emacs@gnu.org; Wed, 04 Jul 2018 10:54:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fajAP-0007nX-JS for bug-gnu-emacs@gnu.org; Wed, 04 Jul 2018 10:54:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 04 Jul 2018 14:54: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.153071602729953 (code B ref 32034); Wed, 04 Jul 2018 14:54:01 +0000 Original-Received: (at 32034) by debbugs.gnu.org; 4 Jul 2018 14:53:47 +0000 Original-Received: from localhost ([127.0.0.1]:46832 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fajAA-0007n3-L2 for submit@debbugs.gnu.org; Wed, 04 Jul 2018 10:53:46 -0400 Original-Received: from mail-wm0-f50.google.com ([74.125.82.50]:39880) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fajA8-0007mp-Jk for 32034@debbugs.gnu.org; Wed, 04 Jul 2018 10:53:45 -0400 Original-Received: by mail-wm0-f50.google.com with SMTP id p11-v6so6119618wmc.4 for <32034@debbugs.gnu.org>; Wed, 04 Jul 2018 07:53:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=xzqUnVIY90aAiaQ6hJvyouDoukqW8gRTiVLGHUoQflI=; b=Fk3l1tA5guP0hCKDGvj9ZhZCRGAjAi1QAawDAg1GF0+ztYvtkJjbl1Uz98c6EJl8Y4 qxgwjL5LoXKcl3/PhKNKYyE8xeEgEFDxxCcj44hdgCq4BOh3EGyRBQWPtL83Or8Vbp8x 6yAY1+wxeTBAGG9yb/0JgqTGwFp1qm02WvjgzKBV19aTXw8gULBewGd+qamN91ZZbrZr WH4g70Nl8q54eJuWrqSixjfPVVcXfTXmVtfH0RdM/lMpfSS3xrIGb1hbTaG7jKJYtI1F tZur8WvRLoMHPZFnhytkl50zfCafaiFNjtmW6ykvAAVnMfA9pkmUCkn0HgPrkm3bSmwz JHYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=xzqUnVIY90aAiaQ6hJvyouDoukqW8gRTiVLGHUoQflI=; b=B4/6wUY+leDWQG09Q/J/BtnGAu3ynRd9MDtuAc6SbVQ8rdu/dIqwc6szrVLIXfGobZ iw7wQsVLNgzqZPyIO0DsmS6jUwh6zP5u7CeTlnP2CLAUZZQPYEBioCDN7EorWq7PvmBE ZWldDzIUPnY1f+2lnGHGSOJB/AP2t6t4fH8aapWaChoz2gMXas5C0P6mkQXpKhPro+s0 KaFVqo8sbA476YMInCvVhD/z1FbuFyIjz2KT2Qm6qFtLptNqUAeQaNgvqP/wlb4s2MWn ZVNH/kWua1h2lnN2wcChrBenIBj/gtWiCLbouKxY/819O5qZv5efawrHMY0yQ8RKxGAN vZyg== X-Gm-Message-State: APt69E16e8F12JTygtmLDqOVCanvlpLJIJaswGA60n5TuqQZn/h0/hxl MRRDyv0X7XXLksz9AkOIqv5Hji+I X-Google-Smtp-Source: AAOMgpciVPvhuFlo8KjTP1MkIiN2BHTAZGm3NCan0MajSFtYkBQJ6PosH0NB6HV3yYC+KlV3H/V4pQ== X-Received: by 2002:a1c:e3d5:: with SMTP id a204-v6mr1798260wmh.20.1530716018560; Wed, 04 Jul 2018 07:53:38 -0700 (PDT) Original-Received: from lolita.yourcompany.com (188.139.62.94.rev.vodafone.pt. [94.62.139.188]) by smtp.gmail.com with ESMTPSA id b190-v6sm7476371wma.24.2018.07.04.07.53.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Jul 2018 07:53:37 -0700 (PDT) In-Reply-To: <54af7707-12a6-4d89-de8d-b07ac626c898@yandex.ru> (Dmitry Gutov's message of "Wed, 4 Jul 2018 17:33:42 +0300") 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:148186 Archived-At: Dmitry Gutov writes: > On 7/4/18 4:37 PM, Jo=C3=A3o T=C3=A1vora 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. I don't understand. Will _successful_ navigation ever land me on a spot where the identifier I looked for _isn't_ there? >> 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. Yes, we agree. > Similarly if xref-file-location grows a new optional field which > defaults to nil. Only in this case it's more code in the backend, and repeated across backends. >>> 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. So it would be a good idea to have this in grep/xref grep results after all? >> 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 ex= tra 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). I don't fully understand this, but I just remembered that it's better to have a separate class for another, probably more interesting reason. We should just make it a mix-in: that way, we can give "hinted" semantics to existing location classes, not just xref-file-location. Regarding ignore-errors, we should (quite independently of the remaining discussion) first agree if xref-location-marker should be allowed to error at all, and what should happen if it does.