doomemacs/modules/emacs/vc/config.el

81 lines
2.8 KiB
EmacsLisp
Raw Normal View History

;;; emacs/vc/config.el -*- lexical-binding: t; -*-
(when IS-WINDOWS
(setenv "GIT_ASKPASS" "git-gui--askpass"))
(setq vc-make-backup-files nil
vc-follow-symlinks t)
(after! git-timemachine
;; HACK Waiting for https://gitlab.com/pidu/git-timemachine/issues/77
:boom: revise advice naming convention (1/2) This is first of three big naming convention updates that have been a long time coming. With 2.1 on the horizon, all the breaking updates will batched together in preparation for the long haul. In this commit, we do away with the asterix to communicate that a function is an advice function, and we replace it with the '-a' suffix. e.g. doom*shut-up -> doom-shut-up-a doom*recenter -> doom-recenter-a +evil*static-reindent -> +evil--static-reindent-a The rationale behind this change is: 1. Elisp's own formatting/indenting tools would occasionally struggle with | and * (particularly pp and cl-prettyprint). They have no problem with / and :, fortunately. 2. External syntax highlighters (like pygmentize, discord markdown or github markdown) struggle with it, sometimes refusing to highlight code beyond these symbols. 3. * and | are less expressive than - and -- in communicating the intended visibility, versatility and stability of a function. 4. It complicated the regexps we must use to search for them. 5. They were arbitrary and over-complicated to begin with, decided on haphazardly way back when Doom was simply "my private config". Anyhow, like how predicate functions have the -p suffix, we'll adopt the -a suffix for advice functions, -h for hook functions and -fn for variable functions. Other noteable changes: - Replaces advice-{add,remove}! macro with new def-advice! macro. The old pair weren't as useful. The new def-advice! saves on a lot of space. - Removed "stage" assertions to make sure you were using the right macros in the right place. Turned out to not be necessary, we'll employ better checks later.
2019-07-18 15:42:52 +02:00
(def-advice! +vc--git-timemachine-show-commit-a ()
"Fix `git-timemachine-show-commit'."
:override #'git-timemachine-show-commit
(interactive)
(let ((rev (car git-timemachine-revision)))
(if (fboundp 'magit-revision-mode)
(with-temp-buffer
(save-excursion
(magit-setup-buffer #'magit-revision-mode nil
(magit-buffer-revision rev)
(magit-buffer-range (format "%s^..%s" rev rev))
(magit-buffer-diff-args nil)
(magit-buffer-diff-files nil))))
(message "You need to install magit to show commit"))))
;; Sometimes I forget `git-timemachine' is enabled in a buffer, so instead of
;; showing revision details in the minibuffer, show them in
;; `header-line-format', which has better visibility.
(setq git-timemachine-show-minibuffer-details t)
(advice-add #'git-timemachine--show-minibuffer-details :override #'+vc*update-header-line)
(after! evil
;; rehash evil keybindings so they are recognized
(add-hook 'git-timemachine-mode-hook #'evil-normalize-keymaps))
(when (featurep! :tools magit)
(add-transient-hook! #'git-timemachine-blame (require 'magit-blame))))
;;;###package git-commit
(def-package! git-commit
:after-call after-find-file
:config
(global-git-commit-mode +1)
(set-yas-minor-mode! 'git-commit-mode)
(add-hook 'git-commit-mode-hook
(defun +vc--enforce-git-commit-conventions-h ()
"See https://chris.beams.io/posts/git-commit/"
(setq fill-column 72
git-commit-summary-max-length 50
git-commit-style-convention-checks '(overlong-summary-line non-empty-second-line))))
(add-hook 'git-commit-setup-hook
(defun +vc--start-in-insert-state-maybe ()
"Start git-commit-mode in insert state if in a blank commit message,
otherwise in default state."
(when (and (bound-and-true-p evil-mode)
(bobp) (eolp))
(evil-insert-state)))))
(after! vc-annotate
(set-popup-rules!
2018-07-19 03:40:31 +02:00
'(("^\\vc-d" :select nil) ; *vc-diff*
("^\\vc-c" :select t))) ; *vc-change-log*
(set-evil-initial-state!
'(vc-annotate-mode vc-git-log-view-mode)
'normal))
(after! smerge-mode
2018-03-24 04:40:24 -04:00
(unless EMACS26+
(with-no-warnings
(defalias #'smerge-keep-upper #'smerge-keep-mine)
(defalias #'smerge-keep-lower #'smerge-keep-other)
(defalias #'smerge-diff-base-upper #'smerge-diff-base-mine)
(defalias #'smerge-diff-upper-lower #'smerge-diff-mine-other)
(defalias #'smerge-diff-base-lower #'smerge-diff-base-other))))