.emacs.d

the most bloated Emacs config on this planet
git clone https://git.trogloxene.org/.emacs.d.git
Log | Files | Refs

commit 2c727f1ae52ea543bb0cfd3fd60699b592aa520a
parent 31e0e2c88a24122320484c807141460b2b805a6d
Author: andsy10 <andsy1016@gmail.com>
Date:   Mon, 19 Oct 2026 05:23:07 +0800

Extract vc configuration and reorganize edit settings

Diffstat:
Minit.el | 1+
Mlisp/init-base.el | 62--------------------------------------------------------------
Mlisp/init-edit.el | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mlisp/init-package.el | 89-------------------------------------------------------------------------------
Alisp/init-vc.el | 88+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 161 insertions(+), 151 deletions(-)

diff --git a/init.el b/init.el @@ -28,6 +28,7 @@ (require 'init-edit) (require 'init-completion) (require 'init-package) + (require 'init-vc) (require 'init-org) (require 'init-prog) (require 'init-elisp) diff --git a/lisp/init-base.el b/lisp/init-base.el @@ -322,67 +322,5 @@ (setq speedbar-directory-unshown-regexp "\\`\\.\\.?\\'") (setq speedbar-show-unknown-files t)) -;; isearch -(my-use-package isearch - :straight nil - :hook - (isearch-mode-end . my-goto-match-beginning) - (lazy-count-update . force-mode-line-update) - :init - (defun my-goto-match-beginning () - (when (and isearch-forward (not isearch-mode-end-hook-quit)) - (goto-char isearch-other-end))) - - ;; move lazy count numbers to mode-line - (setq isearch-lazy-count t - lazy-count-prefix-format nil) - - (defface my-isearch-count - '((t (:inherit font-lock-type-face :weight bold))) - "Face for the isearch match count in the mode-line." - :group 'isearch) - - (defconst my-isearch-count--mode-line-construct - '(:eval (my-isearch-count-format))) - - (defun my-isearch-count-format () - "Like `isearch-lazy-count-format' but use custom format." - (when (and isearch-mode - isearch-lazy-count - isearch-lazy-count-current - (not isearch-error) - (not isearch-suspended)) - (propertize - (format "(%s/%s) " - (if isearch-lazy-highlight-forward - isearch-lazy-count-current - (if (eq isearch-lazy-count-current 0) - 0 - (- isearch-lazy-count-total - isearch-lazy-count-current - -1))) - (if (and isearch-lazy-count-invisible - lazy-count-invisible-format) - (concat (format "%s" (or isearch-lazy-count-total "?")) - (format lazy-count-invisible-format - isearch-lazy-count-invisible)) - (or isearch-lazy-count-total "?"))) - 'face 'my-isearch-count))) - - (unless (member my-isearch-count--mode-line-construct - (default-value 'mode-line-format)) - (setq-default mode-line-format - (cons my-isearch-count--mode-line-construct - (default-value 'mode-line-format))))) - -;; diff -(my-use-package diff-mode - :straight nil - :init - (defun my-diff-kill-ring-save-hack (fun &rest args) - (let ((major-mode 'diff-mode)) - (apply fun args))) - (advice-add #'diff-kill-ring-save :around #'my-diff-kill-ring-save-hack)) - (provide 'init-base) ;;; init-base.el ends here diff --git a/lisp/init-edit.el b/lisp/init-edit.el @@ -16,6 +16,78 @@ :config (setq electric-pair-inhibit-predicate 'electric-pair-conservative-inhibit)) +;; ediff +(my-use-package ediff + :straight nil + :hook + ((ediff-prepare-buffer . outline-show-all) + (ediff-quit . winner-undo)) + :config + (setq ediff-window-setup-function 'ediff-setup-windows-plain + ediff-split-window-function 'split-window-horizontally)) + +;; diff +(my-use-package diff-mode + :straight nil + :init + (defun my-diff-kill-ring-save-hack (fun &rest args) + (let ((major-mode 'diff-mode)) + (apply fun args))) + (advice-add #'diff-kill-ring-save :around #'my-diff-kill-ring-save-hack)) + +;; isearch +(my-use-package isearch + :straight nil + :hook + (isearch-mode-end . my-goto-match-beginning) + (lazy-count-update . force-mode-line-update) + :init + (defun my-goto-match-beginning () + (when (and isearch-forward (not isearch-mode-end-hook-quit)) + (goto-char isearch-other-end))) + + ;; move lazy count numbers to mode-line + (setq isearch-lazy-count t + lazy-count-prefix-format nil) + + (defface my-isearch-count + '((t (:inherit font-lock-type-face :weight bold))) + "Face for the isearch match count in the mode-line." + :group 'isearch) + + (defconst my-isearch-count--mode-line-construct + '(:eval (my-isearch-count-format))) + + (defun my-isearch-count-format () + "Like `isearch-lazy-count-format' but use custom format." + (when (and isearch-mode + isearch-lazy-count + isearch-lazy-count-current + (not isearch-error) + (not isearch-suspended)) + (propertize + (format "(%s/%s) " + (if isearch-lazy-highlight-forward + isearch-lazy-count-current + (if (eq isearch-lazy-count-current 0) + 0 + (- isearch-lazy-count-total + isearch-lazy-count-current + -1))) + (if (and isearch-lazy-count-invisible + lazy-count-invisible-format) + (concat (format "%s" (or isearch-lazy-count-total "?")) + (format lazy-count-invisible-format + isearch-lazy-count-invisible)) + (or isearch-lazy-count-total "?"))) + 'face 'my-isearch-count))) + + (unless (member my-isearch-count--mode-line-construct + (default-value 'mode-line-format)) + (setq-default mode-line-format + (cons my-isearch-count--mode-line-construct + (default-value 'mode-line-format))))) + ;; repeat (my-use-package repeat :straight nil diff --git a/lisp/init-package.el b/lisp/init-package.el @@ -179,95 +179,6 @@ With a prefix ARG create a new *scratch* buffer." consult-buffer-filter))))) (setq persp-initial-frame-name "main")) -;; magit -(my-use-package magit - :init - (defun my-magit-toggle-parent-section () - "Toggle parent magit section." - (interactive) - (magit-section-up) - (magit-section-toggle (magit-section-at))) - :config - (setq magit-bind-magit-project-status nil) - (unless *is-windows* - (setq magit-diff-refine-hunk 'all))) - -;; ediff -(my-use-package ediff - :straight nil - :hook ((ediff-prepare-buffer . outline-show-all) - (ediff-quit . winner-undo)) - :config - (setq ediff-window-setup-function 'ediff-setup-windows-plain - ediff-split-window-function 'split-window-horizontally)) - -;; diff-hl -(my-use-package diff-hl - :hook - (diff-hl-mode . diff-hl-margin-mode) - (diff-hl-mode . global-diff-hl-show-hunk-mouse-mode) - (diff-hl-mode . diff-hl-flydiff-mode)) - -;; vc -(my-use-package vc - :straight nil - :commands vc-create-repo - :init - (defun my-vc-annotate-diff-current-revision () - "Show the diff of the revision displayed in this vc-annotate buffer -against its previous revision." - (interactive) - (if (not (derived-mode-p 'vc-annotate-mode)) - (message "Not a vc annotate buffer") - (let* ((file (caadr vc-buffer-overriding-fileset)) - (rev vc-buffer-revision) - (prev-rev - (let ((vc-use-short-revision vc-annotate-use-short-revision)) - (vc-call-backend vc-annotate-backend 'previous-revision file rev)))) - (if (not prev-rev) - (message "No previous revisions") - (vc-diff-internal vc-allow-async-diff - (list vc-annotate-backend (list file)) - prev-rev rev))))) - - (defun my-vc-print-log-current-revision () - "Print the log of the revision displayed in this vc-annotate buffer." - (interactive) - (if (not (derived-mode-p 'vc-annotate-mode)) - (message "Not a vc annotate buffer") - (let* ((file (cadr vc-buffer-overriding-fileset)) - (rev vc-buffer-revision)) - (vc-print-log-internal vc-annotate-backend file rev t 1))))) - -(my-use-package consult-vc - :straight - (consult-vc :type git - :repo "https://git.trogloxene.org/consult-vc.git") - :config - (setq consult-vc-annotate-revision-narrow-key-forward ?\] - consult-vc-annotate-revision-narrow-key-backward ?\[)) - -;; project -(my-use-package project - :straight nil - :autoload project-root - :config - (setq project-switch-commands (assq-delete-all 'project-vc-dir project-switch-commands)) - (setq project-switch-commands - (seq-uniq (append project-switch-commands - '((magit-project-status "Magit" ?v) - (ghostel-project "Ghostel" ?t) - (project-query-replace-regexp "Query Replace" ?q) - (consult-git-grep "Grep" ?g) - (consult-project-buffer "Buffers" ?b) - (project-ibuffer "Ibuffer" ?i) - (pilish "Pi" ?a)))))) - -(my-use-package project-ibuffer - :straight - (project-ibuffer :type git - :repo "https://git.trogloxene.org/project-ibuffer.git")) - ;; emms (my-use-package emms my-enable-unessentials :config diff --git a/lisp/init-vc.el b/lisp/init-vc.el @@ -0,0 +1,88 @@ +;;; init-vc.el --- version control -*- lexical-binding: t -*- + +;;; Commentary: + +;;; Code: + +;; magit +(my-use-package magit + :init + (defun my-magit-toggle-parent-section () + "Toggle parent magit section." + (interactive) + (magit-section-up) + (magit-section-toggle (magit-section-at))) + :config + (setq magit-bind-magit-project-status nil) + (unless *is-windows* + (setq magit-diff-refine-hunk 'all))) + +;; diff-hl +(my-use-package diff-hl + :hook + (diff-hl-mode . diff-hl-margin-mode) + (diff-hl-mode . global-diff-hl-show-hunk-mouse-mode) + (diff-hl-mode . diff-hl-flydiff-mode)) + +;; vc +(my-use-package vc + :straight nil + :commands vc-create-repo + :init + (defun my-vc-annotate-diff-current-revision () + "Show the diff of the revision displayed in this vc-annotate buffer +against its previous revision." + (interactive) + (if (not (derived-mode-p 'vc-annotate-mode)) + (message "Not a vc annotate buffer") + (let* ((file (caadr vc-buffer-overriding-fileset)) + (rev vc-buffer-revision) + (prev-rev + (let ((vc-use-short-revision vc-annotate-use-short-revision)) + (vc-call-backend vc-annotate-backend 'previous-revision file rev)))) + (if (not prev-rev) + (message "No previous revisions") + (vc-diff-internal vc-allow-async-diff + (list vc-annotate-backend (list file)) + prev-rev rev))))) + + (defun my-vc-print-log-current-revision () + "Print the log of the revision displayed in this vc-annotate buffer." + (interactive) + (if (not (derived-mode-p 'vc-annotate-mode)) + (message "Not a vc annotate buffer") + (let* ((file (cadr vc-buffer-overriding-fileset)) + (rev vc-buffer-revision)) + (vc-print-log-internal vc-annotate-backend file rev t 1))))) + +(my-use-package consult-vc + :straight + (consult-vc :type git + :repo "https://git.trogloxene.org/consult-vc.git") + :config + (setq consult-vc-annotate-revision-narrow-key-forward ?\] + consult-vc-annotate-revision-narrow-key-backward ?\[)) + +;; project +(my-use-package project + :straight nil + :autoload project-root + :config + (setq project-switch-commands (assq-delete-all 'project-vc-dir project-switch-commands)) + (setq project-switch-commands + (seq-uniq (append project-switch-commands + '((magit-project-status "Magit" ?v) + (ghostel-project "Ghostel" ?t) + (project-query-replace-regexp "Query Replace" ?q) + (consult-git-grep "Grep" ?g) + (consult-project-buffer "Buffers" ?b) + (project-ibuffer "Ibuffer" ?i) + (pilish "Pi" ?a)))))) + +(my-use-package project-ibuffer + :straight + (project-ibuffer :type git + :repo "https://git.trogloxene.org/project-ibuffer.git")) + +(provide 'init-vc) +;;; init-vc.el ends here