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: Mon, 17 Jan 2022 02:19:50 +0200 Message-ID: <921c0b69-7bac-b78a-54d8-987165331661@yandex.ru> 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> <86czkr36ll.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23568"; 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 , Eli Zaretskii , emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jan 17 01:22:20 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 1n9Fmt-0005zM-Ky for ged-emacs-devel@m.gmane-mx.org; Mon, 17 Jan 2022 01:22:19 +0100 Original-Received: from localhost ([::1]:44318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n9Fmr-0003eR-MH for ged-emacs-devel@m.gmane-mx.org; Sun, 16 Jan 2022 19:22:18 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:44332) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9Fm4-0002zT-IF for emacs-devel@gnu.org; Sun, 16 Jan 2022 19:21:28 -0500 Original-Received: from [2a00:1450:4864:20::32a] (port=42736 helo=mail-wm1-x32a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n9Fm2-0004NS-Gh; Sun, 16 Jan 2022 19:21:28 -0500 Original-Received: by mail-wm1-x32a.google.com with SMTP id ay4-20020a05600c1e0400b0034a81a94607so18045237wmb.1; Sun, 16 Jan 2022 16:21:25 -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=r9r+ii4WzcCe19vflfcoFet5E4o5RXkevaJBp5Sd7sM=; b=YyehSUDPjk6q5TiE2lmsoi2An2YmXO09HTO3y+MQuP5B/7kMbA9tCbd8B3uTg9FHCO +aPHO61uAtpAP1XflErtJvZrMIJfrztpW+RgAwLuX5HDqTmso/xw3D5ojkyXq/+wwZmJ fxrqf1wp/AUDb727gxCMLSssd4FAQJfSWHnbLnY6UYmdR4WzGsryZ/ArXKbxs6DmJIbi 3auA4KckSz6jnjtt8/r5Sl1JbrPhewC4PlpuBUbW/KHSUO82xXWTsc4j9szyo7EXVKCH pe7vkil+xiR3ObbIXo/gYwxtZpxjVFbkKtOFWLpJ+vGsT9BDOYT+MnRIfSVb86tPcnw3 NR/w== 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=r9r+ii4WzcCe19vflfcoFet5E4o5RXkevaJBp5Sd7sM=; b=o5d0tMj16jddtIsJyHZQHi30Of2FD+KQamvXCnUtpOXgXq5TuM6g69iTZ0wtZIDxJu lGSBxwArU677+OCwSFr6l35Ea7AtyeyCBi8qWUUnPDQTCMzs7g4byURAKjutHB56sCZ8 IzWjyc2L2m9pfqfMJzTWslicLfSc4DuFjwLi4GFd59FrAaouICxGRPQpYY6R79scDDZX 2Sx4uhavcfi3xe98tC0wadha37JGCkpSENEu7DE8EWikfFOQ5MnTM8r2Ilz1bo2VYfcn k0Zs5chmM+9gKv0Q0O04BNK9YRT94mvRxRhjH4huu4iLinpioorIzAncpX5tPFRg+rfQ 0rwQ== X-Gm-Message-State: AOAM532ioWN634LcZ4wnvNeBv+IsDG87sm23UdVMhNnIfNKfetf1jWO2 AqP0Z0qsVwN7+S7ghVWQ0N2UK0iK7ro= X-Google-Smtp-Source: ABdhPJxK0++fns2rUlxfLIN3mmI+ylSoGGxzPvuf6NvU9Io+AC/9nRlQsAMDcQ8KIk3frsZNzK8DGA== X-Received: by 2002:a7b:c457:: with SMTP id l23mr25001171wmi.57.1642378885011; Sun, 16 Jan 2022 16:21:25 -0800 (PST) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id a18sm11929352wrf.42.2022.01.16.16.21.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 16 Jan 2022 16:21:24 -0800 (PST) In-Reply-To: <86czkr36ll.fsf@mail.linkov.net> Content-Language: en-US X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::32a (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=raaahh@gmail.com; helo=mail-wm1-x32a.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.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NICE_REPLY_A=-0.001, PDS_HP_HELO_NORDNS=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:284853 Archived-At: On 16.01.2022 19:58, Juri Linkov wrote: >>> 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. The patch works for project-query-replace-regexp but not for xref-find-references-and-replace, which still doesn't suggest the symbol at point as FROM (BTW, in the final version this function should probably use #'find-tag-default rather than 'find-tag-default-as-regexp). >>> 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. I don't really have a preference as to how the implementation is organized, as long as it all works. As far as I'm concerned, it might as well use read-regexp-defaults-function. But the implementation is made more complicated by the fact that read-regexp and read-from-minibuffer treat their PROMPT and DEFAULTS arguments differently. E.g. the latter won't return DEFAULT-VALUE on empty input and won't format the prompt. If I use read-string instead, it uses the default value instead of empty input, but does not format the prompt still. > It already uses > 'query-replace-read-from-suggestions' where the top value > could be the default. That would affect all callers of query-replace-read-from, wouldn't it? I'm not sure, but a conservative approach (which we often take here) would be to try to avoid that.