blob: 43c9390e74653727a4b057fcf4ddf989ca669e32 [file] [log] [blame]
<!DOCTYPE html>
<html>
<!-- Created by Texinfo 6.8dev+dev, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- This manual is for GNU Texinfo (version 6.8dev, 23 February 2022),
a documentation system that can produce both online information and a
printed manual from a single source using semantic markup.
Copyright (C) 1988, 1990-1993, 1995-1999, 2001-2022 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
Texts. A copy of the license is included in the section entitled
"GNU Free Documentation License". -->
<title>Functions Commands (GNU Texinfo 6.8dev)</title>
<meta name="description" content="Functions Commands (GNU Texinfo 6.8dev)">
<meta name="keywords" content="Functions Commands (GNU Texinfo 6.8dev)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2any">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link href="index.html" rel="start" title="Top">
<link href="Command-and-Variable-Index.html" rel="index" title="Command and Variable Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Def-Cmds-in-Detail.html" rel="up" title="Def Cmds in Detail">
<link href="Variables-Commands.html" rel="next" title="Variables Commands">
<style type="text/css">
<!--
div.example {margin-left: 3.2em}
-->
</style>
</head>
<body lang="en">
<div class="subsection-level-extent" id="Functions-Commands">
<div class="nav-panel">
<p>
Next: <a href="Variables-Commands.html" accesskey="n" rel="next">Variables and Similar Entities</a>, Up: <a href="Def-Cmds-in-Detail.html" accesskey="u" rel="up">The Definition Commands</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Command-and-Variable-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h4 class="subsection" id="Functions-and-Similar-Entities">13.5.1 Functions and Similar Entities</h4>
<p>This section describes the commands for describing functions and similar
entities:
</p>
<dl class="table">
<dd><a class="index-entry-id" id="index-deffn"></a>
</dd>
<dt><code class="code">@deffn <var class="var">category</var> <var class="var">name</var> <var class="var">arguments</var>&hellip;</code></dt>
<dd><p>The <code class="code">@deffn</code> command is the general definition command for
functions, interactive commands, and similar entities that may take
arguments. You must choose a term to describe the category of entity
being defined; for example, &ldquo;Function&rdquo; could be used if the entity is
a function. The <code class="code">@deffn</code> command is written at the beginning of a
line and is followed on the same line by the category of entity being
described, the name of this particular entity, and its arguments, if
any. Terminate the definition with <code class="code">@end deffn</code> on a line of its
own.
</p>
<p>For example, here is a definition:
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">@deffn Command forward-char nchars
Move point forward @var{nchars} characters.
@end deffn
</pre></div></div>
<p>This shows a rather terse definition for a &ldquo;command&rdquo; named
<code class="code">forward-char</code> with one argument, <var class="var">nchars</var>.
</p>
<p><code class="code">@deffn</code> prints argument names such as <var class="var">nchars</var> in slanted
type in the printed output, because we think of these names as
metasyntactic variables&mdash;they stand for the actual argument values.
Within the text of the description, however, write an argument name
explicitly with <code class="code">@var</code> to refer to the value of the argument.
In the example above, we used &lsquo;<samp class="samp">@var{nchars}</samp>&rsquo; in this way.
</p>
<p>In the extremely unusual case when an argument name contains
&lsquo;<samp class="samp">--</samp>&rsquo;, or another character sequence which is treated specially
(see <a class="pxref" href="Conventions.html">General Syntactic Conventions</a>), use <code class="code">@code</code> around the special
characters. This avoids the conversion to typographic en-dashes and
em-dashes.
</p>
<p>The template for <code class="code">@deffn</code> is:
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">@deffn <var class="var">category</var> <var class="var">name</var> <var class="var">arguments</var>&hellip;
<var class="var">body-of-definition</var>
@end deffn
</pre></div></div>
<a class="index-entry-id" id="index-defun"></a>
</dd>
<dt><code class="code">@defun <var class="var">name</var> <var class="var">arguments</var>&hellip;</code></dt>
<dd><p>The <code class="code">@defun</code> command is the definition command for functions.
<code class="code">@defun</code> is equivalent to &lsquo;<samp class="samp">@deffn Function &hellip;</samp>&rsquo;.
Terminate the definition with <code class="code">@end defun</code> on a line of its own.
Thus, the template is:
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">@defun <var class="var">function-name</var> <var class="var">arguments</var>&hellip;
<var class="var">body-of-definition</var>
@end defun
</pre></div></div>
<a class="index-entry-id" id="index-defmac"></a>
</dd>
<dt><code class="code">@defmac <var class="var">name</var> <var class="var">arguments</var>&hellip;</code></dt>
<dd><p>The <code class="code">@defmac</code> command is the definition command for macros.
<code class="code">@defmac</code> is equivalent to &lsquo;<samp class="samp">@deffn Macro &hellip;</samp>&rsquo; and
works like <code class="code">@defun</code>.
</p>
<a class="index-entry-id" id="index-defspec"></a>
</dd>
<dt><code class="code">@defspec <var class="var">name</var> <var class="var">arguments</var>&hellip;</code></dt>
<dd><p>The <code class="code">@defspec</code> command is the definition command for special
forms. (In Lisp, a special form is an entity much like a function;
see <a data-manual="elisp" href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Special-Forms.html#Special-Forms">Special Forms</a> in <cite class="cite">GNU Emacs Lisp Reference Manual</cite>.)
<code class="code">@defspec</code> is equivalent to &lsquo;<samp class="samp">@deffn {Special Form}
&hellip;</samp>&rsquo; and works like <code class="code">@defun</code>.
</p></dd>
</dl>
<p>All these commands create entries in the index of functions.
</p>
</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Variables-Commands.html">Variables and Similar Entities</a>, Up: <a href="Def-Cmds-in-Detail.html">The Definition Commands</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Command-and-Variable-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>