From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jon Eskin Newsgroups: gmane.emacs.devel Subject: Re: [Patch] Add project.el command to replace symbol at point throughout project Date: Tue, 11 Jan 2022 04:50:13 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000eb166f05d54b611c" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8278"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Manuel Uberti Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jan 11 10:51:38 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 1n7DoX-0001xp-2q for ged-emacs-devel@m.gmane-mx.org; Tue, 11 Jan 2022 10:51:37 +0100 Original-Received: from localhost ([::1]:49816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n7DoV-00072t-IA for ged-emacs-devel@m.gmane-mx.org; Tue, 11 Jan 2022 04:51:35 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7DnY-0005qn-QH for emacs-devel@gnu.org; Tue, 11 Jan 2022 04:50:38 -0500 Original-Received: from [2607:f8b0:4864:20::d32] (port=41500 helo=mail-io1-xd32.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n7DnP-0006em-4T for emacs-devel@gnu.org; Tue, 11 Jan 2022 04:50:34 -0500 Original-Received: by mail-io1-xd32.google.com with SMTP id i82so47663ioa.8 for ; Tue, 11 Jan 2022 01:50:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BLqQ1QMi0yv1pvD1VpfXaJR1uls42OjkXqQ0B5hmClU=; b=Er2oz6EA1+lE1dE8AgtTk5SXw28dcBmtrjuEStuSDl4Lnm2o/btgbfQgMd7ylDgTvi d7w2h8MHM0dWlGd1nF+JpMwuxZDn4Oz5vPLTeiEhsDCKdCyK3Xs71Bed7DMNAqvDH6mN X82gbFdq76Qp6Uc0s6xNimm75fu2w1HqpSdNo9uFgYPZrYxvK/m5dRMKF1wusW8y2/OX EvmlaIxFs6NRgdpg75l2c4K7JxAfcTQ60PC6u5OmcMlpEV6pAQKynJXKD4r/Q5kjoe13 qNbeiH+bAgQFBtx3/ncCgSG6kZIT5COFRXmN1qdob2KO5QXTL0J0Zznzn2GYgAP898Vl gKvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BLqQ1QMi0yv1pvD1VpfXaJR1uls42OjkXqQ0B5hmClU=; b=zTUS4gf3ZgD+3j8aC3alrclTTCVy6jRLppIvOU/b9Uzycu0e3QSlfWxog7vlQNqFo/ +erWjxvOmRzDJ5c0SYeqehtoKMtMnUrri18HC8afBXIVun4CF8qRbcA4cXSYecBhcqXR SSfWno3WzGoqvKcC+yWi3OTIOTrQqzSHaMUQNHom/wxUjx8Zdr5JPg60jEdYFmv5uouL 5QYTN5GsEsKjREXxV5tjrP4r/xf8klSbDLhF4uzXP7PVkkNxPssp8Hh4ZdWPDMEDsX1v LrIpzUxZ1p/prjrJokIgjR3JnZRkttzk32HKLdZT6Bte2sH8ee8fQ+JWgC3grV6t4Uzz BnIQ== X-Gm-Message-State: AOAM532BJBwmhrS7Sw36qse5zdHah7i+EBuG9tCY21cWeIbuVf/JwQhC HaatTlx8xSI3u8xJg0akE5h8KRZJ0qWuftBRskWOux3a X-Google-Smtp-Source: ABdhPJwDmtjCfb0iEZzmb5AavdADR1EedH1Qo4XMNXS/EIDqiIlQOWmiBZGhBBHk7b6IXvYRcC4ieQnEz8d0gWlDCNk= X-Received: by 2002:a6b:e508:: with SMTP id y8mr1687552ioc.177.1641894625612; Tue, 11 Jan 2022 01:50:25 -0800 (PST) In-Reply-To: X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d32 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::d32; envelope-from=eskinjp@gmail.com; helo=mail-io1-xd32.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=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:284581 Archived-At: --000000000000eb166f05d54b611c Content-Type: text/plain; charset="UTF-8" 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'. Unfortunately I couldn't find a way to make that work- I couldn't find a function or variable referring to the item being cross referenced in the context of an xref buffer. If I understand correctly, xref only seems to be concerned with logic to deal with xref results that it is provided. With that assumption I couldn't really think of a way to architect a good solution without modifying xref in a way that violates [what I understood to be] its intent. I'm definitely open to suggestions on how to make that work, though. On Tue, Jan 11, 2022 at 2:51 AM Manuel Uberti wrote: > On 11/01/22 08:45, Jon Eskin wrote: > > Attached is a small patch adding command > 'project-query-replace-at-point' to > > project.el. The command is designed to improve the ergonomics of making > a > > project wide text replacement of a symbol at point. > > > > Currently, if you want to make a project wide replacement of a symbol > using > > project.el, the best options I've found are: > > > > - Mark the symbol you wish to replace > > - Save symbol to kill ring with 'kill-ring-save' > > - Enter command 'project-query-replace-regexp' > > - Paste in the symbol, taking care to quote regex if necessary, and hit > return > > - Enter the replacement string and hit return > > > > or > > > > - Mark the symbol you wish to replace > > - Save symbol to kill ring with 'kill-ring-save' > > - Place cursor on symbol and enter command 'project-find-regexp' > > - Hit return at the next prompt to accept the default prompt > > - Enter command 'xref-query-replace-in-results' > > - Enter the replacement string and hit return > > > > 'project-query-replace-at-point' regex-quotes the symbol at point and > then calls > > into the fileloop-initialize-replace function used by the existing > > project-query-replace-regexp command. > > > > Replacing a symbol with 'project-query-replace-at-point' occurs as > follows: > > > > - Place cursor on symbol and enter command > 'project-query-replace-at-point' > > - Enter the replacement string and hit return > > > > Let me know what you guys think. I haven't contributed before so please > let me > > know if I'm doing anything incorrectly. > > > > I usually use the `project-find-regexp` approach you described, but I > agree a > simpler solution would be nicer. > > -- > Manuel Uberti > www.manueluberti.eu > -- Jon Eskin (301) 675-6663 --000000000000eb166f05d54b611c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
That's a great function, I love seeing all the re= sults 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 'proj= ect-find-regexp'.

Unfortunately I couldn&= #39;t find a way to make that work- I couldn't find a function or varia= ble referring to the item being cross referenced in the context of an xref = buffer. If I understand correctly, xref only seems to be concerned with log= ic to deal with xref results that it is provided. With that assumption I co= uldn't really think of a way to architect a good solution without modif= ying xref in a way that violates [what I understood to be] its intent. I= 9;m definitely open to suggestions on how to make that work, though.

On Tue, Jan 11, 2022 at 2:51 AM Manuel Uberti <manuel.uberti@inventati.org&= gt; wrote:
On 11= /01/22 08:45, Jon Eskin wrote:
> Attached is a small patch adding command 'project-query-replace-at= -point' to
> project.el. The command is designed to improve the ergonomics of makin= g a
> project wide text replacement of a symbol at point.
>
> Currently, if you want to make a project wide replacement of a symbol = using
> project.el, the best options I've found are:
>
> - Mark the symbol you wish to replace
> - Save symbol to kill ring with 'kill-ring-save'
> - Enter command 'project-query-replace-regexp'
> - Paste in the symbol, taking care to quote regex if necessary, and hi= t return
> - Enter the replacement string and hit return
>
> or
>
> - Mark the symbol you wish to replace
> - Save symbol to kill ring with 'kill-ring-save'
> - Place cursor on symbol and enter command 'project-find-regexp= 9;
> - Hit return at the next prompt to accept the default prompt
> - Enter command 'xref-query-replace-in-results'
> - Enter the replacement string and hit return
>
> 'project-query-replace-at-point' regex-quotes the symbol at po= int and then calls
> into the fileloop-initialize-replace function used by the existing > project-query-replace-regexp command.
>
> Replacing a symbol with 'project-query-replace-at-point' occur= s as follows:
>
> - Place cursor on symbol and enter command 'project-query-replace-= at-point'
> - Enter the replacement string and hit return
>
> Let me know what you guys think. I haven't contributed before so p= lease let me
> know if I'm doing anything incorrectly.
>

I usually use the `project-find-regexp` approach you described, but I agree= a
simpler solution would be nicer.

--
Manuel Uberti
www.manueluberti.eu


--
Jon Eskin
(301) 675-6663
--000000000000eb166f05d54b611c--