Tag: elisp
Our next elisp project us going to write a function that will automatically generate function headers. This was actually the first useful elisp I ever wrote around thirty years ago. I forget how I wrote it then so this is a total rewrite.
Nowadays we have Javadoc for java and tools like Sphinx for other languages. If we write specially formatted comments in our code, these tools will pull out the comments and build a web site or document with hyperlinked documentation.
# COMMENTSTwo more videos to finish up the rot13 project.
The first video covers about prefix arguments. The idea is when calling an Emacs function interactively, you can specify a numeric argument either by typing C-u # where # is a single digit or M-x ## where ## is an integer which can be positive, negative, single or multiple digits. You then type the key for your command or invoke it with its full name M-x.
# COMMENTSRather than one long boring video, I thought it would be better to split up the remainder of the Rot13 project into 4 shorter boring ones :-).
Here are the first two.
Before we can really do anything interesting, we need to be able write programs that make decisions. For that we need conditionals or if statements. That's covered in the first video.
Like other languages, elisp has an if statement but it's more of an if function.
# COMMENTSIt's been a couple of weeks since my last post. Sorry - been repainting the apartment so I was limited to my laptop for a while.
Now that we've gone over a few basics we can explore new elisp features while building "useful" things. This video has us building code to implement ROT13. ROT13 is a particular instance of a Caesar or rotational cipher. In a Caesar Cipher, you take each letter and "rotate" it by a certain number of places.
# COMMENTSHere's another short video - this one on declaring functions in elisp.
Not much to say about it. It's similar to other languages.
In Python or C++ you might have:
# Python def add2(a, b): return a+b // C++ int add2(int a, int b){ return a+b; } Elisp is similar:
(defun add2 (a b) (+ a b)) But it's a little more "mathy." You've got the special form defun, then the name of the function, parameters in parens and then the body - all wrapped in parentheses.
# COMMENTSI was planning on writing this yesterday but caught up in watching "Paths of Glory."
The plan was to have each topic revolve around a "real" project but I realized that first we have to cover some basics. Specifically, variables and functions. I was going to cover them together but the video was getting a little long so we're doing variables here and writing functions next time.
Like other languages, Emacs uses variables to store values.
# COMMENTSHere's the first video in my learning elisp series.
Elisp is a lisp variant embedded within the Emacs editor. You could actually describe Emacs as an "elisp machine" in the same sense of the old lisp machines. It's not quite the same as the way most other editors have extension or plugin languages. Other than the core of Emacs, which is written in C, everything is elisp. Even when you type in a key.
# COMMENTS