Emacs Fun - Lisp


Summary

Emacs can work as a great interpreter for Lisp, specifically "Emacs Lisp", its own variant. And you can make Emacs even better by programming extensions to it yourself, using, yep, Lisp!

And yes, I am teaching myself Lisp. It works! It is fun. It looks *cool*. What a way to program!

I am using the pdf below to learn Emacs Lisp, along with some videos that I found.

An Introduction to Programming in Emacs Lisp

Launching the Lisp REPL

To launch the REPL, you type Meta-x ielm. Similar to IDLE for Python, when you are in the Lisp REPL, you can define functions, and variables, and run commands for Lisp.

As a super-simple example, below will print out the result of 2+2 -

ELISP> (+ 2 2)
4 (#o4, #x4, ?\C-d)

The result is 4 (decimal), #o4 (octal), and #x4 (Hexidecimal)

This is a super-easy example, but it shows that, similar to IDLE, you have a Lisp REPL, built right into Emacs!

Lisp Files

But you don't need to use the REPL. Below is a simple list in Emacs. Emacs interprets that as a list, since it starts with a single quote. When I put my cursor after the last parenthesis, and type C+x C+e, I get the following result.

'(this is my list)
(this is my list) // the output

Until right now, I thought you would need to do that in a file with a .el extension, but nope, I ran it right in this gemini file, with a .gmi extension. And it executed it. (You need to have the file loaded in Emacs, of course).

Conclusion

I'm trying to convert a friend of mine over to Emacs (*waves*). He is currently a vim user (*gasps!*).

One of the things I've been talking about is Lisp, and how cool it works in Emacs, and how you can expand Emacs with it.

I'm not sure that converted him. Then I just pressed the F10 key, and it brought up the menu system at the top of Emacs (which I'm running in a Terminal). That's an easy way to use a lot of the commands, and quickly learn the shortcuts you can use.

It is the little things! Wish me luck. I'll keep trying to get him over to Emacs!

More Emacs fun to come!

Abbreviations

C = Cntr (Control key)

Meta = your meta key, usually Alt (sometimes Escape)

Links

Lantashi Files, main section

Email: lantashi [at] protonmail [dot] com


Source