git layer: Improve git-link support and update README
This commit is contained in:
parent
610eeddfd5
commit
9f94f4ddbe
|
@ -25,8 +25,7 @@
|
||||||
- [Github support](#github-support)
|
- [Github support](#github-support)
|
||||||
- [magit-gh-pulls](#magit-gh-pulls)
|
- [magit-gh-pulls](#magit-gh-pulls)
|
||||||
- [gist.el](#gistel)
|
- [gist.el](#gistel)
|
||||||
- [github-browse-file](#github-browse-file)
|
- [Browse files](#browse-files)
|
||||||
- [git-link](#git-link)
|
|
||||||
|
|
||||||
<!-- markdown-toc end -->
|
<!-- markdown-toc end -->
|
||||||
|
|
||||||
|
@ -45,6 +44,8 @@ Features:
|
||||||
This layer also provides support for Github with:
|
This layer also provides support for Github with:
|
||||||
- [magit-gh-pulls][]: handy `magit` add-on to manage Github pull requests.
|
- [magit-gh-pulls][]: handy `magit` add-on to manage Github pull requests.
|
||||||
- [gist.el][]: full-featured mode to browse and post Githug gists.
|
- [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][].
|
New to Magit? Checkout the [official intro][].
|
||||||
|
|
||||||
|
@ -341,28 +342,22 @@ In the gist list buffer:
|
||||||
<kbd>V</kbd> | `visual-line state`
|
<kbd>V</kbd> | `visual-line state`
|
||||||
<kbd>y</kbd> | print URL and copy it
|
<kbd>y</kbd> | print URL and copy it
|
||||||
|
|
||||||
### github-browse-file
|
### Browse files
|
||||||
|
|
||||||
Key Binding | Description
|
Key Binding | Description
|
||||||
----------------------|------------------------------------------------------------
|
----------------------|------------------------------------------------------------
|
||||||
<kbd>SPC g f b</kbd> | browse to file on github
|
<kbd>SPC g f b</kbd> | browse to file on github
|
||||||
|
|
||||||
### git-link
|
|
||||||
|
|
||||||
Key Binding | Description
|
|
||||||
----------------------|------------------------------------------------------------
|
|
||||||
<kbd>SPC g f l</kbd> | browse to file on github/bitbucket/etc (on current line possition)
|
|
||||||
<kbd>SPC g f c</kbd> | browse to file on github/bitbucket/etc (on current line at commit)
|
<kbd>SPC g f c</kbd> | browse to file on github/bitbucket/etc (on current line at commit)
|
||||||
|
<kbd>SPC g f C</kbd> | only copy the generated link on the kill ring
|
||||||
|
<kbd>SPC g f l</kbd> | browse to file on github/bitbucket/etc (on current line position)
|
||||||
|
<kbd>SPC g f L</kbd> | 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
|
**Notes**
|
||||||
|
- You can use the universal argument `SPC u` to select a remote repository.
|
||||||
Pro Tip #2: You can select a region and use git-link to have the whole region selected in the link
|
- You can use `git-link` on a region.
|
||||||
|
- When the link is opened, the URL is also copied in the kill ring, you can
|
||||||
Pro tip #3: The link is openned automatically, but it's copied to the clipboard
|
override this behavior by setting the variable `git-link-open-in-browser` to
|
||||||
too if you don't want for any reason to have the link opened all the time, put this on your `dotspacemacs/config`:
|
`nil`.
|
||||||
```elisp
|
|
||||||
(setq git-link-open-in-browser nil)
|
|
||||||
```
|
|
||||||
|
|
||||||
[git]: http://git-scm.com/
|
[git]: http://git-scm.com/
|
||||||
[download page]: http://git-scm.com/downloads
|
[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
|
[git-messenger]: https://github.com/syohex/emacs-git-messenger
|
||||||
[magit-gh-pulls]: https://github.com/sigma/magit-gh-pulls
|
[magit-gh-pulls]: https://github.com/sigma/magit-gh-pulls
|
||||||
[gist.el]: https://github.com/defunkt/gist.el
|
[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
|
||||||
|
|
|
@ -325,11 +325,30 @@ which require an initialization must be listed explicitly in the list.")
|
||||||
|
|
||||||
(defun git/init-git-link ()
|
(defun git/init-git-link ()
|
||||||
(use-package git-link
|
(use-package git-link
|
||||||
|
:if git-enable-github-support
|
||||||
|
:defer t
|
||||||
:init
|
:init
|
||||||
|
(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
|
(evil-leader/set-key
|
||||||
"gfl" 'git-link
|
"gfl" 'git-link
|
||||||
"gfc" 'git-link-commit)
|
"gfL" 'spacemacs/git-link-copy-url-only
|
||||||
(setq git-link-open-in-browser t)))
|
"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 ()
|
(defun git/init-magit-gitflow ()
|
||||||
(use-package magit-gitflow
|
(use-package magit-gitflow
|
||||||
|
|
Loading…
Reference in a new issue