forked from magnars/.emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-magit.el
110 lines (84 loc) · 2.95 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
;; Subtler highlight
(set-face-background 'magit-item-highlight "#121212")
(set-face-background 'diff-file-header "#121212")
(set-face-foreground 'diff-context "#666666")
(set-face-foreground 'diff-added "#00cc33")
(set-face-foreground 'diff-removed "#ff0000")
;; todo:
;; diff-added-face diff-changed-face
;; diff-context-face diff-file-header-face
;; diff-function-face diff-header-face
;; diff-hunk-header-face diff-index-face
;; diff-indicator-added-face diff-indicator-changed-face
;; diff-indicator-removed-face diff-nonexistent-face
;; diff-removed-face
;; 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)
(defun magit-save-and-exit-commit-mode ()
(interactive)
(save-buffer)
(server-edit)
(delete-window))
(defun magit-exit-commit-mode ()
(interactive)
(kill-buffer)
(delete-window))
(eval-after-load "git-commit-mode"
'(define-key git-commit-mode-map (kbd "C-c C-k") 'magit-exit-commit-mode))
;; 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)
;; full screen vc-annotate
(defun vc-annotate-quit ()
"Restores the previous window configuration and kills the vc-annotate buffer"
(interactive)
(kill-buffer)
(jump-to-register :vc-annotate-fullscreen))
(eval-after-load "vc-annotate"
'(progn
(defadvice vc-annotate (around fullscreen activate)
(window-configuration-to-register :vc-annotate-fullscreen)
ad-do-it
(delete-other-windows))
(define-key vc-annotate-mode-map (kbd "q") 'vc-annotate-quit)))
;; 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)
;; Show blame for current line
(require-package 'git-messenger)
(global-set-key (kbd "C-x v p") #'git-messenger:popup-message)
;; no highlight on diff section
(defun magit-highlight-section ())
(provide 'setup-magit)