[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: |
Arthur Miller |
Subject: |
Re: Emacs: adding 1 to every number made of 2 digits inside a marked region. |
Date: |
Tue, 28 Sep 2021 03:51:42 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:
> Arthur Miller wrote:
>
>> Emanuel Berg via Users list for the GNU Emacs text editor
>> <help-gnu-emacs@gnu.org> writes:
>>
>>> Arthur Miller wrote:
>>>
>>>> | some | 34 | |
>>>> | word | 30 | |
>>>> | another | 38 | |
>>>> | thing | 59 | |
>>>> | to | 39 | |
>>>> | say | 10 | |
>>>> | here | 47 | |
>>>
>>> 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)))) )))))
>>
>> Ah no, not really; you are parsing region, that is not what I wanted
>> there. There is org api to do this.
>
> This doesn't require Org ...
I know. But it is trivial with org, which is included in Emacs anyway.
| some | 34 | |
| word | 30 | |
| another | 38 | |
| thing | 59 | |
| to | 39 | |
| say | 10 | |
| here | 47 | |
#+TBLFM: $3='(1+ '$2);N
Michael showed with calc. I was jsut showing different way, but goofed a bit.
- Re: [External] : Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., (continued)
- Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Andreas Röhler, 2021/09/23
- Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Michael Heerdegen, 2021/09/26
- Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Arthur Miller, 2021/09/26
- Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Arthur Miller, 2021/09/26
- Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Emanuel Berg, 2021/09/26
- Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Hongyi Zhao, 2021/09/27
- Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Emanuel Berg, 2021/09/27
- Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Arthur Miller, 2021/09/27
- Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Emanuel Berg, 2021/09/27
- Re: Emacs: adding 1 to every number made of 2 digits inside a marked region.,
Arthur Miller <=
- Re: Emacs: adding 1 to every number made of 2 digits inside a marked region., Arthur Miller, 2021/09/26