169 lines
12 KiB
HTML
169 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<!-- This manual documents Guile version 3.0.10.
|
|
|
|
Copyright (C) 1996-1997, 2000-2005, 2009-2023 Free Software Foundation,
|
|
Inc.
|
|
|
|
Copyright (C) 2021 Maxime Devos
|
|
|
|
Copyright (C) 2024 Tomas Volf
|
|
|
|
|
|
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, no Front-Cover Texts, and no Back-Cover Texts. A
|
|
copy of the license is included in the section entitled "GNU Free
|
|
Documentation License." -->
|
|
<title>Hook Reference (Guile Reference Manual)</title>
|
|
|
|
<meta name="description" content="Hook Reference (Guile Reference Manual)">
|
|
<meta name="keywords" content="Hook Reference (Guile Reference Manual)">
|
|
<meta name="resource-type" content="document">
|
|
<meta name="distribution" content="global">
|
|
<meta name="Generator" content=".texi2any-real">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
|
|
<link href="index.html" rel="start" title="Top">
|
|
<link href="Concept-Index.html" rel="index" title="Concept Index">
|
|
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
|
<link href="Hooks.html" rel="up" title="Hooks">
|
|
<link href="C-Hooks.html" rel="next" title="C Hooks">
|
|
<link href="Hook-Example.html" rel="prev" title="Hook Example">
|
|
<style type="text/css">
|
|
<!--
|
|
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
|
|
span:hover a.copiable-link {visibility: visible}
|
|
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
|
|
-->
|
|
</style>
|
|
<link rel="stylesheet" type="text/css" href="https://www.gnu.org/software/gnulib/manual.css">
|
|
|
|
|
|
</head>
|
|
|
|
<body lang="en">
|
|
<div class="subsubsection-level-extent" id="Hook-Reference">
|
|
<div class="nav-panel">
|
|
<p>
|
|
Next: <a href="C-Hooks.html" accesskey="n" rel="next">Hooks For C Code.</a>, Previous: <a href="Hook-Example.html" accesskey="p" rel="prev">Hook Usage by Example</a>, Up: <a href="Hooks.html" accesskey="u" rel="up">Hooks</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
<hr>
|
|
<h4 class="subsubsection" id="Hook-Reference-1"><span>6.9.6.2 Hook Reference<a class="copiable-link" href="#Hook-Reference-1"> ¶</a></span></h4>
|
|
|
|
<p>When you create a hook with <code class="code">make-hook</code>, you must specify the arity
|
|
of the procedures which can be added to the hook. If the arity is not
|
|
given explicitly as an argument to <code class="code">make-hook</code>, it defaults to
|
|
zero. All procedures of a given hook must have the same arity, and when
|
|
the procedures are invoked using <code class="code">run-hook</code>, the number of
|
|
arguments passed must match the arity specified at hook creation time.
|
|
</p>
|
|
<p>The order in which procedures are added to a hook matters. If the third
|
|
parameter to <code class="code">add-hook!</code> is omitted or is equal to <code class="code">#f</code>, the
|
|
procedure is added in front of the procedures which might already be on
|
|
that hook, otherwise the procedure is added at the end. The procedures
|
|
are always called from the front to the end of the list when they are
|
|
invoked via <code class="code">run-hook</code>.
|
|
</p>
|
|
<p>The ordering of the list of procedures returned by <code class="code">hook->list</code>
|
|
matches the order in which those procedures would be called if the hook
|
|
was run using <code class="code">run-hook</code>.
|
|
</p>
|
|
<p>Note that the C functions in the following entries are for handling
|
|
<em class="dfn">Scheme-level</em> hooks in C. There are also <em class="dfn">C-level</em> hooks which
|
|
have their own interface (see <a class="pxref" href="C-Hooks.html">Hooks For C Code.</a>).
|
|
</p>
|
|
<dl class="first-deffn">
|
|
<dt class="deffn" id="index-make_002dhook"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">make-hook</strong> <var class="def-var-arguments">[n_args]</var><a class="copiable-link" href="#index-make_002dhook"> ¶</a></span></dt>
|
|
<dt class="deffnx def-cmd-deffn" id="index-scm_005fmake_005fhook"><span class="category-def">C Function: </span><span><strong class="def-name">scm_make_hook</strong> <var class="def-var-arguments">(n_args)</var><a class="copiable-link" href="#index-scm_005fmake_005fhook"> ¶</a></span></dt>
|
|
<dd><p>Create a hook for storing procedure of arity <var class="var">n_args</var>.
|
|
<var class="var">n_args</var> defaults to zero. The returned value is a hook
|
|
object to be used with the other hook procedures.
|
|
</p></dd></dl>
|
|
|
|
<dl class="first-deffn">
|
|
<dt class="deffn" id="index-hook_003f"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">hook?</strong> <var class="def-var-arguments">x</var><a class="copiable-link" href="#index-hook_003f"> ¶</a></span></dt>
|
|
<dt class="deffnx def-cmd-deffn" id="index-scm_005fhook_005fp"><span class="category-def">C Function: </span><span><strong class="def-name">scm_hook_p</strong> <var class="def-var-arguments">(x)</var><a class="copiable-link" href="#index-scm_005fhook_005fp"> ¶</a></span></dt>
|
|
<dd><p>Return <code class="code">#t</code> if <var class="var">x</var> is a hook, <code class="code">#f</code> otherwise.
|
|
</p></dd></dl>
|
|
|
|
<dl class="first-deffn">
|
|
<dt class="deffn" id="index-hook_002dempty_003f"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">hook-empty?</strong> <var class="def-var-arguments">hook</var><a class="copiable-link" href="#index-hook_002dempty_003f"> ¶</a></span></dt>
|
|
<dt class="deffnx def-cmd-deffn" id="index-scm_005fhook_005fempty_005fp"><span class="category-def">C Function: </span><span><strong class="def-name">scm_hook_empty_p</strong> <var class="def-var-arguments">(hook)</var><a class="copiable-link" href="#index-scm_005fhook_005fempty_005fp"> ¶</a></span></dt>
|
|
<dd><p>Return <code class="code">#t</code> if <var class="var">hook</var> is an empty hook, <code class="code">#f</code>
|
|
otherwise.
|
|
</p></dd></dl>
|
|
|
|
<dl class="first-deffn">
|
|
<dt class="deffn" id="index-add_002dhook_0021"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">add-hook!</strong> <var class="def-var-arguments">hook proc [append_p]</var><a class="copiable-link" href="#index-add_002dhook_0021"> ¶</a></span></dt>
|
|
<dt class="deffnx def-cmd-deffn" id="index-scm_005fadd_005fhook_005fx"><span class="category-def">C Function: </span><span><strong class="def-name">scm_add_hook_x</strong> <var class="def-var-arguments">(hook, proc, append_p)</var><a class="copiable-link" href="#index-scm_005fadd_005fhook_005fx"> ¶</a></span></dt>
|
|
<dd><p>Add the procedure <var class="var">proc</var> to the hook <var class="var">hook</var>. The
|
|
procedure is added to the end if <var class="var">append_p</var> is true,
|
|
otherwise it is added to the front. The return value of this
|
|
procedure is not specified.
|
|
</p></dd></dl>
|
|
|
|
<dl class="first-deffn">
|
|
<dt class="deffn" id="index-remove_002dhook_0021"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">remove-hook!</strong> <var class="def-var-arguments">hook proc</var><a class="copiable-link" href="#index-remove_002dhook_0021"> ¶</a></span></dt>
|
|
<dt class="deffnx def-cmd-deffn" id="index-scm_005fremove_005fhook_005fx"><span class="category-def">C Function: </span><span><strong class="def-name">scm_remove_hook_x</strong> <var class="def-var-arguments">(hook, proc)</var><a class="copiable-link" href="#index-scm_005fremove_005fhook_005fx"> ¶</a></span></dt>
|
|
<dd><p>Remove the procedure <var class="var">proc</var> from the hook <var class="var">hook</var>. The
|
|
return value of this procedure is not specified.
|
|
</p></dd></dl>
|
|
|
|
<dl class="first-deffn">
|
|
<dt class="deffn" id="index-reset_002dhook_0021"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">reset-hook!</strong> <var class="def-var-arguments">hook</var><a class="copiable-link" href="#index-reset_002dhook_0021"> ¶</a></span></dt>
|
|
<dt class="deffnx def-cmd-deffn" id="index-scm_005freset_005fhook_005fx"><span class="category-def">C Function: </span><span><strong class="def-name">scm_reset_hook_x</strong> <var class="def-var-arguments">(hook)</var><a class="copiable-link" href="#index-scm_005freset_005fhook_005fx"> ¶</a></span></dt>
|
|
<dd><p>Remove all procedures from the hook <var class="var">hook</var>. The return
|
|
value of this procedure is not specified.
|
|
</p></dd></dl>
|
|
|
|
<dl class="first-deffn">
|
|
<dt class="deffn" id="index-hook_002d_003elist"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">hook->list</strong> <var class="def-var-arguments">hook</var><a class="copiable-link" href="#index-hook_002d_003elist"> ¶</a></span></dt>
|
|
<dt class="deffnx def-cmd-deffn" id="index-scm_005fhook_005fto_005flist"><span class="category-def">C Function: </span><span><strong class="def-name">scm_hook_to_list</strong> <var class="def-var-arguments">(hook)</var><a class="copiable-link" href="#index-scm_005fhook_005fto_005flist"> ¶</a></span></dt>
|
|
<dd><p>Convert the procedure list of <var class="var">hook</var> to a list.
|
|
</p></dd></dl>
|
|
|
|
<dl class="first-deffn">
|
|
<dt class="deffn" id="index-run_002dhook"><span class="category-def">Scheme Procedure: </span><span><strong class="def-name">run-hook</strong> <var class="def-var-arguments">hook arg …</var><a class="copiable-link" href="#index-run_002dhook"> ¶</a></span></dt>
|
|
<dt class="deffnx def-cmd-deffn" id="index-scm_005frun_005fhook"><span class="category-def">C Function: </span><span><strong class="def-name">scm_run_hook</strong> <var class="def-var-arguments">(hook, args)</var><a class="copiable-link" href="#index-scm_005frun_005fhook"> ¶</a></span></dt>
|
|
<dd><p>Apply all procedures from the hook <var class="var">hook</var> to the arguments <var class="var">arg</var>
|
|
<small class="enddots">...</small>. The order of the procedure application is first to last.
|
|
The return value of this procedure is not specified.
|
|
</p></dd></dl>
|
|
|
|
<p>If, in C code, you are certain that you have a hook object and well
|
|
formed argument list for that hook, you can also use
|
|
<code class="code">scm_c_run_hook</code>, which is identical to <code class="code">scm_run_hook</code> but
|
|
does no type checking.
|
|
</p>
|
|
<dl class="first-deftypefn">
|
|
<dt class="deftypefn" id="index-scm_005fc_005frun_005fhook"><span class="category-def">C Function: </span><span><code class="def-type">void</code> <strong class="def-name">scm_c_run_hook</strong> <code class="def-code-arguments">(SCM hook, SCM args)</code><a class="copiable-link" href="#index-scm_005fc_005frun_005fhook"> ¶</a></span></dt>
|
|
<dd><p>The same as <code class="code">scm_run_hook</code> but without any type checking to confirm
|
|
that <var class="var">hook</var> is actually a hook object and that <var class="var">args</var> is a
|
|
well-formed list matching the arity of the hook.
|
|
</p></dd></dl>
|
|
|
|
<p>For C code, <code class="code">SCM_HOOKP</code> is a faster alternative to
|
|
<code class="code">scm_hook_p</code>:
|
|
</p>
|
|
<dl class="first-deftypefn">
|
|
<dt class="deftypefn" id="index-SCM_005fHOOKP"><span class="category-def">C Macro: </span><span><code class="def-type">int</code> <strong class="def-name">SCM_HOOKP</strong> <code class="def-code-arguments">(x)</code><a class="copiable-link" href="#index-SCM_005fHOOKP"> ¶</a></span></dt>
|
|
<dd><p>Return 1 if <var class="var">x</var> is a Scheme-level hook, 0 otherwise.
|
|
</p></dd></dl>
|
|
|
|
|
|
</div>
|
|
<hr>
|
|
<div class="nav-panel">
|
|
<p>
|
|
Next: <a href="C-Hooks.html">Hooks For C Code.</a>, Previous: <a href="Hook-Example.html">Hook Usage by Example</a>, Up: <a href="Hooks.html">Hooks</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|