Add copy-to-clipboard support to :gbr & +vc/git-browse

This commit is contained in:
Henrik Lissner 2018-07-31 16:33:16 +02:00
parent 3948255445
commit 74b700f9a7
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
3 changed files with 19 additions and 8 deletions

View file

@ -70,7 +70,7 @@ command from the current directory instead of the project root."
;; GIT ;; GIT
(ex! "gist" #'+gist:send) ; send current buffer/region to gist (ex! "gist" #'+gist:send) ; send current buffer/region to gist
(ex! "gistl" #'+gist:list) ; list gists by user (ex! "gistl" #'+gist:list) ; list gists by user
(ex! "gbrowse" #'+vc/git-browse) ; show file in github/gitlab (ex! "gbrowse" #'+vc:git-browse) ; show file in github/gitlab
(ex! "gissues" #'+vc/git-browse-issues) ; show github issues (ex! "gissues" #'+vc/git-browse-issues) ; show github issues
(ex! "git" #'magit-status) ; open magit status window (ex! "git" #'magit-status) ; open magit status window
(ex! "gstage" #'magit-stage) (ex! "gstage" #'magit-stage)

View file

@ -0,0 +1,8 @@
;;; emacs/vc/autoload/evil.el -*- lexical-binding: t; -*-
;;;###if (featurep! :feature evil)
;;;###autoload (autoload '+vc:git-browse "emacs/vc/autoload/evil" nil t)
(evil-define-command +vc:git-browse (bang)
"Ex interface to `+vc/git-browse'."
(interactive "<!>")
(+vc/git-browse bang))

View file

@ -1,4 +1,4 @@
;;; emacs/vc/autoload.el -*- lexical-binding: t; -*- ;;; emacs/vc/autoload/vc.el -*- lexical-binding: t; -*-
;;;###autoload ;;;###autoload
(defun +vc-git-root-url () (defun +vc-git-root-url ()
@ -13,21 +13,24 @@
(defvar git-link-open-in-browser) (defvar git-link-open-in-browser)
;;;###autoload ;;;###autoload
(defun +vc/git-browse () (defun +vc/git-browse (arg)
"Open the website for the current version controlled file. Fallback to "Open the website for the current version controlled file. Fallback to
repository root." repository root."
(interactive) (interactive "P")
(require 'git-link) (require 'git-link)
(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 t)) (let ((git-link-open-in-browser (not arg)))
(git-link (git-link--select-remote) beg end)))) (git-link (git-link--select-remote) beg end))))
;;;###autoload ;;;###autoload
(defun +vc/git-browse-issues () (defun +vc/git-browse-issues (arg)
"Open the issues page for current repo." "Open the issues page for current repo."
(interactive) (interactive "P")
(browse-url (format "%s/issues" (+vc-git-root-url)))) (let ((url (format "%s/issues" (+vc-git-root-url))))
(if arg
(message "%s" (kill-new url))
(browse-url url))))
;;;###autoload ;;;###autoload
(defun +vc/git-browse-pulls () (defun +vc/git-browse-pulls ()