|
From: | Arthur Miller |
Subject: | Re: Emacs: adding 1 to every number made of 2 digits inside a marked region. |
Date: | Mon, 27 Sep 2021 12:59:26 +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: > >> | 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.
[Prev in Thread] | Current Thread | [Next in Thread] |