💥 revise hook/var fns naming convention (2/2)

This is second of three big naming convention changes. In this commit,
we change the naming conventions for hook functions and variable
functions:

1. Replace the bar | to indicate a hook function with a -h suffix, e.g.

     doom|init-ui -> doom-init-ui-h
     doom|run-local-var-hooks -> doom-run-local-var-hooks-h

2. And add a -fn suffix for functions meant to be set on variables,
   e.g.

     (setq magit-display-buffer-function #'+magit-display-buffer-fn)

See ccf327f8 for the reasoning behind these changes.
This commit is contained in:
Henrik Lissner 2019-07-18 15:27:20 +02:00
parent 51d3b1b424
commit 149b2617b0
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
58 changed files with 521 additions and 517 deletions

View file

@ -77,7 +77,7 @@
nil 'nomessage) nil 'nomessage)
(cond ((not noninteractive) (cond ((not noninteractive)
(doom|run-all-startup-hooks)) (doom-run-all-startup-hooks-h))
((and (not (cdr args)) ((and (not (cdr args))
(member (car args) '("help" "h"))) (member (car args) '("help" "h")))
(usage)) (usage))

View file

@ -250,7 +250,7 @@ regex PATTERN. Returns the number of killed buffers."
;; Hooks ;; Hooks
;;;###autoload ;;;###autoload
(defun doom|mark-buffer-as-real () (defun doom-mark-buffer-as-real-h ()
"Hook function that marks the current buffer as real." "Hook function that marks the current buffer as real."
(doom-set-buffer-real (current-buffer) t)) (doom-set-buffer-real (current-buffer) t))

View file

@ -21,7 +21,7 @@ to persist across Emacs sessions.")
name under `pcache-directory' (by default a subdirectory under name under `pcache-directory' (by default a subdirectory under
`doom-cache-dir'). One file may contain multiple cache entries.") `doom-cache-dir'). One file may contain multiple cache entries.")
(defun doom|save-persistent-cache () (defun doom-save-persistent-cache-h ()
"Hook to run when an Emacs session is killed. Saves all persisted variables "Hook to run when an Emacs session is killed. Saves all persisted variables
listed in `doom-cache-alists' to files." listed in `doom-cache-alists' to files."
(dolist (alist (butlast doom-cache-alists 1)) (dolist (alist (butlast doom-cache-alists 1))
@ -29,7 +29,7 @@ listed in `doom-cache-alists' to files."
for var in (cdr alist) for var in (cdr alist)
if (symbol-value var) if (symbol-value var)
do (doom-cache-set var it nil key)))) do (doom-cache-set var it nil key))))
(add-hook 'kill-emacs-hook #'doom|save-persistent-cache) (add-hook 'kill-emacs-hook #'doom-save-persistent-cache-h)
;; ;;

View file

@ -1,5 +1,9 @@
;;; core/autoload/config.el -*- lexical-binding: t; -*- ;;; core/autoload/config.el -*- lexical-binding: t; -*-
;;;###autoload
(defvar doom-reload-hook nil
"A list of hooks to run when `doom/reload' is called.")
;;;###autoload ;;;###autoload
(defvar doom-reloading-p nil (defvar doom-reloading-p nil
"TODO") "TODO")
@ -72,16 +76,6 @@ Uses the same mechanism as 'bin/doom env reload'."
(error "Failed to generate env file")) (error "Failed to generate env file"))
(doom-load-env-vars doom-env-file)) (doom-load-env-vars doom-env-file))
;;;###autoload
(defun doom/reload-font ()
"Reload your fonts, if they're set.
See `doom|init-fonts'."
(interactive)
(when doom-font
(set-frame-font doom-font t))
(doom|init-fonts)
(mapc #'doom|init-emoji-fonts (frame-list)))
;;;###autoload ;;;###autoload
(defun doom/reload-theme () (defun doom/reload-theme ()
"Reload the current color theme." "Reload the current color theme."
@ -92,4 +86,4 @@ See `doom|init-fonts'."
(when (and doom-theme (not (memq doom-theme custom-enabled-themes))) (when (and doom-theme (not (memq doom-theme custom-enabled-themes)))
(let (doom--prefer-theme-elc) (let (doom--prefer-theme-elc)
(load-theme doom-theme t))) (load-theme doom-theme t)))
(doom|init-fonts))) (doom-init-fonts-h)))

View file

@ -169,12 +169,12 @@ markdown and copies it to your clipboard, ready to be pasted into bug reports!"
(load! "config" (plist-get plist :path) t))) (load! "config" (plist-get plist :path) t)))
doom-modules) doom-modules)
(run-hook-wrapped 'doom-init-modules-hook #'doom-try-run-hook) (run-hook-wrapped 'doom-init-modules-hook #'doom-try-run-hook)
(doom|run-all-startup-hooks))) (doom-run-all-startup-hooks-h)))
(`vanilla-doom ; only Doom core (`vanilla-doom ; only Doom core
`((setq doom-private-dir "/tmp/does/not/exist" `((setq doom-private-dir "/tmp/does/not/exist"
doom-init-modules-p t) doom-init-modules-p t)
(load-file ,user-init-file) (load-file ,user-init-file)
(doom|run-all-startup-hooks))) (doom-run-all-startup-hooks-h)))
(`vanilla ; nothing loaded (`vanilla ; nothing loaded
`((package-initialize))))))) `((package-initialize)))))))
"\n(unwind-protect (progn\n" contents "\n)\n" "\n(unwind-protect (progn\n" contents "\n)\n"
@ -357,7 +357,7 @@ If INIT-FILE is non-nil, profile that instead of USER-INIT-FILE."
init-file init-file
esup-server-port esup-server-port
esup-depth) esup-depth)
"--eval=(doom|run-all-startup-hooks)")))) "--eval=(doom-run-all-startup-hooks-h)"))))
(when esup-run-as-batch-p (when esup-run-as-batch-p
(setq process-args (append process-args '("--batch")))) (setq process-args (append process-args '("--batch"))))
(setq esup-child-process (apply #'start-process process-args))) (setq esup-child-process (apply #'start-process process-args)))

View file

@ -65,6 +65,15 @@ FRAME parameter defaults to current frame."
;; ;;
;;; Commands ;;; Commands
;;;###autoload
(defun doom/reload-font ()
"Reload your fonts, if they're set.
See `doom-init-fonts-h'."
(interactive)
(when doom-font
(set-frame-font doom-font t))
(mapc #'doom-init-emoji-fonts-h (frame-list)))
;;;###autoload ;;;###autoload
(defun doom/increase-font-size (count) (defun doom/increase-font-size (count)
"Enlargens the font size across the current frame." "Enlargens the font size across the current frame."

View file

@ -54,7 +54,7 @@ following:
(when (and (eq major-mode 'fundamental-mode) (when (and (eq major-mode 'fundamental-mode)
(functionp mode)) (functionp mode))
(funcall mode)) (funcall mode))
(add-hook 'kill-buffer-hook #'doom|persist-scratch-buffer nil 'local) (add-hook 'kill-buffer-hook #'doom-persist-scratch-buffer-h nil 'local)
(run-hooks 'doom-scratch-buffer-created-hook)) (run-hooks 'doom-scratch-buffer-created-hook))
buffer))) buffer)))
@ -63,7 +63,7 @@ following:
;;; Persistent scratch buffer ;;; Persistent scratch buffer
;;;###autoload ;;;###autoload
(defun doom|persist-scratch-buffer () (defun doom-persist-scratch-buffer-h ()
"Save the current buffer to `doom-scratch-dir'." "Save the current buffer to `doom-scratch-dir'."
(write-region (write-region
(point-min) (point-max) (point-min) (point-max)
@ -71,16 +71,16 @@ following:
doom-scratch-dir))) doom-scratch-dir)))
;;;###autoload ;;;###autoload
(defun doom|persist-scratch-buffers () (defun doom-persist-scratch-buffers-h ()
"Save all scratch buffers to `doom-scratch-dir'." "Save all scratch buffers to `doom-scratch-dir'."
(setq doom-scratch-buffers (cl-delete-if-not #'buffer-live-p doom-scratch-buffers)) (setq doom-scratch-buffers (cl-delete-if-not #'buffer-live-p doom-scratch-buffers))
(dolist (buffer doom-scratch-buffers) (dolist (buffer doom-scratch-buffers)
(with-current-buffer buffer (with-current-buffer buffer
(doom|persist-scratch-buffer)))) (doom-persist-scratch-buffer-h))))
;;;###autoload ;;;###autoload
(unless noninteractive (unless noninteractive
(add-hook 'kill-emacs-hook #'doom|persist-scratch-buffers)) (add-hook 'kill-emacs-hook #'doom-persist-scratch-buffers-h))
;; ;;

View file

@ -211,25 +211,25 @@ Respects `require-final-newline'."
;; Hooks ;; Hooks
;;;###autoload ;;;###autoload
(defun doom|enable-delete-trailing-whitespace () (defun doom-enable-delete-trailing-whitespace-h ()
"Enables the automatic deletion of trailing whitespaces upon file save. "Enables the automatic deletion of trailing whitespaces upon file save.
i.e. enables `ws-butler-mode' in the current buffer." i.e. enables `ws-butler-mode' in the current buffer."
(ws-butler-mode +1)) (ws-butler-mode +1))
;;;###autoload ;;;###autoload
(defun doom|disable-delete-trailing-whitespace () (defun doom-disable-delete-trailing-whitespace-h ()
"Disables the automatic deletion of trailing whitespaces upon file save. "Disables the automatic deletion of trailing whitespaces upon file save.
i.e. disables `ws-butler-mode' in the current buffer." i.e. disables `ws-butler-mode' in the current buffer."
(ws-butler-mode -1)) (ws-butler-mode -1))
;;;###autoload ;;;###autoload
(defun doom|enable-show-trailing-whitespace () (defun doom-enable-show-trailing-whitespace-h ()
"Enable `show-trailing-whitespace' in the current buffer." "Enable `show-trailing-whitespace' in the current buffer."
(setq-local show-trailing-whitespace t)) (setq-local show-trailing-whitespace t))
;;;###autoload ;;;###autoload
(defun doom|disable-show-trailing-whitespace () (defun doom-disable-show-trailing-whitespace-h ()
"Disable `show-trailing-whitespace' in the current buffer." "Disable `show-trailing-whitespace' in the current buffer."
(setq-local show-trailing-whitespace nil)) (setq-local show-trailing-whitespace nil))

View file

@ -41,14 +41,14 @@ are open."
;; Hooks ;; Hooks
;;;###autoload ;;;###autoload
(defun doom|apply-ansi-color-to-compilation-buffer () (defun doom-apply-ansi-color-to-compilation-buffer-h ()
"Applies ansi codes to the compilation buffers. Meant for "Applies ansi codes to the compilation buffers. Meant for
`compilation-filter-hook'." `compilation-filter-hook'."
(with-silent-modifications (with-silent-modifications
(ansi-color-apply-on-region compilation-filter-start (point)))) (ansi-color-apply-on-region compilation-filter-start (point))))
;;;###autoload ;;;###autoload
(defun doom|disable-show-paren-mode () (defun doom-disable-show-paren-mode-h ()
"Turn off `show-paren-mode' buffer-locally." "Turn off `show-paren-mode' buffer-locally."
(setq-local show-paren-mode nil)) (setq-local show-paren-mode nil))

View file

@ -1,16 +1,5 @@
;;; core-editor.el -*- lexical-binding: t; -*- ;;; core-editor.el -*- lexical-binding: t; -*-
(defvar doom-large-file-size 2
"Size (in MB) above which the user will be prompted to open the file literally
to avoid performance issues. Opening literally means that no major or minor
modes are active and the buffer is read-only.")
(defvar doom-large-file-modes-list
'(fundamental-mode special-mode archive-mode tar-mode jka-compr
git-commit-mode image-mode doc-view-mode doc-view-mode-maybe
ebrowse-tree-mode pdf-view-mode tags-table-mode)
"Major modes that `doom|check-large-file' will ignore.")
(defvar-local doom-inhibit-indent-detection nil (defvar-local doom-inhibit-indent-detection nil
"A buffer-local flag that indicates whether `dtrt-indent' should try to detect "A buffer-local flag that indicates whether `dtrt-indent' should try to detect
indentation settings or not. This should be set by editorconfig if it indentation settings or not. This should be set by editorconfig if it
@ -74,10 +63,10 @@ detected.")
(def-package! autorevert (def-package! autorevert
;; revert buffers when their files/state have changed ;; revert buffers when their files/state have changed
:hook (focus-in . doom|auto-revert-buffers) :hook (focus-in . doom-auto-revert-buffers-h)
:hook (after-save . doom|auto-revert-buffers) :hook (after-save . doom-auto-revert-buffers-h)
:hook (doom-switch-buffer . doom|auto-revert-buffer) :hook (doom-switch-buffer . doom-auto-revert-buffer-h)
:hook (doom-switch-window . doom|auto-revert-buffer) :hook (doom-switch-window . doom-auto-revert-buffer-h)
:config :config
(setq auto-revert-verbose t ; let us know when it happens (setq auto-revert-verbose t ; let us know when it happens
auto-revert-use-notify nil auto-revert-use-notify nil
@ -90,17 +79,19 @@ detected.")
;; grind Emacs to a halt if you do expensive IO (outside of Emacs) on the ;; grind Emacs to a halt if you do expensive IO (outside of Emacs) on the
;; files you have open (like compression). We only really need revert changes ;; files you have open (like compression). We only really need revert changes
;; when we switch to a buffer or when we focus the Emacs frame. ;; when we switch to a buffer or when we focus the Emacs frame.
(defun doom|auto-revert-buffers () (defun doom-auto-revert-buffer-h ()
"Auto revert current buffer, if necessary."
(unless auto-revert-mode
(let ((revert-without-query t))
(auto-revert-handler))))
(defun doom-auto-revert-buffers-h ()
"Auto revert's stale buffers (that are visible)." "Auto revert's stale buffers (that are visible)."
(unless auto-revert-mode (unless auto-revert-mode
(dolist (buf (doom-visible-buffers)) (dolist (buf (doom-visible-buffers))
(with-current-buffer buf (with-current-buffer buf
(auto-revert-handler))))) (doom-auto-revert-buffer-h))))))
(defun doom|auto-revert-buffer ()
"Auto revert current buffer, if necessary."
(unless auto-revert-mode
(auto-revert-handler))))
(def-package! recentf (def-package! recentf
;; Keep track of recently opened files ;; Keep track of recently opened files
@ -126,19 +117,18 @@ detected.")
file)) file))
(setq recentf-filename-handlers '(doom--recent-file-truename abbreviate-file-name)) (setq recentf-filename-handlers '(doom--recent-file-truename abbreviate-file-name))
(defun doom|recentf-touch-buffer () (add-hook! '(doom-switch-window-hook write-file-functions)
"Bump file in recent file list when it is switched or written to." (defun doom--recentf-touch-buffer-h ()
(when buffer-file-name "Bump file in recent file list when it is switched or written to."
(recentf-add-file buffer-file-name)) (when buffer-file-name
;; Return nil for `write-file-functions' (recentf-add-file buffer-file-name))
nil) ;; Return nil for `write-file-functions'
(add-hook 'doom-switch-window-hook #'doom|recentf-touch-buffer) nil))
(add-hook 'write-file-functions #'doom|recentf-touch-buffer)
(defun doom|recentf-add-dired-directory () (add-hook 'dired-mode-hook
"Add dired directory to recentf file list." (defun doom--recentf-add-dired-directory-h ()
(recentf-add-file default-directory)) "Add dired directory to recentf file list."
(add-hook 'dired-mode-hook #'doom|recentf-add-dired-directory) (recentf-add-file default-directory)))
(unless noninteractive (unless noninteractive
(add-hook 'kill-emacs-hook #'recentf-cleanup) (add-hook 'kill-emacs-hook #'recentf-cleanup)
@ -155,14 +145,14 @@ detected.")
savehist-additional-variables '(kill-ring search-ring regexp-search-ring)) savehist-additional-variables '(kill-ring search-ring regexp-search-ring))
(savehist-mode +1) (savehist-mode +1)
(defun doom|unpropertize-kill-ring () (add-hook 'kill-emacs-hook
"Remove text properties from `kill-ring' in the interest of shrinking the (defun doom-unpropertize-kill-ring-h ()
savehist file." "Remove text properties from `kill-ring' for a smaller savehist file."
(setq kill-ring (cl-loop for item in kill-ring (setq kill-ring (cl-loop for item in kill-ring
if (stringp item) if (stringp item)
collect (substring-no-properties item) collect (substring-no-properties item)
else if item collect it))) else if item collect it)))))
(add-hook 'kill-emacs-hook #'doom|unpropertize-kill-ring))
(def-package! saveplace (def-package! saveplace
;; persistent point location in buffers ;; persistent point location in buffers
@ -223,7 +213,7 @@ savehist file."
origin)))) origin))))
result)) result))
(defun doom|set-jump () (defun doom-set-jump-h ()
"Run `better-jumper-set-jump' but return nil, for short-circuiting hooks." "Run `better-jumper-set-jump' but return nil, for short-circuiting hooks."
(better-jumper-set-jump) (better-jumper-set-jump)
nil)) nil))
@ -243,16 +233,15 @@ savehist file."
:unless noninteractive :unless noninteractive
:defer t :defer t
:init :init
(defun doom|detect-indentation ()
(unless (or (not after-init-time)
doom-inhibit-indent-detection
(member (substring (buffer-name) 0 1) '(" " "*"))
(memq major-mode doom-detect-indentation-excluded-modes))
;; Don't display messages in the echo area, but still log them
(let ((inhibit-message (not doom-debug-mode)))
(dtrt-indent-mode +1))))
(add-hook! '(change-major-mode-after-body-hook read-only-mode-hook) (add-hook! '(change-major-mode-after-body-hook read-only-mode-hook)
#'doom|detect-indentation) (defun doom-detect-indentation-h ()
(unless (or (not after-init-time)
doom-inhibit-indent-detection
(member (substring (buffer-name) 0 1) '(" " "*"))
(memq major-mode doom-detect-indentation-excluded-modes))
;; Don't display messages in the echo area, but still log them
(let ((inhibit-message (not doom-debug-mode)))
(dtrt-indent-mode +1)))))
:config :config
(setq dtrt-indent-run-after-smie t) (setq dtrt-indent-run-after-smie t)
@ -323,12 +312,12 @@ savehist file."
sp-escape-quotes-after-insert nil) ; not smart enough sp-escape-quotes-after-insert nil) ; not smart enough
;; autopairing in `eval-expression' and `evil-ex' ;; autopairing in `eval-expression' and `evil-ex'
(defun doom|init-smartparens-in-eval-expression () (add-hook 'minibuffer-setup-hook
"Enable `smartparens-mode' in the minibuffer, during `eval-expression' or (defun doom--init-smartparens-in-eval-expression-h ()
"Enable `smartparens-mode' in the minibuffer, during `eval-expression' or
`evil-ex'." `evil-ex'."
(when (memq this-command '(eval-expression evil-ex)) (when (memq this-command '(eval-expression evil-ex))
(smartparens-mode))) (smartparens-mode))))
(add-hook 'minibuffer-setup-hook #'doom|init-smartparens-in-eval-expression)
(sp-local-pair 'minibuffer-inactive-mode "'" nil :actions nil) (sp-local-pair 'minibuffer-inactive-mode "'" nil :actions nil)
(sp-local-pair 'minibuffer-inactive-mode "`" nil :actions nil) (sp-local-pair 'minibuffer-inactive-mode "`" nil :actions nil)

View file

@ -157,20 +157,20 @@ localleader prefix."
;; Bind `doom-leader-key' and `doom-leader-alt-key' as late as possible to give ;; Bind `doom-leader-key' and `doom-leader-alt-key' as late as possible to give
;; the user a chance to modify them. ;; the user a chance to modify them.
(defun doom|init-leader-keys () (add-hook 'doom-after-init-modules-hook
"Bind `doom-leader-key' and `doom-leader-alt-key'." (defun doom-init-leader-keys-h ()
(let ((map general-override-mode-map)) "Bind `doom-leader-key' and `doom-leader-alt-key'."
(if (not (featurep 'evil)) (let ((map general-override-mode-map))
(progn (if (not (featurep 'evil))
(cond ((equal doom-leader-alt-key "C-c") (progn
(set-keymap-parent doom-leader-map mode-specific-map)) (cond ((equal doom-leader-alt-key "C-c")
((equal doom-leader-alt-key "C-x") (set-keymap-parent doom-leader-map mode-specific-map))
(set-keymap-parent doom-leader-map ctl-x-map))) ((equal doom-leader-alt-key "C-x")
(define-key map (kbd doom-leader-alt-key) 'doom/leader)) (set-keymap-parent doom-leader-map ctl-x-map)))
(evil-define-key* '(normal visual motion) map (kbd doom-leader-key) 'doom/leader) (define-key map (kbd doom-leader-alt-key) 'doom/leader))
(evil-define-key* '(emacs insert) map (kbd doom-leader-alt-key) 'doom/leader)) (evil-define-key* '(normal visual motion) map (kbd doom-leader-key) 'doom/leader)
(general-override-mode +1))) (evil-define-key* '(emacs insert) map (kbd doom-leader-alt-key) 'doom/leader))
(add-hook 'doom-after-init-modules-hook #'doom|init-leader-keys) (general-override-mode +1))))
;; ;;

View file

@ -176,8 +176,8 @@ advised)."
(declare (indent 1)) (declare (indent 1))
(let ((append (if (eq (car forms) :after) (pop forms))) (let ((append (if (eq (car forms) :after) (pop forms)))
(fn (if (symbolp (car forms)) (fn (if (symbolp (car forms))
(intern (format "doom|transient-hook-%s" (pop forms))) (intern (format "doom--transient-%s-h" (pop forms)))
(make-symbol "doom|transient-hook")))) (make-symbol "doom--transient-h"))))
`(let ((sym ,hook-or-function)) `(let ((sym ,hook-or-function))
(fset ',fn (fset ',fn
(lambda (&rest _) (lambda (&rest _)
@ -204,8 +204,8 @@ This macro accepts, in order:
2. The hook(s) to be added to: either an unquoted mode, an unquoted list of 2. The hook(s) to be added to: either an unquoted mode, an unquoted list of
modes, a quoted hook variable or a quoted list of hook variables. If modes, a quoted hook variable or a quoted list of hook variables. If
unquoted, '-hook' will be appended to each symbol. unquoted, '-hook' will be appended to each symbol.
3. The function(s) to be added: this can be one function, a list thereof, or 3. The function(s) to be added: this can be one function, a list thereof, a
body forms (implicitly wrapped in a closure). list of `defun's, or body forms (implicitly wrapped in a closure).
Examples: Examples:
(add-hook! 'some-mode-hook 'enable-something) (same as `add-hook') (add-hook! 'some-mode-hook 'enable-something) (same as `add-hook')
@ -226,15 +226,23 @@ Examples:
(:append (setq append-p t)) (:append (setq append-p t))
(:local (setq local-p t)) (:local (setq local-p t))
(:remove (setq hook-fn 'remove-hook)))) (:remove (setq hook-fn 'remove-hook))))
(let ((hooks (doom--resolve-hook-forms (pop args))) (let* ((defun-forms nil)
(funcs (hooks (doom--resolve-hook-forms (pop args)))
(let ((val (car args))) (funcs
(if (memq (car-safe val) '(quote function)) (let ((val (car args)))
(if (cdr-safe (cadr val)) (if (memq (car-safe val) '(quote function))
(cadr val) (if (cdr-safe (cadr val))
(list (cadr val))) (cadr val)
(list args)))) (list (cadr val)))
forms) (or (and (eq (car-safe val) 'defun)
(cl-loop for arg in args
if (not (eq (car-safe arg) 'defun))
return nil
else
collect (cadr arg)
and do (push arg defun-forms)))
(list args)))))
forms)
(dolist (fn funcs) (dolist (fn funcs)
(setq fn (if (symbolp fn) (setq fn (if (symbolp fn)
`(function ,fn) `(function ,fn)
@ -244,7 +252,9 @@ Examples:
`(remove-hook ',hook ,fn ,local-p) `(remove-hook ',hook ,fn ,local-p)
`(add-hook ',hook ,fn ,append-p ,local-p)) `(add-hook ',hook ,fn ,append-p ,local-p))
forms))) forms)))
`(progn ,@(if append-p (nreverse forms) forms))))) (macroexp-progn
(append (nreverse defun-forms)
(if append-p (nreverse forms) forms))))))
(defmacro remove-hook! (&rest args) (defmacro remove-hook! (&rest args)
"A convenience macro for removing N functions from M hooks. "A convenience macro for removing N functions from M hooks.
@ -277,7 +287,7 @@ If N and M = 1, there's no benefit to using this macro over `remove-hook'.
(macroexp-progn (macroexp-progn
(cl-loop for hook in (doom--resolve-hook-forms hooks) (cl-loop for hook in (doom--resolve-hook-forms hooks)
for mode = (string-remove-suffix "-hook" (symbol-name hook)) for mode = (string-remove-suffix "-hook" (symbol-name hook))
for fn = (intern (format "doom|setq-%s-for-%s" vars mode)) for fn = (intern (format "doom--setq-%s-for-%s-h" vars mode))
collect `(fset ',fn collect `(fset ',fn
(lambda (&rest _) (lambda (&rest _)
,@(let (forms) ,@(let (forms)
@ -330,7 +340,7 @@ The available conditions are:
(not (or (listp files) (not (or (listp files)
(stringp files)))) (stringp files))))
(user-error "associate! :files expects a string or list of strings")) (user-error "associate! :files expects a string or list of strings"))
(let ((hook-name (intern (format "doom--init-mode-%s" mode)))) (let ((hook-name (intern (format "doom--enable-mode-%s-h" mode))))
`(progn `(progn
(fset ',hook-name (fset ',hook-name
(lambda () (lambda ()
@ -414,7 +424,7 @@ all themes. It will apply to all themes once they are loaded.
'(org-ellipsis :inherit org-tag) '(org-ellipsis :inherit org-tag)
'(which-key-docstring-face :inherit font-lock-comment-face))" '(which-key-docstring-face :inherit font-lock-comment-face))"
`(let* ((themes (doom-enlist (or ,theme 'user))) `(let* ((themes (doom-enlist (or ,theme 'user)))
(fn (gensym (format "doom|customize-%s-" (mapconcat #'symbol-name themes "-"))))) (fn (gensym (format "doom--customize-%s-h-" (mapconcat #'symbol-name themes "-")))))
(fset fn (fset fn
(lambda () (lambda ()
(dolist (theme themes) (dolist (theme themes)

View file

@ -275,7 +275,7 @@ If ALL-P is non-nil, return paths of possible modules, activated or otherwise."
(defun use-package-handler/:after-call (name _keyword hooks rest state) (defun use-package-handler/:after-call (name _keyword hooks rest state)
(if (plist-get state :demand) (if (plist-get state :demand)
(use-package-process-keywords name rest state) (use-package-process-keywords name rest state)
(let ((fn (make-symbol (format "doom|transient-hook--load-%s" name)))) (let ((fn (make-symbol (format "doom--after-call-%s-h" name))))
(use-package-concat (use-package-concat
`((fset ',fn `((fset ',fn
(lambda (&rest _) (lambda (&rest _)

View file

@ -8,11 +8,11 @@
(unless IS-LINUX (setq command-line-x-option-alist nil)) (unless IS-LINUX (setq command-line-x-option-alist nil))
;; Fix the clipboard in terminal or daemon Emacs (non-GUI) ;; Fix the clipboard in terminal or daemon Emacs (non-GUI)
(defun doom|init-clipboard-in-tty-emacs () (defun doom-init-clipboard-in-tty-emacs-h ()
(if IS-MAC (if IS-MAC
(if (require 'osx-clipboard nil t) (osx-clipboard-mode)) (if (require 'osx-clipboard nil t) (osx-clipboard-mode))
(if (require 'xclip nil t) (xclip-mode)))) (if (require 'xclip nil t) (xclip-mode))))
(add-hook 'tty-setup-hook #'doom|init-clipboard-in-tty-emacs) (add-hook 'tty-setup-hook #'doom-init-clipboard-in-tty-emacs-h)
;; Enable mouse in terminal Emacs ;; Enable mouse in terminal Emacs
(add-hook 'tty-setup-hook #'xterm-mouse-mode) (add-hook 'tty-setup-hook #'xterm-mouse-mode)

View file

@ -57,29 +57,29 @@ Emacs.")
;; projectile's cache (into the hundreds of MBs). This purges those entries ;; projectile's cache (into the hundreds of MBs). This purges those entries
;; when exiting Emacs to prevent slowdowns/freezing when cache files are ;; when exiting Emacs to prevent slowdowns/freezing when cache files are
;; loaded or written to. ;; loaded or written to.
(defun doom|cleanup-project-cache () (add-hook 'kill-emacs-hook
"Purge projectile cache entries that: (defun doom-cleanup-project-cache-h ()
"Purge projectile cache entries that:
a) have too many files (see `doom-projectile-cache-limit'), a) have too many files (see `doom-projectile-cache-limit'),
b) represent blacklisted directories that are too big, change too often or are b) represent blacklisted directories that are too big, change too often or are
private. (see `doom-projectile-cache-blacklist'), private. (see `doom-projectile-cache-blacklist'),
c) are not valid projectile projects." c) are not valid projectile projects."
(when (bound-and-true-p projectile-projects-cache) (when (and (bound-and-true-p projectile-projects-cache)
(cl-loop with blacklist = (mapcar #'file-truename doom-projectile-cache-blacklist) (not noninteractive))
for proot in (hash-table-keys projectile-projects-cache) (cl-loop with blacklist = (mapcar #'file-truename doom-projectile-cache-blacklist)
if (or (not (stringp proot)) for proot in (hash-table-keys projectile-projects-cache)
(>= (length (gethash proot projectile-projects-cache)) if (or (not (stringp proot))
doom-projectile-cache-limit) (>= (length (gethash proot projectile-projects-cache))
(member (substring proot 0 -1) blacklist) doom-projectile-cache-limit)
(and doom-projectile-cache-purge-non-projects (member (substring proot 0 -1) blacklist)
(not (doom-project-p proot)))) (and doom-projectile-cache-purge-non-projects
do (doom-log "Removed %S from projectile cache" proot) (not (doom-project-p proot))))
and do (remhash proot projectile-projects-cache) do (doom-log "Removed %S from projectile cache" proot)
and do (remhash proot projectile-projects-cache-time) and do (remhash proot projectile-projects-cache)
and do (remhash proot projectile-project-type-cache)) and do (remhash proot projectile-projects-cache-time)
(projectile-serialize-cache))) and do (remhash proot projectile-project-type-cache))
(unless noninteractive (projectile-serialize-cache))))
(add-hook 'kill-emacs-hook #'doom|cleanup-project-cache))
;; It breaks projectile's project root resolution if HOME is a project (e.g. ;; It breaks projectile's project root resolution if HOME is a project (e.g.
;; it's a git repo). In that case, we disable bottom-up root searching to ;; it's a git repo). In that case, we disable bottom-up root searching to

View file

@ -53,7 +53,7 @@ size.")
(defvar doom--prefer-theme-elc nil (defvar doom--prefer-theme-elc nil
"If non-nil, `load-theme' will prefer the compiled theme (unlike its default "If non-nil, `load-theme' will prefer the compiled theme (unlike its default
behavior). Do not set this directly, this is let-bound in `doom|init-theme'.") behavior). Do not set this directly, this is let-bound in `doom-init-theme-h'.")
;; ;;
@ -85,8 +85,8 @@ behavior). Do not set this directly, this is let-bound in `doom|init-theme'.")
(defvar doom--last-window nil) (defvar doom--last-window nil)
(defvar doom--last-frame nil) (defvar doom--last-frame nil)
(defun doom|run-switch-window-hooks () (defun doom-run-switch-window-hooks-h ()
(let ((gc-cons-threshold doom-gc-cons-upper-limit)) (let ((gc-cons-threshold most-positive-fixnum))
(unless (or doom-inhibit-switch-window-hooks (unless (or doom-inhibit-switch-window-hooks
(eq doom--last-window (selected-window)) (eq doom--last-window (selected-window))
(minibufferp)) (minibufferp))
@ -94,7 +94,7 @@ behavior). Do not set this directly, this is let-bound in `doom|init-theme'.")
(run-hooks 'doom-switch-window-hook) (run-hooks 'doom-switch-window-hook)
(setq doom--last-window (selected-window)))))) (setq doom--last-window (selected-window))))))
(defun doom|run-switch-frame-hooks (&rest _) (defun doom-run-switch-frame-hooks-h (&rest _)
(unless (or doom-inhibit-switch-frame-hooks (unless (or doom-inhibit-switch-frame-hooks
(eq doom--last-frame (selected-frame)) (eq doom--last-frame (selected-frame))
(frame-parameter nil 'parent-frame)) (frame-parameter nil 'parent-frame))
@ -130,7 +130,7 @@ behavior). Do not set this directly, this is let-bound in `doom|init-theme'.")
"Don't kill the scratch buffer. Meant for `kill-buffer-query-functions'." "Don't kill the scratch buffer. Meant for `kill-buffer-query-functions'."
(not (eq (current-buffer) (doom-fallback-buffer)))) (not (eq (current-buffer) (doom-fallback-buffer))))
(defun doom|highlight-non-default-indentation () (defun doom-highlight-non-default-indentation-h ()
"Highlight whitespace that doesn't match your `indent-tabs-mode' setting. "Highlight whitespace that doesn't match your `indent-tabs-mode' setting.
e.g. If you indent with spaces by default, tabs will be highlighted. If you e.g. If you indent with spaces by default, tabs will be highlighted. If you
@ -224,7 +224,7 @@ read-only or not file-visiting."
;; Use `show-trailing-whitespace' instead of `whitespace-mode' because it's ;; Use `show-trailing-whitespace' instead of `whitespace-mode' because it's
;; faster (implemented in C). But try to only enable it in editing buffers. ;; faster (implemented in C). But try to only enable it in editing buffers.
(setq-default show-trailing-whitespace nil) (setq-default show-trailing-whitespace nil)
(setq-hook! '(prog-mode-hook text-mode-hook conf-mode-hook) show-trailing-whitespace t) (add-hook! (prog-mode text-mode conf-mode) #'doom-enable-show-trailing-whitespace-h)
;; The native border "consumes" a pixel of the fringe on righter-most splits, ;; The native border "consumes" a pixel of the fringe on righter-most splits,
;; `window-divider' does not. Available since Emacs 25.1. ;; `window-divider' does not. Available since Emacs 25.1.
@ -279,23 +279,22 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
:config :config
(defvar doom--ediff-saved-wconf nil) (defvar doom--ediff-saved-wconf nil)
;; Restore window config after quitting ediff ;; Restore window config after quitting ediff
(defun doom|ediff-save-wconf () (add-hook 'ediff-before-setup-hook
(setq doom--ediff-saved-wconf (current-window-configuration))) (defun doom--ediff-save-wconf-h ()
(add-hook 'ediff-before-setup-hook #'doom|ediff-save-wconf) (setq doom--ediff-saved-wconf (current-window-configuration))))
(add-hook! '(ediff-quit-hook ediff-suspend-hook)
(defun doom|ediff-restore-wconf () (defun doom--ediff-restore-wconf-h ()
(when (window-configuration-p doom--ediff-saved-wconf) (when (window-configuration-p doom--ediff-saved-wconf)
(set-window-configuration doom--ediff-saved-wconf))) (set-window-configuration doom--ediff-saved-wconf)))
(add-hook 'ediff-quit-hook #'doom|ediff-restore-wconf 'append) 'append))
(add-hook 'ediff-suspend-hook #'doom|ediff-restore-wconf 'append))
(def-package! hl-line (def-package! hl-line
;; Highlights the current line ;; Highlights the current line
:hook ((prog-mode text-mode conf-mode) . hl-line-mode) :hook ((prog-mode text-mode conf-mode) . hl-line-mode)
:config :config
;; I don't need hl-line showing in other windows. This also offers a small ;; PERF Not having to render the hl-line overlay in multiple buffers offers a
;; speed boost when buffer is displayed in multiple windows. ;; tiny performance boost. I also don't need to see it in other buffers.
(setq hl-line-sticky-flag nil (setq hl-line-sticky-flag nil
global-hl-line-sticky-flag nil) global-hl-line-sticky-flag nil)
@ -303,17 +302,15 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
;; selection region harder to see while in evil visual mode. ;; selection region harder to see while in evil visual mode.
(after! evil (after! evil
(defvar doom-buffer-hl-line-mode nil) (defvar doom-buffer-hl-line-mode nil)
(add-hook 'evil-visual-state-entry-hook
(defun doom|disable-hl-line () (defun doom-disable-hl-line-h ()
(when hl-line-mode (when hl-line-mode
(setq-local doom-buffer-hl-line-mode t) (setq-local doom-buffer-hl-line-mode t)
(hl-line-mode -1))) (hl-line-mode -1))))
(add-hook 'evil-visual-state-entry-hook #'doom|disable-hl-line) (add-hook 'evil-visual-state-exit-hook
(defun doom-enable-hl-line-maybe-h ()
(defun doom|enable-hl-line-maybe () (when doom-buffer-hl-line-mode
(when doom-buffer-hl-line-mode (hl-line-mode +1))))))
(hl-line-mode +1)))
(add-hook 'evil-visual-state-exit-hook #'doom|enable-hl-line-maybe)))
(def-package! winner (def-package! winner
@ -366,8 +363,8 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
""))) "")))
;;;###package hide-mode-line-mode ;;;###package hide-mode-line-mode
(add-hook 'completion-list-mode-hook #'hide-mode-line-mode) (add-hook! '(completion-list-mode-hook Man-mode-hook)
(add-hook 'Man-mode-hook #'hide-mode-line-mode) #'hide-mode-line-mode)
;; Better fontification of number literals in code ;; Better fontification of number literals in code
(def-package! highlight-numbers (def-package! highlight-numbers
@ -384,10 +381,11 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
;;; Line numbers ;;; Line numbers
;; line numbers in most modes ;; line numbers in most modes
(add-hook! (prog-mode text-mode conf-mode) #'display-line-numbers-mode) (add-hook! '(prog-mode-hook text-mode-hook conf-mode-hook)
#'display-line-numbers-mode)
(defun doom|enable-line-numbers () (display-line-numbers-mode +1)) (defun doom-enable-line-numbers-h () (display-line-numbers-mode +1))
(defun doom|disable-line-numbers () (display-line-numbers-mode -1)) (defun doom-disable-line-numbers-h () (display-line-numbers-mode -1))
;; `nlinum' is used for Emacs 25 users, as Emacs 26+ has native line numbers. ;; `nlinum' is used for Emacs 25 users, as Emacs 26+ has native line numbers.
(def-package! nlinum (def-package! nlinum
@ -432,12 +430,12 @@ character that looks like a space that `whitespace-mode' won't affect.")
str)) str))
(setq nlinum-format-function #'doom-nlinum-format-fn) (setq nlinum-format-function #'doom-nlinum-format-fn)
(defun doom|init-nlinum-width () (add-hook 'nlinum-mode-hook
"Calculate line number column width beforehand (optimization)." (defun doom--init-nlinum-width-h ()
(setq nlinum--width "Calculate line number column width beforehand (optimization)."
(length (save-excursion (goto-char (point-max)) (setq nlinum--width
(format-mode-line "%l"))))) (length (save-excursion (goto-char (point-max))
(add-hook 'nlinum-mode-hook #'doom|init-nlinum-width)) (format-mode-line "%l")))))))
(def-package! nlinum-hl (def-package! nlinum-hl
;; Fixes disappearing line numbers in nlinum and other quirks ;; Fixes disappearing line numbers in nlinum and other quirks
@ -466,7 +464,7 @@ character that looks like a space that `whitespace-mode' won't affect.")
;; ;;
;;; Theme & font ;;; Theme & font
(defun doom|init-fonts () (defun doom-init-fonts-h ()
"Loads fonts. "Loads fonts.
Fonts are specified by `doom-font', `doom-variable-pitch-font', Fonts are specified by `doom-font', `doom-variable-pitch-font',
@ -493,14 +491,14 @@ Fonts are specified by `doom-font', `doom-variable-pitch-font',
(font-get (caddr e) :family)) (font-get (caddr e) :family))
(signal 'doom-error e))))) (signal 'doom-error e)))))
(defun doom|init-emoji-fonts (frame) (defun doom-init-emoji-fonts-h (frame)
"Set up unicode fonts (if `doom-unicode-font' is set). "Set up unicode fonts (if `doom-unicode-font' is set).
By default, this uses Apple Color Emoji on MacOS and Symbola on Linux." By default, this uses Apple Color Emoji on MacOS and Symbola on Linux."
(when doom-unicode-font (when doom-unicode-font
(set-fontset-font t 'unicode doom-unicode-font frame 'prepend))) (set-fontset-font t 'unicode doom-unicode-font frame 'prepend)))
(defun doom|init-theme (&optional frame) (defun doom-init-theme-h (&optional frame)
"Load the theme specified by `doom-theme' in FRAME." "Load the theme specified by `doom-theme' in FRAME."
(when (and doom-theme (not (memq doom-theme custom-enabled-themes))) (when (and doom-theme (not (memq doom-theme custom-enabled-themes)))
(with-selected-frame (or frame (selected-frame)) (with-selected-frame (or frame (selected-frame))
@ -531,19 +529,19 @@ startup (or theme switch) time, so long as `doom--prefer-theme-elc' is non-nil."
;; ;;
;;; Bootstrap ;;; Bootstrap
(defun doom|init-ui () (defun doom-init-ui-h ()
"Initialize Doom's user interface by applying all its advice and hooks." "Initialize Doom's user interface by applying all its advice and hooks."
(run-hook-wrapped 'doom-init-ui-hook #'doom-try-run-hook) (run-hook-wrapped 'doom-init-ui-hook #'doom-try-run-hook)
(add-to-list 'kill-buffer-query-functions #'doom|protect-fallback-buffer nil 'eq) (add-to-list 'kill-buffer-query-functions #'doom-protect-fallback-buffer-h nil 'eq)
(add-hook 'after-change-major-mode-hook #'doom|highlight-non-default-indentation) (add-hook 'after-change-major-mode-hook #'doom-highlight-non-default-indentation-h)
;; Initialize custom switch-{buffer,window,frame} hooks: ;; Initialize custom switch-{buffer,window,frame} hooks:
;; + `doom-switch-buffer-hook' ;; + `doom-switch-buffer-hook'
;; + `doom-switch-window-hook' ;; + `doom-switch-window-hook'
;; + `doom-switch-frame-hook' ;; + `doom-switch-frame-hook'
(add-hook 'buffer-list-update-hook #'doom|run-switch-window-hooks) (add-hook 'buffer-list-update-hook #'doom-run-switch-window-hooks-h)
(add-hook 'focus-in-hook #'doom|run-switch-frame-hooks) (add-hook 'focus-in-hook #'doom-run-switch-frame-hooks-h)
(dolist (fn '(switch-to-next-buffer switch-to-prev-buffer)) (dolist (fn '(switch-to-next-buffer switch-to-prev-buffer))
(advice-add fn :around #'doom-run-switch-to-next-prev-buffer-hooks-a)) (advice-add fn :around #'doom-run-switch-to-next-prev-buffer-hooks-a))
(dolist (fn '(switch-to-buffer display-buffer)) (dolist (fn '(switch-to-buffer display-buffer))
@ -553,13 +551,13 @@ startup (or theme switch) time, so long as `doom--prefer-theme-elc' is non-nil."
(add-hook (if (daemonp) (add-hook (if (daemonp)
'after-make-frame-functions 'after-make-frame-functions
'doom-init-ui-hook) 'doom-init-ui-hook)
#'doom|init-theme) #'doom-init-theme-h)
;; Apply `doom-font' et co ;; Apply `doom-font' et co
(add-hook 'doom-after-init-modules-hook #'doom|init-fonts) (add-hook 'doom-after-init-modules-hook #'doom-init-fonts-h)
;; Ensure unicode fonts are set on each frame ;; Ensure unicode fonts are set on each frame
(add-hook 'after-make-frame-functions #'doom|init-emoji-fonts) (add-hook 'after-make-frame-functions #'doom-init-emoji-fonts-h)
(add-hook 'window-setup-hook #'doom|init-ui) (add-hook 'window-setup-hook #'doom-init-ui-h)
;; ;;

View file

@ -231,7 +231,7 @@ original value of `symbol-file'."
`auto-mode-alist'. All elements of this alist are checked, meaning you can `auto-mode-alist'. All elements of this alist are checked, meaning you can
enable multiple minor modes for the same regexp.") enable multiple minor modes for the same regexp.")
(defun doom|enable-minor-mode-maybe () (defun doom-enable-minor-mode-maybe-h ()
"Check file name against `doom-auto-minor-mode-alist'." "Check file name against `doom-auto-minor-mode-alist'."
(when (and buffer-file-name doom-auto-minor-mode-alist) (when (and buffer-file-name doom-auto-minor-mode-alist)
(let ((name buffer-file-name) (let ((name buffer-file-name)
@ -247,7 +247,7 @@ enable multiple minor modes for the same regexp.")
(if (string-match-p (caar alist) name) (if (string-match-p (caar alist) name)
(funcall (cdar alist) 1)) (funcall (cdar alist) 1))
(setq alist (cdr alist)))))) (setq alist (cdr alist))))))
(add-hook 'find-file-hook #'doom|enable-minor-mode-maybe) (add-hook 'find-file-hook #'doom-enable-minor-mode-maybe-h)
;; ;;
@ -256,27 +256,28 @@ enable multiple minor modes for the same regexp.")
;; File+dir local variables are initialized after the major mode and its hooks ;; File+dir local variables are initialized after the major mode and its hooks
;; have run. If you want hook functions to be aware of these customizations, add ;; have run. If you want hook functions to be aware of these customizations, add
;; them to MODE-local-vars-hook instead. ;; them to MODE-local-vars-hook instead.
(defun doom|run-local-var-hooks () (add-hook 'hack-local-variables-hook
"Run MODE-local-vars-hook after local variables are initialized." (defun doom-run-local-var-hooks-h ()
(run-hook-wrapped (intern-soft (format "%s-local-vars-hook" major-mode)) "Run MODE-local-vars-hook after local variables are initialized."
#'doom-try-run-hook)) (run-hook-wrapped (intern-soft (format "%s-local-vars-hook" major-mode))
(add-hook 'hack-local-variables-hook #'doom|run-local-var-hooks) #'doom-try-run-hook)))
;; If `enable-local-variables' is disabled, then `hack-local-variables-hook' is ;; If `enable-local-variables' is disabled, then `hack-local-variables-hook' is
;; never triggered. ;; never triggered.
(defun doom|run-local-var-hooks-if-necessary () (add-hook 'after-change-major-mode-hook
"Run `doom|run-local-var-hooks' if `enable-local-variables' is disabled." (defun doom-run-local-var-hooks-if-necessary-h ()
(unless enable-local-variables "Run `doom-run-local-var-hooks-h' if `enable-local-variables' is disabled."
(doom|run-local-var-hooks))) (unless enable-local-variables
(add-hook 'after-change-major-mode-hook #'doom|run-local-var-hooks-if-necessary 'append) (doom-run-local-var-hooks-h)))
'append)
(defun doom|create-non-existent-directories () (add-hook 'find-file-not-found-functions
"Automatically create missing directories when creating new files." (defun doom-create-missing-directories-h ()
(let ((parent-directory (file-name-directory buffer-file-name))) "Automatically create missing directories when creating new files."
(when (and (not (file-exists-p parent-directory)) (let ((parent-directory (file-name-directory buffer-file-name)))
(y-or-n-p (format "Directory `%s' does not exist! Create it?" parent-directory))) (when (and (not (file-exists-p parent-directory))
(make-directory parent-directory t)))) (y-or-n-p (format "Directory `%s' does not exist! Create it?" parent-directory)))
(add-hook 'find-file-not-found-functions #'doom|create-non-existent-directories) (make-directory parent-directory t)))))
;; ;;
@ -297,7 +298,7 @@ broken up into:
This is already done by the lang/org module, however. This is already done by the lang/org module, however.
If you want to disable incremental loading altogether, either remove If you want to disable incremental loading altogether, either remove
`doom|load-packages-incrementally' from `emacs-startup-hook' or set `doom-load-packages-incrementally-h' from `emacs-startup-hook' or set
`doom-incremental-first-idle-timer' to nil.") `doom-incremental-first-idle-timer' to nil.")
(defvar doom-incremental-first-idle-timer 2 (defvar doom-incremental-first-idle-timer 2
@ -333,18 +334,17 @@ intervals."
reqs t) reqs t)
(doom-log "Finished incremental loading"))))))) (doom-log "Finished incremental loading")))))))
(defun doom|load-packages-incrementally () (add-hook 'window-setup-hook
"Begin incrementally loading packages in `doom-incremental-packages'. (defun doom-load-packages-incrementally-h ()
"Begin incrementally loading packages in `doom-incremental-packages'.
If this is a daemon session, load them all immediately instead." If this is a daemon session, load them all immediately instead."
(if (daemonp) (if (daemonp)
(mapc #'require (cdr doom-incremental-packages)) (mapc #'require (cdr doom-incremental-packages))
(when (integerp doom-incremental-first-idle-timer) (when (integerp doom-incremental-first-idle-timer)
(run-with-idle-timer doom-incremental-first-idle-timer (run-with-idle-timer doom-incremental-first-idle-timer
nil #'doom-load-packages-incrementally nil #'doom-load-packages-incrementally
(cdr doom-incremental-packages) t)))) (cdr doom-incremental-packages) t)))))
(add-hook 'window-setup-hook #'doom|load-packages-incrementally)
;; ;;
@ -392,23 +392,23 @@ Meant to be used with `run-hook-wrapped'."
(unless (file-directory-p dir) (unless (file-directory-p dir)
(make-directory dir t)))) (make-directory dir t))))
(defun doom|display-benchmark (&optional return-p) (defun doom-display-benchmark-h (&optional return-p)
"Display a benchmark, showing number of packages and modules, and how quickly "Display a benchmark, showing number of packages and modules, and how quickly
they were loaded at startup. they were loaded at startup.
If RETURN-P, return the message as a string instead of displaying it." If RETURN-P, return the message as a string instead of displaying it."
(funcall (if return-p #'format #'message) (funcall (if return-p #'format #'message)
"Doom loaded %s packages across %d modules in %.03fs" "Doom loaded %d packages across %d modules in %.03fs"
(length package-activated-list) (- (length load-path) (length doom--initial-load-path))
(if doom-modules (hash-table-count doom-modules) 0) (if doom-modules (hash-table-count doom-modules) 0)
(or doom-init-time (or doom-init-time
(setq doom-init-time (float-time (time-subtract (current-time) before-init-time)))))) (setq doom-init-time (float-time (time-subtract (current-time) before-init-time))))))
(defun doom|run-all-startup-hooks () (defun doom-run-all-startup-hooks-h ()
"Run all startup Emacs hooks. Meant to be executed after starting Emacs with "Run all startup Emacs hooks. Meant to be executed after starting Emacs with
-q or -Q, for example: -q or -Q, for example:
emacs -Q -l init.el -f doom|run-all-startup-hooks" emacs -Q -l init.el -f doom-run-all-startup-hooks-h"
(run-hook-wrapped 'after-init-hook #'doom-try-run-hook) (run-hook-wrapped 'after-init-hook #'doom-try-run-hook)
(setq after-init-time (current-time)) (setq after-init-time (current-time))
(dolist (hook (list 'delayed-warnings-hook (dolist (hook (list 'delayed-warnings-hook
@ -522,7 +522,7 @@ to least)."
(require 'core-os) (require 'core-os)
(if noninteractive (if noninteractive
(require 'core-cli) (require 'core-cli)
(add-hook 'window-setup-hook #'doom|display-benchmark) (add-hook 'window-setup-hook #'doom-display-benchmark-h)
(require 'core-keybinds) (require 'core-keybinds)
(require 'core-ui) (require 'core-ui)
(require 'core-projects) (require 'core-projects)

14
init.el
View file

@ -37,7 +37,7 @@ decrease this. If you experience stuttering, increase this.")
(defvar doom--file-name-handler-alist file-name-handler-alist) (defvar doom--file-name-handler-alist file-name-handler-alist)
(defun doom|restore-startup-optimizations () (defun doom-restore-startup-optimizations-h ()
"Resets garbage collection settings to reasonable defaults (a large "Resets garbage collection settings to reasonable defaults (a large
`gc-cons-threshold' can cause random freezes otherwise) and resets `gc-cons-threshold' can cause random freezes otherwise) and resets
`file-name-handler-alist'." `file-name-handler-alist'."
@ -50,14 +50,14 @@ decrease this. If you experience stuttering, increase this.")
(setq-default gc-cons-threshold doom-gc-cons-threshold) (setq-default gc-cons-threshold doom-gc-cons-threshold)
;; To speed up minibuffer commands (like helm and ivy), we defer garbage ;; To speed up minibuffer commands (like helm and ivy), we defer garbage
;; collection while the minibuffer is active. ;; collection while the minibuffer is active.
(defun doom|defer-garbage-collection () (defun doom-defer-garbage-collection-h ()
(setq gc-cons-threshold doom-gc-cons-upper-limit)) (setq gc-cons-threshold doom-gc-cons-upper-limit))
(defun doom|restore-garbage-collection () (defun doom-restore-garbage-collection-h ()
;; Defer it so that commands launched from the minibuffer can enjoy the ;; Defer it so that commands launched from the minibuffer can enjoy the
;; benefits. ;; benefits.
(run-at-time 1 nil (lambda () (setq gc-cons-threshold doom-gc-cons-threshold)))) (run-at-time 1 nil (lambda () (setq gc-cons-threshold doom-gc-cons-threshold))))
(add-hook 'minibuffer-setup-hook #'doom|defer-garbage-collection) (add-hook 'minibuffer-setup-hook #'doom-defer-garbage-collection-h)
(add-hook 'minibuffer-exit-hook #'doom|restore-garbage-collection) (add-hook 'minibuffer-exit-hook #'doom-restore-garbage-collection-h)
;; GC all sneaky breeky like ;; GC all sneaky breeky like
(add-hook 'focus-out-hook #'garbage-collect)))) (add-hook 'focus-out-hook #'garbage-collect))))
@ -66,13 +66,13 @@ decrease this. If you experience stuttering, increase this.")
(setq gc-cons-threshold doom-gc-cons-threshold) (setq gc-cons-threshold doom-gc-cons-threshold)
;; A big contributor to startup times is garbage collection. We up the gc ;; A big contributor to startup times is garbage collection. We up the gc
;; threshold to temporarily prevent it from running, then reset it later in ;; threshold to temporarily prevent it from running, then reset it later in
;; `doom|restore-startup-optimizations'. ;; `doom-restore-startup-optimizations-h'.
(setq gc-cons-threshold doom-gc-cons-upper-limit) (setq gc-cons-threshold doom-gc-cons-upper-limit)
;; This is consulted on every `require', `load' and various path/io functions. ;; This is consulted on every `require', `load' and various path/io functions.
;; You get a minor speed up by nooping this. ;; You get a minor speed up by nooping this.
(setq file-name-handler-alist nil) (setq file-name-handler-alist nil)
;; Not restoring these to their defaults will cause stuttering/freezes. ;; Not restoring these to their defaults will cause stuttering/freezes.
(add-hook 'after-init-hook #'doom|restore-startup-optimizations)) (add-hook 'after-init-hook #'doom-restore-startup-optimizations-h))
;; Ensure Doom is running out of this file's directory ;; Ensure Doom is running out of this file's directory

View file

@ -24,7 +24,7 @@
(define-key cfw:calendar-mode-map "q" #'+calendar/quit) (define-key cfw:calendar-mode-map "q" #'+calendar/quit)
(add-hook 'cfw:calendar-mode-hook #'doom|mark-buffer-as-real) (add-hook 'cfw:calendar-mode-hook #'doom-mark-buffer-as-real-h)
(add-hook 'cfw:calendar-mode-hook 'hide-mode-line-mode) (add-hook 'cfw:calendar-mode-hook 'hide-mode-line-mode)
(advice-add #'cfw:render-button :override #'+calendar*cfw:render-button)) (advice-add #'cfw:render-button :override #'+calendar*cfw:render-button))

View file

@ -121,10 +121,9 @@
:defer t :defer t
:config :config
(setq company-dict-dir (expand-file-name "dicts" doom-private-dir)) (setq company-dict-dir (expand-file-name "dicts" doom-private-dir))
(defun +company|enable-project-dicts (mode &rest _) (add-hook 'doom-project-hook
"Enable per-project dictionaries." (defun +company--enable-project-dicts-h (mode &rest _)
(if (symbol-value mode) "Enable per-project dictionaries."
(add-to-list 'company-dict-minor-mode-list mode nil #'eq) (if (symbol-value mode)
(setq company-dict-minor-mode-list (delq mode company-dict-minor-mode-list)))) (add-to-list 'company-dict-minor-mode-list mode nil #'eq)
(add-hook 'doom-project-hook #'+company|enable-project-dicts)) (setq company-dict-minor-mode-list (delq mode company-dict-minor-mode-list))))))

View file

@ -1,9 +1,7 @@
;;; completion/helm/autoload/posframe.el -*- lexical-binding: t; -*- ;;; completion/helm/autoload/posframe.el -*- lexical-binding: t; -*-
(add-hook 'helm-cleanup-hook #'+helm|posframe-cleanup)
;;;###autoload ;;;###autoload
(defun +helm-poshandler-frame-center-near-bottom (info) (defun +helm-poshandler-frame-center-near-bottom-fn (info)
"Display the child frame in the center of the frame, slightly closer to the "Display the child frame in the center of the frame, slightly closer to the
bottom, which is easier on the eyes on big displays." bottom, which is easier on the eyes on big displays."
(let ((parent-frame (plist-get info :parent-frame)) (let ((parent-frame (plist-get info :parent-frame))
@ -14,7 +12,7 @@ bottom, which is easier on the eyes on big displays."
(defvar +helm--posframe-buffer nil) (defvar +helm--posframe-buffer nil)
;;;###autoload ;;;###autoload
(defun +helm-posframe-display (buffer &optional _resume) (defun +helm-posframe-display-fn (buffer &optional _resume)
"TODO" "TODO"
(setq helm--buffer-in-new-frame-p t) (setq helm--buffer-in-new-frame-p t)
(let ((solaire-p (bound-and-true-p solaire-mode)) (let ((solaire-p (bound-and-true-p solaire-mode))
@ -52,7 +50,7 @@ bottom, which is easier on the eyes on big displays."
(text-scale-set +helm-posframe-text-scale))))) (text-scale-set +helm-posframe-text-scale)))))
;;;###autoload ;;;###autoload
(defun +helm|posframe-cleanup () (defun +helm-posframe-cleanup-h ()
"TODO" "TODO"
;; Ensure focus is properly returned to the underlying window, by forcing a ;; Ensure focus is properly returned to the underlying window, by forcing a
;; chance in buffer/window focus. This gives the modeline a chance to refresh. ;; chance in buffer/window focus. This gives the modeline a chance to refresh.
@ -60,3 +58,4 @@ bottom, which is easier on the eyes on big displays."
;; ;;
(posframe-delete +helm--posframe-buffer)) (posframe-delete +helm--posframe-buffer))
(add-hook 'helm-cleanup-hook #'+helm-posframe-cleanup-h)

View file

@ -11,8 +11,7 @@ silently ignored.
This falls back to git-grep (then grep) if none of these available.") This falls back to git-grep (then grep) if none of these available.")
;; Posframe (requires +childframe) ;; Posframe (requires +childframe)
(defvar +helm-posframe-handler (defvar +helm-posframe-handler #'+helm-poshandler-frame-center-near-bottom-fn
#'+helm-poshandler-frame-center-near-bottom
"The function that determines the location of the childframe. It should return "The function that determines the location of the childframe. It should return
a cons cell representing the X and Y coordinates. See a cons cell representing the X and Y coordinates. See
`posframe-poshandler-frame-center' as a reference.") `posframe-poshandler-frame-center' as a reference.")
@ -113,12 +112,12 @@ be negative.")
(set-popup-rule! "^\\*helm" :vslot -100 :size 0.22 :ttl nil) (set-popup-rule! "^\\*helm" :vslot -100 :size 0.22 :ttl nil)
;; Hide the modeline ;; Hide the modeline
(defun +helm|hide-mode-line (&rest _) (defun +helm--hide-mode-line (&rest _)
(with-current-buffer (helm-buffer-get) (with-current-buffer (helm-buffer-get)
(unless helm-mode-line-string (unless helm-mode-line-string
(hide-mode-line-mode +1)))) (hide-mode-line-mode +1))))
(add-hook 'helm-after-initialize-hook #'+helm|hide-mode-line) (add-hook 'helm-after-initialize-hook #'+helm--hide-mode-line)
(advice-add #'helm-display-mode-line :override #'+helm|hide-mode-line) (advice-add #'helm-display-mode-line :override #'+helm--hide-mode-line)
(advice-add #'helm-ag-show-status-default-mode-line :override #'ignore) (advice-add #'helm-ag-show-status-default-mode-line :override #'ignore)
;; Use helpful instead of describe-* to display documentation ;; Use helpful instead of describe-* to display documentation

View file

@ -1,6 +1,6 @@
;;; completion/ido/config.el -*- lexical-binding: t; -*- ;;; completion/ido/config.el -*- lexical-binding: t; -*-
(defun +ido|init () (defun +ido-init-h ()
(setq ido-ignore-buffers (setq ido-ignore-buffers
'("\\` " "^\\*ESS\\*" "^\\*Messages\\*" "^\\*Help\\*" "^\\*Buffer" '("\\` " "^\\*ESS\\*" "^\\*Messages\\*" "^\\*Help\\*" "^\\*Buffer"
"^\\*.*Completions\\*$" "^\\*Ediff" "^\\*tramp" "^\\*cvs-" "^\\*.*Completions\\*$" "^\\*Ediff" "^\\*tramp" "^\\*cvs-"
@ -52,7 +52,7 @@
(crm-custom-mode +1) (crm-custom-mode +1)
;; ;;
(remove-hook 'ido-setup-hook #'+ido|init)) (remove-hook 'ido-setup-hook #'+ido-init-h))
;; ;;
(add-hook 'ido-setup-hook #'+ido|init) (add-hook 'ido-setup-hook #'+ido-init-h)

View file

@ -2,12 +2,12 @@
;;;###if (featurep! +childframe) ;;;###if (featurep! +childframe)
;;;###autoload ;;;###autoload
(defun +ivy-display-at-frame-center-near-bottom (str) (defun +ivy-display-at-frame-center-near-bottom-fn (str)
"TODO" "TODO"
(ivy-posframe--display str #'+ivy-poshandler-frame-center-near-bottom)) (ivy-posframe--display str #'+ivy-poshandler-frame-center-near-bottom-fn))
;;;###autoload ;;;###autoload
(defun +ivy-poshandler-frame-center-near-bottom (info) (defun +ivy-poshandler-frame-center-near-bottom-fn (info)
"TODO" "TODO"
(let ((parent-frame (plist-get info :parent-frame)) (let ((parent-frame (plist-get info :parent-frame))
(pos (posframe-poshandler-frame-center info))) (pos (posframe-poshandler-frame-center info)))

View file

@ -77,19 +77,18 @@ immediately runs it on the current candidate (ending the ivy session)."
;; Ensure a jump point is registered before jumping to new locations with ivy ;; Ensure a jump point is registered before jumping to new locations with ivy
(defvar +ivy--origin nil) (defvar +ivy--origin nil)
(defun +ivy--record-position-maybe-fn ()
(defun +ivy|record-position-maybe ()
(with-ivy-window (with-ivy-window
(setq +ivy--origin (point-marker)))) (setq +ivy--origin (point-marker))))
(setq ivy-hooks-alist '((t . +ivy|record-position-maybe))) (setq ivy-hooks-alist '((t . +ivy--record-position-maybe-fn)))
(defun +ivy|set-jump-point-maybe () (add-hook 'minibuffer-exit-hook
(when (and (markerp +ivy--origin) (defun +ivy--set-jump-point-maybe-h ()
(not (equal (with-ivy-window (point-marker)) +ivy--origin))) (when (and (markerp +ivy--origin)
(with-current-buffer (marker-buffer +ivy--origin) (not (equal (with-ivy-window (point-marker)) +ivy--origin)))
(better-jumper-set-jump +ivy--origin))) (with-current-buffer (marker-buffer +ivy--origin)
(setq +ivy--origin nil)) (better-jumper-set-jump +ivy--origin)))
(add-hook 'minibuffer-exit-hook #'+ivy|set-jump-point-maybe) (setq +ivy--origin nil)))
(after! yasnippet (after! yasnippet
(add-to-list 'yas-prompt-functions #'+ivy-yas-prompt nil #'eq)) (add-to-list 'yas-prompt-functions #'+ivy-yas-prompt nil #'eq))
@ -277,11 +276,13 @@ evil-ex-specific constructs, so we disable it solely in evil-ex."
(min-height . ,ivy-height))) (min-height . ,ivy-height)))
;; default to posframe display function ;; default to posframe display function
(setf (alist-get t ivy-posframe-display-functions-alist) #'+ivy-display-at-frame-center-near-bottom) (setf (alist-get t ivy-posframe-display-functions-alist)
#'+ivy-display-at-frame-center-near-bottom-fn)
;; posframe doesn't work well with async sources ;; posframe doesn't work well with async sources
(dolist (fn '(swiper counsel-ag counsel-grep counsel-git-grep)) (dolist (fn '(swiper counsel-ag counsel-grep counsel-git-grep))
(setf (alist-get fn ivy-posframe-display-functions-alist) #'ivy-display-function-fallback))) (setf (alist-get fn ivy-posframe-display-functions-alist)
#'ivy-display-function-fallback)))
(def-package! flx (def-package! flx

View file

@ -47,10 +47,10 @@
;; Smartparens' navigation feature is neat, but does not justify how ;; Smartparens' navigation feature is neat, but does not justify how
;; expensive it is. It's also less useful for evil users. This may need to ;; expensive it is. It's also less useful for evil users. This may need to
;; be reactivated for non-evil users though. Needs more testing! ;; be reactivated for non-evil users though. Needs more testing!
(defun doom|disable-smartparens-navigate-skip-match () (add-hook 'after-change-major-mode-hook
(setq sp-navigate-skip-match nil (defun doom-disable-smartparens-navigate-skip-match-h ()
sp-navigate-consider-sgml-tags nil)) (setq sp-navigate-skip-match nil
(add-hook 'after-change-major-mode-hook #'doom|disable-smartparens-navigate-skip-match) sp-navigate-consider-sgml-tags nil)))
;; Autopair quotes more conservatively; if I'm next to a word/before another ;; Autopair quotes more conservatively; if I'm next to a word/before another
;; quote, I likely don't want to open a new pair. ;; quote, I likely don't want to open a new pair.

View file

@ -4,7 +4,7 @@
(defalias '+literate/reload #'doom/reload) (defalias '+literate/reload #'doom/reload)
;;;###autoload ;;;###autoload
(defun +literate|recompile-maybe () (defun +literate-recompile-maybe-h ()
"Recompile config.org if we're editing an org file in our DOOMDIR. "Recompile config.org if we're editing an org file in our DOOMDIR.
We assume any org file in `doom-private-dir' is connected to your literate We assume any org file in `doom-private-dir' is connected to your literate

View file

@ -46,4 +46,4 @@ byte-compiled from.")
;; Recompile our literate config if we modify it ;; Recompile our literate config if we modify it
(after! org (after! org
(add-hook 'after-save-hook #'+literate|recompile-maybe)) (add-hook 'after-save-hook #'+literate-recompile-maybe-h))

View file

@ -192,7 +192,7 @@ more information on modifiers."
(funcall orig-fn char))) (funcall orig-fn char)))
;;;###autoload ;;;###autoload
(defun +evil*fix-dabbrev-in-minibuffer () (defun +evil--fix-dabbrev-in-minibuffer-h ()
"Make `try-expand-dabbrev' from `hippie-expand' work in minibuffer. See "Make `try-expand-dabbrev' from `hippie-expand' work in minibuffer. See
`he-dabbrev-beg', so we need to redefine syntax for '/'." `he-dabbrev-beg', so we need to redefine syntax for '/'."
(set-syntax-table (let* ((table (make-syntax-table))) (set-syntax-table (let* ((table (make-syntax-table)))

View file

@ -36,9 +36,9 @@ directives. By default, this only recognizes C directives.")
;; more vim-like behavior ;; more vim-like behavior
evil-symbol-word-search t evil-symbol-word-search t
;; cursor appearance ;; cursor appearance
evil-default-cursor '+evil-default-cursor evil-default-cursor '+evil-default-cursor-fn
evil-normal-state-cursor 'box evil-normal-state-cursor 'box
evil-emacs-state-cursor '(box +evil-emacs-cursor) evil-emacs-state-cursor '(box +evil-emacs-cursor-fn)
evil-insert-state-cursor 'bar evil-insert-state-cursor 'bar
evil-visual-state-cursor 'hollow evil-visual-state-cursor 'hollow
;; must be set before evil/evil-collection is loaded ;; must be set before evil/evil-collection is loaded
@ -53,11 +53,11 @@ directives. By default, this only recognizes C directives.")
(advice-add #'help-with-tutorial :after (lambda (&rest _) (evil-emacs-state +1))) (advice-add #'help-with-tutorial :after (lambda (&rest _) (evil-emacs-state +1)))
;; Done in a hook to ensure the popup rules load as late as possible ;; Done in a hook to ensure the popup rules load as late as possible
(defun +evil|init-popup-rules () (add-hook 'doom-init-modules-hook
(set-popup-rules! (defun +evil--init-popup-rules-h ()
'(("^\\*evil-registers" :size 0.3) (set-popup-rules!
("^\\*Command Line" :size 8)))) '(("^\\*evil-registers" :size 0.3)
(add-hook 'doom-init-modules-hook #'+evil|init-popup-rules) ("^\\*Command Line" :size 8)))))
;; Change the cursor color in emacs state. We do it this roundabout way ;; Change the cursor color in emacs state. We do it this roundabout way
;; instead of changing `evil-default-cursor' (or `evil-emacs-state-cursor') so ;; instead of changing `evil-default-cursor' (or `evil-emacs-state-cursor') so
@ -65,19 +65,17 @@ directives. By default, this only recognizes C directives.")
(defvar +evil--default-cursor-color "#ffffff") (defvar +evil--default-cursor-color "#ffffff")
(defvar +evil--emacs-cursor-color "#ff9999") (defvar +evil--emacs-cursor-color "#ff9999")
(defun +evil|update-cursor-color () (add-hook 'doom-load-theme-hook
(setq +evil--default-cursor-color (face-background 'cursor) (defun +evil-update-cursor-color-h ()
+evil--emacs-cursor-color (face-foreground 'warning))) (setq +evil--default-cursor-color (face-background 'cursor)
(add-hook 'doom-load-theme-hook #'+evil|update-cursor-color) +evil--emacs-cursor-color (face-foreground 'warning))))
(defun +evil-default-cursor () (defun +evil-default-cursor-fn ()
(evil-set-cursor-color +evil--default-cursor-color)) (evil-set-cursor-color +evil--default-cursor-color))
(defun +evil-emacs-cursor () (defun +evil-emacs-cursor-fn ()
(evil-set-cursor-color +evil--emacs-cursor-color)) (evil-set-cursor-color +evil--emacs-cursor-color))
(defun +evil|update-shift-width () (setq-hook! 'after-change-major-mode-hook evil-shift-width tab-width)
(setq evil-shift-width tab-width))
(add-hook 'after-change-major-mode-hook #'+evil|update-shift-width)
;; --- keybind fixes ---------------------- ;; --- keybind fixes ----------------------
@ -86,26 +84,26 @@ directives. By default, this only recognizes C directives.")
;; `evil-delete' in wgrep buffers. ;; `evil-delete' in wgrep buffers.
(define-key wgrep-mode-map [remap evil-delete] #'+evil-delete)) (define-key wgrep-mode-map [remap evil-delete] #'+evil-delete))
(defun +evil|disable-highlights () (add-hook 'doom-escape-hook
"Disable ex search buffer highlights." (defun +evil-disable-ex-highlights-h ()
(when (evil-ex-hl-active-p 'evil-ex-search) "Disable ex search buffer highlights."
(evil-ex-nohighlight) (when (evil-ex-hl-active-p 'evil-ex-search)
t)) (evil-ex-nohighlight)
(add-hook 'doom-escape-hook #'+evil|disable-highlights) t)))
;; --- evil hacks ------------------------- ;; --- evil hacks -------------------------
(defun +evil|display-vimlike-save-message ()
"Shorter, vim-esque save messages."
(message "\"%s\" %dL, %dC written"
(if buffer-file-name
(file-relative-name (file-truename buffer-file-name) (doom-project-root))
(buffer-name))
(count-lines (point-min) (point-max))
(buffer-size)))
(unless noninteractive (unless noninteractive
(setq save-silently t) (setq save-silently t)
(add-hook 'after-save-hook #'+evil|display-vimlike-save-message)) (add-hook 'after-save-hook
(defun +evil-display-vimlike-save-message-h ()
"Shorter, vim-esque save messages."
(message "\"%s\" %dL, %dC written"
(if buffer-file-name
(file-relative-name (file-truename buffer-file-name) (doom-project-root))
(buffer-name))
(count-lines (point-min) (point-max))
(buffer-size)))))
;; Make ESC (from normal mode) the universal escaper. See `doom-escape-hook'. ;; Make ESC (from normal mode) the universal escaper. See `doom-escape-hook'.
(advice-add #'evil-force-normal-state :after #'+evil-escape-a) (advice-add #'evil-force-normal-state :after #'+evil-escape-a)
;; Don't move cursor when indenting ;; Don't move cursor when indenting
@ -116,7 +114,7 @@ directives. By default, this only recognizes C directives.")
(advice-add #'evil-ex-replace-special-filenames :override #'+evil-resolve-vim-path-a) (advice-add #'evil-ex-replace-special-filenames :override #'+evil-resolve-vim-path-a)
;; make `try-expand-dabbrev' (from `hippie-expand') work in minibuffer ;; make `try-expand-dabbrev' (from `hippie-expand') work in minibuffer
(add-hook 'minibuffer-inactive-mode-hook #'+evil--fix-dabbrev-in-minibuffer-a) (add-hook 'minibuffer-inactive-mode-hook #'+evil--fix-dabbrev-in-minibuffer-h)
;; Focus and recenter new splits ;; Focus and recenter new splits
(advice-add #'evil-window-split :override #'+evil-window-split-a) (advice-add #'evil-window-split :override #'+evil-window-split-a)
@ -201,20 +199,20 @@ directives. By default, this only recognizes C directives.")
:hook ((ruby-mode enh-ruby-mode) . embrace-ruby-mode-hook) :hook ((ruby-mode enh-ruby-mode) . embrace-ruby-mode-hook)
:hook (emacs-lisp-mode . embrace-emacs-lisp-mode-hook) :hook (emacs-lisp-mode . embrace-emacs-lisp-mode-hook)
:hook ((lisp-mode emacs-lisp-mode clojure-mode racket-mode) :hook ((lisp-mode emacs-lisp-mode clojure-mode racket-mode)
. +evil|embrace-lisp-mode-hook) . +evil-embrace-lisp-mode-hook-h)
:hook ((org-mode LaTeX-mode) . +evil|embrace-latex-mode-hook) :hook ((org-mode LaTeX-mode) . +evil-embrace-latex-mode-hook-h)
:hook ((c++-mode rust-mode rustic-mode csharp-mode java-mode swift-mode typescript-mode) :hook ((c++-mode rust-mode rustic-mode csharp-mode java-mode swift-mode typescript-mode)
. +evil|embrace-angle-bracket-modes-hook) . +evil-embrace-angle-bracket-modes-hook-h)
:init :init
(after! evil-surround (after! evil-surround
(evil-embrace-enable-evil-surround-integration)) (evil-embrace-enable-evil-surround-integration))
:config :config
(setq evil-embrace-show-help-p nil) (setq evil-embrace-show-help-p nil)
(defun +evil|embrace-latex-mode-hook () (defun +evil-embrace-latex-mode-hook-h ()
(embrace-add-pair-regexp ?l "\\[a-z]+{" "}" #'+evil--embrace-latex)) (embrace-add-pair-regexp ?l "\\[a-z]+{" "}" #'+evil--embrace-latex))
(defun +evil|embrace-lisp-mode-hook () (defun +evil-embrace-lisp-mode-hook-h ()
(push (cons ?f (make-embrace-pair-struct (push (cons ?f (make-embrace-pair-struct
:key ?f :key ?f
:read-function #'+evil--embrace-elisp-fn :read-function #'+evil--embrace-elisp-fn
@ -222,7 +220,7 @@ directives. By default, this only recognizes C directives.")
:right-regexp ")")) :right-regexp ")"))
embrace--pairs-list)) embrace--pairs-list))
(defun +evil|embrace-angle-bracket-modes-hook () (defun +evil-embrace-angle-bracket-modes-hook-h ()
(set (make-local-variable 'evil-embrace-evil-surround-keys) (set (make-local-variable 'evil-embrace-evil-surround-keys)
(delq ?< evil-embrace-evil-surround-keys)) (delq ?< evil-embrace-evil-surround-keys))
(push (cons ?< (make-embrace-pair-struct (push (cons ?< (make-embrace-pair-struct
@ -260,11 +258,11 @@ directives. By default, this only recognizes C directives.")
(def-package! evil-exchange (def-package! evil-exchange
:commands evil-exchange :commands evil-exchange
:config :config
(defun +evil|escape-exchange () (add-hook 'doom-escape-hook
(when evil-exchange--overlays (defun +evil--escape-exchange-h ()
(evil-exchange-cancel) (when evil-exchange--overlays
t)) (evil-exchange-cancel)
(add-hook 'doom-escape-hook #'+evil|escape-exchange)) t))))
(def-package! evil-snipe (def-package! evil-snipe

View file

@ -39,13 +39,13 @@
;; disable evil-escape in evil-mc; causes unwanted text on invocation ;; disable evil-escape in evil-mc; causes unwanted text on invocation
(add-to-list 'evil-mc-incompatible-minor-modes 'evil-escape-mode nil #'eq) (add-to-list 'evil-mc-incompatible-minor-modes 'evil-escape-mode nil #'eq)
(defun +multiple-cursors|escape-multiple-cursors () (add-hook 'doom-escape-hook
"Clear evil-mc cursors and restore state." (defun +multiple-cursors-escape-multiple-cursors-h ()
(when (evil-mc-has-cursors-p) "Clear evil-mc cursors and restore state."
(evil-mc-undo-all-cursors) (when (evil-mc-has-cursors-p)
(evil-mc-resume-cursors) (evil-mc-undo-all-cursors)
t)) (evil-mc-resume-cursors)
(add-hook 'doom-escape-hook #'+multiple-cursors|escape-multiple-cursors) t)))
;; Forward declare these so that ex completion and evil-mc support is ;; Forward declare these so that ex completion and evil-mc support is
;; recognized before the autoloaded functions are loaded. ;; recognized before the autoloaded functions are loaded.
@ -71,30 +71,30 @@
(defvar +mc--compat-evil-prev-state nil) (defvar +mc--compat-evil-prev-state nil)
(defvar +mc--compat-mark-was-active nil) (defvar +mc--compat-mark-was-active nil)
(defun +multiple-cursors|compat-switch-to-emacs-state () (add-hook 'multiple-cursors-mode-enabled-hook
(when (and (bound-and-true-p evil-mode) (defun +multiple-cursors-compat-switch-to-emacs-state-h ()
(not (memq evil-state '(insert emacs)))) (when (and (bound-and-true-p evil-mode)
(setq +mc--compat-evil-prev-state evil-state) (not (memq evil-state '(insert emacs))))
(when (region-active-p) (setq +mc--compat-evil-prev-state evil-state)
(setq +mc--compat-mark-was-active t)) (when (region-active-p)
(let ((mark-before (mark)) (setq +mc--compat-mark-was-active t))
(point-before (point))) (let ((mark-before (mark))
(evil-emacs-state 1) (point-before (point)))
(when (or +mc--compat-mark-was-active (region-active-p)) (evil-emacs-state 1)
(goto-char point-before) (when (or +mc--compat-mark-was-active (region-active-p))
(set-mark mark-before))))) (goto-char point-before)
(add-hook 'multiple-cursors-mode-enabled-hook #'+multiple-cursors|compat-switch-to-emacs-state) (set-mark mark-before))))))
(defun +multiple-cursors|compat-back-to-previous-state () (add-hook 'multiple-cursors-mode-disabled-hook
(when +mc--compat-evil-prev-state (defun +multiple-cursors-compat-back-to-previous-state-h ()
(unwind-protect (when +mc--compat-evil-prev-state
(case +mc--compat-evil-prev-state (unwind-protect
((normal visual) (evil-force-normal-state)) (case +mc--compat-evil-prev-state
(t (message "Don't know how to handle previous state: %S" ((normal visual) (evil-force-normal-state))
+mc--compat-evil-prev-state))) (t (message "Don't know how to handle previous state: %S"
(setq +mc--compat-evil-prev-state nil) +mc--compat-evil-prev-state)))
(setq +mc--compat-mark-was-active nil)))) (setq +mc--compat-evil-prev-state nil)
(add-hook 'multiple-cursors-mode-disabled-hook #'+multiple-cursors|compat-back-to-previous-state) (setq +mc--compat-mark-was-active nil)))))
;; When running edit-lines, point will return (position + 1) as a result of ;; When running edit-lines, point will return (position + 1) as a result of
;; how evil deals with regions ;; how evil deals with regions
@ -106,10 +106,10 @@
(goto-char (1- (point))) (goto-char (1- (point)))
(push-mark (1- (mark)))))) (push-mark (1- (mark))))))
(defun +multiple-cursors|evil-compat-rect-switch-state () (add-hook 'rectangular-region-mode-hook
(if rectangular-region-mode (defun +multiple-cursors-evil-compat-rect-switch-state-h ()
(+multiple-cursors|compat-switch-to-emacs-state) (if rectangular-region-mode
(setq +mc--compat-evil-prev-state nil))) (+multiple-cursors-compat-switch-to-emacs-state-h)
(add-hook 'rectangular-region-mode-hook '+multiple-cursors|evil-compat-rect-switch-state) (setq +mc--compat-evil-prev-state nil))))
(defvar mc--default-cmds-to-run-once nil))) (defvar mc--default-cmds-to-run-once nil)))

View file

@ -41,20 +41,20 @@
(global-git-commit-mode +1) (global-git-commit-mode +1)
(set-yas-minor-mode! 'git-commit-mode) (set-yas-minor-mode! 'git-commit-mode)
(defun +vc|enforce-git-commit-conventions () (add-hook 'git-commit-mode-hook
"See https://chris.beams.io/posts/git-commit/" (defun +vc--enforce-git-commit-conventions-h ()
(setq fill-column 72 "See https://chris.beams.io/posts/git-commit/"
git-commit-summary-max-length 50 (setq fill-column 72
git-commit-style-convention-checks '(overlong-summary-line non-empty-second-line))) git-commit-summary-max-length 50
(add-hook 'git-commit-mode-hook #'+vc|enforce-git-commit-conventions) git-commit-style-convention-checks '(overlong-summary-line non-empty-second-line))))
(defun +vc|start-in-insert-state-maybe () (add-hook 'git-commit-setup-hook
"Start git-commit-mode in insert state if in a blank commit message, (defun +vc--start-in-insert-state-maybe ()
"Start git-commit-mode in insert state if in a blank commit message,
otherwise in default state." otherwise in default state."
(when (and (bound-and-true-p evil-mode) (when (and (bound-and-true-p evil-mode)
(bobp) (eolp)) (bobp) (eolp))
(evil-insert-state))) (evil-insert-state)))))
(add-hook 'git-commit-setup-hook #'+vc|start-in-insert-state-maybe))
(after! vc-annotate (after! vc-annotate
(set-popup-rules! (set-popup-rules!

View file

@ -106,7 +106,7 @@ if it's callable, `apropos' otherwise."
;;; Hooks ;;; Hooks
;;;###autoload ;;;###autoload
(defun +emacs-lisp|extend-imenu () (defun +emacs-lisp-extend-imenu-h ()
"Improve imenu support in `emacs-lisp-mode', including recognition for Doom's API." "Improve imenu support in `emacs-lisp-mode', including recognition for Doom's API."
(setq imenu-generic-expression (setq imenu-generic-expression
`(("Section" "^[ \t]*;;;;*[ \t]+\\([^\n]+\\)" 1) `(("Section" "^[ \t]*;;;;*[ \t]+\\([^\n]+\\)" 1)
@ -125,7 +125,7 @@ if it's callable, `apropos' otherwise."
("Types" "^\\s-*(\\(cl-def\\(?:struct\\|type\\)\\|def\\(?:class\\|face\\|group\\|ine-\\(?:condition\\|error\\|widget\\)\\|package\\|struct\\|t\\(?:\\(?:hem\\|yp\\)e\\)\\)\\)\\s-+'?\\(\\(?:\\sw\\|\\s_\\|\\\\.\\)+\\)" 2)))) ("Types" "^\\s-*(\\(cl-def\\(?:struct\\|type\\)\\|def\\(?:class\\|face\\|group\\|ine-\\(?:condition\\|error\\|widget\\)\\|package\\|struct\\|t\\(?:\\(?:hem\\|yp\\)e\\)\\)\\)\\s-+'?\\(\\(?:\\sw\\|\\s_\\|\\\\.\\)+\\)" 2))))
;;;###autoload ;;;###autoload
(defun +emacs-lisp|reduce-flycheck-errors-in-emacs-config () (defun +emacs-lisp-reduce-flycheck-errors-in-emacs-config-h ()
"Remove `emacs-lisp-checkdoc' checker and reduce `emacs-lisp' checker "Remove `emacs-lisp-checkdoc' checker and reduce `emacs-lisp' checker
verbosity when editing a file in `doom-private-dir' or `doom-emacs-dir'." verbosity when editing a file in `doom-private-dir' or `doom-emacs-dir'."
(when (and (bound-and-true-p flycheck-mode) (when (and (bound-and-true-p flycheck-mode)

View file

@ -34,6 +34,9 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
("add-hook" "remove-hook") ("add-hook" "remove-hook")
("add-hook!" "remove-hook!"))) ("add-hook!" "remove-hook!")))
;; TODO
(put 'add-hook 'lisp-indent-function 'defun)
(setq-hook! 'emacs-lisp-mode-hook (setq-hook! 'emacs-lisp-mode-hook
tab-width 2 tab-width 2
;; shorter name in modeline ;; shorter name in modeline
@ -51,12 +54,12 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
rainbow-delimiters-mode rainbow-delimiters-mode
highlight-quoted-mode highlight-quoted-mode
;; initialization ;; initialization
+emacs-lisp|extend-imenu)) +emacs-lisp-extend-imenu-h))
;; Flycheck's two emacs-lisp checkers produce a *lot* of false positives in ;; Flycheck's two emacs-lisp checkers produce a *lot* of false positives in
;; emacs configs, so we disable `emacs-lisp-checkdoc' and reduce the ;; emacs configs, so we disable `emacs-lisp-checkdoc' and reduce the
;; `emacs-lisp' checker's verbosity. ;; `emacs-lisp' checker's verbosity.
(add-hook 'flycheck-mode-hook #'+emacs-lisp|reduce-flycheck-errors-in-emacs-config) (add-hook 'flycheck-mode-hook #'+emacs-lisp-reduce-flycheck-errors-in-emacs-config-h)
;; Special fontification for elisp ;; Special fontification for elisp
(font-lock-add-keywords (font-lock-add-keywords

View file

@ -803,9 +803,9 @@ compelling reason, so..."
auto-fill-mode ; hard line wrapping auto-fill-mode ; hard line wrapping
;; `show-paren-mode' causes flickering with indentation margins made by ;; `show-paren-mode' causes flickering with indentation margins made by
;; `org-indent-mode', so we turn off show-paren-mode altogether ;; `org-indent-mode', so we turn off show-paren-mode altogether
doom|disable-show-paren-mode doom-disable-show-paren-mode-h
;; Shows a lot of false positives, so... ;; Shows a lot of false positives, so...
doom|disable-show-trailing-whitespace doom-disable-show-trailing-whitespace-h
+org|enable-auto-reformat-tables +org|enable-auto-reformat-tables
+org|enable-auto-update-cookies +org|enable-auto-update-cookies

View file

@ -50,8 +50,8 @@ called.")
sp-point-before-same-p)) sp-point-before-same-p))
;; Affects pyenv and conda ;; Affects pyenv and conda
(advice-add #'pythonic-activate :after-while #'+modeline|update-env-in-all-windows) (advice-add #'pythonic-activate :after-while #'+modeline-update-env-in-all-windows-h)
(advice-add #'pythonic-deactivate :after #'+modeline|clear-env-in-all-windows) (advice-add #'pythonic-deactivate :after #'+modeline-clear-env-in-all-windows-h)
(setq-hook! 'python-mode-hook tab-width python-indent-offset)) (setq-hook! 'python-mode-hook tab-width python-indent-offset))
@ -165,8 +165,8 @@ called.")
:after python :after python
:init :init
(when (featurep! :ui modeline) (when (featurep! :ui modeline)
(add-hook 'pyvenv-post-activate-hooks #'+modeline|update-env-in-all-windows) (add-hook 'pyvenv-post-activate-hooks #'+modeline-update-env-in-all-windows-h)
(add-hook 'pyvenv-pre-deactivate-hooks #'+modeline|clear-env-in-all-windows)) (add-hook 'pyvenv-pre-deactivate-hooks #'+modeline-clear-env-in-all-windows-h))
:config :config
(add-hook 'hack-local-variables-hook #'pyvenv-track-virtualenv) (add-hook 'hack-local-variables-hook #'pyvenv-track-virtualenv)
(add-to-list 'global-mode-string (add-to-list 'global-mode-string

View file

@ -10,11 +10,11 @@
;; happen once. ;; happen once.
;; ;;
;; rust-mode is still required for `racer'. ;; rust-mode is still required for `racer'.
(defun +rust|init () (add-hook 'rust-mode-hook
"Switch to `rustic-mode', if it's available." (defun +rust-init-h ()
(when (require 'rustic nil t) "Switch to `rustic-mode', if it's available."
(rustic-mode))) (when (require 'rustic nil t)
(add-hook 'rust-mode-hook #'+rust|init) (rustic-mode))))
(set-docsets! '(rust-mode rustic-mode) "Rust") (set-docsets! '(rust-mode rustic-mode) "Rust")
(when (featurep! +lsp) (when (featurep! +lsp)

View file

@ -106,7 +106,7 @@
(evil-change-to-initial-state)) (evil-change-to-initial-state))
(goto-char (point-max))) (goto-char (point-max)))
(with-current-buffer (pop-to-buffer eshell-buffer) (with-current-buffer (pop-to-buffer eshell-buffer)
(doom|mark-buffer-as-real) (doom-mark-buffer-as-real-h)
(if (eq major-mode 'eshell-mode) (if (eq major-mode 'eshell-mode)
(run-hooks 'eshell-mode-hook) (run-hooks 'eshell-mode-hook)
(eshell-mode)) (eshell-mode))

View file

@ -73,7 +73,7 @@ You should use `set-eshell-alias!' to change this.")
eshell-error-if-no-glob t) eshell-error-if-no-glob t)
;; Consider eshell buffers real ;; Consider eshell buffers real
(add-hook 'eshell-mode-hook #'doom|mark-buffer-as-real) (add-hook 'eshell-mode-hook #'doom-mark-buffer-as-real-h)
;; Keep track of open eshell buffers ;; Keep track of open eshell buffers
(add-hook 'eshell-mode-hook #'+eshell|init) (add-hook 'eshell-mode-hook #'+eshell|init)

View file

@ -1,5 +1,5 @@
;;; term/shell/config.el -*- lexical-binding: t; -*- ;;; term/shell/config.el -*- lexical-binding: t; -*-
;;;###package shell ;;;###package shell
(add-hook 'shell-mode-hook #'doom|mark-buffer-as-real) (add-hook 'shell-mode-hook #'doom-mark-buffer-as-real-h)
(add-hook 'shell-mode-hook #'hide-mode-line-mode) (add-hook 'shell-mode-hook #'hide-mode-line-mode)

View file

@ -36,7 +36,7 @@ If prefix ARG, recreate the term buffer."
(goto-char (point-max))) (goto-char (point-max)))
(setenv "PROOT" (or (doom-project-root) default-directory)) (setenv "PROOT" (or (doom-project-root) default-directory))
(with-current-buffer buffer (with-current-buffer buffer
(doom|mark-buffer-as-real) (doom-mark-buffer-as-real-h)
(multi-term-internal)) (multi-term-internal))
(unless (window-live-p window) (unless (window-live-p window)
(when-let (window (when-let (window

View file

@ -5,5 +5,5 @@
multi-term-switch-after-close 'PREVIOUS) multi-term-switch-after-close 'PREVIOUS)
;;;###package term ;;;###package term
(add-hook 'term-mode-hook #'doom|mark-buffer-as-real) (add-hook 'term-mode-hook #'doom-mark-buffer-as-real-h)
(add-hook 'term-mode-hook #'hide-mode-line-mode) (add-hook 'term-mode-hook #'hide-mode-line-mode)

View file

@ -33,7 +33,7 @@ If prefix ARG is non-nil, recreate vterm buffer in the current project's root."
(setenv "PROOT" (or (doom-project-root) default-directory)) (setenv "PROOT" (or (doom-project-root) default-directory))
(let ((buffer (get-buffer-create buffer-name))) (let ((buffer (get-buffer-create buffer-name)))
(with-current-buffer buffer (with-current-buffer buffer
(doom|mark-buffer-as-real) (doom-mark-buffer-as-real-h)
(vterm-mode)) (vterm-mode))
(pop-to-buffer buffer))))) (pop-to-buffer buffer)))))

View file

@ -7,7 +7,7 @@
:config :config
(set-popup-rule! "^vterm" :size 0.25 :vslot -4 :select t :quit nil :ttl 0) (set-popup-rule! "^vterm" :size 0.25 :vslot -4 :select t :quit nil :ttl 0)
(add-hook 'vterm-mode-hook #'doom|mark-buffer-as-real) (add-hook 'vterm-mode-hook #'doom-mark-buffer-as-real-h)
;; Automatically kill buffer when vterm exits. ;; Automatically kill buffer when vterm exits.
(add-to-list 'vterm-exit-functions (lambda (buffer) (if buffer (kill-buffer buffer)))) (add-to-list 'vterm-exit-functions (lambda (buffer) (if buffer (kill-buffer buffer))))
;; Modeline serves no purpose in vterm ;; Modeline serves no purpose in vterm

View file

@ -23,15 +23,15 @@
(def-package! lsp-ui (def-package! lsp-ui
:hook (lsp-mode . lsp-ui-mode) :hook (lsp-mode . lsp-ui-mode)
:init :init
(defun +lsp|init-ui-flycheck-or-flymake () (add-hook 'lsp-ui-mode-hook
"Sets up flymake-mode or flycheck-mode, depending on `lsp-prefer-flymake'." (defun +lsp-init-ui-flycheck-or-flymake-h ()
(unless (eq :none lsp-prefer-flymake) "Sets up flymake-mode or flycheck-mode, depending on `lsp-prefer-flymake'."
(if (and (not (version< emacs-version "26.1")) (unless (eq :none lsp-prefer-flymake)
lsp-prefer-flymake) (if (and (not (version< emacs-version "26.1"))
(lsp--flymake-setup)) lsp-prefer-flymake)
(require 'lsp-ui-flycheck) (lsp--flymake-setup))
(lsp-ui-flycheck-enable t))) (require 'lsp-ui-flycheck)
(add-hook 'lsp-ui-mode-hook #'+lsp|init-ui-flycheck-or-flymake) (lsp-ui-flycheck-enable t))))
:config :config
(setq lsp-prefer-flymake nil (setq lsp-prefer-flymake nil
lsp-ui-doc-max-height 8 lsp-ui-doc-max-height 8
@ -52,11 +52,11 @@
:init :init
;; Make sure that `company-capf' is disabled since it is incompatible with ;; Make sure that `company-capf' is disabled since it is incompatible with
;; `company-lsp' (see lsp-mode#884) ;; `company-lsp' (see lsp-mode#884)
(defun +lsp|init-company () (add-hook 'lsp-mode-hook
(if (not (bound-and-true-p company-mode)) (defun +lsp-init-company-h ()
(add-hook 'company-mode-hook #'+lsp|init-company t t) (if (not (bound-and-true-p company-mode))
(setq-local company-backends (add-hook 'company-mode-hook #'+lsp-init-company-h t t)
(setq-local company-backends
(cons 'company-lsp (cons 'company-lsp
(remq 'company-capf company-backends))) (remq 'company-capf company-backends)))
(remove-hook 'company-mode-hook #'+lsp|init-company t))) (remove-hook 'company-mode-hook #'+lsp-init-company-h t)))))
(add-hook 'lsp-mode-hook #'+lsp|init-company))

View file

@ -1,7 +1,7 @@
;;; tools/magit/autoload.el -*- lexical-binding: t; -*- ;;; tools/magit/autoload.el -*- lexical-binding: t; -*-
;;;###autoload ;;;###autoload
(defun +magit-display-buffer (buffer) (defun +magit-display-buffer-fn (buffer)
"Marries `magit-display-buffer-fullcolumn-most-v1' with "Marries `magit-display-buffer-fullcolumn-most-v1' with
`magit-display-buffer-same-window-except-diff-v1', except: `magit-display-buffer-same-window-except-diff-v1', except:

View file

@ -32,7 +32,7 @@ It is passed a user and repository name.")
;; 2. The status screen isn't buried when viewing diffs or logs from the ;; 2. The status screen isn't buried when viewing diffs or logs from the
;; status screen. ;; status screen.
(setq transient-display-buffer-action '(display-buffer-below-selected) (setq transient-display-buffer-action '(display-buffer-below-selected)
magit-display-buffer-function #'+magit-display-buffer) magit-display-buffer-function #'+magit-display-buffer-fn)
(set-popup-rule! "^\\(?:\\*magit\\|magit:\\| \\*transient\\*\\)" :ignore t) (set-popup-rule! "^\\(?:\\*magit\\|magit:\\| \\*transient\\*\\)" :ignore t)
;; Add --tags switch ;; Add --tags switch
@ -40,11 +40,11 @@ It is passed a user and repository name.")
"-p" '("-t" "Fetch all tags" ("-t" "--tags"))) "-p" '("-t" "Fetch all tags" ("-t" "--tags")))
;; so magit buffers can be switched to (except for process buffers) ;; so magit buffers can be switched to (except for process buffers)
(defun +magit-buffer-p (buf) (add-hook 'doom-real-buffer-functions
(with-current-buffer buf (defun +magit-buffer-p (buf)
(and (derived-mode-p 'magit-mode) (with-current-buffer buf
(not (eq major-mode 'magit-process-mode))))) (and (derived-mode-p 'magit-mode)
(add-to-list 'doom-real-buffer-functions #'+magit-buffer-p nil #'eq) (not (eq major-mode 'magit-process-mode))))))
;; properly kill leftover magit buffers on quit ;; properly kill leftover magit buffers on quit
(define-key magit-status-mode-map [remap magit-mode-bury-buffer] #'+magit/quit) (define-key magit-status-mode-map [remap magit-mode-bury-buffer] #'+magit/quit)

View file

@ -102,7 +102,7 @@ PLIST can have the following properties:
;; ;;
;;; Bootstrap ;;; Bootstrap
(defun +doom-dashboard|init () (defun +doom-dashboard-init-h ()
"Initializes Doom's dashboard." "Initializes Doom's dashboard."
(unless noninteractive (unless noninteractive
;; Ensure the dashboard becomes Emacs' go-to buffer when there's nothing ;; Ensure the dashboard becomes Emacs' go-to buffer when there's nothing
@ -112,19 +112,19 @@ PLIST can have the following properties:
(when (equal (buffer-name) "*scratch*") (when (equal (buffer-name) "*scratch*")
(set-window-buffer nil (doom-fallback-buffer)) (set-window-buffer nil (doom-fallback-buffer))
(if (daemonp) (if (daemonp)
(add-hook 'after-make-frame-functions #'+doom-dashboard|reload-frame) (add-hook 'after-make-frame-functions #'+doom-dashboard-reload-frame-h)
(+doom-dashboard-reload))) (+doom-dashboard-reload)))
;; Ensure the dashboard is up-to-date whenever it is switched to or resized. ;; Ensure the dashboard is up-to-date whenever it is switched to or resized.
(add-hook 'window-configuration-change-hook #'+doom-dashboard|resize) (add-hook 'window-configuration-change-hook #'+doom-dashboard-resize-h)
(add-hook 'window-size-change-functions #'+doom-dashboard|resize) (add-hook 'window-size-change-functions #'+doom-dashboard-resize-h)
(add-hook 'doom-switch-buffer-hook #'+doom-dashboard|reload-maybe) (add-hook 'doom-switch-buffer-hook #'+doom-dashboard-reload-maybe-h)
(add-hook 'delete-frame-functions #'+doom-dashboard|reload-frame) (add-hook 'delete-frame-functions #'+doom-dashboard-reload-frame-h)
;; `persp-mode' integration: update `default-directory' when switching perspectives ;; `persp-mode' integration: update `default-directory' when switching perspectives
(add-hook 'persp-created-functions #'+doom-dashboard|record-project) (add-hook 'persp-created-functions #'+doom-dashboard--persp-record-project-h)
(add-hook 'persp-activated-functions #'+doom-dashboard|detect-project) (add-hook 'persp-activated-functions #'+doom-dashboard--persp-detect-project-h)
(add-hook 'persp-before-switch-functions #'+doom-dashboard|record-project))) (add-hook 'persp-before-switch-functions #'+doom-dashboard--persp-record-project-h)))
(add-hook 'doom-init-ui-hook #'+doom-dashboard|init) (add-hook 'doom-init-ui-hook #'+doom-dashboard-init-h)
;; ;;
@ -148,7 +148,7 @@ PLIST can have the following properties:
collect (cons car nil) into alist collect (cons car nil) into alist
finally do (setq fringe-indicator-alist alist)) finally do (setq fringe-indicator-alist alist))
;; Ensure point is always on a button ;; Ensure point is always on a button
(add-hook 'post-command-hook #'+doom-dashboard|reposition-point nil t)) (add-hook 'post-command-hook #'+doom-dashboard-reposition-point-h nil t))
(define-key! +doom-dashboard-mode-map (define-key! +doom-dashboard-mode-map
[left-margin mouse-1] #'ignore [left-margin mouse-1] #'ignore
@ -185,7 +185,7 @@ PLIST can have the following properties:
;; ;;
;;; Hooks ;;; Hooks
(defun +doom-dashboard|reposition-point () (defun +doom-dashboard-reposition-point-h ()
"Trap the point in the buttons." "Trap the point in the buttons."
(when (region-active-p) (when (region-active-p)
(setq deactivate-mark t) (setq deactivate-mark t)
@ -198,7 +198,7 @@ PLIST can have the following properties:
(progn (goto-char (point-min)) (progn (goto-char (point-min))
(forward-button 1)))) (forward-button 1))))
(defun +doom-dashboard|reload-maybe () (defun +doom-dashboard-reload-maybe-h ()
"Reload the dashboard or its state. "Reload the dashboard or its state.
If this isn't a dashboard buffer, move along, but record its `default-directory' If this isn't a dashboard buffer, move along, but record its `default-directory'
@ -214,14 +214,14 @@ If this is the dashboard buffer, reload it completely."
(setq +doom-dashboard--last-cwd default-directory) (setq +doom-dashboard--last-cwd default-directory)
(+doom-dashboard-update-pwd)))) (+doom-dashboard-update-pwd))))
(defun +doom-dashboard|reload-frame (_frame) (defun +doom-dashboard-reload-frame-h (_frame)
"Reload the dashboard after a brief pause. This is necessary for new frames, "Reload the dashboard after a brief pause. This is necessary for new frames,
whose dimensions may not be fully initialized by the time this is run." whose dimensions may not be fully initialized by the time this is run."
(when (timerp +doom-dashboard--reload-timer) (when (timerp +doom-dashboard--reload-timer)
(cancel-timer +doom-dashboard--reload-timer)) ; in case this function is run rapidly (cancel-timer +doom-dashboard--reload-timer)) ; in case this function is run rapidly
(setq +doom-dashboard--reload-timer (run-with-timer 0.1 nil #'+doom-dashboard-reload t))) (setq +doom-dashboard--reload-timer (run-with-timer 0.1 nil #'+doom-dashboard-reload t)))
(defun +doom-dashboard|resize (&rest _) (defun +doom-dashboard-resize-h (&rest _)
"Recenter the dashboard, and reset its margins and fringes." "Recenter the dashboard, and reset its margins and fringes."
(let (buffer-list-update-hook (let (buffer-list-update-hook
window-configuration-change-hook window-configuration-change-hook
@ -247,20 +247,20 @@ whose dimensions may not be fully initialized by the time this is run."
2)))) 2))))
?\n))))))))) ?\n)))))))))
(defun +doom-dashboard|detect-project (&rest _) (defun +doom-dashboard--persp-detect-project-h (&rest _)
"Check for a `last-project-root' parameter in the perspective, and set the "Check for a `last-project-root' parameter in the perspective, and set the
dashboard's `default-directory' to it if it exists. dashboard's `default-directory' to it if it exists.
This and `+doom-dashboard|record-project' provides `persp-mode' integration with This and `+doom-dashboard--persp-record-project-h' provides `persp-mode' integration with
the Doom dashboard. It ensures that the dashboard is always in the correct the Doom dashboard. It ensures that the dashboard is always in the correct
project (which may be different across perspective)." project (which may be different across perspective)."
(when (bound-and-true-p persp-mode) (when (bound-and-true-p persp-mode)
(when-let (pwd (persp-parameter 'last-project-root)) (when-let (pwd (persp-parameter 'last-project-root))
(+doom-dashboard-update-pwd pwd)))) (+doom-dashboard-update-pwd pwd))))
(defun +doom-dashboard|record-project (&optional persp &rest _) (defun +doom-dashboard--persp-record-project-h (&optional persp &rest _)
"Record the last `doom-project-root' for the current perspective. See "Record the last `doom-project-root' for the current perspective. See
`+doom-dashboard|detect-project' for more information." `+doom-dashboard--persp-detect-project-h' for more information."
(when (bound-and-true-p persp-mode) (when (bound-and-true-p persp-mode)
(set-persp-parameter (set-persp-parameter
'last-project-root (doom-project-root) 'last-project-root (doom-project-root)
@ -305,9 +305,9 @@ controlled by `+doom-dashboard-pwd-policy'."
(erase-buffer) (erase-buffer)
(run-hooks '+doom-dashboard-functions) (run-hooks '+doom-dashboard-functions)
(goto-char pt) (goto-char pt)
(+doom-dashboard|reposition-point)) (+doom-dashboard-reposition-point-h))
(+doom-dashboard|resize) (+doom-dashboard-resize-h)
(+doom-dashboard|detect-project) (+doom-dashboard--persp-detect-project-h)
(+doom-dashboard-update-pwd) (+doom-dashboard-update-pwd)
(current-buffer))))) (current-buffer)))))
@ -387,7 +387,7 @@ controlled by `+doom-dashboard-pwd-policy'."
(propertize (propertize
(+doom-dashboard--center (+doom-dashboard--center
+doom-dashboard--width +doom-dashboard--width
(doom|display-benchmark 'return)) (doom-display-benchmark-h 'return))
'face 'font-lock-comment-face) 'face 'font-lock-comment-face)
"\n")) "\n"))

View file

@ -22,11 +22,11 @@
"A list of quit messages, picked randomly by `+doom-quit'. Taken from "A list of quit messages, picked randomly by `+doom-quit'. Taken from
http://doom.wikia.com/wiki/Quit_messages and elsewhere.") http://doom.wikia.com/wiki/Quit_messages and elsewhere.")
(defun +doom-quit (&rest _) (defun +doom-quit-fn (&rest _)
(doom-quit-p (doom-quit-p
(format "%s Quit?" (format "%s Quit?"
(nth (random (length +doom-quit-messages)) (nth (random (length +doom-quit-messages))
+doom-quit-messages)))) +doom-quit-messages))))
;; ;;
(setq confirm-kill-emacs #'+doom-quit) (setq confirm-kill-emacs #'+doom-quit-fn)

View file

@ -44,15 +44,16 @@
(def-package! solaire-mode (def-package! solaire-mode
:defer t :defer t
:init :init
(defun +doom|solaire-mode-swap-bg-maybe () (add-hook 'doom-load-theme-hook
(when-let (rule (assq doom-theme +doom-solaire-themes)) (defun +doom--solaire-mode-swap-bg-maybe-h ()
(require 'solaire-mode) (when-let (rule (assq doom-theme +doom-solaire-themes))
(when (cdr rule) (require 'solaire-mode)
(solaire-mode-swap-bg) (when (cdr rule)
(with-eval-after-load 'ansi-color (solaire-mode-swap-bg)
(when-let (color (face-background 'default)) (with-eval-after-load 'ansi-color
(setf (aref ansi-color-names-vector 0) color)))))) (when-let (color (face-background 'default))
(add-hook 'doom-load-theme-hook #'+doom|solaire-mode-swap-bg-maybe t) (setf (aref ansi-color-names-vector 0) color))))))
'append)
:config :config
;; fringe can become unstyled when deleting or focusing frames ;; fringe can become unstyled when deleting or focusing frames
(add-hook 'focus-in-hook #'solaire-mode-reset) (add-hook 'focus-in-hook #'solaire-mode-reset)
@ -67,7 +68,7 @@
;; the hl-line face, hl-line's highlight bleeds into the rest of the window ;; the hl-line face, hl-line's highlight bleeds into the rest of the window
;; after eob. ;; after eob.
(when EMACS26+ (when EMACS26+
(defun +doom--line-range () (defun +doom--line-range-fn ()
(cons (line-beginning-position) (cons (line-beginning-position)
(cond ((let ((eol (line-end-position))) (cond ((let ((eol (line-end-position)))
(and (= eol (point-max)) (and (= eol (point-max))
@ -77,21 +78,21 @@
(= (line-end-position 2) (point-max))) (= (line-end-position 2) (point-max)))
(line-end-position)) (line-end-position))
((line-beginning-position 2))))) ((line-beginning-position 2)))))
(setq hl-line-range-function #'+doom--line-range)) (setq hl-line-range-function #'+doom--line-range-fn))
;; Because fringes can't be given a buffer-local face, they can look odd, so ;; Because fringes can't be given a buffer-local face, they can look odd, so
;; we remove them in the minibuffer and which-key popups (they serve no ;; we remove them in the minibuffer and which-key popups (they serve no
;; purpose there anyway). ;; purpose there anyway).
(defun +doom|disable-fringes-in-minibuffer (&rest _) (add-hook 'solaire-mode-hook
(set-window-fringes (minibuffer-window) 0 0 nil)) (defun +doom-disable-fringes-in-minibuffer-h (&rest _)
(add-hook 'solaire-mode-hook #'+doom|disable-fringes-in-minibuffer) (set-window-fringes (minibuffer-window) 0 0 nil)))
(def-advice! +doom--no-fringes-in-which-key-buffer-a (&rest _) (def-advice! +doom--no-fringes-in-which-key-buffer-a (&rest _)
:after 'which-key--show-buffer-side-window :after 'which-key--show-buffer-side-window
(+doom--disable-fringes-in-minibuffer-h) (+doom-disable-fringes-in-minibuffer-h)
(set-window-fringes (get-buffer-window which-key--buffer) 0 0 nil)) (set-window-fringes (get-buffer-window which-key--buffer) 0 0 nil))
(add-hook! '(minibuffer-setup-hook window-configuration-change-hook) (add-hook! '(minibuffer-setup-hook window-configuration-change-hook)
#'+doom|disable-fringes-in-minibuffer) #'+doom-disable-fringes-in-minibuffer-h)
(solaire-global-mode +1)) (solaire-global-mode +1))

View file

@ -10,6 +10,15 @@
;; Use a more primitive todo-keyword detection method in major modes that ;; Use a more primitive todo-keyword detection method in major modes that
;; don't use/have a valid syntax table entry for comments. ;; don't use/have a valid syntax table entry for comments.
(add-hook! (add-hook! '(pug-mode-hook haml-mode-hook)
(pug-mode haml-mode) (defun +hl-todo--use-face-detection-h ()
#'+hl-todo|use-face-detection)) "Use a different, more primitive method of locating todo keywords."
(set (make-local-variable 'hl-todo-keywords)
'(((lambda (limit)
(let (case-fold-search)
(and (re-search-forward hl-todo-regexp limit t)
(memq 'font-lock-comment-face (doom-enlist (get-text-property (point) 'face))))))
(1 (hl-todo-get-face) t t))))
(when hl-todo-mode
(hl-todo-mode -1)
(hl-todo-mode +1)))))

View file

@ -6,10 +6,8 @@
(setq highlight-indent-guides-method 'character) (setq highlight-indent-guides-method 'character)
:config :config
(add-hook 'focus-in-hook #'highlight-indent-guides-auto-set-faces) (add-hook 'focus-in-hook #'highlight-indent-guides-auto-set-faces)
(defun +indent-guides|disable-maybe ()
(when highlight-indent-guides-mode
(highlight-indent-guides-mode -1)))
;; `highlight-indent-guides' breaks in these modes ;; `highlight-indent-guides' breaks in these modes
(add-hook 'visual-line-mode-hook #'+indent-guides|disable-maybe) (add-hook! '(visual-line-mode-hook org-indent-mode-hook)
(add-hook 'org-indent-mode-hook #'+indent-guides|disable-maybe)) (defun +indent-guides-disable-maybe-h ()
(when highlight-indent-guides-mode
(highlight-indent-guides-mode -1)))))

View file

@ -12,7 +12,7 @@
(defvar +modeline--old-bar-height nil) (defvar +modeline--old-bar-height nil)
;;;###autoload ;;;###autoload
(defun +modeline|resize-for-font () (defun +modeline--resize-for-font-h ()
"Adjust the modeline's height when the font size is changed by "Adjust the modeline's height when the font size is changed by
`doom/increase-font-size' or `doom/decrease-font-size'. `doom/increase-font-size' or `doom/decrease-font-size'.
@ -33,7 +33,7 @@ Meant for `doom-change-font-size-hook'."
(unless EMACS26+ (doom-modeline-refresh-bars)))) (unless EMACS26+ (doom-modeline-refresh-bars))))
;;;###autoload ;;;###autoload
(defun +modeline|update-env-in-all-windows (&rest _) (defun +modeline-update-env-in-all-windows-h (&rest _)
"Update version strings in all buffers." "Update version strings in all buffers."
(dolist (window (window-list)) (dolist (window (window-list))
(with-selected-window window (with-selected-window window
@ -41,7 +41,7 @@ Meant for `doom-change-font-size-hook'."
(force-mode-line-update)))) (force-mode-line-update))))
;;;###autoload ;;;###autoload
(defun +modeline|clear-env-in-all-windows (&rest _) (defun +modeline-clear-env-in-all-windows-h (&rest _)
"Blank out version strings in all buffers." "Blank out version strings in all buffers."
(dolist (buffer (buffer-list)) (dolist (buffer (buffer-list))
(with-current-buffer buffer (with-current-buffer buffer

View file

@ -32,17 +32,17 @@
(add-hook 'doom-modeline-mode-hook #'size-indication-mode) ; filesize in modeline (add-hook 'doom-modeline-mode-hook #'size-indication-mode) ; filesize in modeline
(add-hook 'doom-modeline-mode-hook #'column-number-mode) ; cursor column in modeline (add-hook 'doom-modeline-mode-hook #'column-number-mode) ; cursor column in modeline
(add-hook 'doom-change-font-size-hook #'+modeline|resize-for-font) (add-hook 'doom-change-font-size-hook #'+modeline--resize-for-font-h)
(add-hook 'doom-load-theme-hook #'doom-modeline-refresh-bars) (add-hook 'doom-load-theme-hook #'doom-modeline-refresh-bars)
(add-hook '+doom-dashboard-mode-hook #'doom-modeline-set-project-modeline) (add-hook '+doom-dashboard-mode-hook #'doom-modeline-set-project-modeline)
(defun +modeline|hide-in-non-status-buffer () (add-hook 'magit-mode-hook
"Show minimal modeline in magit-status buffer, no modeline elsewhere." (defun +modeline--hide-in-non-status-buffer-h ()
(if (eq major-mode 'magit-status-mode) "Show minimal modeline in magit-status buffer, no modeline elsewhere."
(doom-modeline-set-project-modeline) (if (eq major-mode 'magit-status-mode)
(hide-mode-line-mode))) (doom-modeline-set-project-modeline)
(add-hook 'magit-mode-hook #'+modeline|hide-in-non-status-buffer) (hide-mode-line-mode))))
;; Remove unused segments & extra padding ;; Remove unused segments & extra padding
(doom-modeline-def-modeline 'main (doom-modeline-def-modeline 'main

View file

@ -24,17 +24,16 @@ or triggered from one of `+nav-flash-exclude-commands'."
(setq +nav-flash--last-point (cons (point-marker) (selected-window))))) (setq +nav-flash--last-point (cons (point-marker) (selected-window)))))
;;;###autoload ;;;###autoload
(defun +nav-flash|delayed-blink-cursor (&rest _) (defun +nav-flash-delayed-blink-cursor-h (&rest _)
"Like `+nav-flash-blink-cursor', but links after a tiny pause, in case it "Like `+nav-flash-blink-cursor', but links after a tiny pause, in case it
isn't clear at run-time if the point will be in the correct window/buffer (like isn't clear at run-time if the point will be in the correct window/buffer (like
for `org-follow-link-hook')." for `org-follow-link-hook')."
(run-at-time 0.1 nil #'+nav-flash|blink-cursor)) (run-at-time 0.1 nil #'+nav-flash-blink-cursor-h))
;;;###autoload ;;;###autoload
(defalias '+nav-flash|blink-cursor #'+nav-flash-blink-cursor) (defalias '+nav-flash-blink-cursor-h #'+nav-flash-blink-cursor)
;;;###autoload ;;;###autoload
(defalias '+nav-flash|blink-cursor-maybe #'+nav-flash-blink-cursor-maybe) (defalias '+nav-flash-blink-cursor-maybe-h #'+nav-flash-blink-cursor-maybe)
;;;###autoload ;;;###autoload
(defalias '+nav-flash-blink-cursor-a #'+nav-flash-blink-cursor-maybe) (defalias '+nav-flash-blink-cursor-a #'+nav-flash-blink-cursor-maybe)

View file

@ -13,12 +13,12 @@
(add-hook! (add-hook!
'(imenu-after-jump-hook better-jumper-post-jump-hook '(imenu-after-jump-hook better-jumper-post-jump-hook
counsel-grep-post-action-hook dumb-jump-after-jump-hook) counsel-grep-post-action-hook dumb-jump-after-jump-hook)
#'+nav-flash|blink-cursor-maybe) #'+nav-flash-blink-cursor-maybe-h)
(add-hook 'doom-switch-window-hook #'+nav-flash|blink-cursor-maybe) (add-hook 'doom-switch-window-hook #'+nav-flash-blink-cursor-maybe-h)
;; `org' ;; `org'
(add-hook 'org-follow-link-hook #'+nav-flash|delayed-blink-cursor) (add-hook 'org-follow-link-hook #'+nav-flash-delayed-blink-cursor-h)
;; `saveplace' ;; `saveplace'
(advice-add #'save-place-find-file-hook :after #'+nav-flash-blink-cursor-a) (advice-add #'save-place-find-file-hook :after #'+nav-flash-blink-cursor-a)

View file

@ -42,14 +42,13 @@
(after! winner (after! winner
(add-to-list 'winner-boring-buffers neo-buffer-name)) (add-to-list 'winner-boring-buffers neo-buffer-name))
;; The cursor always sits at bol. `+neotree*fix-cursor' and ;; The cursor always sits at bol. `+neotree--fix-cursor-h' and
;; `+neotree*indent-cursor' change that behavior, so that the cursor is always ;; `+neotree--indent-cursor-a' change that behavior so that the cursor is
;; on the first non-blank character on the line, in the neo buffer. ;; always on the first non-blank character on the line, in the neo buffer.
(defun +neotree*fix-cursor (&rest _) (add-hook 'neo-enter-hook
(with-current-buffer neo-global--buffer (defun +neotree--fix-cursor-h (&rest _)
(+neotree*indent-cursor))) (with-current-buffer neo-global--buffer
(add-hook 'neo-enter-hook #'+neotree*fix-cursor) (+neotree*indent-cursor))))
(def-advice! +neotree--indent-cursor-a (&rest _) (def-advice! +neotree--indent-cursor-a (&rest _)
:after '(neotree-next-line neotree-previous-line) :after '(neotree-next-line neotree-previous-line)
(beginning-of-line) (beginning-of-line)

View file

@ -22,34 +22,34 @@ to the right fringe.")
(def-package! git-gutter (def-package! git-gutter
:commands (git-gutter:revert-hunk git-gutter:stage-hunk) :commands (git-gutter:revert-hunk git-gutter:stage-hunk)
:init :init
(defun +vc-gutter|init-maybe () (add-hook! '(text-mode-hook prog-mode-hook conf-mode-hook)
"Enable `git-gutter-mode' in the current buffer. (defun +vc-gutter-init-maybe-h ()
"Enable `git-gutter-mode' in the current buffer.
If the buffer doesn't represent an existing file, `git-gutter-mode's activation If the buffer doesn't represent an existing file, `git-gutter-mode's activation
is deferred until the file is saved. Respects `git-gutter:disabled-modes'." is deferred until the file is saved. Respects `git-gutter:disabled-modes'."
(when (or +vc-gutter-in-remote-files (when (or +vc-gutter-in-remote-files
(not (file-remote-p (or buffer-file-name default-directory)))) (not (file-remote-p (or buffer-file-name default-directory))))
(if (not buffer-file-name) (if (not buffer-file-name)
(add-hook 'after-save-hook #'+vc-gutter|init-maybe nil t) (add-hook 'after-save-hook #'+vc-gutter-init-maybe-h nil t)
(when (and (vc-backend buffer-file-name) (when (and (vc-backend buffer-file-name)
(progn (progn
(require 'git-gutter) (require 'git-gutter)
(not (memq major-mode git-gutter:disabled-modes)))) (not (memq major-mode git-gutter:disabled-modes))))
(if (and (display-graphic-p) (if (and (display-graphic-p)
(require 'git-gutter-fringe nil t)) (require 'git-gutter-fringe nil t))
(progn (progn
(setq-local git-gutter:init-function #'git-gutter-fr:init) (setq-local git-gutter:init-function #'git-gutter-fr:init)
(setq-local git-gutter:view-diff-function #'git-gutter-fr:view-diff-infos) (setq-local git-gutter:view-diff-function #'git-gutter-fr:view-diff-infos)
(setq-local git-gutter:clear-function #'git-gutter-fr:clear) (setq-local git-gutter:clear-function #'git-gutter-fr:clear)
(setq-local git-gutter:window-width -1)) (setq-local git-gutter:window-width -1))
(setq-local git-gutter:init-function 'nil) (setq-local git-gutter:init-function 'nil)
(setq-local git-gutter:view-diff-function #'git-gutter:view-diff-infos) (setq-local git-gutter:view-diff-function #'git-gutter:view-diff-infos)
(setq-local git-gutter:clear-function #'git-gutter:clear-diff-infos) (setq-local git-gutter:clear-function #'git-gutter:clear-diff-infos)
(setq-local git-gutter:window-width 1)) (setq-local git-gutter:window-width 1))
(git-gutter-mode +1) (git-gutter-mode +1)
(remove-hook 'after-save-hook #'+vc-gutter|init-maybe t))))) (remove-hook 'after-save-hook #'+vc-gutter-init-maybe-h t))))))
(add-hook! (text-mode prog-mode conf-mode)
#'+vc-gutter|init-maybe)
;; standardize default fringe width ;; standardize default fringe width
(if (fboundp 'fringe-mode) (fringe-mode '4)) (if (fboundp 'fringe-mode) (fringe-mode '4))
:config :config
@ -58,16 +58,15 @@ is deferred until the file is saved. Respects `git-gutter:disabled-modes'."
;; Update git-gutter on focus (in case I was using git externally) ;; Update git-gutter on focus (in case I was using git externally)
(add-hook 'focus-in-hook #'git-gutter:update-all-windows) (add-hook 'focus-in-hook #'git-gutter:update-all-windows)
(defun +vc-gutter|update (&rest _) (add-hook! :append '(doom-escape-hook doom-switch-window-hook)
"Refresh git-gutter on ESC. Return nil to prevent shadowing other (defun +vc-gutter-update-h (&rest _)
"Refresh git-gutter on ESC. Return nil to prevent shadowing other
`doom-escape-hook' hooks." `doom-escape-hook' hooks."
(when git-gutter-mode (when git-gutter-mode
(ignore (git-gutter)))) (ignore (git-gutter)))))
(add-hook 'doom-escape-hook #'+vc-gutter|update t)
;; update git-gutter when using magit commands ;; update git-gutter when using magit commands
(advice-add #'magit-stage-file :after #'+vc-gutter|update) (advice-add #'magit-stage-file :after #'+vc-gutter-update-h)
(advice-add #'magit-unstage-file :after #'+vc-gutter|update)) (advice-add #'magit-unstage-file :after #'+vc-gutter-update-h))
;; subtle diff indicators in the fringe ;; subtle diff indicators in the fringe