Skip to content

Commit

Permalink
Bug fixed async functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
kiwanami committed Jul 6, 2013
1 parent da5a1be commit 90a5c5f
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions ctable.el
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ cancel : Cancel function of data requesting. (Can be nil)
For forward compatibility, these callback functions should have a `&rest' keyword at the end of argument list.
"
request init-num more-num reset cancel)
request (init-num 20) (more-num 20) reset cancel)


(defstruct ctbl:cmodel
Expand Down Expand Up @@ -1396,14 +1396,13 @@ This function assumes that the current buffer is the destination buffer."
0 (ctbl:async-model-init-num amodel)
(lambda (rows) ; >> request succeeded
(with-current-buffer buf
(let
(buffer-read-only
(let (buffer-read-only drows column-formats
(column-widths
(loop for c in cmodels
for title = (ctbl:cmodel-title c)
collect (max (or (ctbl:cmodel-min-width c) 0)
(or (and title (length title)) 0))))
(EOL "\n") drows column-formats)
(EOL "\n"))
;; check cell widths
(setq drows (ctbl:render-check-cell-width rows cmodels column-widths))
;; adjust cell widths for ctbl:dest width
Expand Down Expand Up @@ -1495,15 +1494,15 @@ to urge async data model to request next data chunk."
(when (and cp (not (window-minibuffer-p)))
(ctbl:async-state-on-post-command-hook cp))))

(defun ctbl:async-model-wrapper (rows &rest init-num more-num)
(defun ctbl:async-model-wrapper (rows &optional init-num more-num)
"This function wraps a list of row data in an asynchronous data
model so as to avoid Emacs freezing with a large number of rows."
(lexical-let ((rows rows) (rest-rows rows)
(init-num (or init-num 100))
(more-num (or more-num 100)))
(make-ctbl:async-model
:request
(lambda (row-num len responsef errorf)
(lambda (row-num len responsef errorf &rest)
(funcall
responsef
(cond
Expand All @@ -1521,7 +1520,7 @@ model so as to avoid Emacs freezing with a large number of rows."
(when rest-rows
(setq rest-rows (nthcdr len rest-rows))))
:reset
(lambda () (setq rest-rows rows))
(lambda (&rest) (setq rest-rows rows))
:init-num init-num :more-num more-num)))


Expand Down

0 comments on commit 90a5c5f

Please sign in to comment.