From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 07 08:39:10 2022 Received: (at 45607) by debbugs.gnu.org; 7 Jun 2022 12:39:10 +0000 Received: from localhost ([127.0.0.1]:38923 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nyYUI-0001yM-A2 for submit@debbugs.gnu.org; Tue, 07 Jun 2022 08:39:10 -0400 Received: from quimby.gnus.org ([95.216.78.240]:53012) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nyYUE-0001xl-Cm for 45607@debbugs.gnu.org; Tue, 07 Jun 2022 08:39:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=t5lNPRynBkz+QKPYv9esCS/UI+ZisfYSndk8xxdivW4=; b=QRENzbltbMU8bUaUSVNPRFFvze 63OIMgU5oNYaw6EsPK6PE8ACnNeSNHqEUUfg3GEutNWQTxIT74zLGlVyc7TwjDMR5ompufBdaMj7o S7LtAF4r5+KxwTcVtMqP8r0RcW9SJqejldiJI05/+uXZUo7qrOxGLs7gJzO7YpepySZE=; Received: from [84.212.220.105] (helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nyYU5-0002b2-9Z; Tue, 07 Jun 2022 14:38:59 +0200 From: Lars Ingebrigtsen To: Allen Li Subject: Re: bug#45607: 27.1; compiled replace-string breaks repeat-complex-command References: <80o8i7676p.fsf@felesatra.moe> X-Now-Playing: Miranda Dali's _Miranda Dali_: "Angels" Date: Tue, 07 Jun 2022 14:38:56 +0200 In-Reply-To: <80o8i7676p.fsf@felesatra.moe> (Allen Li's message of "Sat, 02 Jan 2021 01:04:30 -0800") Message-ID: <87czfkir6n.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Allen Li writes: > Interactive commands that act on the region are handled specially such > that when repeated with `repeat-complex-command`, the repeated command > uses the current region rather than the region used [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 45607 Cc: 45607@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Allen Li writes: > Interactive commands that act on the region are handled specially such > that when repeated with `repeat-complex-command`, the repeated command > uses the current region rather than the region used for the previous > invocation of the command. > > `replace-string` does not respect this; it uses the previous region when > repeated with `repeat-complex-command`. > > Note that loading `replace-string` from source (rather than byte > compiled) fixes this problem. So it's probably a problem with byte > compiled commands. (I'm going through old bug reports that unfortunately weren't resolved at the time.) I can reproduce this problem in Emacs 29? In any case, it's because `replace-string' specifies the start/end position in the `interactive' spec (as it should), so it lands in `command-history', and `repeat-complex-command' just executes that. Other commands, like `flush-lines', have pass in nil as start/end, and then computes the start/end in the body of the function. So this can be fixed by rewriting `replace-string' to do the same... but surely there's a lot of commands out there that say: (interactive [...] (list (if (use-region-p) (region-beginning)) And all of these would have the same problem. (interactive "r") does not, because in that case: (defun foo (start end) (interactive "r") (message "%s %s" start end)) The following ends up there in the history: (foo (region-beginning) (region-end)) Does anybody know of a more general solution to this? The reason replace-string works when it's not compiled is the because then this ends up in command-history: (replace-string "buffer" "foo" nil (if (use-region-p) (region-beginning)) (if (use-region-p) (region-end)) nil nil) For some reason. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no