From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hongyi Zhao 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 20:58:49 +0800 Message-ID: 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; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35419"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs To: Stephen Berman Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 23 15:00:09 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 1mTOKf-00091S-0W for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 23 Sep 2021 15:00:09 +0200 Original-Received: from localhost ([::1]:45838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTOKb-0001En-E3 for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 23 Sep 2021 09:00:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56736) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTOJe-0001Ci-74 for help-gnu-emacs@gnu.org; Thu, 23 Sep 2021 08:59:06 -0400 Original-Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]:42788) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mTOJc-0005jb-J1 for help-gnu-emacs@gnu.org; Thu, 23 Sep 2021 08:59:05 -0400 Original-Received: by mail-lf1-x12b.google.com with SMTP id u8so25714865lff.9 for ; Thu, 23 Sep 2021 05:59:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sjPzzKcrzdAI8NoAvTABlU4zZlTZGsrRjkH2ok3lHpg=; b=XoO3dZ2DuAL5ONUdsWZ060EHhfILMAgQQ22qhQ0CCBo7/7vcD7E0l54u6qzT/LOnz4 gTYwI4W/ZqRCmK49E1noKe2uOKY/RBx5ygQD4PqWa9bb2PPe8gj48IY7ql0zRl5PU1dn 6ZVinN2zqo50czgVFWVeXp1zmvtT/KqyQuwx2IVjvRyECYHzz41o57d0SFdaqKQU7Gd2 k88Z6HIM/oULTyAl5jSojQMLsr9rhmRCqxitGOFxeRfzFUfc1ME7pLvIvtQUCHLna3CT ul9J0vTBfSdZIv4tU0OMWCvTLE68cClrldMetumElVqBudJy4hS4TZ/5I6jxFgtOk0B1 Q5og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sjPzzKcrzdAI8NoAvTABlU4zZlTZGsrRjkH2ok3lHpg=; b=kDJIV9jnLMII/Dn6EXqUoYzlMGrd3RBEmheslDnQpUIcBEj/xZwUvTSDVUEEsTsoJA BdbUhG/p88qVN9uLk9fJUPtM1Rquh8nL86Ro6S0BAyZVqSwJ3k+lqMw5nmxUOPB9lfdP 6sv4JZNaISIxJyAQb9nVqpAiGtSLFssxywD5wFleoKREF/fQn17X1MBMRouQ8EHcGW+O PcEEf8UCza73qQ5rvdFRFCrJ6/Qd/Y1tbiez1jLYAEKQiIX+cCnDCiTb4PSdT0iivt5t X5uy2sDBW40antkyYQhP7k6ycQf0dln+PYMQxY3MD5IN9nuhibLNYyH5ca38iNWl+d++ eWXA== X-Gm-Message-State: AOAM533nJmKIFteNbFSqN5KYaNx8bS7DqvqzNp4SJhFMCVKkOysA2WWc 3yvFjma8kb/WbLaRQFjQfmHUQxqEcX74dtfmhOE= X-Google-Smtp-Source: ABdhPJyL8ss6nrwCXnmhdHgu06yLXJAjX+KD0IhAKnBa1ts/zXhEirUsCmR74AjPXjH4NBiO/JUflXiG/5yBpu42vls= X-Received: by 2002:a05:6512:13a5:: with SMTP id p37mr4009043lfa.403.1632401941914; Thu, 23 Sep 2021 05:59:01 -0700 (PDT) In-Reply-To: <875yursi9b.fsf@rub.de> Received-SPF: pass client-ip=2a00:1450:4864:20::12b; envelope-from=hongyi.zhao@gmail.com; helo=mail-lf1-x12b.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.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:133182 Archived-At: 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 Best, HZ