Elisp: Define Function
Define Function
Basic function definition is of the form:
(defun function_name
(param1 param2 etc)
doc_string_optional
body)
(defun ff () "print yay" (message "Yay!"))
(defun gg (x) "add two" (+ x 2))
(defun ff (x y) "add x and y" (+ x y))
When a function is called, the last expression in the function's definition body is returned. (there's no “return statement”.)
Reference
Elisp, Function
- Elisp: Define Function
- Elisp: Define a Command
- Elisp: Function Parameters (optional, rest)
- Elisp: Function Keyword Parameters (Named Parameters)
- Elisp: Docstring Markup
- Elisp: Lambda Function
- Elisp: Exit Loop or Function (throw, catch)
- Elisp: Apply Function, funcall, identity
- Elisp: Types of Functions