[oni-browse-url] Open Mastodon URLs with mastodon.el if installed
This commit is contained in:
parent
cd94e63543
commit
8fb6beda45
1 changed files with 17 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue