From: Haris Bogdanovi�
Subject: emacs evaluating
Date: 
Message-ID: <gmir6e$cno$1@gregory.bnet.hr>
Hi.

When I write a function in emacs, how can I try it ?
Can I open some window (buffer) for evaluating ?

Thanks

From: Xah Lee
Subject: Re: emacs evaluating
Date: 
Message-ID: <8a81b365-c19c-489c-8b35-69d3e6361f09@n33g2000pri.googlegroups.com>
On Feb 6, 6:20 pm, "Haris Bogdanoviæ" <···········@xnet.hr> wrote:
> Hi.
>
> When I write a function in emacs, how can I try it ?
> Can I open some window (buffer) for evaluating ?
>
> Thanks

select the text, and press Alt+x eval-region. Then, you can call it by
Alt+x ‹function name›. (Alt+x is shortcut for execute-extended-
command)

if your function does not have the “(interactive)” clause, then it
won't be visible to user thru execute-extended-command , but you can
still call the function by other fuction.

• Emacs Lisp Basics
  http://xahlee.org/emacs/elisp_basics.html

  Xah
∑ http://xahlee.org/

☄
From: Michael Ekstrand
Subject: Re: emacs evaluating
Date: 
Message-ID: <87ab8y29pt.fsf@jehiel.elehack.net>
"Haris Bogdanoviæ" <···········@xnet.hr> writes:
> When I write a function in emacs, how can I try it ?
> Can I open some window (buffer) for evaluating ?

Look at the *scratch* buffer.  It defaults to a mode called 'Lisp
Interaction', where you can enter forms and then evaluate them with C-j.

- Michael

-- 
mouse, n: A device for pointing at the xterm in which you want to type.
From: Andreas Politz
Subject: Re: emacs evaluating
Date: 
Message-ID: <1233998995.605370@arno.fh-trier.de>
Michael Ekstrand wrote:
> "Haris Bogdanoviæ" <···········@xnet.hr> writes:
>> When I write a function in emacs, how can I try it ?
>> Can I open some window (buffer) for evaluating ?
> 
> Look at the *scratch* buffer.  It defaults to a mode called 'Lisp
> Interaction', where you can enter forms and then evaluate them with C-j.
> 
> - Michael
> 

There is also a repl :

M-x ielm RET

-a
From: Barry Margolin
Subject: Re: emacs evaluating
Date: 
Message-ID: <barmar-C3FE41.22394206022009@mara100-84.onlink.net>
In article <············@gregory.bnet.hr>,
 "Haris Bogdanovi�" <···········@xnet.hr> wrote:

> Hi.
> 
> When I write a function in emacs, how can I try it ?
> Can I open some window (buffer) for evaluating ?

You can use the *scratch* buffer, which is in lisp-interactive-mode by 
default. You can also use M-: to type an expression in the minibuffer 
and evaluate it.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: Haris Bogdanovi�
Subject: Re: emacs evaluating
Date: 
Message-ID: <gmjvvq$fuv$1@gregory.bnet.hr>
When I try to compile function it gives me "make -k" command, I press enter 
and I get error message.
Does emacs have lisp interpreter or I have to install it separatelly ?

"Haris Bogdanovi�" <···········@xnet.hr> wrote in message 
·················@gregory.bnet.hr...
> Hi.
>
> When I write a function in emacs, how can I try it ?
> Can I open some window (buffer) for evaluating ?
>
> Thanks
>
> 
From: Evans Winner
Subject: Re: emacs evaluating
Date: 
Message-ID: <864oz6ndf7.fsf@timbral.net>
"Haris Bogdanoviæ" <···········@xnet.hr> writes:

    When I try to compile function it gives me "make -k"
    command, I press enter and I get error message.  Does
    emacs have lisp interpreter or I have to install it
    separatelly ?

Lisp says, L'emacs c'est moi.  And Emacs says, L'isp c'est
moi.  More or less.  At any rate, Emacs is a text editor
first and foremost, so its model of user interaction is
based on that.  If you do want an interactive repl in the
same sense as in a scheme or Common Lisp you can, as Andreas
mentioned, do M-x ielm RET and that will give you a repl.
But typically in Emacs you are in an editing buffer so you
would just write your lisp form, and then with point after
the end-parenthesis that closes the form you want to
evaluate, do C-x C-e and that form will be evaluated,
whatever side-effects it produces will be produced, and
typically the return value will be displayed in the
mini-buffer.  If you don't like the result, you just edit
the form, and do it again.  You don't have to write out the
whole form again at a repl, and once you have produced a
bunch of those forms that all work together the way you
want, they're already there in the buffer, roughly in the
form that you can directly save as a file and load later.

M-x compile is designed for people writing code in C and
other languages that use external tools like `make' to build
an executable.  If you run it and the current directory does
not contain a Makefile it will, not finding it, complain.
You may be looking for `byte-compile' which you can use in
lisp to compile a function.  Also you can use
`byte-compile-file' interactively to byte-compile a file;
there is a way to use that in dired, as well, which is nice
when you have a lot of files you want to byte-compile.  I
have never used `byte-compile' for a function, but I know
that byte-compiling a file produces a file (a .elc file)
that contains object code (or whatever it's called in Emacs
lisp) but that does not load those expressions into the lisp
image.  So other useful functions are `load-file' which
actually loads the .el or .elc file into the lisp, and
`load-library' which is similar (see the docs).  Finally, if
you are looking at a buffer full of lisp forms you can use
`eval-buffer' to eval all of it at once, or `eval-region'.

I hope that's helpful.  Sorry to be so prolix, but this is
something that I found very confusing myself when I was
starting with Emacs, so I thought I'd try to give a full-ish
(hopefully not to be confused with fool-ish) answer.
From: Pascal J. Bourguignon
Subject: Re: emacs evaluating
Date: 
Message-ID: <87prhufhzk.fsf@galatea.local>
"Haris Bogdanovi�" <···········@xnet.hr> writes:
> "Haris Bogdanovi�" <···········@xnet.hr> wrote in message 
> ·················@gregory.bnet.hr...
>> Hi.
>>
>> When I write a function in emacs, how can I try it ?

Emacs questions are better asked on news:gnu.emacs.help


Type C-x C-e with the point after the function source to enter it into
the emacs lisp image.

They type (your-function your-argument) C-x C-e to evaluate it.


If you type C-y C-x C-e instead, the result of the expression will be
inserted in the buffer at the point.

(+ 1 2) C-u C-x C-e --> 3
(defun f (x) (if (< x 1) 1 (* x (f (1- x))))) C-x C-e
(f 9) C-u C-x C-e --> 362880

You don't need to compile your emacs lisp functions to use them. At
least not until they're debugged.


>> Can I open some window (buffer) for evaluating ?

Yes. M-x ielm RET gives you an interactive REPL to emacs lisp.


> When I try to compile function it gives me "make -k" command, I press enter 
> and I get error message.
> Does emacs have lisp interpreter or I have to install it separatelly ?


You can get information about what an emacs command purpose is with:

C-h f compile RET

As you can see, compile has nothing to do with compiling emacs lisp

code.

It could be used to compile an emacs lisp source, if you defined a
Makefile or used the emacs command to do so.  For example, you could
use:

   emacs --eval '(byte-compile-file "source.el")'

to compile source.el into source.elc with emacs.


But we prefer to do it more interactively in lisp:
To compile a function: (byte-compile 'your-function) C-x C-e
To compile an emacs lisp source file: M-x byte-compile-file RET source.el RET
To load an emacs lisp source: M-x load-file RET source.el RET
To evaluate a while buffer: M-x eval-buffer RET


-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
----------> http://www.netmeister.org/news/learn2quote.html <-----------
---> http://homepage.ntlworld.com/g.mccaughan/g/remarks/uquote.html <---

__Pascal Bourguignon__                     http://www.informatimago.com/
From: Xah Lee
Subject: Re: emacs evaluating
Date: 
Message-ID: <43aa3795-20ce-4b35-8e18-ed57aec47dc7@v5g2000prm.googlegroups.com>
On Feb 7, 6:18 am, ····@informatimago.com (Pascal J. Bourguignon)
wrote:
> "Haris Bogdanoviæ" <···········@xnet.hr> writes:
> > "Haris Bogdanoviæ" <···········@xnet.hr> wrote in message
> >·················@gregory.bnet.hr...
> >> Hi.
>
> >> When I write a function in emacs, how can I try it ?
>
> Emacs questions are better asked on news:gnu.emacs.help

Please feel free to post emacs lisp question in comp.lang.lisp.

There are some Common Lisp fanatics, who often sneer emacs lisp (and
any other lisps) and they often try to drive any non Common Lisp
questions outside of comp.lang.lisp.

  Xah
∑ http://xahlee.org/

☄