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 08:42:10 +0800 Message-ID: References: <878rzol51e.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="29449"; 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 Thu Sep 23 02:43:07 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 1mTCpO-0007TP-UU for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 23 Sep 2021 02:43:06 +0200 Original-Received: from localhost ([::1]:39632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTCpM-0007Cm-HK for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 22 Sep 2021 20:43:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTCom-0007Cb-LN for help-gnu-emacs@gnu.org; Wed, 22 Sep 2021 20:42:28 -0400 Original-Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]:37474) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mTCoj-000194-9l for help-gnu-emacs@gnu.org; Wed, 22 Sep 2021 20:42:28 -0400 Original-Received: by mail-lf1-x12e.google.com with SMTP id i4so19274380lfv.4 for ; Wed, 22 Sep 2021 17:42:23 -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=STcV/b72JsTGoOsxCQFxLpAbLuGKCmGKUw2JQei0D5k=; b=nRV/ec0/QIaLbCqyWvX4oRznfuY4OKRRWuDw7HQmhA32f3hVbrgE2pdfFO3oFiF0X4 Qc+L7h9l87wuusQSZqWgPhn4EI6rmXMZinK5si0/J45aZaaPqAsVR+PGBC4Yx7BL5AtS BFEtVDgZs8Se3w5IeWW7D+VssRHaMncP4zdsTSCujKu7volPmGKZHiabpk+L/1ZRyCgX z0iG8jFu6FDQYY741yw215rzcNGRuS0EBTHjofkNk0EvaeTORSeTW4sjGmo/N+bVlwia 0mEV6LP4OiFi6TthIKT3evYbGQISwxR9f8ZdIRp2xGN/f4QKkQUt4rgQiubQEHh4UkhR suBw== 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=STcV/b72JsTGoOsxCQFxLpAbLuGKCmGKUw2JQei0D5k=; b=4gQlHG4JOnkk5HXV+FJbaCiMZx0bSuZZrFsiJYd/wQmuR7uMvIDtsuxiWm1bZaSfQX hHC1tU/ACNB+zTQ1bDDtSPcQnyZx7saBW7EVoQtuPqt3lVpXlNgf+d/L/0bHR67qtlvy FcWy35mo30Qd6MfpeXPZ1XNsqz+QZbv6CkpIj3rR5mjKiK6of8etE7Zh78V16ByfPahc tSnlf+uSee7z2g1VkMmoYBmqlpmH8M87XPxx7dehsza6Poiw/4youoo5dv8M931ai8Sf /jZMz0Sb8bjZ/Z6qTF/0OYtdMDWogw/Y9lM2mubjzQCgDd7aNV3mxTOE3rFzo729yhDU NjjQ== X-Gm-Message-State: AOAM530Dl+c9XKanZkxRHMcujBbkGXcm1bF92H2iqL21ZHV3ufU0Ht3M pD/IuVX9QTPkaifYQyNKwB5AOlMs3v08f2lPvSU= X-Google-Smtp-Source: ABdhPJyxvFCTDozlu3rJ/6ZlkOLdMT4KYulEHEzMBCbekliFYebmwfdJGw5mSyIcG+kpduD+yQauLtVbz08MOmg4Xvw= X-Received: by 2002:a05:651c:1250:: with SMTP id h16mr2388347ljh.68.1632357741729; Wed, 22 Sep 2021 17:42:21 -0700 (PDT) In-Reply-To: <878rzol51e.fsf@zoho.eu> Received-SPF: pass client-ip=2a00:1450:4864:20::12e; envelope-from=hongyi.zhao@gmail.com; helo=mail-lf1-x12e.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:133158 Archived-At: On Thu, Sep 23, 2021 at 4:38 AM Emanuel Berg via Users list for the GNU Emacs text editor wrote: > > Hongyi Zhao wrote: > > > Today, I stumbled on this interesting discussion [...] > > > > 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 [...] > > When I was still classified as a human being I did something > similar and thanks to Emacs and that professional approach to > preparation that mini-expedition was concluded in > a semi-successful state since there were several survivors. > > Here is the URL to the file but I also yank it last: > > https://dataswamp.org/~incal/TENT > > tent 2515 > sleeping bag 1215 > sleeping pad 880 > Trangia 619 > comic book 580 > pillow 450 > science book 411 > drybag 305 > thermos 270 > powerbank 8000mAh 245 > water bottle 115 > toothpaste 110 > piece of cloth (big) 100 > knife 90 > sticky tape 90 > deodorant 75 > flashlight (3AAA) 73 > piece of cloth (small) 60 > flashlight (USB) 55 > vaseline 50 > toothbrush 15 > skin lotion 13 > comb 11 > spoon/fork 9 > pill case 9 > ------------------------------ > 8365g > > (defun digits-sum () > (interactive) > (save-excursion > (goto-char (point-min)) > (let ((sum 0)) > (while (forward-word) > (let ((number (number-at-point))) > (when number > (cl-incf sum number) ))) > (message "%s" sum) ))) > (defalias 'di #'digits-sum) `M-:' the above code with your data in scratch gives me the following message in minibuffer: [Trailing garbage following expression] HZ