From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#41692: 26.3; Enhancement request, `query-replace': let user use text at point as default Date: Fri, 12 Jun 2020 01:58:36 +0300 Organization: LINKOV.NET Message-ID: <87a719yztv.fsf@mail.linkov.net> References: <3705c67a-f3a1-4667-8c3f-67b41752f355@default> <87a71jwyiw.fsf@mail.linkov.net> <878sh2lctc.fsf@mail.linkov.net> <39e06665-8ab7-4b81-a481-9a8ccf3a15e1@default> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="20948"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: 41692@debbugs.gnu.org To: Drew Adams Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jun 12 01:39:14 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 1jjWmw-0005Po-Ks for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 12 Jun 2020 01:39:14 +0200 Original-Received: from localhost ([::1]:47370 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjWmv-00033l-GC for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 11 Jun 2020 19:39:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44082) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjWmm-00030C-By for bug-gnu-emacs@gnu.org; Thu, 11 Jun 2020 19:39:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55075) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jjWmm-0001FJ-0a for bug-gnu-emacs@gnu.org; Thu, 11 Jun 2020 19:39:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jjWml-0005pG-VA for bug-gnu-emacs@gnu.org; Thu, 11 Jun 2020 19:39:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 Jun 2020 23:39:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41692 X-GNU-PR-Package: emacs Original-Received: via spool by 41692-submit@debbugs.gnu.org id=B41692.159191873022327 (code B ref 41692); Thu, 11 Jun 2020 23:39:03 +0000 Original-Received: (at 41692) by debbugs.gnu.org; 11 Jun 2020 23:38:50 +0000 Original-Received: from localhost ([127.0.0.1]:38380 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jjWmX-0005ny-QS for submit@debbugs.gnu.org; Thu, 11 Jun 2020 19:38:50 -0400 Original-Received: from relay3-d.mail.gandi.net ([217.70.183.195]:35301) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jjWmV-0005nM-LQ for 41692@debbugs.gnu.org; Thu, 11 Jun 2020 19:38:47 -0400 X-Originating-IP: 91.129.108.6 Original-Received: from mail.gandi.net (m91-129-108-6.cust.tele2.ee [91.129.108.6]) (Authenticated sender: juri@linkov.net) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 8A5FD60002; Thu, 11 Jun 2020 23:38:41 +0000 (UTC) In-Reply-To: <39e06665-8ab7-4b81-a481-9a8ccf3a15e1@default> (Drew Adams's message of "Thu, 4 Jun 2020 16:01:21 -0700 (PDT)") 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:181875 Archived-At: --=-=-= Content-Type: text/plain >> Currently `query-replace-read-from' has: >> (if regexp-flag >> (read-regexp prompt nil 'minibuffer-history) >> (read-from-minibuffer >> prompt nil nil nil nil (car search-ring) t)) >> >> It's easy to extend `read-regexp' with more options, >> but what to do for non-regexp case? >> >> Maybe to try to use `read-string' and extend it with >> more M-n options like in `read-regexp'. > > I don't understand the question. `read-from-minibuffer' > accepts a list of default values. Or maybe I don't > understand what you mean by "more options". Right, let's add more default values to `read-from-minibuffer': --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=query-replace-read-from-defaults.patch diff --git a/lisp/replace.el b/lisp/replace.el index 69092c16f9..a5a5200df7 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -227,7 +227,16 @@ query-replace-read-from (if regexp-flag (read-regexp prompt nil 'minibuffer-history) (read-from-minibuffer - prompt nil nil nil nil (car search-ring) t))))) + prompt nil nil nil nil + (delq nil + (list + (when (use-region-p) + (buffer-substring-no-properties + (region-beginning) (region-end))) + (find-tag-default) + (car search-ring) + (car (symbol-value query-replace-from-history-variable)))) + t))))) (to)) (if (and (zerop (length from)) query-replace-defaults) (cons (caar query-replace-defaults) @@ -798,6 +807,9 @@ read-regexp-suggestions appends the list returned by this function to the end of values available via \\\\[next-history-element]." (list + (when (use-region-p) + (buffer-substring-no-properties + (region-beginning) (region-end))) (find-tag-default-as-regexp) (find-tag-default-as-symbol-regexp) (car regexp-search-ring) --=-=-=--