From cc9ae2bb821e00155827e91a8d9303e9b3da59bd Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 26 Jul 2023 00:45:49 +1000 Subject: Add a command to copy the url of the current view --- buildbot-view.el | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'buildbot-view.el') diff --git a/buildbot-view.el b/buildbot-view.el index 0cc9b26..e31d6e5 100644 --- a/buildbot-view.el +++ b/buildbot-view.el @@ -48,6 +48,7 @@ One of `revision', `build', `step', or `log'.") (define-key kmap "b" #'buildbot-view-previous-header-same-thing) (define-key kmap "g" #'buildbot-view-reload) (define-key kmap (kbd "") #'buildbot-view-open-thing-at-point) + (define-key kmap "w" #'buildbot-view-copy-url) kmap) "Keymap for `buildbot-view-mode'.") @@ -365,6 +366,30 @@ otherwise pass the value from the current buffer." (interactive) (buildbot-view-update)) +(defun buildbot-view-format-url () + "Format the url of the current view." + (unless (derived-mode-p 'buildbot-view-mode) + (error "Must be in buildbot mode")) + (pcase buildbot-view-type + ('branch (format "%s/#grid?branch=%s" + buildbot-host + (alist-get 'branch buildbot-view-data))) + ('build + (let ((build (alist-get 'build buildbot-view-data))) + (format "%s/#/builders/%d/builds/%s" + buildbot-host + (alist-get 'builderid build) + (alist-get 'number build)))) + (_ (error "Unsupported type for formatting url: %s" + buildbot-view-type)))) + +(defun buildbot-view-copy-url () + "Copy the url of the current view." + (interactive) + (let ((url (buildbot-view-format-url))) + (kill-new url) + (message "Copied url: %s" url))) + ;;;###autoload (defun buildbot-revision-open (&optional read-host) "Open a revision view. -- cgit v1.2.3