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: C K Kashyap
Subject: Re: need help in improving my boring-repeat function
Date: Fri, 24 Jan 2014 18:58:28 +0530

Cool...I did not know about formatted counter. Thanks Marc.

I'd still like to know how I can go about taking a function as an optional
argument to a function though.

Regards,
Kashyap


On Fri, Jan 24, 2014 at 2:57 PM, marc tfardy <tfardy@tfardoland.net> wrote:

> 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]