# 23.1.1 运行钩子

在本节中，Emacs 记录了`run-hooks`用于运行普通钩子的函数。同时还记录了运行各种异常钩子的函数。

Function: run-hooks \&rest hookvars

该函数将一个或多个普通钩子变量名作为参数，并依次运行每个钩子。每个参数应该是一个符号，它是一个普通的钩子变量。这些参数按指定的顺序运行处理。

如果钩子变量具有非`nil`值，也是函数列表。`run-hooks`一一不带参数的调用所有函数。

钩子变量的值也可以是单个函数——一个 lambda 表达式或一个具有函数定义的符号。但是这种用法已经过时了。

如果钩子变量是缓冲区局部性，那么run-hooks 会使用缓冲区局部变量而不是全局变量。但是，如果缓冲区局部变量包含元素 `t`，则全局钩子变量也将运行。

Function: run-hook-with-args hook \&rest args

此函数调用钩子中的所有异常函数，并向每个异常函数传递参数ARGS。

Function: run-hook-with-args-until-failure hook \&rest args

此函数通过依次调用每个钩子函数来运行异常钩子，直到其中一个函数调用失败。每个钩子函数都会被传递参数args。如果这个函数因为某个钩子函数执行失败而停止，它返回`nil`；否则它返回一个非`nil`值。

Function: run-hook-with-args-until-success hook \&rest args

此函数通过依次调用每个钩子函数来运行异常钩子，直到其中一个函数调用成功。每个钩子函数都会被传递参数args。如果这个函数因为某个钩子函数执行成功而停止，它返回`nil`；否则它返回一个非`nil`值。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://emacs-lisp.ivory.cafe/23.1-gou-zi/23.1.1-yun-hang-gou-zi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
