aboutsummaryrefslogtreecommitdiff
path: root/emacs/.emacs.d/init/ycp-vc.el
blob: 66bb06f41083e55a8285ffee94bab7a017de3429 (plain) (blame)
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
;;; ycp-vc.el -- My config for vcs related -*- lexical-binding: t -*-

;; Copyright (C) 2023 Free Software Foundation.

;; Author: Yuchen Pei <id@ypei.org>
;; Package-Requires: ((emacs "28.2"))

;; This file is part of dotfiles.

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

;; dotfiles 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 Affero General
;; Public License for more details.

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

;;; Commentary:

;; My config for vcs related. Covers diff, vc, magit, ediff etc.

;;; Code:



;;; vc, magit, diff
(my-package vc-hooks
  (:delay 5)
  ;;; avoid the "file is symlink to git controlled repo, follow?"
  (setq vc-follow-symlinks t)
)

;;;; `diff-mode'
(my-package diff-mode
  (setq diff-default-read-only t)
  (setq diff-advance-after-apply-hunk t)
  (setq diff-update-on-the-fly t)
  ;; The following are from Emacs 27.1
  (setq diff-font-lock-prettify t)
  (setq diff-font-lock-syntax 'hunk-also)
  (add-to-list 'safe-local-variable-values '(diff-add-log-use-relative-names . t)))

(my-package ediff
  (:delay 30)
;;;; `ediff'
  (setq ediff-keep-variants nil)
  (setq ediff-make-buffers-readonly-at-startup nil)
  (setq ediff-show-clashes-only t)
  (setq ediff-split-window-function 'split-window-horizontally)
  )

(my-package vc-git
  (:delay 30)
  (add-to-list 'safe-local-variable-values
               '(vc-git-annotate-switches . "-w"))
  (setq vc-git-grep-template "git --no-pager grep -n <C> -A1 -B1 -e <R> -- <F>"))

(my-package diff-hl
  (:delay 30)
  (:install t)
  (global-diff-hl-mode)
  (diff-hl-flydiff-mode))

(my-package diffview
  (:delay 30)
  (:install t)
  )

(my-package git-commit
  (:install t)
  (:delay 30)
  (setq git-commit-summary-max-length 50)
  (setq git-commit-style-convention-checks '(non-empty-second-line)))

(my-package magit
  (:install t)
  (:delay 30)

  (require 'magit-diff)
  (setq magit-diff-refine-hunk t)
  (setq magit-diff-adjust-tab-width t)

  (require 'magit-repos)
  (my-setq-from-local magit-repository-directories)
  (put 'magit-clean 'disabled nil)
  )

(my-package my-magit
  (:delay 30)
  (my-keybind global-map
    "C-x pM" #'my-project-magit-at
    "C-x g" #'my-magit-status)
  )

(my-package magit-annex
  (:delay 60))

(provide 'ycp-vc)