1. Home
  2. Computing & Technology
  3. Linux

Defuns
Emacs Documentation

By , About.com Guide

Top-Level Definitions, or Defuns

In Emacs, a major definition at the top level in the buffer is called a defun. The name comes from Lisp, but in Emacs we use it for all languages.

In most programming language modes, Emacs assumes that a defun is any pair of parentheses (or braces, if the language uses braces this way) that starts at the left margin. For example, in C, the body of a function definition is normally a defun, because the open-brace that begins it is normally at the left margin. A variable's initializer can also count as a defun, if the open-brace that begins the initializer is at the left margin.

However, some language modes provide their own code for recognizing defuns in a way that suits the language syntax and conventions better.

  • Left Margin Paren: An open-paren or similar opening delimiter starts a defun if it is at the left margin.
  • Moving by Defuns: Commands to move over or mark a major definition.
  • Imenu: Making buffer indexes as menus.
  • Which Function: Which Function mode shows which function you are in.

* Emacs Manual Index

Explore Linux
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Linux
  4. Linux Software
  5. Editors
  6. Emacs
  7. Emacs Documentation - Defuns

©2009 About.com, a part of The New York Times Company.

All rights reserved.