Add a random EmacsWiki page to my dashboard
This commit is contained in:
parent
7f3e524136
commit
b6ae70a86b
1 changed files with 23 additions and 0 deletions
|
@ -38,6 +38,29 @@
|
||||||
:button-suffix ""
|
:button-suffix ""
|
||||||
(string-trim-right (car element)))))
|
(string-trim-right (car element)))))
|
||||||
|
|
||||||
|
(defun oni-dashboard-insert-random-wiki-page (_)
|
||||||
|
"Insert a link to a random Emacs Wiki page."
|
||||||
|
(dashboard-insert-heading "Today's Wiki page:" "w")
|
||||||
|
(insert "\n ")
|
||||||
|
(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")
|
||||||
|
(prog1 (cons (url-recreate-url url-current-object)
|
||||||
|
(progn
|
||||||
|
(search-forward "<title>")
|
||||||
|
(let ((beginning (point)))
|
||||||
|
(search-forward "</title>")
|
||||||
|
(forward-char -8)
|
||||||
|
(buffer-substring-no-properties beginning (point)))))
|
||||||
|
(kill-buffer)))))
|
||||||
|
(message "Got: %s" info)
|
||||||
|
(widget-create 'url-link
|
||||||
|
:format (format "%%[%s%%]" (cdr info))
|
||||||
|
:button-suffix ""
|
||||||
|
:button-prefix ""
|
||||||
|
(car info))))
|
||||||
|
|
||||||
|
(add-to-list 'dashboard-item-generators '(random-wiki-page . oni-dashboard-insert-random-wiki-page))
|
||||||
|
(add-to-list 'dashboard-items '(random-wiki-page))
|
||||||
(require 'org-roam)
|
(require 'org-roam)
|
||||||
(add-to-list 'dashboard-item-generators '(random-note . oni-dashboard-insert-random-note))
|
(add-to-list 'dashboard-item-generators '(random-note . oni-dashboard-insert-random-note))
|
||||||
(add-to-list 'dashboard-items '(random-note))
|
(add-to-list 'dashboard-items '(random-note))
|
||||||
|
|
Loading…
Reference in a new issue