Skip to content

Instantly share code, notes, and snippets.

@hchbaw
Created October 1, 2009 15:48
Show Gist options
  • Save hchbaw/199053 to your computer and use it in GitHub Desktop.
Save hchbaw/199053 to your computer and use it in GitHub Desktop.
(progn
(defun tst ()
(macrolet ((with-window-testing-buffer (lines &rest body)
(let ((gb (gensym)))
`(let ((,gb (get-buffer-create "testing")))
(switch-to-buffer ,gb)
(erase-buffer)
(dotimes (_ ,lines)
(insert "a\n"))
(unwind-protect
(progn ,@body)
(kill-buffer ,gb))))))
(with-window-testing-buffer 500
(flet ((line-then (line thunk)
(progn
(goto-line 1)
(sit-for 1)
(goto-line line)
(funcall thunk))))
(multiple-value-bind (a b)
(values
(line-then 500 'window-start)
(line-then 500
(lambda ()
(let (r)
(run-at-time 0.5 nil
(lambda (w)
(setq
r
(window-start w)))
(selected-window))
(sit-for 1)
r))))
(cons (= a b) (cons a b)))))))
(tst))
;;⇒ (nil 1 . 945)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment