From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#41692: 26.3; Enhancement request, `query-replace': let user use text at point as default Date: Thu, 4 Jun 2020 16:01:21 -0700 (PDT) Message-ID: <39e06665-8ab7-4b81-a481-9a8ccf3a15e1@default> References: <3705c67a-f3a1-4667-8c3f-67b41752f355@default> <87a71jwyiw.fsf@mail.linkov.net> <878sh2lctc.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="96205"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 41692@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jun 05 01:02:10 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 1jgysD-000Ovy-Ux for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 05 Jun 2020 01:02:09 +0200 Original-Received: from localhost ([::1]:54280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgysD-0000tG-17 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 04 Jun 2020 19:02:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgys6-0000t8-FK for bug-gnu-emacs@gnu.org; Thu, 04 Jun 2020 19:02:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36218) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jgys6-0005UV-5t for bug-gnu-emacs@gnu.org; Thu, 04 Jun 2020 19:02:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jgys6-0005VW-3c for bug-gnu-emacs@gnu.org; Thu, 04 Jun 2020 19:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Jun 2020 23:02:02 +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.159131170821147 (code B ref 41692); Thu, 04 Jun 2020 23:02:02 +0000 Original-Received: (at 41692) by debbugs.gnu.org; 4 Jun 2020 23:01:48 +0000 Original-Received: from localhost ([127.0.0.1]:47764 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jgyrr-0005V1-UV for submit@debbugs.gnu.org; Thu, 04 Jun 2020 19:01:48 -0400 Original-Received: from userp2120.oracle.com ([156.151.31.85]:53834) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jgyrp-0005Un-LP for 41692@debbugs.gnu.org; Thu, 04 Jun 2020 19:01:46 -0400 Original-Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 054MwLP2033083; Thu, 4 Jun 2020 23:01:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=IoirgfJV3wQ4T32ONzeXi8Fg4IRyBHxmxZzSj5JlAP4=; b=lEKBFMoVs8kNajGBYAKevA+Udl5NhZkeF7iA5naFZ4FgXmMZZM5MinFMMIjmC7vuKYGR 0Y51mxk3jrPFDDqTPOUWHs6CrB6fqquGKyGenL11uJPGF5aoc7+O7Dv3fGNUMdtqwjUj nsmEw8BXYVJ8mjOB6u7hw8OC8hEYbcTvZT34hZVfmp7FOW54W/Sw/5e7B3XQTGjvKTK8 YXCGKC0SokJan2yl6bPY7/kVJkOmOJ9eBtv71QqjSrraZvVKn1oxSuzH629CvnbxTlSB X2EyvkgJcUgO8hSE1X1GszwOI93in354TYEbmO3w35MHRGbhJmHXgyUjPaA1qRqcZSOH qA== Original-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 31f9260754-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 04 Jun 2020 23:01:39 +0000 Original-Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 054Mw73I138469; Thu, 4 Jun 2020 23:01:39 GMT Original-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 31f926a2rj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 04 Jun 2020 23:01:39 +0000 Original-Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 054N1ZgP020898; Thu, 4 Jun 2020 23:01:35 GMT In-Reply-To: <878sh2lctc.fsf@mail.linkov.net> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.5005.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9642 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 adultscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006040160 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9642 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 adultscore=0 suspectscore=0 cotscore=-2147483648 bulkscore=0 clxscore=1015 impostorscore=0 priorityscore=1501 malwarescore=0 mlxlogscore=999 spamscore=0 lowpriorityscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006040160 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:181529 Archived-At: > 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)) >=20 > It's easy to extend `read-regexp' with more options, > but what to do for non-regexp case? >=20 > 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". I think I referred you to my code in `replace+.el'. Here it is, in case I didn't: https://www.emacswiki.org/emacs/download/replace%2b.el In my code for `query-replace-read-from' I determine the default value(s) by evaluating this: (search/replace-default (symbol-value query-replace-from-history-variable)) I use function `search/replace-default' in lots of search and replace functions. It's the place where this logic is used to get default values: Return a default value or list of such for search & replace functions. A list of default input strings is computed and returned. The possible strings are, in order: * The active region, if option `search/replace-region-as-default-flag' is non-nil. * The secondary selection, if option `search/replace-2nd-sel-as-default-flag' is non-nil. * The result of calling the value of option `search/replace-default-fn', if non-nil. * The first entry in the history list HISTORY. Option `search/replace-default-fn' lets users decide what function to use, to grab buffer text as the default. The option's default value is a function that grabs the non-nil symbol name that's nearest point. If that function isn't available then the default value is `word-at-point'. HTH.