Permalink
Browse files

Switched to asynchronous url-retrieve call which gets us out of the a…

…nnoying bug in url-retrieve-synchronously where it hangs indefinitely. EOM
  • Loading branch information...
1 parent 3dd5c52 commit 71a97dcf945d04d56aab657aa7d59b162be832de @timvisher committed Nov 23, 2011
Showing with 24 additions and 23 deletions.
  1. +24 −23 emacs/vimgolf.el
View
@@ -294,37 +294,38 @@ unknown key sequence was entered).")
(let ((str (buffer-substring-no-properties start (match-beginning 0))))
(replace-regexp-in-string "^ " "" str)))))
-;;;###autoload
-(defun vimgolf (challenge-id)
- "Open a VimGolf Challenge"
- (interactive "sChallenge ID: ")
+(defun vimgolf-setup (status challenge-id)
(vimgolf-clear-keystrokes)
(setq vimgolf-prior-window-configuration (current-window-configuration)
vimgolf-challenge challenge-id)
- (let ((vimgolf-yaml-buffer (url-retrieve-synchronously (vimgolf-challenge-url challenge-id))))
- (set-buffer vimgolf-yaml-buffer)
- (beginning-of-buffer)
- (let* ((start-text (vimgolf-read-next-data-chunk))
- (end-text (vimgolf-read-next-data-chunk)))
+ (beginning-of-buffer)
+ (let* ((start-text (vimgolf-read-next-data-chunk))
+ (end-text (vimgolf-read-next-data-chunk)))
- (vimgolf-kill-existing-session)
+ (vimgolf-kill-existing-session)
- (let ((vimgolf-start-buffer (get-buffer-create vimgolf-start-buffer-name))
- (vimgolf-work-buffer (get-buffer-create vimgolf-work-buffer-name))
- (vimgolf-end-buffer (get-buffer-create vimgolf-end-buffer-name)))
+ (let ((vimgolf-start-buffer (get-buffer-create vimgolf-start-buffer-name))
+ (vimgolf-work-buffer (get-buffer-create vimgolf-work-buffer-name))
+ (vimgolf-end-buffer (get-buffer-create vimgolf-end-buffer-name)))
- (vimgolf-init-buffer vimgolf-start-buffer start-text)
- (vimgolf-init-buffer vimgolf-end-buffer end-text)
- (vimgolf-reset-work-buffer)
+ (vimgolf-init-buffer vimgolf-start-buffer start-text)
+ (vimgolf-init-buffer vimgolf-end-buffer end-text)
+ (vimgolf-reset-work-buffer)
- ;; Set up windows
- (delete-other-windows)
- (display-buffer vimgolf-end-buffer 'display-buffer-pop-up-window)
- (set-window-buffer (selected-window) vimgolf-work-buffer)
- (switch-to-buffer vimgolf-work-buffer)
- (setq vimgolf-working-window-configuration (current-window-configuration))
+ ;; Set up windows
+ (delete-other-windows)
+ (display-buffer vimgolf-end-buffer 'display-buffer-pop-up-window)
+ (set-window-buffer (selected-window) vimgolf-work-buffer)
+ (switch-to-buffer vimgolf-work-buffer)
+ (setq vimgolf-working-window-configuration (current-window-configuration))
- (vimgolf-enable-capture t)))))
+ (vimgolf-enable-capture t))))
+
+;;;###autoload
+(defun vimgolf (challenge-id)
+ "Open a VimGolf Challenge"
+ (interactive "sChallenge ID: ")
+ (url-retrieve (vimgolf-challenge-url challenge-id) 'vimgolf-setup '(challenge-id)))
(provide 'vimgolf)

0 comments on commit 71a97dc

Please sign in to comment.