Getting started. How do I re-evaluate the buffer in Emacs?

101 views
Skip to first unread message

phil jones

unread,
Feb 9, 2017, 4:32:20 PM2/9/17
to Overtone
I'm just getting started with Overtone, having been using Sonic Pi for a year or so.

But I like Clojure ... and sort of like Emacs. So Overtone ought to be for me.

However, I can't find an answer to this (stupidly simple) question.

I've installed Sam Aaron's Emacs Live. And I've opened a cider-jack-in repl. I can execute examples of Overtone by pasting them into the repl, but I obviously want to build up a piece in an actual code buffer.

Watching dozens of video tutorials I'm seeing people obviously making changes in the code buffer and then re-evaluating it. But nowhere can I find what key combinations to use to make this happen.

I tried c-x c-e and M-x eval-buffer and these seem to produce various error messages ... I think they're trying to execute Emacs Lisp instead of Clojure.

So what do I press to re-evaluate the buffer (and have the result available in the cider-repl)?

cheers

Phil

joa...@verona.se

unread,
Feb 9, 2017, 5:43:09 PM2/9/17
to phil jones, Overtone
I usually just evaluate snippets of code as I build things up.
I then stand at the end of an expression and type c-x c-e.
It should do the right thing if cider is working properly.

As a side note my son tried out some of my songs the other day and he
found c-x c-e hard to type. So I made a little emacs macro for him,
which did c-e and then c-x c-e.

Emacs takes a little bit getting used to, but I had a co-worker who
learned clojure and cider rather quickly recently. He used the spacemacs
skin.


> cheers
>
> Phil
--
Joakim Verona



phil jones

unread,
Feb 10, 2017, 9:48:40 AM2/10/17
to joa...@verona.se, Overtone
Thanks,

Yes. I've now managed to get c-x c-e working in the buffer ... (I
didn't have the cursor in the right place before) but it would be nice
to re-evaluate the whole thing at once rather than bit by bit (I'm
"developling" music rather than live-coding).

Is there no way to do this?

Also, although it runs when I'm in the buffer, things I define in the
buffer don't seem to be in scope in the repl buffer. Is this right?

Phil

joa...@verona.se

unread,
Feb 10, 2017, 9:56:32 AM2/10/17
to phil jones, Overtone
phil jones <inte...@gmail.com> writes:

> Thanks,
>
> Yes. I've now managed to get c-x c-e working in the buffer ... (I
> didn't have the cursor in the right place before) but it would be nice
> to re-evaluate the whole thing at once rather than bit by bit (I'm
> "developling" music rather than live-coding).

if you are in a defun you can do C-M-x to redefine the defun.

>
> Is there no way to do this?
>
> Also, although it runs when I'm in the buffer, things I define in the
> buffer don't seem to be in scope in the repl buffer. Is this right?

Maybe your repl is not in the same namespace as your buffer?

A pedagogical way to ensure this is to copy paste the ns form from the
buffer to the repl and eval. (then there are cider shortcuts to do the
same thing, but copy pasting works even if you are not in a connected repl)
--
Joakim Verona
joa...@verona.se
+46705459454

phil jones

unread,
Feb 10, 2017, 10:11:00 AM2/10/17
to Overtone, inte...@gmail.com
OK. Thanks .. now I understand the namespace thing.

Yes, I was assuming that the repl should have been in the same namespace by default.

many thanks

Phil

Joseph Wilk

unread,
Feb 10, 2017, 1:09:38 PM2/10/17
to over...@googlegroups.com, phil jones
On 9 February 2017 at 21:32:20, phil jones (inte...@gmail.com) wrote:
I'm just getting started with Overtone, having been using Sonic Pi for a year or so.

But I like Clojure ... and sort of like Emacs. So Overtone ought to be for me.

However, I can't find an answer to this (stupidly simple) question.

I've installed Sam Aaron's Emacs Live. And I've opened a cider-jack-in repl. I can execute examples of Overtone by pasting them into the repl, but I obviously want to build up a piece in an actual code buffer.

Watching dozens of video tutorials I'm seeing people obviously making changes in the code buffer and then re-evaluating it. But nowhere can I find what key combinations to use to make this happen.

I tried c-x c-e and M-x eval-buffer and these seem to produce various error messages ... I think they're trying to execute Emacs Lisp instead of Clojure.


Glad this seems to be sorted. Thought I would add one other tip the secret of Emacs for me at-least is to never start with the keyboard shortcuts. 

Whenever I’m lost, I start with the looking through the full functions names. When selected they tend to hint to you the shortcut key.

A smooth way to get to climb the emacs mountain.

Thanks,

— 
Joseph Wilk
http://blog.josephwilk.net 
@josephwilk




So what do I press to re-evaluate the buffer (and have the result available in the cider-repl)?

cheers

Phil
--
You received this message because you are subscribed to the Google Groups "Overtone" group.
To unsubscribe from this group and stop receiving emails from it, send an email to overtone+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Johnny Brown

unread,
Sep 30, 2019, 6:55:32 PM9/30/19
to Overtone
C-c C-k will eval (and prompt you to save) the whole buffer
Reply all
Reply to author
Forward
0 new messages