Add git-timemachine support to browse-at-remote
browse-at-remote commands will now open the current file at the active revision on that project's git forge in your browser.
This commit is contained in:
parent
3c19d9528e
commit
87e48cbc90
1 changed files with 25 additions and 0 deletions
|
@ -48,6 +48,31 @@
|
|||
;; `header-line-format', which has better visibility.
|
||||
(setq git-timemachine-show-minibuffer-details t)
|
||||
|
||||
;; TODO PR this to `git-timemachine'
|
||||
(defadvice! +vc-support-git-timemachine-a (orig-fn)
|
||||
"Allow `browse-at-remote' commands in git-timemachine buffers to open that
|
||||
file in your browser at the visited revision."
|
||||
:around #'browse-at-remote-get-url
|
||||
(if git-timemachine-mode
|
||||
(let* ((start-line (line-number-at-pos (min (region-beginning) (region-end))))
|
||||
(end-line (line-number-at-pos (max (region-beginning) (region-end))))
|
||||
(remote-ref (browse-at-remote--remote-ref buffer-file-name))
|
||||
(remote (car remote-ref))
|
||||
(ref (car git-timemachine-revision))
|
||||
(relname
|
||||
(file-relative-name
|
||||
buffer-file-name (expand-file-name (vc-git-root buffer-file-name))))
|
||||
(target-repo (browse-at-remote--get-url-from-remote remote))
|
||||
(remote-type (browse-at-remote--get-remote-type target-repo))
|
||||
(repo-url (cdr target-repo))
|
||||
(url-formatter (browse-at-remote--get-formatter 'region-url remote-type)))
|
||||
(unless url-formatter
|
||||
(error (format "Origin repo parsing failed: %s" repo-url)))
|
||||
(funcall url-formatter repo-url ref relname
|
||||
(if start-line start-line)
|
||||
(if (and end-line (not (equal start-line end-line))) end-line)))
|
||||
(funcall orig-fn)))
|
||||
|
||||
(defadvice! +vc-update-header-line-a (revision)
|
||||
"Show revision details in the header-line, instead of the minibuffer.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue