<commit_before>;;; emacs/vc/config.el -*- lexical-binding: t; -*-

;; `git-timemachine'
(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)
  (advice-add #'git-timemachine--show-minibuffer-details :override #'+vc*update-header-line)

  (after! evil
    ;; Force evil to rehash keybindings for the current state
    (add-hook 'git-timemachine-mode-hook #'evil-normalize-keymaps))

  (when (featurep! :tools magit)
    (add-transient-hook! #'git-timemachine-blame (require 'magit-blame))))


;; `git-commit-mode'
(defun +vc|enforce-git-commit-conventions ()
  "See https://chris.beams.io/posts/git-commit/"
  (setq fill-column 72
        git-commit-summary-max-length 50
        git-commit-style-convention-checks '(overlong-summary-line non-empty-second-line)))
(add-hook 'git-commit-mode-hook #'+vc|enforce-git-commit-conventions)
(when (featurep! :feature evil)
  (add-hook 'git-commit-mode-hook #'evil-insert-state))


;;
;; `vc' (built-in)
;;

;; `vc-hooks'
(setq vc-make-backup-files nil)

;; `vc-annotate' (built-in)
(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)
    'normal))

;; `smerge-mode' (built-in)
(after! smerge-mode
  (unless EMACS26+
    (with-no-warnings<commit_msg>Use insert mode only if git commit is empty<commit_after>;;; emacs/vc/config.el -*- lexical-binding: t; -*-

;; `git-timemachine'
(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)
  (advice-add #'git-timemachine--show-minibuffer-details :override #'+vc*update-header-line)

  (after! evil
    ;; Force evil to rehash keybindings for the current state
    (add-hook 'git-timemachine-mode-hook #'evil-normalize-keymaps))

  (when (featurep! :tools magit)
    (add-transient-hook! #'git-timemachine-blame (require 'magit-blame))))


;; `git-commit-mode'
(defun +vc|enforce-git-commit-conventions ()
  "See https://chris.beams.io/posts/git-commit/"
  (setq fill-column 72
        git-commit-summary-max-length 50
        git-commit-style-convention-checks '(overlong-summary-line non-empty-second-line)))
(add-hook 'git-commit-mode-hook #'+vc|enforce-git-commit-conventions)

(defun +vc|start-in-insert-state-maybe ()
  "Start git-commit-mode in insert state if in a blank commit message,
otherwise in default state."
  (when (and (bound-and-true-p evil-mode)
             (bobp) (eolp))
    (evil-insert-state)))
(add-hook 'git-commit-setup-hook #'+vc|start-in-insert-state-maybe)


;;
;; `vc' (built-in)
;;

;; `vc-hooks'
(setq vc-make-backup-files nil)

;; `vc-annotate' (built-in)
(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)
    'normal))

;; `smerge-mode' (built-in)
(after! smerge-mode
  (unless EMACS26+
    (with-no-warnings
{'fraction_non_alphanumeric': 0.1745325022261799, 'fraction_numerical': 0.003561887800534283, 'mean_word_length': 3.687065368567455, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2102914', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1251, 'n_words': 257}