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#44905: 27.1; Packages that customize xref-show-xrefs-function can break Dired's dired-do-find-regexp-and-replace Date: Mon, 30 Nov 2020 03:00:17 +0200 Message-ID: <808e5fa8-9a5f-766e-39b0-c68da53b0d50@yandex.ru> References: <7ab2afb1-33ec-bca0-4014-131130e71a04@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19877"; 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: 44905@debbugs.gnu.org To: Daniel =?UTF-8?Q?Mart=C3=ADn?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 30 02:01:59 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 1kjXZn-00051b-40 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 30 Nov 2020 02:01:59 +0100 Original-Received: from localhost ([::1]:43502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kjXZm-000787-5u for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 29 Nov 2020 20:01:58 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44504) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kjXYs-0006mN-BJ for bug-gnu-emacs@gnu.org; Sun, 29 Nov 2020 20:01:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41400) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kjXYs-0005gZ-2B for bug-gnu-emacs@gnu.org; Sun, 29 Nov 2020 20:01:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kjXYs-0005y9-0f for bug-gnu-emacs@gnu.org; Sun, 29 Nov 2020 20:01:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 30 Nov 2020 01:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44905 X-GNU-PR-Package: emacs Original-Received: via spool by 44905-submit@debbugs.gnu.org id=B44905.160669802822894 (code B ref 44905); Mon, 30 Nov 2020 01:01:01 +0000 Original-Received: (at 44905) by debbugs.gnu.org; 30 Nov 2020 01:00:28 +0000 Original-Received: from localhost ([127.0.0.1]:52946 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kjXYK-0005xB-D7 for submit@debbugs.gnu.org; Sun, 29 Nov 2020 20:00:28 -0500 Original-Received: from mail-wm1-f51.google.com ([209.85.128.51]:53144) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kjXYH-0005wy-V3 for 44905@debbugs.gnu.org; Sun, 29 Nov 2020 20:00:26 -0500 Original-Received: by mail-wm1-f51.google.com with SMTP id a6so2126726wmc.2 for <44905@debbugs.gnu.org>; Sun, 29 Nov 2020 17:00:25 -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=wyfeYt8B8Lf0hutzhUQrNSWSsMe6SVKPR6zLBT9kUr8=; b=ckNLqutgemUV0mA5FnWFQyi+yBpsJjp57MRY1H2ZRru7kZNtlMEFIyqWarhTsO4T0T jXs6YjPSiMs9FpBbZBQJEmOaQTZkd8G/bNXyq9Ah/oFrJZXwStY7/ZZYc9ilK88Ifo1w mOuyzhO5nvBUSKv8T+Gz8mjBkccnYbADMwLJjvUpufRa+BHTP+ftqvyds3dnClgMTAjE rqsaebJTSgj2HhWPgwSvnAWFxidqQycrBcTVQXquEiZpbTRCHaB66L1O075f/Cb8ypcZ kKFh+2JPcw3XwOqPyeuOZzG49JMVsMr3OM3m7JRFTeFg9P6KVbm1OT5DP6OYvCdY6/lg oe5Q== 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=wyfeYt8B8Lf0hutzhUQrNSWSsMe6SVKPR6zLBT9kUr8=; b=Y4Nq14Q3jDfuz/yxSSyyhwEtkBb28su5Paetw9IpcsJ0sivtXmwCnFORuObFa3gVgs 4pnvvS8VSt2fMiAngvUSQS7LBbpWML80wwArVl2mHqJEybXjvWrOK6DoLJtLiYWIu7Lc xGtLzzo3eNiSkhQSLnQwTqcYPo8+fj/xwWvB7jQgku8KrpcxeP4r158Ac+qd/Oat/g9o RUHWsvPlv/skdNaG2Xxt7+2FcCYYq/gxtW51P3WrYHJUqDKvtHzCNo51HXwSG41oIe74 uoMuNlBkF7JT2IzA72ND7++kNCrUAGCtXOatYdWhup3NiLiKh5fN/+XwAD2vgy8bUXuy ep1w== X-Gm-Message-State: AOAM530hpQbHGPY/BcWrS5XwseWRDg31MHas7P7y8lAxUflDeodhkswO vc23EBG+0UH2+7Wuio2Po7Y= X-Google-Smtp-Source: ABdhPJw1QXB4jHbn1wQwtdpLFKVLfqIqpUS6Ssh+Xqu2i/z9gn5wEGAvcnyebXYYFcTtjqQisTs/WQ== X-Received: by 2002:a05:600c:2314:: with SMTP id 20mr16529680wmo.92.1606698019849; Sun, 29 Nov 2020 17:00:19 -0800 (PST) Original-Received: from [192.168.0.4] ([66.205.71.3]) by smtp.googlemail.com with ESMTPSA id b12sm2142005wmj.2.2020.11.29.17.00.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 29 Nov 2020 17:00:18 -0800 (PST) In-Reply-To: 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:194586 Archived-At: On 29.11.2020 14:57, Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: > Dmitry Gutov writes: >> >> While this change in the Right Thing(tm), I have to question the >> wisdom of setting xref-show-xrefs-function to an Ivy or Helm-based >> function, though. Those UIs serve to help you choose one item, whereas >> commands like dired-do-find-regexp and project-find-regexp show the >> user a list of matches, to interact with (usually) several of them. > > I agree with you, Ivy/Helm may not be the best UX for Xref, but this > particular problem can still happen even if the user returns a buffer > that represents the Xref data in a different way. I think that > xref-query-replace-in-results assumes certain invariants from the > original *xref* buffer that are not documented. True. >> >> diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el >> index 94a2bbf1f3..4caafc8df6 100644 >> --- a/lisp/dired-aux.el >> +++ b/lisp/dired-aux.el >> @@ -3140,7 +3140,10 @@ dired-do-find-regexp-and-replace >> (query-replace-read-args >> "Query replace regexp in marked files" t t))) >> (list (nth 0 common) (nth 1 common)))) >> - (with-current-buffer (dired-do-find-regexp from) >> + (defvar xref-show-xrefs-function) >> + (with-current-buffer >> + (let ((xref-show-xrefs-function 'xref--show-xref-buffer)) >> + (dired-do-find-regexp from)) >> (xref-query-replace-in-results from to))) >> >> (defun dired-nondirectory-p (file) > > LGTM, thanks. Eli, is this OK for Emacs 27.2? Here's also a slightly more future-proofed version that avoids referencing the function we might want to rename/change later: diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el index 94a2bbf1f3..26155190d4 100644 --- a/lisp/dired-aux.el +++ b/lisp/dired-aux.el @@ -3140,7 +3140,13 @@ dired-do-find-regexp-and-replace (query-replace-read-args "Query replace regexp in marked files" t t))) (list (nth 0 common) (nth 1 common)))) - (with-current-buffer (dired-do-find-regexp from) + (require 'xref) + (defvar xref-show-xrefs-function) + (with-current-buffer + (let ((xref-show-xrefs-function + ;; Some future-proofing (bug#44905). + (eval (car (get 'xref-show-xrefs-function 'standard-value))))) + (dired-do-find-regexp from)) (xref-query-replace-in-results from to))) (defun dired-nondirectory-p (file)