;;; ycp-vc.el -- My config for vcs related -*- lexical-binding: t -*- ;; Copyright (C) 2023 Free Software Foundation. ;; Author: Yuchen Pei ;; 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 . ;;; Commentary: ;; My config for vcs related. Covers diff, vc, magit, ediff etc. ;;; Code: ;;; vc, magit, diff (my-package vc (:delay 5) ;; A var from newer emacs, in .dir-locals of emacs source (add-to-list 'safe-local-variable-values '(vc-prepare-patches-separately))) (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) (my-keybind global-map "C-c = b" #'ediff-buffers "C-c = B" #'ediff-buffers3 "C-c = c" #'compare-windows "C-c = =" #'ediff-files "C-c = f" #'ediff-files "C-c = F" #'ediff-files3 "C-c = m" #'count-matches "C-c = r" #'ediff-revision "C-c = p" #'ediff-patch-file "C-c = P" #'ediff-patch-buffer "C-c = l" #'ediff-regions-linewise "C-c = w" #'ediff-regions-wordwise) (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) (add-hook 'ediff-before-setup-hook 'my-select-new-frame) (setq ediff-combination-pattern '("<<<<<<< A: HEAD" A "||||||| Ancestor" Ancestor "=======" B ">>>>>>> B: Incoming")) (setq ediff-diff-options "-w") (setq ediff-window-setup-function 'ediff-setup-windows-plain) ) (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 -A1 -B1 -e -- ")) (my-package diff-hl (:delay 30) (:install t) ;; diff-hl-mode can slow down things in buffers visiting large ;; files, so here we only enable it for prog-mode (add-hook 'prog-mode-hook #'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-style-convention-checks '(non-empty-second-line)) ;; Refresh all buffers in the project after a commit for diff-hl (require 'my-diff-hl) (add-hook 'git-commit-post-finish-hook #'my-project-diff-hl-update) ) (my-package magit (:install t) (:delay 30) (require 'magit-diff) (setq magit-diff-refine-hunk t) (setq magit-diff-adjust-tab-width t) (add-hook 'magit-diff-mode-hook #'my-turn-off-truncate-lines) (require 'magit-repos) (my-setq-from-local magit-repository-directories) (put 'magit-clean 'disabled nil) (require 'magit-ediff) (add-hook 'magit-ediff-quit-hook 'delete-frame) (require 'magit-branch) (advice-add 'magit-checkout :filter-args #'my-magit-ignore-other-worktrees) ) (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 git-email (:delay 30) ;; Fixes concatenation of the subject and the first line, when ;; there's one empty line in between (setq git-email-subject-regexp (rx bol "Subject:" (zero-or-more space) "[" (zero-or-more (not (any "]" "\n"))) "PATCH" (zero-or-more (not (any "]" "\n"))) "]" (one-or-more space) (one-or-more not-newline))) (require 'my-git-email) (setq git-email-compose-email-function 'my-git-email-gnus-compose) (require 'git-email-magit) ) (my-package magit-annex (:delay 60)) (provide 'ycp-vc)