Dear Emacs gurus:
I can perform this inteactive substitution
CM-%: \(^[0-9]+ \)\(.+\) -> \2 \1)
in order to change a buffer line prefixed with a number into one
post-fixed with the same number but I can't figue out how to do the
same programatically to a whole region. I started with this code:
(defun verse-num-move-beg-to-end (beg end)
"Move int-string and following space from beginning of line to end of
line throughout region."
(interactive "r")
(goto-char beg)
(while (<= (point) end)
(re-search-forward "^[0-9]+ ")
(setq num (substring (match-string 0) 0 -1)) ;; should be a string
of ;;digits without trailing space
(print num)
;; here the value generates a wrong argument error:
setq: Wrong type argument: listp, #("234" 0 3 (fontified t))
(type-of #("234" 0 3 (fontified t)))
;; I have a function which is a black box to to me but it works in the
larger context I have it in. Does match-string do something like this
implicitly (casting a list as a string?)
...
(substring (match-string 0) 0 -1)
(replace-match "" nil t)
234 asentuhasneothu ;; example buffer-line