doomemacs/modules/emacs/vc/config.el
Henrik Lissner fdcb259bcd
Major refactor of Doom core files
- Remove core-os and move many of its settings out to other core
  libraries, where they belong
- Significantly improve commenting & compartmentalization of many
  settings
- Correct some mis-named public hooks (that were named as if they were
  private)
- Move the vast majority of optimizations to "Optimizations" section in
  core.el
- Don't activate xclip-mode or osx-clipboard-mode if we're accessing
  Emacs through an SSH connection (does more bad than good there)
- Add fast-but-imprecise-scrolling = t
- Set bidi-display-reordering = 'left-to-right, at the recommendation of
  an Emacs dev. Apparently setting it to nil is undefined, as Emacs is
  designed to always assume it's set; setting it explicitly to
  left-to-right will still do what was originally intended by turning it
  off: to reduce line/text scans for bidirectional text, which gives us
  a moderate boost in general runtime snappiness
- Set inhibit-compacting-fon-caches = t on windows (where it struggles
  especially with icon fonts)
- Disables "literal" mode for very large files (because I will be
  backporting so-long.el from Emacs 27 in the next commit)
2019-07-22 02:30:38 +02:00

80 lines
2.8 KiB
EmacsLisp

;;; 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
(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!
'(("^\\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
(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))))