forked from purcell/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-git.el
84 lines (63 loc) · 2.55 KB
/
init-git.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
(require-package 'magit)
(require-package 'git-gutter-fringe)
(require-package 'git-blame)
(require-package 'git-commit-mode)
(require-package 'gitignore-mode)
(require-package 'gitconfig-mode)
(require-package 'yagist)
(require-package 'github-browse-file)
(setq-default
magit-save-some-buffers nil
magit-process-popup-time 10
magit-diff-refine-hunk t
magit-completing-read-function 'magit-ido-completing-read)
(global-set-key [(meta f12)] 'magit-status)
(eval-after-load 'magit
'(progn
;; Don't let magit-status mess up window configurations
;; http://whattheemacsd.com/setup-magit.el-01.html
(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)
(when (get-register :magit-fullscreen)
(ignore-errors
(jump-to-register :magit-fullscreen))))
(define-key magit-status-mode-map (kbd "q") 'magit-quit-session)))
;;; When we start working on git-backed files, use git-wip if available
(eval-after-load 'vc-git
'(progn
(global-magit-wip-save-mode)
(diminish 'magit-wip-save-mode)))
;;; Use the fringe version of git-gutter
(eval-after-load 'git-gutter
'(require 'git-gutter-fringe))
(when *is-a-mac*
(add-hook 'magit-mode-hook (lambda () (local-unset-key [(meta h)]))))
;;; git-svn support
(eval-after-load 'magit
'(progn
(require 'magit-svn)))
(eval-after-load 'compile
'(progn
(dolist (defn (list '(git-svn-updated "^\t[A-Z]\t\\(.*\\)$" 1 nil nil 0 1)
'(git-svn-needs-update "^\\(.*\\): needs update$" 1 nil nil 2 1)))
(add-to-list 'compilation-error-regexp-alist-alist defn))
(dolist (defn '(git-svn-updated git-svn-needs-update))
(add-to-list 'compilation-error-regexp-alist defn))))
(defvar git-svn--available-commands nil "Cached list of git svn subcommands")
(defun git-svn (dir)
"Run git svn"
(interactive "DSelect directory: ")
(unless git-svn--available-commands
(setq git-svn--available-commands
(string-all-matches "^ \\([a-z\\-]+\\) +" (shell-command-to-string "git svn help") 1)))
(let* ((default-directory (vc-git-root dir))
(compilation-buffer-name-function (lambda (major-mode-name) "*git-svn*")))
(compile (concat "git svn "
(ido-completing-read "git-svn command: " git-svn--available-commands nil t)))))
(provide 'init-git)