From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#45607: 27.1; compiled replace-string breaks repeat-complex-command Date: Tue, 07 Jun 2022 14:38:56 +0200 Message-ID: <87czfkir6n.fsf@gnus.org> References: <80o8i7676p.fsf@felesatra.moe> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4039"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 45607@debbugs.gnu.org To: Allen Li Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jun 07 15:03:50 2022 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 1nyYsA-0000m2-Eb for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 07 Jun 2022 15:03:50 +0200 Original-Received: from localhost ([::1]:43752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyYs9-0004jF-2S for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 07 Jun 2022 09:03:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyYV9-00082N-1G for bug-gnu-emacs@gnu.org; Tue, 07 Jun 2022 08:40:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45029) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyYV8-0003dP-Lj for bug-gnu-emacs@gnu.org; Tue, 07 Jun 2022 08:40:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nyYV8-0001zn-Gp for bug-gnu-emacs@gnu.org; Tue, 07 Jun 2022 08:40:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 07 Jun 2022 12:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45607 X-GNU-PR-Package: emacs Original-Received: via spool by 45607-submit@debbugs.gnu.org id=B45607.16546055507590 (code B ref 45607); Tue, 07 Jun 2022 12:40:02 +0000 Original-Received: (at 45607) by debbugs.gnu.org; 7 Jun 2022 12:39:10 +0000 Original-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 Original-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=; Original-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 X-Now-Playing: Miranda Dali's _Miranda Dali_: "Angels" In-Reply-To: <80o8i7676p.fsf@felesatra.moe> (Allen Li's message of "Sat, 02 Jan 2021 01:04:30 -0800") 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:233880 Archived-At: 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