forked from magnars/.emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup-magit.el
67 lines (51 loc) · 1.93 KB
/
setup-magit.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
(autoload 'magit-status "magit")
(eval-after-load "magit"
'(progn
(require 'magit-svn)
;; Subtler highlight
(set-face-background 'magit-item-highlight "#121212")
(set-face-foreground 'diff-context "#666666")
(set-face-foreground 'diff-added "#00cc33")
(set-face-foreground 'diff-removed "#ff0000")
;; Load git configurations
;; For instance, to run magit-svn-mode in a project, do:
;;
;; git config --add magit.extension svn
;;
(add-hook 'magit-mode-hook 'magit-load-config-extensions)
;; C-x C-k to kill file on line
(defun magit-kill-file-on-line ()
"Show file on current magit line and prompt for deletion."
(interactive)
(magit-visit-item)
(delete-current-buffer-file)
(magit-refresh))
(define-key magit-status-mode-map (kbd "C-x C-k") 'magit-kill-file-on-line)
;; full screen magit-status
(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)
;; ignore whitespace
(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)
))
(provide 'setup-magit)