Add magit-next as an extension (submodule)

Set git-use-magit-next to t in the layer variable to use it.
For now magit-ghpull from github layer is disabled.
A LOT of issues with next magit and evil remain to be fixed
This commit is contained in:
syl20bnr 2015-06-23 23:52:24 -04:00
parent 28896f1059
commit 7876176d38
6 changed files with 150 additions and 6 deletions

4
.gitmodules vendored
View file

@ -16,3 +16,7 @@
[submodule "spacemacs/extensions/spray"]
path = spacemacs/extensions/spray
url = https://github.com/syl20bnr/spray
[submodule "contrib/!source-control/git/extensions/magit-next"]
path = contrib/!source-control/git/extensions/magit-next
url = https://github.com/magit/magit
branch = next

View file

@ -17,3 +17,6 @@
(defvar git-magit-status-fullscreen nil
"If non nil magit-status buffer is displayed in fullscreen.")
(defvar git-use-magit-next nil
"If non nil magit next branch will be used.")

View file

@ -0,0 +1,130 @@
;;; extensions.el --- Git Layer Extensions File for Spacemacs
;;
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(setq git-post-extensions '())
(when git-use-magit-next
(setq git-post-extensions '(magit-next)))
(defun git/init-magit-next ()
(use-package magit
:if git-use-magit-next
:commands (magit-status
magit-blame-mode
magit-log
magit-commit)
:init
(progn
(add-to-list 'load-path (format "%smagit-next/lisp/"
(configuration-layer/get-layer-property
'git :ext-dir)))
(setq magit-last-seen-setup-instructions "1.4.0"
magit-completing-read-function 'magit-ido-completing-read)
(add-hook 'git-commit-mode-hook 'fci-mode)
;; must enable auto-fill-mode again because somehow fci-mode disable it
(add-hook 'git-commit-mode-hook 'auto-fill-mode)
;; On Windows, we must use Git GUI to enter username and password
;; See: https://github.com/magit/magit/wiki/FAQ#windows-cannot-push-via-https
(when (eq window-system 'w32)
(setenv "GIT_ASKPASS" "git-gui--askpass"))
(defun spacemacs/magit-diff-head ()
"Execute `magit-diff' against current HEAD."
(interactive)
(magit-diff "HEAD"))
(evil-leader/set-key
"gb" 'magit-blame-mode
"gl" 'magit-log
"gs" 'magit-status
"gd" 'spacemacs/magit-diff-head
"gC" 'magit-commit)
(evilify magit-commit-mode magit-commit-mode-map
(kbd "C-j") 'magit-goto-next-section
(kbd "C-k") 'magit-goto-previous-section
(kbd "C-n") 'magit-goto-next-section
(kbd "C-p") 'magit-goto-previous-section
(kbd "C-v") 'magit-revert-item)
(evilify magit-log-mode magit-log-mode-map
(kbd "C-j") 'magit-goto-next-section
(kbd "C-k") 'magit-goto-previous-section
(kbd "C-n") 'magit-goto-next-section
(kbd "C-p") 'magit-goto-previous-section
(kbd "C-v") 'magit-revert-item)
(evilify magit-process-mode magit-process-mode-map
(kbd "C-j") 'magit-goto-next-section
(kbd "C-k") 'magit-goto-previous-section
(kbd "C-n") 'magit-goto-next-section
(kbd "C-p") 'magit-goto-previous-section
(kbd "C-v") 'magit-revert-item)
(evilify magit-branch-manager-mode magit-branch-manager-mode-map
"K" 'magit-discard-item
"L" 'magit-key-mode-popup-logging
(kbd "C-j") 'magit-goto-next-section
(kbd "C-k") 'magit-goto-previous-section
(kbd "C-n") 'magit-goto-next-section
(kbd "C-p") 'magit-goto-previous-section
(kbd "C-v") 'magit-revert-item)
(evilify magit-status-mode magit-status-mode-map
"K" 'magit-discard-item
"L" 'magit-key-mode-popup-logging
"H" 'magit-key-mode-popup-diff-options
(kbd "C-j") 'magit-goto-next-section
(kbd "C-k") 'magit-goto-previous-section
(kbd "C-n") 'magit-goto-next-section
(kbd "C-p") 'magit-goto-previous-section
(kbd "C-v") 'magit-revert-item)
(evilify magit-diff-mode magit-diff-mode-map
"K" 'magit-discard-item
"L" 'magit-key-mode-popup-logging
"H" 'magit-key-mode-popup-diff-options
(kbd "C-j") 'magit-goto-next-section
(kbd "C-k") 'magit-goto-previous-section
(kbd "C-n") 'magit-goto-next-section
(kbd "C-p") 'magit-goto-previous-section
(kbd "C-v") 'magit-revert-item))
:config
(progn
;; (spacemacs|hide-lighter magit-auto-revert-mode)
(define-key magit-staged-section-map "k" 'evil-previous-visual-line)
(define-key magit-hunk-section-map "k" 'evil-previous-visual-line)
(define-key magit-file-section-map "k" 'evil-previous-visual-line)
;; full screen magit-status
(when git-magit-status-fullscreen
(defadvice magit-status (around magit-fullscreen activate)
(window-configuration-to-register :magit-fullscreen)
ad-do-it
(delete-other-windows))
(defun magit-quit-session ()
"Restores the previous window configuration and kills the magit buffer"
(interactive)
(kill-buffer)
(jump-to-register :magit-fullscreen))
(define-key magit-status-mode-map (kbd "q") 'magit-quit-session))
(defun magit-toggle-whitespace ()
(interactive)
(if (member "-w" magit-diff-options)
(magit-dont-ignore-whitespace)
(magit-ignore-whitespace)))
(defun magit-ignore-whitespace ()
(interactive)
(add-to-list 'magit-diff-options "-w")
(magit-refresh))
(defun magit-dont-ignore-whitespace ()
(interactive)
(setq magit-diff-options (remove "-w" magit-diff-options))
(magit-refresh))
(define-key magit-status-mode-map (kbd "W") 'magit-toggle-whitespace))))

@ -0,0 +1 @@
Subproject commit 4bfc8690db5f865de03049ce621de25140bbc678

View file

@ -15,16 +15,19 @@
gitattributes-mode
gitconfig-mode
gitignore-mode
git-commit-mode
git-messenger
git-rebase-mode
git-timemachine
helm-gitignore
magit
magit-gitflow
magit-svn
smeargle))
(unless git-use-magit-next
(push 'magit git-packages)
;; not compatible with magit-next
(push 'magit-svn git-packages)
(push 'git-commit-mode git-packages)
(push 'git-rebase-mode git-packages)
(push 'magit-gitflow git-packages))
(defun git/init-helm-gitignore ()
(use-package helm-gitignore
:defer t
@ -105,6 +108,7 @@
(defun git/init-magit ()
(use-package magit
:if (not git-use-magit-next)
:defer t
:init
(progn

View file

@ -17,9 +17,11 @@
github-browse-file
;; not up to date
;; helm-gist
magit-gh-pulls
))
(unless git-use-magit-next
(push 'magit-gh-pulls git-packages))
(defun github/init-gist ()
(use-package gist
:defer t