* Re: need help in improving my boring-repeat function
[not found] <mailman.12676.1390553090.10748.help-gnu-emacs@gnu.org>
@ 2014-01-24 9:27 ` marc tfardy
2014-01-24 13:28 ` C K Kashyap
0 siblings, 1 reply; 3+ messages in thread
From: marc tfardy @ 2014-01-24 9:27 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: need help in improving my boring-repeat function
2014-01-24 9:27 ` need help in improving my boring-repeat function marc tfardy
@ 2014-01-24 13:28 ` C K Kashyap
0 siblings, 0 replies; 3+ messages in thread
From: C K Kashyap @ 2014-01-24 13:28 UTC (permalink / raw)
To: marc tfardy; +Cc: help-gnu-emacs@gnu.org
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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* need help in improving my boring-repeat function
@ 2014-01-24 8:44 C K Kashyap
0 siblings, 0 replies; 3+ messages in thread
From: C K Kashyap @ 2014-01-24 8:44 UTC (permalink / raw)
To: help-gnu-emacs@gnu.org
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?
Regards,
Kashyap
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-01-24 13:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.12676.1390553090.10748.help-gnu-emacs@gnu.org>
2014-01-24 9:27 ` need help in improving my boring-repeat function marc tfardy
2014-01-24 13:28 ` C K Kashyap
2014-01-24 8:44 C K Kashyap
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.