I am an hour new into programming in Emacs lisp. I have a little experience with scheme so I understand the big picture of lisps in general. However, I have only used the "pure functional" subset of scheme and do not know how to do practical tasks.
Write now, I know that C-x C-e
will evaluate the code enclosed by the parentheses' by the current cursor position.
I wish to loop from i = 1 to 10 and print the values of i out. How is this done? I tried the following:
(defvar i 1)
(while (< i 11)
(print "i: " i)
(setq i (+ i 1)))
Emacs tells me: invalid function 0
.
- How do I do this correctly?
- Why is emacs telling me
invalid function 0
Feel free to give me tips about how to use the scratch buffer (all I know is C-x C-e
evaluates) in emacs. Thanks for all the help!
EDIT1: Could someone tell me how to print out sequential values of i
using a while loop?
EDIT2: When I evaluate the code, it opens up another tiny buffer showing each value of i
one at a time. However, it is not a large buffer and only shows values of i
from 13 to 19. When I try to get into that buffer, it closes immediately. How do I "scroll" through that tiny buffer? Note that I use emacs 24.3 through the terminal
EDIT3: I figured out that the tiny buffer is the Messages buffer. Is there a better way to view the output of my elisp code? The Messages buffer is full of other junk from evaluating things in emacs.