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: Sun, 16 Jan 2022 19:58:46 +0200 Organization: LINKOV.NET Message-ID: <86czkr36ll.fsf@mail.linkov.net> References: <83zgo2770l.fsf@gnu.org> <83zgo15dhp.fsf@gnu.org> <83czkw3uvl.fsf@gnu.org> <170a1c89-7767-0930-f726-f7b2551876b2@yandex.ru> <44f72f97-d1d8-0b4c-73a0-7f077fb1ef26@yandex.ru> <0617E8BF-CC43-4D82-8648-064252F644FD@gmail.com> <86pmos3no7.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25446"; 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 , Eli Zaretskii , emacs-devel@gnu.org To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jan 16 19:04:17 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 1n99t2-0006Ol-W6 for ged-emacs-devel@m.gmane-mx.org; Sun, 16 Jan 2022 19:04:16 +0100 Original-Received: from localhost ([::1]:60852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n99t1-0006Xd-Hg for ged-emacs-devel@m.gmane-mx.org; Sun, 16 Jan 2022 13:04:15 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:37080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n99rz-0005AL-JU for emacs-devel@gnu.org; Sun, 16 Jan 2022 13:03:12 -0500 Original-Received: from relay9-d.mail.gandi.net ([217.70.183.199]:36713) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n99rx-0002SH-Nd; Sun, 16 Jan 2022 13:03:11 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 711DAFF804; Sun, 16 Jan 2022 18:03:06 +0000 (UTC) In-Reply-To: (Dmitry Gutov's message of "Sun, 16 Jan 2022 05:02:35 +0200") Received-SPF: pass client-ip=217.70.183.199; envelope-from=juri@linkov.net; helo=relay9-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_H2=-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:284842 Archived-At: >> This is needed to handle `read-regexp` in `occur-read-primary-args` >> that uses the symbol `regexp-history-last` by default. > > occur? > > read-regexp is called from query-replace-read-from. > > Binding read-regexp-defaults-function doesn't seem to work because its use > is for some reason predicated on (and defaults (symbolp defaults)) > evaluating to non-nil. > > And 'read-regexp' is called with nil second argument. The customizable user option 'read-regexp-defaults-function' was created for the following problem: by default, 'occur' uses the last history item as the default value, so 'read-regexp-defaults-function' could be customized to get a tag at point as the default value of 'occur'. Exactly the same situation is with 'query-replace-read-from': by default, it uses the last history item, so changing the value of 'read-regexp-defaults-function' should also affect the query-replace like in the patch that I sent to Jon. >> Before finishing this implementation, please answer one question. >> `query-replace-read-from` uses two minibuffer-reading functions: >> (if regexp-flag >> (read-regexp prompt sym-at-point 'minibuffer-history) >> (read-from-minibuffer >> prompt nil nil nil nil >> (query-replace-read-from-suggestions) t)) >> Do you think the same default with the symbol at point >> should be used for the non-regexp case with read-from-minibuffer as well? >> If yes, then we need a different solution that works for both cases. > > It doesn't have to be the same. project-query-replace-regexp could bind > read-regexp-defaults-function, and xref-find-references-and-replace could > bind something else. But that variable still needs to be created. xref-find-references-and-replace calls query-replace-read-args with a non-regexp flag, so I have no idea what new variable could be created for read-from-minibuffer. It already uses 'query-replace-read-from-suggestions' where the top value could be the default.