In the introduction to the Emacs Lisp manual, users are told that...
Emacs Lisp is more than a mere extension language; it is a full computer programming language in its own right. You can use it as you would any other programming language.And this is great! Now we can learn one of the most critical tasks a program can perform: printing "Hello, World!" to the screen.
If you're just starting out (like me), login to your tilde.club account and type:
NOTE: You don't need to type the " $" — that just represents your terminal prompt.
You are greeted by a screenful of helpful information, and if you have never used Emacs before, pay close attention to the instructions about how to enter commands using the C- (Ctrl) and M- (Alt or Esc) keys. It's a great idea to take the builtin tutorial; you'll learn just enough basics to move around and familiarize yourself with the program. Instructions to do so are right there on the initial screen, and it's as easy as typing C-h t.
If you need more help, try visiting the Emacs Documentation & Support page. Now, onto Lisp.
Full disclosure: I am using An Introduction to Programming in Emacs Lisp to learn this language. The beginning of the text clearly states
This is An Introduction to Programming in Emacs Lisp, for people who are not programmers.and that's me — not a programmer! If you're already an accomplished coder, you may find the Reference Manual to be more helpful.
To begin working with Emacs Lisp, I usually do one of two things: I enter the *scratch* buffer:
...checking to make sure the echo area displays "(default *scratch)" before hitting Enter. The other option is to use the REPL (read-eval-print loop):
If I'm using Lisp for quick evaluations, as a calculator for example, I prefer the ielm REPL. ielm may or may not be "Interactive Evaluation of Lisp Mode". It is highly likely that I am completely wrong about this.
Using the *scratch* buffer is preferred when writing longer snippets. The main advantage is that *scratch* can be saved to a file for further / later use. The biggest disadvantage is that one must evaluate each expression separately using the command:
Whichever way you choose, we're about ready to Lisp. Almost. Let's do something marginally practical.
I have family in Italy. I enjoy complaining about the weather. How can elisp help me combine these two seemingly disparate facts? By converting F to C.
To convert Farenheit to Celcius, one just needs to remember the formula: C = (F - 32) * (5 / 9). One can type this into Emacs at anytime and get an answer, but it's quicker and easier to create a function to do it for us. Here's my attempt:
We can call our function at anytime by typing (for example) (f2c 102.0), and we see that 102F is 38.88888888888889C.