diff options
Diffstat (limited to 'oni-browse-url.el')
-rw-r--r-- | oni-browse-url.el | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/oni-browse-url.el b/oni-browse-url.el index 7bd702e..33260d2 100644 --- a/oni-browse-url.el +++ b/oni-browse-url.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse <tom@ryuslash.org> ;; Keywords: local -;; Version: 2022.0311.230935 +;; Version: 2022.1213.070851 ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -27,6 +27,8 @@ (require 'browse-url) +(autoload 'mastodon-url-lookup "mastodon") + ;; Ideas: ;; - Split out to different functions for Medium, Twitter, Youtube, etc. ;; - Split the medium one into *.medium.com and also allow arbitrary sites to be added. @@ -73,6 +75,20 @@ before this filter." 'browse-url-default-windows-browser 'browse-url-firefox)) +;; Taken from https://mas.to/@ParetoOptimalDev/109378647927115065 +(defun oni-browse-url-browse-mastodon (url &rest _args) + "Open URL in mastodon." + (mastodon-url-lookup url)) + +(when (package-installed-p 'mastodon) + (add-to-list 'browse-url-handlers + (cons (rx "http" (optional "s") "://" + (minimal-match (one-or-more (not "/"))) + "/@" + (minimal-match (one-or-more (not "/"))) + "/") + #'oni-browse-url-browse-mastodon))) + (advice-add 'browse-url :filter-args #'browse-url-redirect-alternative) (provide 'oni-browse-url) |