From 092304d9e0ccc37cc0ddaa9b136457e56a1cac20 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 12 Oct 2025 11:47:26 -0500 Subject: changing repositories --- modules/diff-config.el | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 modules/diff-config.el (limited to 'modules/diff-config.el') diff --git a/modules/diff-config.el b/modules/diff-config.el new file mode 100644 index 00000000..ff106ead --- /dev/null +++ b/modules/diff-config.el @@ -0,0 +1,53 @@ +;;; diff-config.el --- diff Configuration -*- lexical-binding: t; coding: utf-8; -*- +;; author Craig Jennings + +;;; Commentary: + +;; I've configured Ediff for a clean and efficient diff experience. + +;; • Ediff will use a plain control window, horizontal splits, ignore whitespace, and only highlight the current change. +;; • A single keymap under "C-c D" has bindings: +;; - ediff-files (f) +;; - ediff-buffers (b) +;; - ediff-revision (r) +;; - ediff-directories (D) +;; • An Ediff hook that remaps j/k to next/previous differences for easier navigation +;; • The winner-mode functionality ensures window layouts are restored after quitting Ediff + +;; Note: Here's a highly useful setup for configuring ediff. +;; https://oremacs.com/2015/01/17/setting-up-ediff/ + +;;; Code: + +(use-package ediff + :ensure nil ;; built-in + :defer t + :custom + (ediff-window-setup-function 'ediff-setup-windows-plain) + (ediff-split-window-function 'split-window-horizontally) + (ediff-diff-options "-w") + (ediff-highlight-all-diffs nil) + :bind-keymap ("C-c D" . cj/ediff-map) + :init + ;; adding this to a hook to make sure ediff is loaded due to :defer + (defvar cj/ediff-map + (let ((m (make-sparse-keymap))) + (define-key m "f" #'ediff-files) ; C-c D f + (define-key m "b" #'ediff-buffers) ; C-c D b + (define-key m "r" #'ediff-revision) ; C-c D r + (define-key m "D" #'ediff-directories) ; C-c D D + m) + "Prefix map for quick Ediff commands under C-c D.") + :config + (defun cj/ediff-hook () + "Use j/k to navigate differences in Ediff." + (ediff-setup-keymap) ;; keep the defaults… + (define-key ediff-mode-map "j" #'ediff-next-difference) + (define-key ediff-mode-map "k" #'ediff-previous-difference)) + + (add-hook 'ediff-mode-hook #'cj/ediff-hook) + (add-hook 'ediff-after-quit-hook-internal #'winner-undo)) + + +(provide 'diff-config) +;;; diff-config.el ends here -- cgit v1.2.3