help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacs: adding 1 to every number made of 2 digits inside a marked reg


From: Hongyi Zhao
Subject: Re: Emacs: adding 1 to every number made of 2 digits inside a marked region.
Date: Thu, 23 Sep 2021 16:02:22 +0800

On Thu, Sep 23, 2021 at 4:38 AM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> 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

What do you mean by saying this?

> 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)
>
> -------------------------------------------------------------------------------
>
>                   https://dataswamp.org/~incal/TENT
>
> --
> underground experts united
> https://dataswamp.org/~incal



reply via email to

[Prev in Thread] Current Thread [Next in Thread]