-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-magit.el
52 lines (42 loc) · 1.55 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
;; 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-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))
(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)
;; C-c C-a to amend without any prompt
(defun magit-just-amend ()
(interactive)
(save-window-excursion
(magit-with-refresh
(shell-command "git --no-pager commit --amend --reuse-message=HEAD"))))
(eval-after-load "magit"
'(define-key magit-status-mode-map (kbd "C-c C-a") 'magit-just-amend))
;; This code makes magit-status run alone in the frame, and then
;; restores the old window configuration when you quit out of magit.
;; No more juggling windows after commiting.
(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)