summaryrefslogtreecommitdiffstats
path: root/ravi-init-vc.el
blob: 3f63bfdd06e86e186f9aecbd24c964ae9b2cfef5 (plain)
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
;;; ravi-init-vc.el --- vc control

;; Copyright (C) 2013  

;; Author:  <ravi@nero.lan>
;; Keywords: vc

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;; Version control initialization

;;; Code:

;; Git
(use-package magit
  :bind ("<M-f3>" . magit-status)
  :config
  (progn
    (setq-default
     magit-process-popup-time 10
     magit-diff-refine-hunk t
     magit-completing-read-function 'magit-ido-completing-read
     )
    (require 'fullframe)
    (fullframe magit-status magit-mode-quit-window :magit-fullscreen nil)
    (use-package vc-git
      :defer t
      :bind ("C-x v f" . vc-git-grep)
      :config
      (progn
	(global-magit-wip-save-mode)
	(diminish 'magit-wip-save-mode)
	)
      )
    (after-load 'magit-key-mode
		(require 'magit-svn))
    
    (after-load 'compile
		(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)
		  (add-to-list 'compilation-error-regexp-alist (car defn))))

    (defvar git-svn--available-commands nil "Cached list of git svn subcommands")

    (defun git-svn (dir)
      "Run a git svn subcommand in DIR."
      (interactive "DSelect directory: ")
      (unless git-svn--available-commands
	(setq git-svn--available-commands
	      (sanityinc/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))))
      )

    (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))

    (bind-key "W" 'magit-toggle-whitespace magit-status-mode-map)

    (defun magit-just-amend ()
      (interactive)
      (save-window-excursion
	(magit-with-refresh
	  (shell-command "git --no-pager commit --amend --reuse-message=HEAD"))))
    (bind-key "C-a" 'magit-just-amend magit-status-mode-map)

    )
  :ensure t
  )
(use-package git-gutter
  :config
  (progn
    (use-package git-gutter-fringe
      :ensure t
      )
    (global-git-gutter-mode 1)
    )
  :ensure t
  :diminish git-gutter-mode
  )
(use-package git-commit-mode
  :ensure t
  )
(use-package git-rebase-mode
  :ensure t
  )
(use-package gitignore-mode
  :ensure t
  )
(use-package gitconfig-mode
  :ensure t
  )
(use-package git-messenger
  :ensure t
  :bind ("C-x v p" . git-messenger:popup-message)
  )

(provide 'ravi-init-vc)
;;; ravi-init-vc.el ends here