forked from purcell/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-git.el
80 lines (59 loc) · 2.78 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
(setq magit-save-some-buffers nil
magit-process-popup-time 10
magit-completing-read-function 'magit-ido-completing-read)
(defun magit-status-somedir ()
(interactive)
(let ((current-prefix-arg t))
(magit-status default-directory)))
(global-set-key [(meta f12)] 'magit-status)
(global-set-key [(shift meta f12)] 'magit-status-somedir)
(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)
(jump-to-register :magit-fullscreen))
(define-key magit-status-mode-map (kbd "q") 'magit-quit-session)))
(when *is-a-mac*
(add-hook 'magit-mode-hook (lambda () (local-unset-key [(meta h)]))))
(eval-after-load 'magit
'(progn
(require 'magit-svn)))
;;----------------------------------------------------------------------------
;; git-svn conveniences
;;----------------------------------------------------------------------------
(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)))))
;;----------------------------------------------------------------------------
;; gist fixes
;;----------------------------------------------------------------------------
;; If using a "password = !some command" in .gitconfig, we need to
;; run the specified command to find the actual value
(defadvice gh-config (after sanityinc/maybe-execute-bang (key) activate)
(when (and (string= key "password")
(string-prefix-p "!" ad-return-value))
(setq ad-return-value (shell-command-to-string (substring ad-return-value 1)))))
(provide 'init-git)