From 9f94f4ddbec629e038344b831e3003badbfb0c0e Mon Sep 17 00:00:00 2001 From: syl20bnr Date: Sun, 12 Apr 2015 12:45:16 -0400 Subject: [PATCH] git layer: Improve git-link support and update README --- contrib/git/README.md | 33 +++++++++++++++------------------ contrib/git/packages.el | 27 +++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/contrib/git/README.md b/contrib/git/README.md index ce374702d..f99179761 100644 --- a/contrib/git/README.md +++ b/contrib/git/README.md @@ -25,8 +25,7 @@ - [Github support](#github-support) - [magit-gh-pulls](#magit-gh-pulls) - [gist.el](#gistel) - - [github-browse-file](#github-browse-file) - - [git-link](#git-link) + - [Browse files](#browse-files) @@ -45,6 +44,8 @@ Features: This layer also provides support for Github with: - [magit-gh-pulls][]: handy `magit` add-on to manage Github pull requests. - [gist.el][]: full-featured mode to browse and post Githug gists. +- [github-browse-file][] and [git-link][]: quickly browse github URL in your +browser. New to Magit? Checkout the [official intro][]. @@ -341,28 +342,22 @@ In the gist list buffer: V | `visual-line state` y | print URL and copy it -### github-browse-file +### Browse files Key Binding | Description ----------------------|------------------------------------------------------------ SPC g f b | browse to file on github - -### git-link - - Key Binding | Description -----------------------|------------------------------------------------------------ -SPC g f l | browse to file on github/bitbucket/etc (on current line possition) SPC g f c | browse to file on github/bitbucket/etc (on current line at commit) +SPC g f C | only copy the generated link on the kill ring +SPC g f l | browse to file on github/bitbucket/etc (on current line position) +SPC g f L | only copy the generated link on the kill ring -Pro Tip: if you have multiple remotes, try prepending `SPC u` to the calls to the git-link - -Pro Tip #2: You can select a region and use git-link to have the whole region selected in the link - -Pro tip #3: The link is openned automatically, but it's copied to the clipboard -too if you don't want for any reason to have the link opened all the time, put this on your `dotspacemacs/config`: -```elisp -(setq git-link-open-in-browser nil) -``` +**Notes** +- You can use the universal argument `SPC u` to select a remote repository. +- You can use `git-link` on a region. +- When the link is opened, the URL is also copied in the kill ring, you can +override this behavior by setting the variable `git-link-open-in-browser` to +`nil`. [git]: http://git-scm.com/ [download page]: http://git-scm.com/downloads @@ -376,3 +371,5 @@ too if you don't want for any reason to have the link opened all the time, put t [git-messenger]: https://github.com/syohex/emacs-git-messenger [magit-gh-pulls]: https://github.com/sigma/magit-gh-pulls [gist.el]: https://github.com/defunkt/gist.el +[git-link]: https://github.com/sshaw/git-link +[github-browse-file]: https://github.com/osener/github-browse-file diff --git a/contrib/git/packages.el b/contrib/git/packages.el index 4632d9bba..332689226 100644 --- a/contrib/git/packages.el +++ b/contrib/git/packages.el @@ -325,11 +325,30 @@ which require an initialization must be listed explicitly in the list.") (defun git/init-git-link () (use-package git-link + :if git-enable-github-support + :defer t :init - (evil-leader/set-key - "gfl" 'git-link - "gfc" 'git-link-commit) - (setq git-link-open-in-browser t))) + (progn + + (defun spacemacs/git-link-copy-url-only () + "Only copy the generated link to the kill ring." + (interactive) + (let (git-link-open-in-browser) + (call-interactively 'git-link))) + + (defun spacemacs/git-link-commit-copy-url-only () + "Only copy the generated link to the kill ring." + (interactive) + (let (git-link-open-in-browser) + (call-interactively 'git-link-commit))) + + (evil-leader/set-key + "gfl" 'git-link + "gfL" 'spacemacs/git-link-copy-url-only + "gfc" 'git-link-commit + "gfC" 'spacemacs/git-link-commit-copy-url-only) + ;; default is to open the generated link + (setq git-link-open-in-browser t)))) (defun git/init-magit-gitflow () (use-package magit-gitflow