2015-11-30 04:03:38 +00:00
|
|
|
;;; funcs.el --- Version control functions File
|
|
|
|
;;
|
2016-01-12 02:40:54 +00:00
|
|
|
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
|
2015-11-30 04:03:38 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
2016-07-07 00:59:06 +00:00
|
|
|
(defun spacemacs/vcs-next-hunk ()
|
2015-11-30 04:03:38 +00:00
|
|
|
(interactive)
|
|
|
|
(let ((current-prefix-arg t))
|
|
|
|
(call-interactively
|
|
|
|
(cl-case version-control-diff-tool
|
|
|
|
(diff-hl 'diff-hl-next-hunk)
|
|
|
|
(git-gutter 'git-gutter:next-hunk)
|
|
|
|
(git-gutter+ 'git-gutter+-next-hunk)))))
|
|
|
|
|
2016-07-07 00:59:06 +00:00
|
|
|
(defun spacemacs/vcs-previous-hunk ()
|
2015-11-30 04:03:38 +00:00
|
|
|
(interactive)
|
|
|
|
(let ((current-prefix-arg t))
|
|
|
|
(call-interactively
|
|
|
|
(cl-case version-control-diff-tool
|
|
|
|
(diff-hl 'diff-hl-previous-hunk)
|
|
|
|
(git-gutter 'git-gutter:previous-hunk)
|
|
|
|
(git-gutter+ 'git-gutter+-previous-hunk)))))
|
|
|
|
|
2016-07-07 00:59:06 +00:00
|
|
|
(defun spacemacs/vcs-revert-hunk ()
|
2015-11-30 04:03:38 +00:00
|
|
|
(interactive)
|
|
|
|
(let ((current-prefix-arg t))
|
|
|
|
(call-interactively
|
|
|
|
(cl-case version-control-diff-tool
|
|
|
|
(diff-hl 'diff-hl-revert-hunk)
|
|
|
|
(git-gutter 'git-gutter:revert-hunk)
|
|
|
|
(git-gutter+ 'git-gutter+-revert-hunks)))))
|
|
|
|
|
2016-07-07 00:59:06 +00:00
|
|
|
(defun spacemacs/vcs-stage-hunk ()
|
2015-11-30 04:03:38 +00:00
|
|
|
(interactive)
|
2016-02-09 20:29:44 +00:00
|
|
|
(if (eq 'diff-hl version-control-diff-tool)
|
|
|
|
(message "Staging not available")
|
|
|
|
(let ((current-prefix-arg t))
|
|
|
|
(call-interactively
|
|
|
|
(cl-case version-control-diff-tool
|
|
|
|
(git-gutter 'git-gutter:stage-hunk)
|
|
|
|
(git-gutter+ 'git-gutter+-stage-hunks))))))
|
2015-11-30 04:03:38 +00:00
|
|
|
|
2016-07-07 00:59:06 +00:00
|
|
|
(defun spacemacs/vcs-show-hunk ()
|
2015-11-30 04:03:38 +00:00
|
|
|
(interactive)
|
|
|
|
(let ((current-prefix-arg t))
|
|
|
|
(call-interactively
|
|
|
|
(cl-case version-control-diff-tool
|
|
|
|
(diff-hl 'diff-hl-diff-goto-hunk)
|
|
|
|
(git-gutter 'git-gutter:popup-hunk)
|
|
|
|
(git-gutter+ 'git-gutter+-show-hunk-inline-at-point)))))
|
|
|
|
|
2016-07-07 00:59:06 +00:00
|
|
|
(defun spacemacs/vcs-enable-margin ()
|
2015-11-30 04:03:38 +00:00
|
|
|
(interactive)
|
|
|
|
(let ((current-prefix-arg t))
|
|
|
|
(call-interactively
|
|
|
|
(cl-case version-control-diff-tool
|
2016-01-08 17:32:10 +00:00
|
|
|
(diff-hl 'diff-hl-mode)
|
2015-11-30 04:03:38 +00:00
|
|
|
(git-gutter 'git-gutter-mode)
|
|
|
|
(git-gutter+ 'git-gutter+-mode)))))
|
|
|
|
|
2016-07-07 00:59:06 +00:00
|
|
|
(defun spacemacs/vcs-disable-margin ()
|
2015-11-30 04:03:38 +00:00
|
|
|
(interactive)
|
|
|
|
(let ((current-prefix-arg nil))
|
|
|
|
(call-interactively
|
|
|
|
(cl-case version-control-diff-tool
|
2016-01-08 17:32:10 +00:00
|
|
|
(diff-hl 'diff-hl-mode)
|
2015-11-30 04:03:38 +00:00
|
|
|
(git-gutter 'git-gutter-mode)
|
|
|
|
(git-gutter+ 'git-gutter+-mode)))))
|
|
|
|
|
2016-07-07 00:59:06 +00:00
|
|
|
(defun spacemacs/vcs-enable-margin-globally ()
|
2015-11-30 04:03:38 +00:00
|
|
|
(interactive)
|
|
|
|
(let ((current-prefix-arg t))
|
|
|
|
(call-interactively
|
|
|
|
(cl-case version-control-diff-tool
|
2016-01-08 17:32:10 +00:00
|
|
|
(diff-hl 'global-diff-hl-mode)
|
2015-11-30 04:03:38 +00:00
|
|
|
(git-gutter 'global-git-gutter-mode)
|
|
|
|
(git-gutter+ 'global-git-gutter+-mode)))))
|
|
|
|
|
2016-07-07 00:59:06 +00:00
|
|
|
(defun spacemacs/vcs-disable-margin-globally ()
|
2015-11-30 04:03:38 +00:00
|
|
|
(interactive)
|
|
|
|
(let ((current-prefix-arg nil))
|
|
|
|
(call-interactively
|
|
|
|
(cl-case version-control-diff-tool
|
2016-01-08 17:32:10 +00:00
|
|
|
(diff-hl 'global-diff-hl-mode)
|
2015-11-30 04:03:38 +00:00
|
|
|
(git-gutter 'global-git-gutter-mode)
|
|
|
|
(git-gutter+ 'global-git-gutter+-mode)))))
|
|
|
|
|
2016-07-07 00:59:06 +00:00
|
|
|
(defun spacemacs/vcs-show-help ()
|
2015-11-30 04:03:38 +00:00
|
|
|
(interactive)
|
|
|
|
(setq version-control--ms-doc-toggle
|
|
|
|
(logxor version-control--ms-doc-toggle 1)))
|
|
|
|
|
2016-07-07 00:59:06 +00:00
|
|
|
(defun spacemacs/vcs-margin-p ()
|
2015-11-30 04:03:38 +00:00
|
|
|
(interactive)
|
|
|
|
(cl-case version-control-diff-tool
|
2016-01-08 17:32:10 +00:00
|
|
|
(diff-hl diff-hl-mode)
|
2016-05-19 05:21:01 +00:00
|
|
|
(git-gutter (bound-and-true-p git-gutter-mode))
|
|
|
|
(git-gutter+ (bound-and-true-p git-gutter+-mode))))
|
2015-11-30 04:03:38 +00:00
|
|
|
|
2016-07-07 00:59:06 +00:00
|
|
|
(defun spacemacs/vcs-margin-global-p ()
|
2015-11-30 04:03:38 +00:00
|
|
|
(interactive)
|
|
|
|
(cl-case version-control-diff-tool
|
2016-01-08 17:32:10 +00:00
|
|
|
(diff-hl global-diff-hl-mode)
|
2015-11-30 04:03:38 +00:00
|
|
|
(git-gutter global-git-gutter-mode)
|
|
|
|
(git-gutter+ global-git-gutter+-mode)))
|
|
|
|
|
|
|
|
(spacemacs|add-toggle version-control-margin
|
2016-07-07 00:59:06 +00:00
|
|
|
:status (spacemacs/vcs-margin-p)
|
|
|
|
:on (spacemacs/vcs-enable-margin)
|
|
|
|
:off (spacemacs/vcs-disable-margin)
|
2015-11-30 04:03:38 +00:00
|
|
|
:documentation "Enable diff margins."
|
|
|
|
:evil-leader "Td")
|
|
|
|
|
|
|
|
(spacemacs|add-toggle version-control-margin-globally
|
2016-07-07 00:59:06 +00:00
|
|
|
:status (spacemacs/vcs-margin-global-p)
|
|
|
|
:on (spacemacs/vcs-enable-margin-globally)
|
|
|
|
:off (spacemacs/vcs-disable-margin-globally)
|
2015-11-30 04:03:38 +00:00
|
|
|
:documentation "Enable diff margins globally."
|
2015-11-30 04:08:38 +00:00
|
|
|
:evil-leader "T C-d")
|