diff options
| author | Yuchen Pei <id@ypei.org> | 2023-07-26 00:45:49 +1000 | 
|---|---|---|
| committer | Yuchen Pei <id@ypei.org> | 2023-07-26 00:45:49 +1000 | 
| commit | cc9ae2bb821e00155827e91a8d9303e9b3da59bd (patch) | |
| tree | 1b8ab3d06dfc67807255101c64e15a09d31d696e | |
| parent | 8b79772896c54013f08597a40446d64d0f53ccf8 (diff) | |
Add a command to copy the url of the current view
| -rw-r--r-- | buildbot-view.el | 25 | 
1 files changed, 25 insertions, 0 deletions
| 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 "<return>") #'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. | 
