2018-06-21 21:14:00 +02:00
|
|
|
;;; emacs/vc/config.el -*- lexical-binding: t; -*-
|
|
|
|
|
2019-07-21 04:02:09 +02:00
|
|
|
(when IS-WINDOWS
|
|
|
|
(setenv "GIT_ASKPASS" "git-gui--askpass"))
|
|
|
|
|
|
|
|
|
2019-08-23 21:27:28 -04:00
|
|
|
(after! vc-annotate
|
|
|
|
(set-popup-rules!
|
|
|
|
'(("^\\vc-d" :select nil) ; *vc-diff*
|
|
|
|
("^\\vc-c" :select t))) ; *vc-change-log*
|
|
|
|
(set-evil-initial-state!
|
|
|
|
'(vc-annotate-mode vc-git-log-view-mode)
|
2019-10-26 21:34:44 -04:00
|
|
|
'normal)
|
|
|
|
|
|
|
|
;; Clean up after itself
|
|
|
|
(define-key vc-annotate-mode-map [remap quit-window] #'kill-current-buffer))
|
|
|
|
|
2019-08-23 21:27:28 -04:00
|
|
|
|
2018-06-21 21:14:00 +02:00
|
|
|
(after! git-timemachine
|
|
|
|
;; Sometimes I forget `git-timemachine' is enabled in a buffer, so instead of
|
|
|
|
;; showing revision details in the minibuffer, show them in
|
|
|
|
;; `header-line-format', which has better visibility.
|
|
|
|
(setq git-timemachine-show-minibuffer-details t)
|
2019-12-15 02:17:40 -05:00
|
|
|
|
|
|
|
(defadvice! +vc-update-header-line-a (revision)
|
|
|
|
"Show revision details in the header-line, instead of the minibuffer.
|
|
|
|
|
|
|
|
Sometimes I forget `git-timemachine' is enabled in a buffer. Putting revision
|
|
|
|
info in the `header-line-format' is a good indication."
|
|
|
|
:override #'git-timemachine--show-minibuffer-details
|
|
|
|
(let* ((date-relative (nth 3 revision))
|
|
|
|
(date-full (nth 4 revision))
|
|
|
|
(author (if git-timemachine-show-author (concat (nth 6 revision) ": ") ""))
|
|
|
|
(sha-or-subject (if (eq git-timemachine-minibuffer-detail 'commit) (car revision) (nth 5 revision))))
|
|
|
|
(setq header-line-format
|
|
|
|
(format "%s%s [%s (%s)]"
|
|
|
|
(propertize author 'face 'git-timemachine-minibuffer-author-face)
|
|
|
|
(propertize sha-or-subject 'face 'git-timemachine-minibuffer-detail-face)
|
|
|
|
date-full date-relative))))
|
2018-06-21 21:14:00 +02:00
|
|
|
|
|
|
|
(after! evil
|
2018-07-29 18:26:20 +02:00
|
|
|
;; rehash evil keybindings so they are recognized
|
2018-07-28 12:56:52 +02:00
|
|
|
(add-hook 'git-timemachine-mode-hook #'evil-normalize-keymaps))
|
|
|
|
|
|
|
|
(when (featurep! :tools magit)
|
2019-07-21 23:35:17 +02:00
|
|
|
(add-transient-hook! #'git-timemachine-blame (require 'magit-blame)))
|
|
|
|
|
|
|
|
(map! :map git-timemachine-mode-map
|
2019-10-26 21:34:44 -04:00
|
|
|
:n "C-p" #'git-timemachine-show-previous-revision
|
|
|
|
:n "C-n" #'git-timemachine-show-next-revision
|
|
|
|
:n "gb" #'git-timemachine-blame
|
2019-07-21 23:35:17 +02:00
|
|
|
:n "gtc" #'git-timemachine-show-commit))
|
2018-06-21 21:14:00 +02:00
|
|
|
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! git-commit
|
2019-06-07 23:07:37 +02:00
|
|
|
:after-call after-find-file
|
|
|
|
:config
|
|
|
|
(global-git-commit-mode +1)
|
|
|
|
(set-yas-minor-mode! 'git-commit-mode)
|
2018-08-01 19:26:20 +02:00
|
|
|
|
2019-08-23 20:29:35 -04:00
|
|
|
;; Enforce git commit conventions.
|
|
|
|
;; See https://chris.beams.io/posts/git-commit/
|
|
|
|
(setq git-commit-summary-max-length 50
|
|
|
|
git-commit-style-convention-checks '(overlong-summary-line non-empty-second-line))
|
|
|
|
(setq-hook! 'git-commit-mode-hook fill-column 72)
|
2018-07-28 13:05:47 +02:00
|
|
|
|
2019-07-28 14:52:59 +02:00
|
|
|
(add-hook! 'git-commit-setup-hook
|
2019-07-23 12:30:47 +02:00
|
|
|
(defun +vc-start-in-insert-state-maybe ()
|
2019-07-18 15:27:20 +02:00
|
|
|
"Start git-commit-mode in insert state if in a blank commit message,
|
2018-07-28 13:05:47 +02:00
|
|
|
otherwise in default state."
|
2019-07-18 15:27:20 +02:00
|
|
|
(when (and (bound-and-true-p evil-mode)
|
|
|
|
(bobp) (eolp))
|
|
|
|
(evil-insert-state)))))
|