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: [Patch] Add project.el command to replace symbol at point throughout project Date: Thu, 13 Jan 2022 03:03:41 +0200 Message-ID: References: <33d9f13d-7b46-1c06-f7d5-6d1f70b5d0fb@yandex.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------E93D042BC6EC9C61B18D65F3" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33805"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 Cc: Manuel Uberti , emacs-devel@gnu.org To: Jon Eskin Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Jan 13 02:07:09 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 1n7oa5-0008ge-1z for ged-emacs-devel@m.gmane-mx.org; Thu, 13 Jan 2022 02:07:09 +0100 Original-Received: from localhost ([::1]:47750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n7oa3-0004BA-5k for ged-emacs-devel@m.gmane-mx.org; Wed, 12 Jan 2022 20:07:07 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:39310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7oYG-000385-8L for emacs-devel@gnu.org; Wed, 12 Jan 2022 20:05:16 -0500 Original-Received: from [2a00:1450:4864:20::431] (port=35664 helo=mail-wr1-x431.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n7oYB-0002Qg-9J for emacs-devel@gnu.org; Wed, 12 Jan 2022 20:05:14 -0500 Original-Received: by mail-wr1-x431.google.com with SMTP id e9so7315823wra.2 for ; Wed, 12 Jan 2022 17:05:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=WWpSmnZ08IgyUNOwqaywC+OYj7RXg0r+jjKstYvcCfI=; b=OXpV74/c4kyB5puACkLCSPGd8VDizUyuaQ6fZasoteBo/8Jflns4aAhV12+xgkWWFU usSazDSYdFXKoXB3gTcUi3FGPePkNmTzs/MzGztRKAclJbASAzuRyRObvVAWInFIE4Nh HHQWf1xxjRe95dKBZKLud8ol4mMUhYdU4CuJyZjv0HmRZIW3AuSk9ywE4GUJftk3uQLu dUOHPwzt66nWyMJSGKPQNrsjmHmcGudSxrB16HfWhr8pB5u6ghM0+w9XtbTRmwB0rbLK pTOHzd6TJFMdYUJmf3SZJIlfChl9Emmq4IfvpOqUzVH/w4flYMzZyKEeEV16WVppRW0B 0qOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=WWpSmnZ08IgyUNOwqaywC+OYj7RXg0r+jjKstYvcCfI=; b=oGMFiXgAHWA58NroTp+E2C9KfczZRP3Qm6oc29fTYfBAk2vRttesm2iIRQwayI3ki7 FMqqKwOnPq/EtAi5O0oDRyvr3HvoAh4BLJ53eX/B88ERi4YhBiACc1b4tpvyk1fokBWC Ti+hHy6Tg5GjkkBnkNGqwHHxAvOZAxRvNhoLqkQtfRZl8h0F7HtfqZMnvnZ5ylgTOfpd LUtctMYdfACW4LbQFD6Ews2nLUf8qYEsdBLKL9EiIlMT+1YXzEuyc6nogrgfbbJcY3vn B0QMY4cm2vsdfobqFocVNb4/OzcuhLsCleNEYBciDYz8FUFfF8+57Hi2rI55IEq2uKKL s4/A== X-Gm-Message-State: AOAM533uddhXwJi+ov2NpP+1xxrPPf6q1wD1QeMuSQR/0FlaNTM0eEKI ifBl779YSD55IK7qIJa0H1vJvnpz9k0= X-Google-Smtp-Source: ABdhPJwjlK6HwYr/1+nIvoP9949hNSmCl9AEbHSV0gy0+7SVDtjEvqAQrOf9TG3Ci+crhYllH3iP5w== X-Received: by 2002:a5d:528a:: with SMTP id c10mr1819739wrv.399.1642035909288; Wed, 12 Jan 2022 17:05:09 -0800 (PST) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id l25sm1037411wmh.18.2022.01.12.17.05.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Jan 2022 17:05:08 -0800 (PST) In-Reply-To: Content-Language: en-US X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::431 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=raaahh@gmail.com; helo=mail-wr1-x431.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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:284674 Archived-At: This is a multi-part message in MIME format. --------------E93D042BC6EC9C61B18D65F3 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 12.01.2022 11:42, Jon Eskin wrote: > > >> On Jan 11, 2022, at 10:43 PM, Dmitry Gutov wrote: >> >> On 11.01.2022 11:50, Jon Eskin wrote: >>> That's a great function, I love seeing all the results in an xref buffer. I previously explored adding a command to the xref similar to 'xref-query-replace-in-results' that pre-populates the FROM field with the item you were searching for when you executed 'project-find-regexp'. >> >> Would it help to have an easier version of xref-query-replace-in-results, or do we really need a separate command called project-find-regexp-and-replace? > > An easier version of xref-query-replace-in-results would be preferable to me personally, at least. Try out this change, then (attached). --------------E93D042BC6EC9C61B18D65F3 Content-Type: text/x-patch; charset=UTF-8; name="simpler-xref-query-replace-in-results.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="simpler-xref-query-replace-in-results.diff" diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 9ce63a8f8a..06faf16a31 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -738,11 +738,20 @@ xref-query-replace-in-results "Perform interactive replacement of FROM with TO in all displayed xrefs. This command interactively replaces FROM with TO in the names of the -references displayed in the current *xref* buffer." +references displayed in the current *xref* buffer. + +When called interactively, it uses '.*' as FROM, which means +replace the whole name. Unless called with prefix argument, in +which case the user is prompted for both FROM and TO." (interactive - (let ((fr (read-regexp "Xref query-replace (regexp)" ".*"))) - (list fr - (read-regexp (format "Xref query-replace (regexp) %s with: " fr))))) + (let* ((fr + (if prefix-arg + (read-regexp "Query-replace (regexp)" ".*") + ".*")) + (prompt (if prefix-arg + (format "Query-replace (regexp) %s with: " fr) + "Query-replace all matches with: "))) + (list fr (read-regexp prompt)))) (let* (item xrefs iter) (save-excursion (while (setq item (xref--search-property 'xref-item)) --------------E93D042BC6EC9C61B18D65F3--