From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.help Subject: Re: Emacs: adding 1 to every number made of 2 digits inside a marked region. Date: Thu, 23 Sep 2021 15:29:04 +0200 Message-ID: <87tuibqv33.fsf@rub.de> References: <87pmt0bdao.fsf@rub.de> <87r1dfsqj4.fsf@gmx.net> <87ee9fsojd.fsf@rub.de> <87a6k3siyp.fsf@rub.de> <875yursi9b.fsf@rub.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28669"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: help-gnu-emacs To: Hongyi Zhao Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 23 15:29:32 2021 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 1mTOn5-0007K0-Vc for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 23 Sep 2021 15:29:31 +0200 Original-Received: from localhost ([::1]:39442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTOn4-0001LX-7C for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 23 Sep 2021 09:29:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTOmj-0001LP-RX for help-gnu-emacs@gnu.org; Thu, 23 Sep 2021 09:29:09 -0400 Original-Received: from mout.gmx.net ([212.227.17.22]:39509) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTOmi-0005F0-6v for help-gnu-emacs@gnu.org; Thu, 23 Sep 2021 09:29:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1632403746; bh=BZwfRHRHUcNoa0v4018yd9cja2zWYG5XwCKSYLDDFmc=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=eYMYcYj6QD5JAjS85JgHdoaw9tTnl0kk0ziqZITDa+rbe+LChDwFkuEgt2Ib6kfjJ 1ll35fmXzgOGncPsDgLCeYrxAolb1RC9bI3kAhqF60xxQbZ+0RUQwLqfy9VHirwkZo Rxj/Y/dE6xFAlJp8yhfTCOGTvdD2Kv45V8W9EATM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from strobelfs ([188.109.192.197]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N0XD2-1moFcr34r6-00wV3y; Thu, 23 Sep 2021 15:29:05 +0200 In-Reply-To: (Hongyi Zhao's message of "Thu, 23 Sep 2021 20:58:49 +0800") X-Provags-ID: V03:K1:4vhgQQhyRH0NhVku9BsfFZjHQ65ukiYNnUH8Yz10vQKlcEuzjgX AmbYPBmMbXryDfBQfQCKzEw6OvZ9WIbW+EYs891au/MUagTHxktU+hhqWpuTbas6V8168sz qOIWgOpj2oRdsV6VpgJPyUnUICAPm46F7AhWUb7ifUEnhdFoqc1PvjuL+lUVvMI9F6ON1vr X9lWG+/x0t58EF+vafcCg== X-UI-Out-Filterresults: notjunk:1;V03:K0:1UebCsmR0rE=:DNYaU7EuQSzI5FDqucXqZI C6QEca1SggM8xr6tGQqqt4EHuh9Dmh+j+utmDsMpifoLOi7g3FlCYCj2ldCDnTf5e6E95xz0H u4Vd63RSkhCcL3xqVsGpAKNeRwSygDyypvHZYBy8J0HibkKiejWYwCpm9O1EmuPAYIqZkhOf6 y5Gko+vMdvZ0LtXV9foClf3J9kSBu28GNcYUbcluUNqCX3/nYT4rZbarQ1ITyUEXNIrqy8T7r 3CTgQ60R1lIvd8NXcc0GGlrvmK2xh0QIUzU/+obth/K/kgamoN2rCB9LULu+RIcDwXz47h1Od IhpOwkQOA2Crk4oswq+DEQDZZWzQyXEhSxbZwBSOMJb8RIa3Ixx1tK8aQ0vs7t2VbQV5miUuu QO7xWn7oiSjxIQUCcom2jeHC4VPaYIOdnVtGyIsCnPY3XlJyZmbkJEzU61ILpiaPehLHNGo3w p5IaAJApkqhbeBMPEpk468kcBLUUxJlUftIY5NnKChNMkFX4FM+vzrXnTcEGFa1gmPUhnQHb5 T+QDYEIGe3e2AtBFidG6fk/8ElHSw+NRGpKE+sua6p8cX6CglK7jWF2A6U9+0NFclKMyI2IVh Qr5FkQUZyArkx77A8OROihd8dLCtw4ZMF+R/3cxWeM9zZu41p+zhTvqM0L+ySYfQu40pUfr+P Do+zQfHr9KwgpE/UwrbbnPBmTt41hJDb0o8PjF6htkzJNYwSTd+MuX/JEGU3sML43qHuqlcyF S6nDecXQsVYAk/8gCwnYgu0TtlbyuNMsU15lDaZw3/5i2h9hOqaJ6lLBQUBDaAHn8EypOi4O Received-SPF: pass client-ip=212.227.17.22; envelope-from=stephen.berman@gmx.net; helo=mout.gmx.net 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_MSPIKE_H2=-0.001, 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.23 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" Xref: news.gmane.io gmane.emacs.help:133185 Archived-At: On Thu, 23 Sep 2021 20:58:49 +0800 Hongyi Zhao wrote: > On Thu, Sep 23, 2021 at 6:23 PM Stephen Berman wrote: > [...] >> > Tried but it does nothing. >> >> Since you're now searching backwards, are you sure you had point *after* >> the numbers? I.e., if this is the *scratch* buffer: >> >> ------------------------------------------------------- >> ;; some 35 >> ;; word 31 >> ;; another 39 >> ;; thing 60 >> ;; to 40 >> ;; say 11 >> ;; here 48 >> >> (while (re-search-backward "[[:digit:]]\\{2\\}" nil t) >> (let ((x (match-string 0)) >> (pt (point))) >> (delete-char 2) >> (insert (format "%d" (1+ (string-to-number x)))) >> (goto-char pt))) >> ------------------------------------------------------- >> >> then put the cursor at the end of the sexp and type `C-x C-e'. > > This way works. But the invalid method I tried before is as follows: > > Select the data block and put the point at the end of it in scratch, > then `M-:' the above code in minibuffer. With this method, I only the > following message generated in minibuffer: > > Mark set > nil If by selecting the data block you mean: (with emacs -Q) putting point before the start of the block, typing `C-SPC', then moving point to the end of the block: that works for me, so I don't know why it doesn't work you. Steve Berman