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: Mon, 27 Sep 2021 13:57:41 +0800 Message-ID: References: <878rzj7xt8.fsf@web.de> <87o88esthh.fsf@zoho.eu> 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="40146"; mail-complaints-to="usenet@ciao.gmane.io" To: Emanuel Berg , help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 27 07:58:45 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 1mUjf2-000AH7-GZ for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 27 Sep 2021 07:58:44 +0200 Original-Received: from localhost ([::1]:55428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mUjf1-00026J-G1 for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 27 Sep 2021 01:58:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38998) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUjeG-00024j-Px for help-gnu-emacs@gnu.org; Mon, 27 Sep 2021 01:57:56 -0400 Original-Received: from mail-vs1-xe30.google.com ([2607:f8b0:4864:20::e30]:42612) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mUjeD-0007eb-Pw for help-gnu-emacs@gnu.org; Mon, 27 Sep 2021 01:57:56 -0400 Original-Received: by mail-vs1-xe30.google.com with SMTP id z62so16861535vsz.9 for ; Sun, 26 Sep 2021 22:57:53 -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; bh=AsXxtxSZN2L+IJzebODc1mk/dFC4hUdSB9fVKLf0bPA=; b=DdNG6pBQbdrlMTFRHczEuHwFknZnD3iCePh+xQaoApaV/z7Gq+rgfDh2+fcQ+8I6cm kBZ/JctbGlW2uySECpI5lb+LXMmLwuMDFXdvqzcJ7XU4AcptTcVUoVDdGqBb0zneDDdc Vb7/EXWarPNNnMhyw9ShBOqUkgYcz3vNkBE+jwtXowYKJ2uoiUVsLq1oBiNNF6Aw/zN8 dQLMf9tY0UtKYp7TThgEtSbkocJHktTUOMXcDglohz43DEU1qypqMy/L0s8XIzWjPXDq RxzPkhhxSdfc8scsG4Pbvs+vSw2DAhCixG43FuUUsfbYus8/FUtTqyd01Nh6tTuwgYKb aOPw== 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; bh=AsXxtxSZN2L+IJzebODc1mk/dFC4hUdSB9fVKLf0bPA=; b=txq4IsPy4zJOjiyMUqtNLS6Cvo686+3iKV5XVFMXCzJ97UwE/dH4/Dxncicz/RDbwg IlhQHQPlWTYF9af2lEuS33gdTTrpXlfUvsNcltDthGsjPeh48ktqkv24f3mhqcTQBYNk TiK2h/KSxJp2qUwxwYkH1olY+l/jQNE6gY+KeT5kA/QFY/ZNo3tfhfLPml+yI4fARP06 F7oq8xSfBzdBSU8buadkPxoq5cZclHq+gfMi2tfQJgn2AICe/1tNYjCpSwZruFDWcQMW qD2vU6mLL0tQnP4hjQAjBjXPc8w1c8ViBDW7G+mQVpMHyvsmgUgYbpK54CQ1srl7esju bLAQ== X-Gm-Message-State: AOAM530MBSChOnlg8+sYL1glI7yYV3k8fiXUwt50fH4k9T3pj8KiTPnM PhcOuvLPSDLdAnuDGaXY/a7dGpam2FoxEHkDv/8= X-Google-Smtp-Source: ABdhPJx9nxaKHBBwKhTH/trct41oxbVJmxqzafsBWSg/fMiipcM9jBy6U5A1CKjyl06n0ruW8KXoDfDYgqANW+dleX8= X-Received: by 2002:a05:6102:1357:: with SMTP id j23mr17225789vsl.25.1632722272677; Sun, 26 Sep 2021 22:57:52 -0700 (PDT) In-Reply-To: <87o88esthh.fsf@zoho.eu> Received-SPF: pass client-ip=2607:f8b0:4864:20::e30; envelope-from=hongyi.zhao@gmail.com; helo=mail-vs1-xe30.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:133283 Archived-At: On Mon, Sep 27, 2021 at 9:22 AM Emanuel Berg via Users list for the GNU Emacs text editor wrote: > > Arthur Miller wrote: > > > | some | 34 | | > > | word | 30 | | > > | another | 38 | | > > | thing | 59 | | > > | to | 39 | | > > | say | 10 | | > > | here | 47 | | I'm still not so clear about the above method, especially, must I add all the vertical bars to my original data for doing this operation and then remove them again? > > Her you go: > > (defun inc-all (&optional beg end) > (interactive (when (use-region-p) > (list (region-beginning) (region-end)) )) > (let ((bg (or beg (point-min))) > (ed (or end (point-max))) ) > (save-mark-and-excursion > (goto-char bg) > (while (re-search-forward "[[:digit:]]\\{2\\}" ed t) > (replace-match > (format "%d" (1+ (string-to-number (match-string 0)))) ))))) Again, must the above code depend on vertical bars/lines in the data? HZ