Function: erc-once-with-server-event
erc-once-with-server-event is a byte-compiled function defined in
erc.el.gz.
Signature
(erc-once-with-server-event EVENT F)
Documentation
Run function F the next time EVENT occurs in the current-buffer.
You should make sure that current-buffer is a server buffer.
This function temporarily adds a function to EVENT's hook to call F with
two arguments (proc and parsed). After F is called, the function is
removed from EVENT's hook. F should return either nil
or t, where nil indicates that the other functions on EVENT's hook
should be run too, and t indicates that other functions should
not be run.
Please be sure to use this function in server-buffers. In
channel-buffers it may not work at all, as it uses the LOCAL
argument of add-hook and remove-hook to ensure multiserver
capabilities.
Source Code
;; Defined in /usr/src/emacs/lisp/erc/erc.el.gz
(defun erc-once-with-server-event (event f)
"Run function F the next time EVENT occurs in the `current-buffer'.
You should make sure that `current-buffer' is a server buffer.
This function temporarily adds a function to EVENT's hook to call F with
two arguments (`proc' and `parsed'). After F is called, the function is
removed from EVENT's hook. F should return either nil
or t, where nil indicates that the other functions on EVENT's hook
should be run too, and t indicates that other functions should
not be run.
Please be sure to use this function in server-buffers. In
channel-buffers it may not work at all, as it uses the LOCAL
argument of `add-hook' and `remove-hook' to ensure multiserver
capabilities."
(unless (erc-server-buffer-p)
(error
"You should only run `erc-once-with-server-event' in a server buffer"))
(let ((fun (make-symbol "fun"))
(hook (erc-get-hook event)))
(put fun 'erc-original-buffer (current-buffer))
(fset fun (lambda (proc parsed)
(with-current-buffer (get fun 'erc-original-buffer)
(remove-hook hook fun t))
(fmakunbound fun)
(funcall f proc parsed)))
(add-hook hook fun nil t)
fun))