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

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

Re: need help in improving my boring-repeat function


From: marc tfardy
Subject: Re: need help in improving my boring-repeat function
Date: Fri, 24 Jan 2014 10:27:17 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

Am 24.01.14 09:44, schrieb C K Kashyap:
Hi,
I've written a function to do some repeated insertions of lines like this -

(defun boring-repeat (count str)
   (interactive "sEnter count: \nsEnter format string: \n")
   (dotimes (i (string-to-number count))
     (insert (format str i))))

I was wondering how I could modify it so that I could optionally take a
function that could modify "i"

So if I call boring-repeat with 2 and hello%2d -> I'd get hello00 hello02
but say I could want hello01 and hello 02 or someother transformation on i

How can I go about implementing it?

Why not a macro with a formated counter?
C-x C-k C-c - for initial value
C-x C-k C-f - for formated string, e.g. hallo%02d
C-x C-k TAB - for insert


--
(or greets gruesse pozdro)
tfardy


reply via email to

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