GNU Emacs Lisp Reference Manual Lists
First set a variable to zero; then add one to the number each time the program repeats itself. You might use this to count how many times a part of your program repeats itself. This special form is just like set the related reference except that the first argument is quoted automatically, so you don’t need to type the quote mark yourself.
There will be times when unwind-protect and condition-case are the right tools for the job. Always remember to exit the recursive edit state, otherwise the unwind forms will not be evaluated and you may end up with an Emacs session that is in an inconsistent state. With default settings, the mode line shows levels of recursive edits by placing square brackets around the indicator with the major and minor modes (What are major and minor modes). As always, the unhighlight-regexp is evaluated no matter what. Let me now show you when unwinding-protect makes sense. If, by contrast, DOING-STUFF exits without doing what it was supposed to (a “non-local exit”), then the UNDOING-STUFF will still be evaluated and there will be no return value.
The else clause does not need a progn because internally it is functionally equivalent to using a &rest for the arguments. Put them at the end of a balanced expression, as you have seen in all my examples. A “predicate” is a function that returns true, technically non-nil, when its condition is met, else it returns nil (Side effect and return value).
The symbols nil and t are special as they always refer to themselves, meaning that when you evaluate them you get back exactly what you evaluated (Add metadata to symbols). Every time you evaluate a quote expression, you get back the expression without the quote. Without it, my-greet-person-from-country would be evaluated, which would return an error of a void/undefined variable, unless that symbol was also defined as a variable.
Every other list in Lisp looks more or less like one of these examples, except that the list may be longer and more complex. Odd as it seems, the examples we have seen cover almost all of what Lisp lists look like! When Lisp reads the expression, it gets rid of all the extra whitespace (but it needs to have at least one space between atoms in order to tell them apart.) Both examples show what to Lisp is the same list, the list made up of the symbols `this’, `list’, `looks’, `like’, and `this’ in that order. Strings are a different kind of atom than numbers or symbols and are used differently.
Notable examples are before-save-hook and pre-command-hook. It is evaluated after the text-mode is done setting all its variables. These are evaluated in sequence when the hook runs. You know that each major and minor mode runs its own hook (What are major and minor modes). It will not specify a parent mode as there is no such concept of inheritance for minor modes.
It returns nil if no association in alist has a CDR equal to value. The append function also allows integers as arguments. The sum is then returned as the value of the inner list and passed to the setq which sets the variable counter to this new value. Each time you evaluate the second expression, the value of the counter will be incremented. So if you again evaluate counter, the number 1 will appear in the echo area. If you evaluate the first of these expressions, the initializer, (setq counter 0), and then evaluate the third expression, counter, the number 0 will appear in the echo area.
Normally, you would want to do this in a buffer whose major mode is designed for editing Emacs Lisp (What are major and minor modes). You type a key on your keyboard and a character is written to the current buffer at the point where the cursor is. You do not need to learn different, typically incompatible, programming languages or configuration formats to make Emacs perform the computations you want.
