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.devel Subject: Re: xref-query-replace-in-results error message after xref-find-definitions, was: Re: bug#58158: 29.0.50; [overlay] Interval tree iteration considered harmful Date: Tue, 11 Oct 2022 19:41:35 +0300 Message-ID: References: <83h70qhez0.fsf@gnu.org> <83edvuhaby.fsf@gnu.org> <831qruh67o.fsf@gnu.org> <83y1u2foli.fsf@gnu.org> <83zgehe6iq.fsf@gnu.org> <95113379-99d8-eba4-f980-a7fca11430d5@yandex.ru> <834jwfmn5a.fsf@gnu.org> <838rlohzeo.fsf@gnu.org> <83mta2g91p.fsf@gnu.org> <237a3e26-03b8-a2a9-90bd-d50c3670a131@yandex.ru> <83wn96efyn.fsf@gnu.org> <5bb803bf-f51b-c175-f908-c60066d6967d@yandex.ru> <83v8oqeeqf.fsf@gnu.org> <7c0849be-145e-e073-49b5-63749e8d8282@yandex.ru> <83sfjuecyw.fsf@gnu.org> <83k056e4dz.fsf@gnu.org> 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="14351"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Oct 11 18:44:06 2022 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 1oiIMP-0003Xj-Qn for ged-emacs-devel@m.gmane-mx.org; Tue, 11 Oct 2022 18:44:05 +0200 Original-Received: from localhost ([::1]:53504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiIMO-0004oq-Nl for ged-emacs-devel@m.gmane-mx.org; Tue, 11 Oct 2022 12:44:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52136) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiIKM-0003Nb-KU for emacs-devel@gnu.org; Tue, 11 Oct 2022 12:41:59 -0400 Original-Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:39559) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oiIKK-0005mB-2L; Tue, 11 Oct 2022 12:41:58 -0400 Original-Received: by mail-wr1-x42a.google.com with SMTP id f11so22522048wrm.6; Tue, 11 Oct 2022 09:41:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=hhenQq19iFP92t8Kn9pAVTcu4NpF/BWkhwe/mnM9XF8=; b=WWvYb1dGpLubunoNLSBPZhYe3aOIqUDMe1Sd3BrIZNJ+u0/2w6eA5x3GrvhcxwtJVy uX1xhSXNowoLWk9RcABSOq86b9KCKg6BDZbjbPpmQzolN7eeL66SWnTu2mHYmPR2NY6N 2oy8ZP0JoCU8u4L6i0U/eERWU45XGnXqyEHJrg2+I0QKG+QOCU4UIceQUNkbO4HS7ymk jIQxPGQK0zHuV2jdVxGGjJTpzXVh9qepZSkK80gbfv2i0wAEIX8CMkr67Uy5rUIPJyFT XXJ++ESVEIwzetBarMabr0zIlmSRDaX5H7ww8P+yfkX0ikY8DZ5enB48MPFRRUMXYCkC Ke/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hhenQq19iFP92t8Kn9pAVTcu4NpF/BWkhwe/mnM9XF8=; b=6ueCwgSHoRtmpvYC+IpDtk94u+a7YZc9SA3Y1s8oPnwAmqRlHiDmzJG6tJUqkGZk5M O4U0riBfPxx4LLAIIdR0FU6RF8mbNzHOhnZ2HhEynUdDyOYiLxdZ4p6lOI+9FXpyf8HI T4MtpLh2IQB1lXHpCp6jHSz69bqrYWn4i4Me1+KGVp1JpO5hMGIQ3rsySqLlHXHGmy5C QguAu3NJ/C/9oGJ0A4Gro0kl5VFzBnwLjpfFLP/sjKI0JcqCqHHbHSGLFG6Y8JYy0Pq3 oN7Mw1nYf9W/MKQDkc3mZEX6nH7/FNZwC0PBjOvrQWE/4XDgnnSGOB38ihux0L5ogPzk jeeg== X-Gm-Message-State: ACrzQf3BAPu4Kkag/1k+lQ+ftF+viu98jHZS//i0v0zhRodCNkGnW898 dAvHJjB1i1vP6LhBRb6utG9ny/xZHvA= X-Google-Smtp-Source: AMsMyM5EjdufsuX+BUxUz+2E0hz4FoJN+TrnguSA0bYAXlxqhR0KG1S4RGzRcqrMlJbvzxqKuYa4gw== X-Received: by 2002:a5d:6245:0:b0:225:3e24:e5b1 with SMTP id m5-20020a5d6245000000b002253e24e5b1mr16291088wrv.698.1665506497250; Tue, 11 Oct 2022 09:41:37 -0700 (PDT) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id v24-20020a1cf718000000b003a6125562e1sm12627395wmh.46.2022.10.11.09.41.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Oct 2022 09:41:36 -0700 (PDT) Content-Language: en-US In-Reply-To: <83k056e4dz.fsf@gnu.org> Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=raaahh@gmail.com; helo=mail-wr1-x42a.google.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NICE_REPLY_A=-2.934, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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:297502 Archived-At: On 11.10.2022 19:01, Eli Zaretskii wrote: >>> So maybe just saying >>> >>> Cannot do global replacement using results of \\[xref-find-definitions] >>> >>> should be okay? >> >> Isn't it almost the same as I suggested upthread? Except I suggested >> "this search" instead of naming the specific command. > > I'm not trying to argue, I'm trying to find the best message text. It > doesn't matter who suggested it first, what matters whether it is > accurate and self-explanatory. I wasn't playing "who said it first" either, but pointing at the previous suggestion as a little more inherently-accurate. >> Do you think naming it will be helpful enough to sacrifice the 10% >> accuracy of the message? I suppose someone might have indeed forgotten >> that they did the search using xref-find-definitions. > > What are the 10% of inaccuracy? Sorry, losing 100% accuracy, to get a slightly smaller percentage. > If the message will only ever be > shown when 'r' is invoked after M-., then what is inaccurate in it? Almost only ever. With potential for exceptions, unless we try to enforce their absence. >>>> That would mean that one 'r' can work in lsp-mode's >>>> xref-find-definitions results (they define a bunch of custom commands >>>> like lsp-find-definition and lsp-find-declaration, but that probably >>>> doesn't matter). Not sure if we should do something about that. >>> >>> If 'r' happens to work in that case, we don't have to worry about the >>> error message, right? >> >> That's correct, but having the command succeed might be a problem by >> itself, couldn't it? It will rename the definitions (and/or >> declarations), but not other occurrences. > > No error message could possibly prevent that from happening, could it? Only if it happens somewhere else, or if the check before the errors is changed significantly. >> If we go in from this direction, we can have >> xref-show-definitions-buffer (the default >> xref-show-definitions-function) ensure that the binding for 'r' is set >> to some command that always reports an error (like 'cannot replace in >> definitions'), or is unbound. > > But users can always invoke the command by name as well. That's, uh, true. But having commands intended for one major mode silently failing (or doing that in a weird fashion) when invoked with 'M-x' in another major mode has not usually been a concern for us. >> This would do nothing for custom values of >> xref-show-definitions-function, but should remove most of the confusion >> with default configuration. And some non-default ones as well (lsp-mode >> doesn't change the value of xref-show-definitions-function). >> >> If the docstring of xref-show-definitions-function looks okay to you, we >> can use its vocabulary. >> >> Cannot replace in definition search results >> >> should cover xref-find-definitions, lsp-find-definition and >> lsp-find-declaration. Wouldn't help with lsp-find-implementation, though >> (its results are also questionable WRT renaming because they don't >> include all references either), but it won't make it worse. > > Hmm... maybe > > Cannot perform global replacement in find-definition results > > Another idea would be for the error message to be constructed > dynamically, and include the precise command that produced the Xref > buffer, if xref.el could record that in some buffer-local variable. I suppose it could. But then some backend (such as lsp or possibly eglot) might return 'definitions' results in format suitable for replacements, and that will mean that one can replace in xref-find-definitions's results, just with some backends but not others. And with that, the error message Cannot do global replacement using results of \\[xref-find-definitions] shown to the same user at a different time (perhaps when they're editing Elisp) will become a lie. And then, okay, we could try to add the name of the backend symbol to the error message as well, but it's much harder to capture that one, especially given that not every command using Xref output will go through xref-backend-functions (project-find-regexp is a counter-example).