basis question

Discussion of Emacs Lisp
Post Reply
Posts: 2
Joined: Sat Mar 22, 2014 11:44 pm

basis question

Post by oldbloke » Sun Mar 23, 2014 12:24 am

Hi all,

Embarrassingly simple question here, and please let me know if I should be posting on another forum, like an emacs one. Complete beginner here Re: computers, programming, LISP, EMACS. Let me say first that I'm very keen to learn LISP, from what I have read it's the best language around and already whenever I see a parentheses, even in everyday print, I get a bit of a thrill.

After many weeks of searching the net I've managed to get EMACS and SLIME (+ sbcl) running on my ubuntu 12.04 system. I've read and or flicked through both the slime and emacs manuals however I'm currently stuck. ALL I want to be able to do at this early stage of my learning is to write LISP code, save it and run it at a later time.

When I first started trying to learn LISP ( a few months ago) I became frustrated and turned to Python. Writing, saving and running python code later was easy, basically "run"the file and there you go. On my second attempt at LISP, as noted above, I managed to get EMACS and SLIME on my computer. A helpful youtube video showed me how 1) create a file: C-x C-f; 2) split the view: C-x 3; 3) load SLIME into one side of the split screen: m-x slime. But after that I'm stuck. So this is what I'd like to know if someone would kindly help me:

From the split screen I learned from youtube: How do I write, save and run later, LISP code (I'm working my way through Land of Lisp and Practical LISP and I want to be able to save what I'm writing and come back to it later and run it). For example, do I write my code in the buffer side of the split screen or the other side in which I've loaded slime. Once I've written some code how do I save it so I can come back to it and run it so that it works. For example I just want to be able to write the (defun say-hello () (print "Please type your name:")... example in land of lisp, save it and come back later and run it so that when I enter my name the computer replies! that's all I want to be able to do at this stage. Can anyone help me please?

Thank you in advance.

Posts: 226
Joined: Fri Aug 06, 2010 6:34 am
Location: Germany

Re: basis question

Post by edgar-rft » Mon Mar 24, 2014 4:47 am

oldbloke wrote:I want to be able to save what I'm writing and come back to it later and run it...
The "Emacs keyboard shortcuts" way:

1. Create a new file via C-x C-f and give the file a name with a ".lisp" extension like "myfile.lisp". Emacs recognizes files with a ".lisp" extension automatically as Lisp code and switches the buffer to lisp-mode.

You can switch any Emacs buffer to Lisp mode by typing: M-x lisp-mode RET

2. Type your Lisp code in the "myfile.lisp" buffer and save it to disk via C-x C-s.

See the Emacs manual File Handling for more file commands. It's also possible to load and save files via the "File" menu in the Emacs menu bar.

3. Load the code from the "myfile.lisp" buffer into Common Lisp via C-c C-k.

See the SLIME manual Compilation commands how to compile and load Common Lisp code via Emacs keyboard shortcuts.

In the Emacs "myfile.lisp" buffer there should appear a SLIME menu in the Emacs menu bar. In the SLIME menu you can find the most important SLIME commands and their keyboard shortcuts. This is faster than reading the SLIME manual.

You can also load a file with Common Lisp code from the SLIME REPL:

Code: Select all

CL-USER> (load "myfile.lisp")
If you get a "file not found" error then you must specify the file with the full pathname.

If you like watching videos:
As you apparently already have managed to get SLIME running, ignore the "you should always use the newest SLIME version from CVS" advice from the videos and use your SLIME version until you find a reason that makes an update really necessary.

- edgar

Posts: 2
Joined: Sat Mar 22, 2014 11:44 pm

Re: basis question

Post by oldbloke » Fri Mar 28, 2014 4:51 pm

Thanks for your help edgar. I will try C-c C-k to load a .lisp file.

While playing around since my original post I have found that C-c C-c seems to compile my code from a .lisp file into the slime split screen for evaluation. small steps!

Thanks again.

Post Reply