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

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

Re: newbie elisp help ??


From: William Case
Subject: Re: newbie elisp help ??
Date: Wed, 15 Aug 2007 14:16:56 -0400

Hi Lennart;

Thanks for the speedy reply.

On Wed, 2007-08-15 at 19:48 +0200, Lennart Borgman (gmail) wrote:
> William Case wrote:
> > Hi;
> > 
> > I am trying to write a function that will insert a line of asterisks+
> > spaces across a buffer (as a section divider).  It was started as an
> > exercise and has become an exercise in futility.
> > 
> > I am working in the scratch pad using C-j to test the function as it is
> > being built.  I have:  (insert "* ").  It returns "* nil". Obviously I
> > don't want the "nil" to appear.  How do I get rid of it? 
> > 
> > More importantly to me, how do I get the (insert "* ") command to repeat
> > 27 times to give me 54 characters across the buffer?  I know how to make
> > a recursive loop, but it seems to me this is a fairly common challenge
> > and there is a probably a function for repetition that I can't find.
> > 
> > I suppose I am asking for the programming equivalent of 'C-u n'.
> > 
> > 'insert-char' allows for repeating but only one character at a time, not
> > two.
> > 
> > Any guidance would be appreciated.
> 
> Try this:
> 
>    M-: (insert (make-string 50 ?*))

Unfortunately, (make-string 50 ?*) is the single character '*', I was
shooting for something that was a repetition of two characters (*SPC) so
that my section divider looked like:

/* * * * * * * * * * * * * * * * * * * * */

I would begin and end the function with (insert 47).

I tried (insert (make-string 5 "* ")) and variations thereof, i.e. with
and without quotes and ASCII numbers.

-- 
Regards Bill





reply via email to

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