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 09:24:31 +0200 Message-ID: <87r1dfsqj4.fsf@gmx.net> References: <87pmt0bdao.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="3361"; 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 09:26:03 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 1mTJ7J-0000iw-Hi for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 23 Sep 2021 09:26:01 +0200 Original-Received: from localhost ([::1]:35752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTJ7H-0002SU-EW for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 23 Sep 2021 03:25:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTJ5z-0002SE-Nj for help-gnu-emacs@gnu.org; Thu, 23 Sep 2021 03:24:39 -0400 Original-Received: from mout.gmx.net ([212.227.15.19]:59807) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTJ5v-0005Ca-3c for help-gnu-emacs@gnu.org; Thu, 23 Sep 2021 03:24:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1632381872; bh=jgvaRIQ90qrbw7Jq5KErNE3vwMR+XfXTT5aryODm/Ms=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=HNMnb6iiU4rNJQ0dDAOXpV5brH+Vd5fOhcMTGQcdKDBiKm5NBztJAf3gWrpOtMHDk +aT1CGx5ZESAgX7ntow2Qusl5GjTZ8XKU3fDJXhx9oHHJDb6mN+lo7n8NZxifNuq8L ZjZsXY9HHcDxVUVv2AFPhcUyGfqa7bRbJOcufkoE= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from strobelfs ([188.109.192.197]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MD9T1-1mcLVB1u1B-009CWm; Thu, 23 Sep 2021 09:24:32 +0200 In-Reply-To: (Hongyi Zhao's message of "Thu, 23 Sep 2021 08:23:26 +0800") X-Provags-ID: V03:K1:gNQA9xhRtPp83QXhH1CXGiz3K2FZVnqq6l+ouN4dqdIr5SxEAcr 7ohVdCoLnGp1D1GZs6anX1WFU+CGrWlvRzGKhGNTzQJSgJSe8yNGbYV7fh7syZ8aEaVcPMJ dcNVQTzeqxdTQa4es9eqokxoddp8OWqdMkOUzRNN0JRBuT0cbIiwJOAUeSYxbgWYTN5gOqV /8MFFjihBdHCHOx0zdY6A== X-UI-Out-Filterresults: notjunk:1;V03:K0:MYQ4+NqkNDU=:U26A0KDY86FjxXKKXCz3pV zdQwE2CFUJkTBj4cDfPRWy3SH6U/zzXMux6CRsLUgnKNMyBqq7LhYqIWvQ0e9ywaJABQeu75G Wq2tyVZnRglpPbXpW4Gt7Oe+u0iaTN490Zrh1s7bHKO/2diSL4BW8O8ExMZ9f/c9zxS4D2kHS raKtv8W+L5lr1kClooP62Tpx6QKNIXaiUeriLugUO3QWY7iObvwm2eNbbzkNZ0QegEefoZoV8 zPZNsQstqxkoCh4rS+GD+Maz0k4cHKb4a15CheooyWVqiTwphZ/dZ6lS5/3YUIN5sSPI834oc hX4vKt30jFQ5FZKKaEst55TYzdeydiXHiGY44bQ9sPYyhDzoJJEpH1N7zlAuBcPvwWqsjRWD6 REZJ9ip/9KR7XmThDg+NCI4sp6kFXnvZ/jVzOmzJ0NCjU397J32UlQQRm3k4yXZcAAluCiJ0U uXuZyNc+f9tYS13tE0bfqY14GYpNyETS7lBqdcc4X3NR356NQBFugDLDxp7h7l1LY0YCkZWGh r6WOEP53ysgs5yvXROvlJLYe4bXluhC3g6yLEKb8XDfYKTEgehUlOvw1rRfNE0N9tVLMVsJCl V7TbTH65/pdnaZD28ny8ZzANauHcvroylGgqENBAL3Zax0EUdXfO1N0w+hzuIdXMXQajGYNVJ uTv4bnYd/ptVwQcalmArxi2xbH7DS2W/N9NMHavF3AZkXdNzry9C/pLN+h1vDjNPA/I7l1Ytn pC5P6QViMZuHhrOwB8kQjlfpxoEeMP3Q528uqtlikwZjFmXh9jHQglMCfhyXuMEqZJRGFSHF Received-SPF: pass client-ip=212.227.15.19; envelope-from=stephen.berman@gmx.net; helo=mout.gmx.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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:133164 Archived-At: On Thu, 23 Sep 2021 08:23:26 +0800 Hongyi Zhao wrote: > On Thu, Sep 23, 2021 at 3:50 AM Stephen Berman wrote: >> >> On Wed, 22 Sep 2021 22:28:28 +0800 Hongyi Zhao wrote: >> >> > Today, I stumbled on this interesting discussion here [1]: >> > >> > -------------------- >> > Imagine I've got the following in a text file opened under Emacs: >> > >> > some 34 >> > word 30 >> > another 38 >> > thing 59 >> > to 39 >> > say 10 >> > here 47 >> > >> > and I want to turn into this, adding 1 to every number made of 2 digits: >> > >> > some 35 >> > word 31 >> > another 39 >> > thing 60 >> > to 40 >> > say 11 >> > here 48 >> > -------------------- [...] > This one does nothing: > > (while (re-search-forward "\\<[0-9][0-9]\\>" nil t) (let ((x > (match-string 0))) (delete-backward-char 2) (insert (format "%d" (1+ > (string-to-number x)))))) It works for me. How exactly did you use it? Steve Berman