From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: [Patch] Add project.el command to replace symbol at point throughout project Date: Thu, 13 Jan 2022 00:12:11 +0200 Message-ID: <62b2cf17-60ec-63cf-99d0-6d38d8b1a869@yandex.ru> References: <88e2f28a-925b-551c-b85b-0af400997dc5@yandex.ru> <699f09df-d685-ce80-7c57-a36824e7066b@yandex.ru> <868rvkpw2u.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17308"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 Cc: Jon Eskin , emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jan 12 23:14:39 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 1n7lt9-0004QF-MC for ged-emacs-devel@m.gmane-mx.org; Wed, 12 Jan 2022 23:14:39 +0100 Original-Received: from localhost ([::1]:54532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n7lt8-0006Xg-Mk for ged-emacs-devel@m.gmane-mx.org; Wed, 12 Jan 2022 17:14:38 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7lsE-00059i-No for emacs-devel@gnu.org; Wed, 12 Jan 2022 17:13:42 -0500 Original-Received: from [2a00:1450:4864:20::430] (port=42639 helo=mail-wr1-x430.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n7lsC-0001i9-M9 for emacs-devel@gnu.org; Wed, 12 Jan 2022 17:13:42 -0500 Original-Received: by mail-wr1-x430.google.com with SMTP id k30so6720321wrd.9 for ; Wed, 12 Jan 2022 14:13:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=5owxuZ/czjbGAjA3L9KltzUERJ+gYOyYHOr8EmtUzc4=; b=pUcuto5peilHaHKvGub7LrLhMCWuP/X4qdIo2vznX7avXWfWVZbpR0KojQis3ZAI5W OeUwcudag/2JWPf4Il6xd0UKOMC1Rk26G0qgQTAqyfRbwX590oU7ilH0EsvH3l9QWaEQ 2TMIRm93LPLyLTcbmIpQ0/NFR+aZCGPQJ+7g1+/WoK3nCWFeS37HvQxu8tBzfCuHiQLt 92tpU6Cyb3VN3VfnbGQHa6bSUqlEmqqGoo/ribeculsQPJdc6k31bsSdsWfFQmSnfwb+ ZhVwZVQXYwdm2vTPEtoEunlhC5u/lhXaj3t/8ijQQ6PALf/yMYebas7ljg/Xi5tmKe9l 4d2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=5owxuZ/czjbGAjA3L9KltzUERJ+gYOyYHOr8EmtUzc4=; b=kXZtH4B651Wfpx+uTSAVzE2eObZw31OSIhDpuj347lRj+bkmE8LBHVDx0equi9KY75 wAAizmL80gSNCEC/tnsstM55TmA2QpAG3bU3iUiGLNsC1827hW5yxMeF04swtQCBmkIE JBTE3frmfOcXSsXSoVVPzr4OoF7Bqm6eLX6ztRQsNgfQyJye/E4jneFHz5tNjIc4NxgZ xATd3lP5wWmF2kFXbfZ2RBc6jZVOoM6kTG5x+XlxA4ilXHzdyme2gtIbN7pcw5Q0qoG6 JY4A5euM88rzo6U6T5Zad+59SGBzyt48XoFPcfMTRR+UOHSB6E6XoTiqHc9MAl/j0dao e4gw== X-Gm-Message-State: AOAM533xUquBhDWY5GfTCnH64fmIXqP4VIt9OIf+n45LZCd2lmoccjBU YVTNIUFmvfeg2NbgeBVX7Fl35549biA= X-Google-Smtp-Source: ABdhPJyG1xR76W95u2t4kgzb01t1OYvPZEVOzAPkqM4+/9DCvBcUH/TSZI/gvoGG+vNsVp0pIqprFQ== X-Received: by 2002:a05:6000:1548:: with SMTP id 8mr1377022wry.489.1642025618958; Wed, 12 Jan 2022 14:13:38 -0800 (PST) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id s1sm845392wrv.38.2022.01.12.14.13.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Jan 2022 14:13:38 -0800 (PST) In-Reply-To: <868rvkpw2u.fsf@mail.linkov.net> Content-Language: en-US X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::430 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=raaahh@gmail.com; helo=mail-wr1-x430.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NICE_REPLY_A=-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:284670 Archived-At: On 12.01.2022 21:56, Juri Linkov wrote: >>>> 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. That probably makes sense. But the user could use 'M-p' for that and otherwise enjoy a different default (FROM defaulting to symbol-at-point). But it would be a breaking change, admittedly. > 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. ...or that. After all, when doing project-wise replacements, you probably wouldn't repeat the same search twice. Or at least, not do it often. >>>> 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? Could be an improvement, but I'm not sure how that'd look, or what text to show ("future history" is not a very obvious name).