From 6dd72d53233fe1c79eba80dcdc6de36f2f784f5f Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Fri, 24 Feb 2023 23:32:56 -0800 Subject: [PATCH] feat(oni-package): Add keybinding to directly open a package's URL I frequently want to just open the URL of a package to see the readme and possibly some screenshots. There doesn't appeart to be a built-in keybinding for that. --- oni-package.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/oni-package.el b/oni-package.el index e277b0e..0a283a8 100644 --- a/oni-package.el +++ b/oni-package.el @@ -114,5 +114,18 @@ DESCRIPTION is the text of the news item." (add-hook 'package-menu-mode-hook 'hl-line-mode) +;; Set up a keybinding to open a package's URL + +(defun oni-package-open-url () + (interactive nil package-menu-mode) + (let* ((pkg-desc (tabulated-list-get-id)) + (url (map-elt (package-desc-extras pkg-desc) :url))) + (if url + (browse-url url) + (error "Package %s doesn't appear to have a url" + (package-desc-name pkg-desc))))) + +(define-key package-menu-mode-map (kbd "o") #'oni-package-open-url) + (provide 'oni-package) ;;; oni-package.el ends here