Updating Doom Emacs.

This commit is contained in:
Derek Taylor
2020-06-19 22:43:40 -05:00
parent 0f664d532a
commit a5c86c514a
453 changed files with 13527 additions and 12455 deletions

View File

@@ -1,13 +1,10 @@
;;; tools/magit/config.el -*- lexical-binding: t; -*-
;;
;;; Packages
(use-package! magit
:commands magit-file-delete
:defer-incrementally (dash f s with-editor git-commit package eieio lv transient)
:init
(setq magit-auto-revert-mode nil) ; we do this ourselves
(setq magit-auto-revert-mode nil) ; we do this ourselves further down
;; Must be set early to prevent ~/.emacs.d/transient from being created
(setq transient-levels-file (concat doom-etc-dir "transient/levels")
transient-values-file (concat doom-etc-dir "transient/values")
@@ -19,12 +16,27 @@
;; Don't autosave repo buffers. This is too magical, and saving can
;; trigger a bunch of unwanted side-effects, like save hooks and
;; formatters. Trust us to know what we're doing.
magit-save-repository-buffers nil)
magit-save-repository-buffers nil
;; Magit runs git *a lot*. Having to scan your PATH so many times can
;; add up with each invokation, especially on Catalina (macOS) or
;; Windows, so we resolve it once.
magit-git-executable (executable-find magit-git-executable))
(add-hook 'magit-process-mode-hook #'goto-address-mode)
(defadvice! +magit-invalidate-projectile-cache-a (&rest _args)
;; We ignore the args to `magit-checkout'.
(defadvice! +magit-revert-repo-buffers-deferred-a (&rest _)
:after '(magit-checkout magit-branch-and-checkout)
(projectile-invalidate-cache nil))
;; Since the project likely now contains new files, best we undo the
;; projectile cache so it can be regenerated later.
(projectile-invalidate-cache nil)
;; Use a more efficient strategy to auto-revert buffers whose git state has
;; changed: refresh the visible buffers immediately...
(+magit-mark-stale-buffers-h))
;; ...then refresh the rest only when we switch to them, not all at once.
(add-hook 'doom-switch-buffer-hook #'+magit-revert-buffer-maybe-h)
;; Center the target file, because it's poor UX to have it at the bottom of
;; the window after invoking `magit-status-here'.
(advice-add #'magit-status-here :after #'doom-recenter-a)
;; The default location for git-credential-cache is in
;; ~/.cache/git/credential. However, if ~/.git-credential-cache/ exists, then
@@ -36,6 +48,20 @@
"~/.cache/")
"git/credential/socket")))
;; Prevent scrolling when manipulating magit-status hunks. Otherwise you must
;; reorient yourself every time you stage/unstage/discard/etc a hunk.
;; Especially so on larger projects."
(defvar +magit--pos nil)
(add-hook! 'magit-pre-refresh-hook
(defun +magit--set-window-state-h ()
(setq-local +magit--pos (list (current-buffer) (point) (window-start)))))
(add-hook! 'magit-post-refresh-hook
(defun +magit--restore-window-state-h ()
(when (and +magit--pos (eq (current-buffer) (car +magit--pos)))
(goto-char (cadr +magit--pos))
(set-window-start nil (caddr +magit--pos) t)
(kill-local-variable '+magit--pos))))
;; Magit uses `magit-display-buffer-traditional' to display windows, by
;; default, which is a little primitive. `+magit-display-buffer' marries
;; `magit-display-buffer-fullcolumn-most-v1' with
@@ -50,7 +76,7 @@
(set-popup-rule! "^\\(?:\\*magit\\|magit:\\| \\*transient\\*\\)" :ignore t)
(add-hook 'magit-popup-mode-hook #'hide-mode-line-mode)
;; Add --tags switch
;; Add additional switches that seem common enough
(transient-append-suffix 'magit-fetch "-p"
'("-t" "Fetch all tags" ("-t" "--tags")))
(transient-append-suffix 'magit-pull "-r"
@@ -63,7 +89,8 @@
(and (derived-mode-p 'magit-mode)
(not (eq major-mode 'magit-process-mode))))))
;; properly kill leftover magit buffers on quit
;; Clean up after magit by killing leftover magit buffers and reverting
;; affected buffers (or at least marking them as need-to-be-reverted).
(define-key magit-status-mode-map [remap magit-mode-bury-buffer] #'+magit/quit)
;; Close transient with ESC
@@ -71,10 +98,12 @@
(use-package! forge
:when (featurep! +forge)
;; We defer loading even further because forge's dependencies will try to
;; compile emacsql, which is a slow and blocking operation.
:after-call magit-status
:init
:commands forge-create-pullreq forge-create-issue
:preface
(setq forge-database-file (concat doom-etc-dir "forge/forge-database.sqlite"))
:config
;; All forge list modes are derived from `forge-topic-list-mode'
@@ -101,8 +130,8 @@ ensure it is built when we actually use Forge."
(message (concat "Failed to build emacsql; forge may not work correctly.\n"
"See *Compile-Log* buffer for details"))
;; HACK Due to changes upstream, forge doesn't initialize completely if
;; it doesn't find `emacsql-sqlite-executable', so we have to do it
;; manually after installing it.
;; it doesn't find `emacsql-sqlite-executable', so we have to do it
;; manually after installing it.
(setq forge--sqlite-available-p t)
(magit-add-section-hook 'magit-status-sections-hook 'forge-insert-pullreqs nil t)
(magit-add-section-hook 'magit-status-sections-hook 'forge-insert-issues nil t)
@@ -142,7 +171,7 @@ ensure it is built when we actually use Forge."
(setq evil-magit-state 'normal
evil-magit-use-z-for-folds t)
:config
(unmap! magit-mode-map
(undefine-key! magit-mode-map
;; Replaced by z1, z2, z3, etc
"M-1" "M-2" "M-3" "M-4"
"1" "2" "3" "4"