Add hub browse fallback for browse-at-remote (WIP)
This commit is contained in:
parent
6950a6986f
commit
095051895a
1 changed files with 20 additions and 9 deletions
|
@ -49,16 +49,27 @@
|
||||||
:n [tab] 'vc-annotate-toggle-annotation-visibility
|
:n [tab] 'vc-annotate-toggle-annotation-visibility
|
||||||
:n "RET" 'vc-annotate-find-revision-at-line))
|
:n "RET" 'vc-annotate-find-revision-at-line))
|
||||||
|
|
||||||
(evil-define-command narf:git-remote-browse (&optional bang file)
|
(use-package browse-at-remote
|
||||||
"Open the website for the current (or specified) version controlled FILE. If BANG,
|
:commands (browse-at-remote/browse browse-at-remote/to-clipboard)
|
||||||
|
:init
|
||||||
|
(evil-define-command narf:git-remote-browse (&optional bang)
|
||||||
|
"Open the website for the current (or specified) version controlled FILE. If BANG,
|
||||||
then use hub to do it."
|
then use hub to do it."
|
||||||
(interactive "<!><f>")
|
(interactive "<!>")
|
||||||
(let ((url (shell-command-to-string "hub browse -u -- ")))
|
(let (url)
|
||||||
(when url
|
(condition-case err
|
||||||
(setq url (concat (s-trim url) "/" (f-relative (buffer-file-name) (narf/project-root)))))
|
(setq url (browse-at-remote/get-url))
|
||||||
(if bang
|
(error
|
||||||
(message "Url copied to clipboard: %s" (kill-new url))
|
(setq url (shell-command-to-string "hub browse -u --"))
|
||||||
(browse-url url))))
|
(setq url (if url
|
||||||
|
(concat (s-trim url) "/" (f-relative (buffer-file-name) (narf/project-root))
|
||||||
|
(when (use-region-p) (format "#L%s-L%s"
|
||||||
|
(line-number-at-pos (region-beginning))
|
||||||
|
(line-number-at-pos (region-end)))))))))
|
||||||
|
(when url
|
||||||
|
(if bang
|
||||||
|
(message "Url copied to clipboard: %s" (kill-new url))
|
||||||
|
(browse-url url))))))
|
||||||
|
|
||||||
(provide 'core-vcs)
|
(provide 'core-vcs)
|
||||||
;;; core-vcs.el ends here
|
;;; core-vcs.el ends here
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue