emacs/vc: if prefix ARG, open region/line on master branch

This commit is contained in:
Henrik Lissner 2019-10-25 16:12:38 -04:00
parent 467bd53b70
commit d8ea65b968
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -15,14 +15,17 @@
(defvar git-link-use-commit) (defvar git-link-use-commit)
;;;###autoload ;;;###autoload
(defun +vc/git-browse-region-or-line (&optional arg) (defun +vc/git-browse-region-or-line (&optional arg)
"Open the website for the current version controlled file. Fallback to "Open the website for the current line of this version controlled file.
repository root." Uses the currently checked out branch. If prefix ARG, then use 'master' branch.
If an url can't be ascertained, opens the repository's root."
(interactive "P") (interactive "P")
(require 'git-link) (require 'git-link)
(let (git-link-use-commit) (let ((git-link-default-branch (if arg "master" git-link-default-branch))
current-prefix-arg ; don't propagate to `git-link'
git-link-use-commit)
(cl-destructuring-bind (beg end) (cl-destructuring-bind (beg end)
(if buffer-file-name (git-link--get-region)) (if buffer-file-name (git-link--get-region))
(let ((git-link-open-in-browser (not arg))) (let ((git-link-open-in-browser t))
(git-link (git-link--select-remote) beg end))))) (git-link (git-link--select-remote) beg end)))))
;;;###autoload ;;;###autoload