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,10 +1,26 @@
;;; tools/magit/autoload.el -*- lexical-binding: t; -*-
;; HACK Magit complains loudly when it can't determine its own version, which is
;; the case when magit is built through straight. The warning is harmless,
;; however, so we just need it to shut up.
;; HACK Magit complains loudly (but harmlessly) when it can't determine its own
;; version in a sparse clone. This was fixed upstream in
;; magit/magit@b1b2683, but only for macOS and Linux users. Windows doesn't
;; support symlinks as unix knows them, so `magit-version' can't resolve
;; its own repo's path.
;;;###autoload
(advice-add #'magit-version :override #'ignore)
(when! IS-WINDOWS
(defadvice! +magit--ignore-version-a (&optional print-dest)
:override #'magit-version
(when print-dest
(defvar magit-git-debug)
(princ (format "Magit (unknown), Git %s, Emacs %s, %s"
(or (let ((magit-git-debug
(lambda (err)
(display-warning '(magit git) err :error))))
(magit-git-version t))
"(unknown)")
emacs-version
system-type)
print-dest))
nil))
;;;###autoload
(defun +magit-display-buffer-fn (buffer)
@@ -41,28 +57,42 @@
;;
;; Commands
;;; Auto-revert
(defun +magit--refresh-vc-in-buffer (buffer)
(defvar +magit--stale-p nil)
(defun +magit--revert-buffer (buffer)
(with-current-buffer buffer
(when (and vc-mode (fboundp 'vc-refresh-state))
(vc-refresh-state))
(when (and (bound-and-true-p git-gutter-mode)
(fboundp '+version-control|update-git-gutter))
(+version-control|update-git-gutter))
(setq +magit--vc-is-stale-p nil)))
(kill-local-variable '+magit--stale-p)
(when buffer-file-name
(if (buffer-modified-p (current-buffer))
(when (bound-and-true-p vc-mode)
(vc-refresh-state)
(force-mode-line-update))
(revert-buffer t t)))))
;;;###autoload
(defvar-local +magit--vc-is-stale-p nil)
(defun +magit-mark-stale-buffers-h ()
"Revert all visible buffers and mark buried buffers as stale.
Stale buffers are reverted when they are switched to, assuming they haven't been
modified."
(dolist (buffer (buffer-list))
(when (buffer-live-p buffer)
(if (get-buffer-window buffer)
(+magit--revert-buffer buffer)
(with-current-buffer buffer
(setq-local +magit--stale-p t))))))
;;;###autoload
(defun +magit-refresh-vc-state-maybe-h ()
(defun +magit-revert-buffer-maybe-h ()
"Update `vc' and `git-gutter' if out of date."
(when +magit--vc-is-stale-p
(+magit--refresh-vc-in-buffer (current-buffer))))
(when +magit--stale-p
(+magit--revert-buffer (current-buffer))))
;;;###autoload
(add-hook 'doom-switch-buffer-hook #'+magit-refresh-vc-state-maybe-h)
;;
;;; Commands
;;;###autoload
(defun +magit/quit (&optional kill-buffer)
@@ -76,12 +106,7 @@ control in buffers."
(eq major-mode 'magit-status-mode)))
(window-list)))
(mapc #'+magit--kill-buffer (magit-mode-get-buffers))
(dolist (buffer (buffer-list))
(when (buffer-live-p buffer)
(if (get-buffer-window buffer)
(+magit--refresh-vc-in-buffer buffer)
(with-current-buffer buffer
(setq +magit--vc-is-stale-p t)))))))
(+magit-mark-stale-buffers-h)))
(defun +magit--kill-buffer (buf)
"TODO"