From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Evan Aad Newsgroups: gmane.emacs.help Subject: How to search inside a region that has just been used as the target of a replace operation? Date: Fri, 27 Jan 2023 10:55:26 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12981"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 27 09:56:30 2023 Return-path: Envelope-to: geh-help-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 1pLKX7-0003F1-U8 for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 27 Jan 2023 09:56:29 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pLKWN-00037w-UX; Fri, 27 Jan 2023 03:55:43 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pLKWK-00035L-Th for help-gnu-emacs@gnu.org; Fri, 27 Jan 2023 03:55:40 -0500 Original-Received: from mail-yw1-x1130.google.com ([2607:f8b0:4864:20::1130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pLKWJ-0003Ls-7A for help-gnu-emacs@gnu.org; Fri, 27 Jan 2023 03:55:40 -0500 Original-Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-4a263c4ddbaso59077597b3.0 for ; Fri, 27 Jan 2023 00:55:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=iZIQK26F5HuzwjhKHAYMMOLTA8toODTK5PFK27gAo1g=; b=X8ctr9ie0URZFu7DQkjkBUguxn45LTHoHyKnoug28RhGo5FdeR6XaCXjVe73se0Inn atjZA/nXq/W1jXZ0bdbr2mR8GwFwzUlXwQDn/S83R2HNEZHICh8CVn3yIJ6s6wUGnj9Z A6CDk1Z4MJKL/fpJoBamRMzenPk63FmbBZnmUKIUdzJdo5yfGv2GZJBFXsgbkfa6bwAL ZsOUr6uq3YiyD34XDVuIfpirwm2rphOHplGt4h28bLTWv+jW0UxZS0DyYEcowKG1Ugzx uB642LmFhQZVuhIg3aF5uJv6x6yc+H+1B+Bc9abNHT75VNKyH1Fegce6EWdT2nBMvwWE bZ7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=iZIQK26F5HuzwjhKHAYMMOLTA8toODTK5PFK27gAo1g=; b=xQDDt7X5sCUCZu+5vm1ptQlm/mCW5D/nkihTxNA0zLur5enfoRY1Jfek08A2p7jb1M qZ93y8egpvKXA6nIsKNt/PU+p9ZjAq1lX/q0D9Fq/vmVIM3dowceiDqwiQmtSfRcJXb2 dAMgHXquuq+o+mA0nlVKhLRlzMVG0I4B6uCNbU78IS3ICw1Vd0vDSh/I2KNJKXUIjNvU nrcL2/oZPp5ioqixJgNE9EmjoRY+7AkauqunHRF7cxhj6CSJoUmW/TxkF2BBCs2BfbhP P9e7Egh2QjAKl97XHM9Wj2Dt2lYsFgFhojDK9PkZkPDllpLrkTARc5bL+SvaqoB+PMa1 AJTw== X-Gm-Message-State: AFqh2kp1Wm4ntF+9LM9QxY4i2Tk1csBBBvXyj7EiyuyFmM0MngO+KHEF 2TVb4kaB20/gaCh3DSl3fdHpr+ewCanzsHLJUCnJrbqn X-Google-Smtp-Source: AMrXdXt/aon2kdooNEvlgbdfgNZdqO1pAZ219xFegRtjY3C0was/nsejx9HdL9AfzX3Po0FArSJ5fXdGl+03WVFwkvc= X-Received: by 2002:a81:5253:0:b0:501:f4d5:e3fe with SMTP id g80-20020a815253000000b00501f4d5e3femr2335985ywb.221.1674809737153; Fri, 27 Jan 2023 00:55:37 -0800 (PST) Received-SPF: pass client-ip=2607:f8b0:4864:20::1130; envelope-from=oddeveneven@gmail.com; helo=mail-yw1-x1130.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:142533 Archived-At: I'd like to be able to search inside a region that has just been used as the target of a replace operation, without having to specify explicitly the region's start and end points. Here's a concrete usage scenario: 1. Initial state: the current buffer contains the text "ABCBD", and the cursor is on 'A'. 2. Select the region "BCB": C-f C-SPC C-f C-f C-f. 3. Replace all occurrences of the string "C" inside the selected region: M-x replace-string, C, c. The buffer's content is now "ABcBD". Goal: Replace all occurrences of the string "B" inside the region selected previously by the string "b", so that, at the end of the operation, the buffer's content will be "AbcbD". I'd like to accomplish the goal without having to explicitly specify the region's start and end points. How can this be accomplished? Attempt no. 1, the naive approach: 4. Replace all occurrences of the string "B" by the string "b" starting from the state that was in effect at the end of step no. 3: M-x replace-string, B, b. In the end the buffer's content was "ABcbD". The goal is not met, because the first occurrence of 'B' was not replaced, even though it was part of the original region. Attemp no. 2, reactivate the region: 4. Reactivate the region: C-x C-X. 5. Replace all occurrences of the string "B" by the string "b": M-x replace-string, B, b. In the end the buffer's content was "AbcBD". The goal is not met, because the second occurrence of 'B' has not been replaced, even though it was part of the original region.