doomemacs/modules/feature/version-control/autoload.el

28 lines
920 B
EmacsLisp
Raw Normal View History

;;; feature/version-control/autoload.el -*- lexical-binding: t; -*-
2017-02-03 20:29:09 -05:00
;;;###autoload
2017-02-11 06:51:59 -05:00
(defun +vcs-root ()
2017-02-03 20:29:09 -05:00
"Get git url root."
(let ((remote (git-link--select-remote)))
(if (git-link--remote-host remote)
(format "https://%s/%s"
(git-link--remote-host remote)
(git-link--remote-dir remote))
(error "Remote `%s' is unknown or contains an unsupported URL" remote))))
2017-02-03 20:29:09 -05:00
;;;###autoload
(defun +vcs/git-browse ()
"Open the website for the current version controlled file. Fallback to
repository root."
2017-02-03 20:29:09 -05:00
(interactive)
(destructuring-bind (beg end) (if buffer-file-name (git-link--get-region))
(git-link (git-link--select-remote) beg end)))
2017-02-03 20:29:09 -05:00
;;;###autoload
(defun +vcs/git-browse-issues ()
"Open the github issues page for current repo."
(interactive)
2017-02-11 06:51:59 -05:00
(if-let (root (+vcs-root))
2017-02-03 20:29:09 -05:00
(browse-url (concat root "/issues"))
(user-error "No git root found!")))