summaryrefslogtreecommitdiffstats
path: root/lisp/ravi-init-vc.el
blob: a28a75a5fe8d3572dec3d471fd76d042b11dd920 (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
;;; 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)
         ("C-x v B" . magit-blame)
         ("C-x v F" . magit-file-log))
  :config
  (progn
    (setq-default
     magit-process-popup-time 10
     magit-diff-refine-hunk t
     magit-completing-read-function (if ravi/use-helm-instead-of-ido
                                        'helm--completing-read-default
                                      'magit-ido-completing-read))

    (setq magit-restore-window-configuration t)

    (use-package magit-svn
      :config (add-hook 'magit-mode-hook 'magit-svn-mode)
      :ensure t)
    )
  :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 gitignore-mode
  :ensure t)
(use-package gitconfig-mode
  :ensure t)
(use-package git-messenger
  :bind ("C-x v p" . git-messenger:popup-message)
  :ensure t)
(use-package git-timemachine
  :bind ("C-x v t" . git-timemachine)
  :ensure t)
(use-package vc-git
  :bind ("C-x v f" . vc-git-grep))

;; Stolen almost entirely from Fuco (Matus Goljer)
(use-package ediff
  :config
  (progn
    (defvar my-ediff-before-config nil "Window configuration before ediff.")
    (defvar my-ediff-after-config nil "Window configuration after ediff.")

    (defun my-ediff-before-setup ()
      "Function to be called before any buffers or window setup for
    ediff."
      (setq my-ediff-before-config (current-window-configuration))
      (set-register ?b (list my-ediff-before-config (point-marker))))

    (defun my-ediff-after-setup ()
      "Function to be called after buffers and window setup for ediff."
      (setq my-ediff-after-config (current-window-configuration))
      (set-register ?e (list my-ediff-after-config (point-marker))))

    (defun my-ediff-quit ()
      "Function to be called when ediff quits."
      (when my-ediff-before-config
        (set-window-configuration my-ediff-before-config))
      ;; clean up ediff bullshit
      (->> (buffer-list)
        (-map 'buffer-name)
        (--select (string-match-p "\\*[Ee]diff" it))
        (-map 'kill-buffer)))

    (add-hook 'ediff-before-setup-hook 'my-ediff-before-setup)
    (add-hook 'ediff-after-setup-windows-hook 'my-ediff-after-setup 'append)
    (add-hook 'ediff-quit-hook 'my-ediff-quit)))

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