aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2023-10-12 21:59:45 -0700
committerGravatar Tom Willemse2023-10-12 21:59:45 -0700
commitb6ae70a86b73ca9e0cce114232c02c317385dd67 (patch)
treea7c2df30cf58dd102386f5ebf7307d5c271255b8
parent7f3e524136c18bc5fe1292123ce3f03b84c2f0e8 (diff)
downloadnew-dotfiles-b6ae70a86b73ca9e0cce114232c02c317385dd67.tar.gz
new-dotfiles-b6ae70a86b73ca9e0cce114232c02c317385dd67.zip
Add a random EmacsWiki page to my dashboard
-rw-r--r--oni/home/services/emacs/oni-dashboard.el23
1 files changed, 23 insertions, 0 deletions
diff --git a/oni/home/services/emacs/oni-dashboard.el b/oni/home/services/emacs/oni-dashboard.el
index a0a1767..b08be37 100644
--- a/oni/home/services/emacs/oni-dashboard.el
+++ b/oni/home/services/emacs/oni-dashboard.el
@@ -38,6 +38,29 @@
:button-suffix ""
(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)
(add-to-list 'dashboard-item-generators '(random-note . oni-dashboard-insert-random-note))
(add-to-list 'dashboard-items '(random-note))