diff options
| -rw-r--r-- | .emacs | 34 |
1 files changed, 31 insertions, 3 deletions
@@ -384,9 +384,24 @@ ;;; Version control. -(add-hook 'git-commit-setup-hook 'git-commit-turn-on-flyspell) - -(setq magit-process-finish-apply-ansi-colors t) +(defvar my/git-commit-fill-columns + '((my/emacs-repo-p . 63))) + +(defun my/git-upstreams () + ;; TODO: memoize, perhaps? + (seq-uniq + (seq-keep + (lambda (remote-desc) + (and (string-match "\\`.*\t\\(.*\\) (fetch)\\'" remote-desc) + (match-string 1 remote-desc))) + (process-lines "git" "remote" "-v")))) + +(cl-defun my/git-commit-maybe-set-fill-column () + (let ((remotes (my/git-upstreams))) + (pcase-dolist (`(,pred . ,column) my/git-commit-fill-columns) + (when (funcall pred remotes) + (cl-return-from my/git-commit-maybe-set-fill-column + (setq fill-column column)))))) (defun my/revision-at-point () (cond @@ -475,6 +490,11 @@ (ibuffer-switch-to-saved-filter-groups "my/ibuffer-groups"))) ;;; Development helpers. +(defun my/emacs-repo-p (upstreams) + "Guess whether we are working in the Emacs repository. +UPSTREAMS is a list of fetch URLs." + (member "https://git.savannah.gnu.org/git/emacs.git" upstreams)) + (defun my/emacs-run-testcase () (interactive) (require 'which-func) @@ -805,6 +825,13 @@ resolve-conf-generic-mode x-resource-generic-mode))) +(use-package git-commit + :config + (my/setopt git-commit-setup-hook + (my/list-update git-commit-setup-hook + '(git-commit-turn-on-flyspell + my/git-commit-maybe-set-fill-column)))) + (use-package isearch :delight "🔍" :custom @@ -819,6 +846,7 @@ (magit-ediff-dwim-show-on-hunks t) (magit-revision-show-gravatars t) :config + (setq magit-process-finish-apply-ansi-colors t) ;; See `diff-hl' form for rationale. (add-hook 'magit-pre-refresh-hook 'diff-hl-magit-pre-refresh) (add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh)) |
