unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Pascal Bourguignon <pjb@informatimago.com>
To: help-gnu-emacs@gnu.org
Subject: Re: newbie elisp help ??
Date: Wed, 15 Aug 2007 20:02:52 +0200	[thread overview]
Message-ID: <87bqd84qwj.fsf@thalassa.informatimago.com> (raw)
In-Reply-To: mailman.4824.1187198869.32220.help-gnu-emacs@gnu.org

William Case <billlinux@rogers.com> writes:

> 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". 

Wrong.  (insert "* ") returns just nil, whose textual representation
is inserted by the command bound to C-j.


> Obviously I
> don't want the "nil" to appear.  How do I get rid of it? 

I don't know what command you have bound to C-j.  I use C-x C-e and
C-u C-x C-e to execute forms.   Without C-u, it doesn't print (insert
the textual representation of) the result of the form.


> More importantly to me, how do I get the (insert "* ") command to repeat
> 27 times to give me 54 characters across the buffer?  

Writting a loop!

(require 'cl)                     C-x C-e
(loop repeat 27 do (insert "* ")) C-x C-e

inserts:

* * * * * * * * * * * * * * * * * * * * * * * * * * * 

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

How do I make a static mobile?
How do I make a red blue?


> I suppose I am asking for the programming equivalent of 'C-u n'.

I suppose you could read some programming tutorial.  Wouldn't that be a good idea?
What about googling for: emacs lisp tutorial


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.

       reply	other threads:[~2007-08-15 18:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.4824.1187198869.32220.help-gnu-emacs@gnu.org>
2007-08-15 18:02 ` Pascal Bourguignon [this message]
2007-08-15 19:04   ` newbie elisp help ?? William Case
2007-08-17 20:44   ` Thien-Thi Nguyen
2007-08-15 20:08 ` Joel J. Adamson
2007-08-16  2:30   ` William Case
     [not found]   ` <mailman.4845.1187231410.32220.help-gnu-emacs@gnu.org>
2007-08-16 14:09     ` Joel J. Adamson
2007-08-15 17:27 William Case
2007-08-15 17:48 ` Lennart Borgman (gmail)
2007-08-15 18:16   ` William Case
2007-08-15 18:24     ` Lennart Borgman (gmail)
     [not found] ` <46C342F9.8070808@gmail.com>
2007-08-15 19:07   ` William Case

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bqd84qwj.fsf@thalassa.informatimago.com \
    --to=pjb@informatimago.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).