From 7876176d3895dfb6c3f757569f22223a9458be01 Mon Sep 17 00:00:00 2001 From: syl20bnr Date: Tue, 23 Jun 2015 23:52:24 -0400 Subject: [PATCH] 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 --- .gitmodules | 4 + contrib/!source-control/git/config.el | 3 + contrib/!source-control/git/extensions.el | 130 ++++++++++++++++++ .../!source-control/git/extensions/magit-next | 1 + contrib/!source-control/git/packages.el | 14 +- contrib/!source-control/github/packages.el | 4 +- 6 files changed, 150 insertions(+), 6 deletions(-) create mode 100644 contrib/!source-control/git/extensions.el create mode 160000 contrib/!source-control/git/extensions/magit-next diff --git a/.gitmodules b/.gitmodules index a52ca47a8..ed81e4c04 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/contrib/!source-control/git/config.el b/contrib/!source-control/git/config.el index 34146a948..daaa11643 100644 --- a/contrib/!source-control/git/config.el +++ b/contrib/!source-control/git/config.el @@ -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.") diff --git a/contrib/!source-control/git/extensions.el b/contrib/!source-control/git/extensions.el new file mode 100644 index 000000000..6c033f213 --- /dev/null +++ b/contrib/!source-control/git/extensions.el @@ -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 +;; 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)))) diff --git a/contrib/!source-control/git/extensions/magit-next b/contrib/!source-control/git/extensions/magit-next new file mode 160000 index 000000000..4bfc8690d --- /dev/null +++ b/contrib/!source-control/git/extensions/magit-next @@ -0,0 +1 @@ +Subproject commit 4bfc8690db5f865de03049ce621de25140bbc678 diff --git a/contrib/!source-control/git/packages.el b/contrib/!source-control/git/packages.el index befba5e2b..95c101c18 100644 --- a/contrib/!source-control/git/packages.el +++ b/contrib/!source-control/git/packages.el @@ -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 diff --git a/contrib/!source-control/github/packages.el b/contrib/!source-control/github/packages.el index a4a24e038..838f04f46 100644 --- a/contrib/!source-control/github/packages.el +++ b/contrib/!source-control/github/packages.el @@ -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