Emacs Lisp Basics

By Xah Lee. Date: . Last updated: .

This page is a short, practical, tutorial of Emacs Lisp the language.

To evaluate elisp code, for example, type (+ 3 4), then move your cursor to after the closing parenthesis, then Alt+x eval-last-sexp Or, select the lisp code, then Alt+x eval-region. [see Evaluate Emacs Lisp Code]

emacs lisp eval 2022-07-25
eval emacs lisp code

To find the doc string of a function, Alt+x describe-function then type the function name. [see Documentation Lookup]

To turn on syntax highlight, Alt+x emacs-lisp-mode.

Working with Lisp in Emacs

After you read this chapter, check out the following to learn how to efficiently work with lisp in emacs.

Printing

; printing
(message "hi")

; printing variable values
(message "Her age is: %d" 16)        ; %d is for number
(message "Her name is: %s" "Vicky")  ; %s is for string
(message "My list is: %S" (list 8 2 3))  ; %S is for any lisp expression

You can see the output in the Messages Buffer.

[see Print, Output]

[see Format String]

Arithmetic

Convert Int/Float/String

True, False

Test Equality

Variables

Block of Expressions

If Then Else

Loop, Iteration

Data Structure: List, Vector

String Functions

Format String

Define a Function

Lisp Basics

ErgoEmacs mascot-s276x226
Buy Xah Emacs Tutorial

Lisp Basics

Basics

Lisp Data Structure

Function

Lisp Symbol

Lisp Misc

Working with Elisp