Tidy: Organization

This commit is contained in:
Adam Porter 2021-08-10 00:58:02 -05:00
parent 081502116e
commit 3b5688fd60

View file

@ -1206,6 +1206,19 @@ data slot."
(defvar ement-room-event-fns nil (defvar ement-room-event-fns nil
"Alist mapping event types to functions which process an event of each type in the room's buffer.") "Alist mapping event types to functions which process an event of each type in the room's buffer.")
(defun ement-room--handle-events (events)
"Process EVENTS in current buffer.
Calls `ement-progress-update' for each event. Uses handlers
defined in `ement-room-event-fns'. The current buffer should be
a room's buffer."
(cl-loop for event being the elements of events ;; EVENTS may be a list or array.
for handler = (alist-get (ement-event-type event) ement-room-event-fns nil nil #'equal)
when handler
do (funcall handler event)
do (ement-progress-update)))
;;;;;; Event handlers
(defmacro ement-room-defevent (type &rest body) (defmacro ement-room-defevent (type &rest body)
"Define an event handling function for events of TYPE. "Define an event handling function for events of TYPE.
Around the BODY, the variable `event' is bound to the event being Around the BODY, the variable `event' is bound to the event being
@ -1270,16 +1283,6 @@ function to `ement-room-event-fns', which see."
(ement-room--insert-event event) (ement-room--insert-event event)
(ewoc-set-hf ement-ewoc "" footer))) (ewoc-set-hf ement-ewoc "" footer)))
(defun ement-room--handle-events (events)
"Process EVENTS in current buffer.
Uses handlers defined in `ement-room-event-fns'. The current
buffer should be a room's buffer."
(cl-loop for event being the elements of events ;; EVENTS may be a list or array.
for handler = (alist-get (ement-event-type event) ement-room-event-fns nil nil #'equal)
when handler
do (funcall handler event)
do (ement-progress-update)))
;;;;; EWOC ;;;;; EWOC
(defun ement-room--ewoc-next-matching (ewoc node pred) (defun ement-room--ewoc-next-matching (ewoc node pred)