From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: [Patch] Add project.el command to replace symbol at point throughout project Date: Wed, 12 Jan 2022 21:56:09 +0200 Organization: LINKOV.NET Message-ID: <868rvkpw2u.fsf@mail.linkov.net> References: <88e2f28a-925b-551c-b85b-0af400997dc5@yandex.ru> <699f09df-d685-ce80-7c57-a36824e7066b@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11528"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: Jon Eskin , emacs-devel@gnu.org To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jan 12 20:57:52 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 1n7jkm-0002qv-I9 for ged-emacs-devel@m.gmane-mx.org; Wed, 12 Jan 2022 20:57:52 +0100 Original-Received: from localhost ([::1]:50020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n7jkh-0005ko-H9 for ged-emacs-devel@m.gmane-mx.org; Wed, 12 Jan 2022 14:57:48 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:36390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7jjt-0004ri-5A for emacs-devel@gnu.org; Wed, 12 Jan 2022 14:56:57 -0500 Original-Received: from relay6-d.mail.gandi.net ([217.70.183.198]:40823) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7jjq-0006tC-DA for emacs-devel@gnu.org; Wed, 12 Jan 2022 14:56:56 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 3A4F9C0005; Wed, 12 Jan 2022 19:56:50 +0000 (UTC) In-Reply-To: <699f09df-d685-ce80-7c57-a36824e7066b@yandex.ru> (Dmitry Gutov's message of "Wed, 12 Jan 2022 21:43:43 +0200") Received-SPF: pass client-ip=217.70.183.198; envelope-from=juri@linkov.net; helo=relay6-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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:284665 Archived-At: >>> If we're trying to improve project-query-replace-regexp, why not make it >>> use the symbol at point by default? >>> >> I thought about the option of using symbol at point by default, but >> I noticed that the command currently uses the history >> variable. I wondered if some people were relying on its current behavior >> in a way that I didn’t anticipate (especially since I’m pretty new to all >> this). If so, it would be an annoying change to have to worry about >> whether the cursor is on a symbol when using a command you previously >> relied on. I wanted to try to put forth something possibly useful without >> breaking stuff. >> >>> You would use the same command, but would be able to press RET to have >>> the default regexp (symbol at point) used as FROM. I don't have a patch >>> yet, but it might be something that all callers of >>> query-replace-read-args might benefit from. >> Since I think I can understand what you’re suggesting, I would be happy >> to make an attempt at a patch to modify the callers of >> query-replace-read-args to default to a regexp quoted >> symbol-at-point. But no worries if you would rather have experienced eyes >> on it. > > I'm actually not sure about the best way to implement this: whether we > definitely want query-replace-read-args to use symbol-at-point as the > default FROM. But it does sounds handy to me. Let's ask the developer who > touched it last. query-replace-read-args can't be changed because in query-replace RET should use the previous from->to pair from the history. So if you want, you could change project-query-replace-regexp: let-bind read-regexp-defaults-function around the call of query-replace-read-args, and use a symbol at point as the default. >>> And you can actually do this right now: >>> >>> - Enter command 'project-query-replace-regexp' >>> - Press M-n, having the symbol at point picked up as FROM, hit return >>> - Enter the replacement string and hit return >> This is awesome! Did not know about that behavior, thank you for sharing! > > That capability actually comes with the "forward history" thing. Not very > obvious, but when you learn about it, it's pretty nice. Maybe the prompt should show some indication that the default can be fetched by M-n?