define-erc-response-handler
define-erc-response-handler is a Lisp macro in `erc-backend.el
'.
(define-erc-response-handler (NAME &rest ALIASES) &optional EXTRA-FN-DOC EXTRA-VAR-DOC &rest FN-BODY)
Define an ERC handler hook/function pair.
NAME is the response name as sent by the server (see the IRC RFC for
meanings).
This creates:
- a hook variable `erc-server-NAME-functions' initialized to `erc-server-NAME'.
- a function `erc-server-NAME' with body FN-BODY.
If ALIASES is non-nil, each alias in ALIASES is `defalias'ed to
`erc-server-NAME'.
Alias hook variables are created as `erc-server-ALIAS-functions' and
initialized to the same default value as `erc-server-NAME-functions'.
FN-BODY is the body of `erc-server-NAME' it may refer to the two
function arguments PROC and PARSED.
If EXTRA-FN-DOC is non-nil, it is inserted at the beginning of the
defined function's docstring.
If EXTRA-VAR-DOC is non-nil, it is inserted at the beginning of the
defined variable's docstring.
As an example:
(define-erc-response-handler (311 WHOIS WI)
"Some non-generic function documentation."
"Some non-generic variable documentation."
(do-stuff-with-whois proc parsed))
Would expand to:
(prog2
(defvar erc-server-311-functions 'erc-server-311
"Some non-generic variable documentation.
Hook called upon receiving a 311 server response.
Each function is called with two arguments, the process associated
with the response and the parsed response.
See also `erc-server-311'.")
(defun erc-server-311 (proc parsed)
"Some non-generic function documentation.
Handler for a 311 server response.
PROC is the server process which returned the response.
PARSED is the actual response as an `erc-response' struct.
If you want to add responses don't modify this function, but rather
add things to `erc-server-311-functions' instead."
(do-stuff-with-whois proc parsed))
(puthash "311" 'erc-server-311-functions erc-server-responses)
(puthash "WHOIS" 'erc-server-WHOIS-functions erc-server-responses)
(puthash "WI" 'erc-server-WI-functions erc-server-responses)
(defalias 'erc-server-WHOIS 'erc-server-311)
(defvar erc-server-WHOIS-functions 'erc-server-311
"Some non-generic variable documentation.
Hook called upon receiving a WHOIS server response.
Each function is called with two arguments, the process associated
with the response and the parsed response. If the function returns
non-nil, stop processing the hook. Otherwise, continue.
See also `erc-server-311'.")
(defalias 'erc-server-WI 'erc-server-311)
(defvar erc-server-WI-functions 'erc-server-311
"Some non-generic variable documentation.
Hook called upon receiving a WI server response.
Each function is called with two arguments, the process associated
with the response and the parsed response. If the function returns
non-nil, stop processing the hook. Otherwise, continue.
See also `erc-server-311'."))