Make the dashboard wiki page loading asynchronous
This commit is contained in:
parent
b6ae70a86b
commit
1f92565b73
1 changed files with 24 additions and 15 deletions
|
@ -43,21 +43,30 @@
|
||||||
(dashboard-insert-heading "Today's Wiki page:" "w")
|
(dashboard-insert-heading "Today's Wiki page:" "w")
|
||||||
(insert "\n ")
|
(insert "\n ")
|
||||||
(dashboard-insert-shortcut 'random-wiki-page "w" "Today's Wiki page:")
|
(dashboard-insert-shortcut 'random-wiki-page "w" "Today's Wiki page:")
|
||||||
(let ((info (with-current-buffer (url-retrieve-synchronously "https://www.emacswiki.org/emacs?action=random")
|
(let ((text-beginning-marker (point-marker)))
|
||||||
(prog1 (cons (url-recreate-url url-current-object)
|
(insert "Loading...")
|
||||||
(progn
|
(url-retrieve "https://www.emacswiki.org/emacs?action=random"
|
||||||
(search-forward "<title>")
|
(lambda (&rest _args)
|
||||||
(let ((beginning (point)))
|
(let ((info (prog1 (cons (url-recreate-url url-current-object)
|
||||||
(search-forward "</title>")
|
(progn
|
||||||
(forward-char -8)
|
(search-forward "<title>")
|
||||||
(buffer-substring-no-properties beginning (point)))))
|
(let ((beginning (point)))
|
||||||
(kill-buffer)))))
|
(search-forward "</title>")
|
||||||
(message "Got: %s" info)
|
(forward-char -8)
|
||||||
(widget-create 'url-link
|
(buffer-substring-no-properties beginning (point)))))
|
||||||
:format (format "%%[%s%%]" (cdr info))
|
(kill-buffer))))
|
||||||
:button-suffix ""
|
(with-current-buffer (marker-buffer text-beginning-marker)
|
||||||
:button-prefix ""
|
(let ((inhibit-read-only t))
|
||||||
(car info))))
|
(save-excursion
|
||||||
|
(goto-char (marker-position text-beginning-marker))
|
||||||
|
(delete-char 10)
|
||||||
|
(widget-create 'url-link
|
||||||
|
:format (format "%%[%s%%]" (cdr info))
|
||||||
|
:button-suffix ""
|
||||||
|
:button-prefix ""
|
||||||
|
(car info)))))))
|
||||||
|
nil
|
||||||
|
t)))
|
||||||
|
|
||||||
(add-to-list 'dashboard-item-generators '(random-wiki-page . oni-dashboard-insert-random-wiki-page))
|
(add-to-list 'dashboard-item-generators '(random-wiki-page . oni-dashboard-insert-random-wiki-page))
|
||||||
(add-to-list 'dashboard-items '(random-wiki-page))
|
(add-to-list 'dashboard-items '(random-wiki-page))
|
||||||
|
|
Loading…
Reference in a new issue