💥 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:
parent
51d3b1b424
commit
149b2617b0
58 changed files with 521 additions and 517 deletions
2
bin/doom
2
bin/doom
|
@ -77,7 +77,7 @@
|
|||
nil 'nomessage)
|
||||
|
||||
(cond ((not noninteractive)
|
||||
(doom|run-all-startup-hooks))
|
||||
(doom-run-all-startup-hooks-h))
|
||||
((and (not (cdr args))
|
||||
(member (car args) '("help" "h")))
|
||||
(usage))
|
||||
|
|
|
@ -250,7 +250,7 @@ regex PATTERN. Returns the number of killed buffers."
|
|||
;; Hooks
|
||||
|
||||
;;;###autoload
|
||||
(defun doom|mark-buffer-as-real ()
|
||||
(defun doom-mark-buffer-as-real-h ()
|
||||
"Hook function that marks the current buffer as real."
|
||||
(doom-set-buffer-real (current-buffer) t))
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ to persist across Emacs sessions.")
|
|||
name under `pcache-directory' (by default a subdirectory under
|
||||
`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
|
||||
listed in `doom-cache-alists' to files."
|
||||
(dolist (alist (butlast doom-cache-alists 1))
|
||||
|
@ -29,7 +29,7 @@ listed in `doom-cache-alists' to files."
|
|||
for var in (cdr alist)
|
||||
if (symbol-value var)
|
||||
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)
|
||||
|
||||
|
||||
;;
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
;;; 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
|
||||
(defvar doom-reloading-p nil
|
||||
"TODO")
|
||||
|
@ -72,16 +76,6 @@ Uses the same mechanism as 'bin/doom env reload'."
|
|||
(error "Failed to generate 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
|
||||
(defun doom/reload-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)))
|
||||
(let (doom--prefer-theme-elc)
|
||||
(load-theme doom-theme t)))
|
||||
(doom|init-fonts)))
|
||||
(doom-init-fonts-h)))
|
||||
|
|
|
@ -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)))
|
||||
doom-modules)
|
||||
(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
|
||||
`((setq doom-private-dir "/tmp/does/not/exist"
|
||||
doom-init-modules-p t)
|
||||
(load-file ,user-init-file)
|
||||
(doom|run-all-startup-hooks)))
|
||||
(doom-run-all-startup-hooks-h)))
|
||||
(`vanilla ; nothing loaded
|
||||
`((package-initialize)))))))
|
||||
"\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
|
||||
esup-server-port
|
||||
esup-depth)
|
||||
"--eval=(doom|run-all-startup-hooks)"))))
|
||||
"--eval=(doom-run-all-startup-hooks-h)"))))
|
||||
(when esup-run-as-batch-p
|
||||
(setq process-args (append process-args '("--batch"))))
|
||||
(setq esup-child-process (apply #'start-process process-args)))
|
||||
|
|
|
@ -65,6 +65,15 @@ FRAME parameter defaults to current frame."
|
|||
;;
|
||||
;;; 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
|
||||
(defun doom/increase-font-size (count)
|
||||
"Enlargens the font size across the current frame."
|
||||
|
|
|
@ -54,7 +54,7 @@ following:
|
|||
(when (and (eq major-mode 'fundamental-mode)
|
||||
(functionp 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))
|
||||
buffer)))
|
||||
|
||||
|
@ -63,7 +63,7 @@ following:
|
|||
;;; Persistent scratch buffer
|
||||
|
||||
;;;###autoload
|
||||
(defun doom|persist-scratch-buffer ()
|
||||
(defun doom-persist-scratch-buffer-h ()
|
||||
"Save the current buffer to `doom-scratch-dir'."
|
||||
(write-region
|
||||
(point-min) (point-max)
|
||||
|
@ -71,16 +71,16 @@ following:
|
|||
doom-scratch-dir)))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom|persist-scratch-buffers ()
|
||||
(defun doom-persist-scratch-buffers-h ()
|
||||
"Save all scratch buffers to `doom-scratch-dir'."
|
||||
(setq doom-scratch-buffers (cl-delete-if-not #'buffer-live-p doom-scratch-buffers))
|
||||
(dolist (buffer doom-scratch-buffers)
|
||||
(with-current-buffer buffer
|
||||
(doom|persist-scratch-buffer))))
|
||||
(doom-persist-scratch-buffer-h))))
|
||||
|
||||
;;;###autoload
|
||||
(unless noninteractive
|
||||
(add-hook 'kill-emacs-hook #'doom|persist-scratch-buffers))
|
||||
(add-hook 'kill-emacs-hook #'doom-persist-scratch-buffers-h))
|
||||
|
||||
|
||||
;;
|
||||
|
|
|
@ -211,25 +211,25 @@ Respects `require-final-newline'."
|
|||
;; Hooks
|
||||
|
||||
;;;###autoload
|
||||
(defun doom|enable-delete-trailing-whitespace ()
|
||||
(defun doom-enable-delete-trailing-whitespace-h ()
|
||||
"Enables the automatic deletion of trailing whitespaces upon file save.
|
||||
|
||||
i.e. enables `ws-butler-mode' in the current buffer."
|
||||
(ws-butler-mode +1))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom|disable-delete-trailing-whitespace ()
|
||||
(defun doom-disable-delete-trailing-whitespace-h ()
|
||||
"Disables the automatic deletion of trailing whitespaces upon file save.
|
||||
|
||||
i.e. disables `ws-butler-mode' in the current buffer."
|
||||
(ws-butler-mode -1))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom|enable-show-trailing-whitespace ()
|
||||
(defun doom-enable-show-trailing-whitespace-h ()
|
||||
"Enable `show-trailing-whitespace' in the current buffer."
|
||||
(setq-local show-trailing-whitespace t))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom|disable-show-trailing-whitespace ()
|
||||
(defun doom-disable-show-trailing-whitespace-h ()
|
||||
"Disable `show-trailing-whitespace' in the current buffer."
|
||||
(setq-local show-trailing-whitespace nil))
|
||||
|
|
|
@ -41,14 +41,14 @@ are open."
|
|||
;; Hooks
|
||||
|
||||
;;;###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
|
||||
`compilation-filter-hook'."
|
||||
(with-silent-modifications
|
||||
(ansi-color-apply-on-region compilation-filter-start (point))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom|disable-show-paren-mode ()
|
||||
(defun doom-disable-show-paren-mode-h ()
|
||||
"Turn off `show-paren-mode' buffer-locally."
|
||||
(setq-local show-paren-mode nil))
|
||||
|
||||
|
|
|
@ -1,16 +1,5 @@
|
|||
;;; 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
|
||||
"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
|
||||
|
@ -74,10 +63,10 @@ detected.")
|
|||
|
||||
(def-package! autorevert
|
||||
;; revert buffers when their files/state have changed
|
||||
:hook (focus-in . doom|auto-revert-buffers)
|
||||
:hook (after-save . doom|auto-revert-buffers)
|
||||
:hook (doom-switch-buffer . doom|auto-revert-buffer)
|
||||
:hook (doom-switch-window . doom|auto-revert-buffer)
|
||||
:hook (focus-in . doom-auto-revert-buffers-h)
|
||||
:hook (after-save . doom-auto-revert-buffers-h)
|
||||
:hook (doom-switch-buffer . doom-auto-revert-buffer-h)
|
||||
:hook (doom-switch-window . doom-auto-revert-buffer-h)
|
||||
:config
|
||||
(setq auto-revert-verbose t ; let us know when it happens
|
||||
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
|
||||
;; 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.
|
||||
(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)."
|
||||
(unless auto-revert-mode
|
||||
(dolist (buf (doom-visible-buffers))
|
||||
(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
|
||||
;; Keep track of recently opened files
|
||||
|
@ -126,19 +117,18 @@ detected.")
|
|||
file))
|
||||
(setq recentf-filename-handlers '(doom--recent-file-truename abbreviate-file-name))
|
||||
|
||||
(defun doom|recentf-touch-buffer ()
|
||||
"Bump file in recent file list when it is switched or written to."
|
||||
(when buffer-file-name
|
||||
(recentf-add-file buffer-file-name))
|
||||
;; Return nil for `write-file-functions'
|
||||
nil)
|
||||
(add-hook 'doom-switch-window-hook #'doom|recentf-touch-buffer)
|
||||
(add-hook 'write-file-functions #'doom|recentf-touch-buffer)
|
||||
(add-hook! '(doom-switch-window-hook write-file-functions)
|
||||
(defun doom--recentf-touch-buffer-h ()
|
||||
"Bump file in recent file list when it is switched or written to."
|
||||
(when buffer-file-name
|
||||
(recentf-add-file buffer-file-name))
|
||||
;; Return nil for `write-file-functions'
|
||||
nil))
|
||||
|
||||
(defun doom|recentf-add-dired-directory ()
|
||||
"Add dired directory to recentf file list."
|
||||
(recentf-add-file default-directory))
|
||||
(add-hook 'dired-mode-hook #'doom|recentf-add-dired-directory)
|
||||
(add-hook 'dired-mode-hook
|
||||
(defun doom--recentf-add-dired-directory-h ()
|
||||
"Add dired directory to recentf file list."
|
||||
(recentf-add-file default-directory)))
|
||||
|
||||
(unless noninteractive
|
||||
(add-hook 'kill-emacs-hook #'recentf-cleanup)
|
||||
|
@ -155,14 +145,14 @@ detected.")
|
|||
savehist-additional-variables '(kill-ring search-ring regexp-search-ring))
|
||||
(savehist-mode +1)
|
||||
|
||||
(defun doom|unpropertize-kill-ring ()
|
||||
"Remove text properties from `kill-ring' in the interest of shrinking the
|
||||
savehist file."
|
||||
(setq kill-ring (cl-loop for item in kill-ring
|
||||
if (stringp item)
|
||||
collect (substring-no-properties item)
|
||||
else if item collect it)))
|
||||
(add-hook 'kill-emacs-hook #'doom|unpropertize-kill-ring))
|
||||
(add-hook 'kill-emacs-hook
|
||||
(defun doom-unpropertize-kill-ring-h ()
|
||||
"Remove text properties from `kill-ring' for a smaller savehist file."
|
||||
(setq kill-ring (cl-loop for item in kill-ring
|
||||
if (stringp item)
|
||||
collect (substring-no-properties item)
|
||||
else if item collect it)))))
|
||||
|
||||
|
||||
(def-package! saveplace
|
||||
;; persistent point location in buffers
|
||||
|
@ -223,7 +213,7 @@ savehist file."
|
|||
origin))))
|
||||
result))
|
||||
|
||||
(defun doom|set-jump ()
|
||||
(defun doom-set-jump-h ()
|
||||
"Run `better-jumper-set-jump' but return nil, for short-circuiting hooks."
|
||||
(better-jumper-set-jump)
|
||||
nil))
|
||||
|
@ -243,16 +233,15 @@ savehist file."
|
|||
:unless noninteractive
|
||||
:defer t
|
||||
: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)
|
||||
#'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
|
||||
(setq dtrt-indent-run-after-smie t)
|
||||
|
||||
|
@ -323,12 +312,12 @@ savehist file."
|
|||
sp-escape-quotes-after-insert nil) ; not smart enough
|
||||
|
||||
;; autopairing in `eval-expression' and `evil-ex'
|
||||
(defun doom|init-smartparens-in-eval-expression ()
|
||||
"Enable `smartparens-mode' in the minibuffer, during `eval-expression' or
|
||||
(add-hook 'minibuffer-setup-hook
|
||||
(defun doom--init-smartparens-in-eval-expression-h ()
|
||||
"Enable `smartparens-mode' in the minibuffer, during `eval-expression' or
|
||||
`evil-ex'."
|
||||
(when (memq this-command '(eval-expression evil-ex))
|
||||
(smartparens-mode)))
|
||||
(add-hook 'minibuffer-setup-hook #'doom|init-smartparens-in-eval-expression)
|
||||
(when (memq this-command '(eval-expression evil-ex))
|
||||
(smartparens-mode))))
|
||||
|
||||
(sp-local-pair 'minibuffer-inactive-mode "'" nil :actions nil)
|
||||
(sp-local-pair 'minibuffer-inactive-mode "`" nil :actions nil)
|
||||
|
|
|
@ -157,20 +157,20 @@ localleader prefix."
|
|||
|
||||
;; Bind `doom-leader-key' and `doom-leader-alt-key' as late as possible to give
|
||||
;; the user a chance to modify them.
|
||||
(defun doom|init-leader-keys ()
|
||||
"Bind `doom-leader-key' and `doom-leader-alt-key'."
|
||||
(let ((map general-override-mode-map))
|
||||
(if (not (featurep 'evil))
|
||||
(progn
|
||||
(cond ((equal doom-leader-alt-key "C-c")
|
||||
(set-keymap-parent doom-leader-map mode-specific-map))
|
||||
((equal doom-leader-alt-key "C-x")
|
||||
(set-keymap-parent doom-leader-map ctl-x-map)))
|
||||
(define-key map (kbd doom-leader-alt-key) 'doom/leader))
|
||||
(evil-define-key* '(normal visual motion) map (kbd doom-leader-key) 'doom/leader)
|
||||
(evil-define-key* '(emacs insert) map (kbd doom-leader-alt-key) 'doom/leader))
|
||||
(general-override-mode +1)))
|
||||
(add-hook 'doom-after-init-modules-hook #'doom|init-leader-keys)
|
||||
(add-hook 'doom-after-init-modules-hook
|
||||
(defun doom-init-leader-keys-h ()
|
||||
"Bind `doom-leader-key' and `doom-leader-alt-key'."
|
||||
(let ((map general-override-mode-map))
|
||||
(if (not (featurep 'evil))
|
||||
(progn
|
||||
(cond ((equal doom-leader-alt-key "C-c")
|
||||
(set-keymap-parent doom-leader-map mode-specific-map))
|
||||
((equal doom-leader-alt-key "C-x")
|
||||
(set-keymap-parent doom-leader-map ctl-x-map)))
|
||||
(define-key map (kbd doom-leader-alt-key) 'doom/leader))
|
||||
(evil-define-key* '(normal visual motion) map (kbd doom-leader-key) 'doom/leader)
|
||||
(evil-define-key* '(emacs insert) map (kbd doom-leader-alt-key) 'doom/leader))
|
||||
(general-override-mode +1))))
|
||||
|
||||
|
||||
;;
|
||||
|
|
|
@ -176,8 +176,8 @@ advised)."
|
|||
(declare (indent 1))
|
||||
(let ((append (if (eq (car forms) :after) (pop forms)))
|
||||
(fn (if (symbolp (car forms))
|
||||
(intern (format "doom|transient-hook-%s" (pop forms)))
|
||||
(make-symbol "doom|transient-hook"))))
|
||||
(intern (format "doom--transient-%s-h" (pop forms)))
|
||||
(make-symbol "doom--transient-h"))))
|
||||
`(let ((sym ,hook-or-function))
|
||||
(fset ',fn
|
||||
(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
|
||||
modes, a quoted hook variable or a quoted list of hook variables. If
|
||||
unquoted, '-hook' will be appended to each symbol.
|
||||
3. The function(s) to be added: this can be one function, a list thereof, or
|
||||
body forms (implicitly wrapped in a closure).
|
||||
3. The function(s) to be added: this can be one function, a list thereof, a
|
||||
list of `defun's, or body forms (implicitly wrapped in a closure).
|
||||
|
||||
Examples:
|
||||
(add-hook! 'some-mode-hook 'enable-something) (same as `add-hook')
|
||||
|
@ -226,15 +226,23 @@ Examples:
|
|||
(:append (setq append-p t))
|
||||
(:local (setq local-p t))
|
||||
(:remove (setq hook-fn 'remove-hook))))
|
||||
(let ((hooks (doom--resolve-hook-forms (pop args)))
|
||||
(funcs
|
||||
(let ((val (car args)))
|
||||
(if (memq (car-safe val) '(quote function))
|
||||
(if (cdr-safe (cadr val))
|
||||
(cadr val)
|
||||
(list (cadr val)))
|
||||
(list args))))
|
||||
forms)
|
||||
(let* ((defun-forms nil)
|
||||
(hooks (doom--resolve-hook-forms (pop args)))
|
||||
(funcs
|
||||
(let ((val (car args)))
|
||||
(if (memq (car-safe val) '(quote function))
|
||||
(if (cdr-safe (cadr val))
|
||||
(cadr val)
|
||||
(list (cadr val)))
|
||||
(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)
|
||||
(setq fn (if (symbolp fn)
|
||||
`(function ,fn)
|
||||
|
@ -244,7 +252,9 @@ Examples:
|
|||
`(remove-hook ',hook ,fn ,local-p)
|
||||
`(add-hook ',hook ,fn ,append-p ,local-p))
|
||||
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)
|
||||
"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
|
||||
(cl-loop for hook in (doom--resolve-hook-forms hooks)
|
||||
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
|
||||
(lambda (&rest _)
|
||||
,@(let (forms)
|
||||
|
@ -330,7 +340,7 @@ The available conditions are:
|
|||
(not (or (listp files)
|
||||
(stringp files))))
|
||||
(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
|
||||
(fset ',hook-name
|
||||
(lambda ()
|
||||
|
@ -414,7 +424,7 @@ all themes. It will apply to all themes once they are loaded.
|
|||
'(org-ellipsis :inherit org-tag)
|
||||
'(which-key-docstring-face :inherit font-lock-comment-face))"
|
||||
`(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
|
||||
(lambda ()
|
||||
(dolist (theme themes)
|
||||
|
|
|
@ -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)
|
||||
(if (plist-get state :demand)
|
||||
(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
|
||||
`((fset ',fn
|
||||
(lambda (&rest _)
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
(unless IS-LINUX (setq command-line-x-option-alist nil))
|
||||
|
||||
;; 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 (require 'osx-clipboard nil t) (osx-clipboard-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
|
||||
(add-hook 'tty-setup-hook #'xterm-mouse-mode)
|
||||
|
|
|
@ -57,29 +57,29 @@ Emacs.")
|
|||
;; projectile's cache (into the hundreds of MBs). This purges those entries
|
||||
;; when exiting Emacs to prevent slowdowns/freezing when cache files are
|
||||
;; loaded or written to.
|
||||
(defun doom|cleanup-project-cache ()
|
||||
"Purge projectile cache entries that:
|
||||
(add-hook 'kill-emacs-hook
|
||||
(defun doom-cleanup-project-cache-h ()
|
||||
"Purge projectile cache entries that:
|
||||
|
||||
a) have too many files (see `doom-projectile-cache-limit'),
|
||||
b) represent blacklisted directories that are too big, change too often or are
|
||||
private. (see `doom-projectile-cache-blacklist'),
|
||||
c) are not valid projectile projects."
|
||||
(when (bound-and-true-p projectile-projects-cache)
|
||||
(cl-loop with blacklist = (mapcar #'file-truename doom-projectile-cache-blacklist)
|
||||
for proot in (hash-table-keys projectile-projects-cache)
|
||||
if (or (not (stringp proot))
|
||||
(>= (length (gethash proot projectile-projects-cache))
|
||||
doom-projectile-cache-limit)
|
||||
(member (substring proot 0 -1) blacklist)
|
||||
(and doom-projectile-cache-purge-non-projects
|
||||
(not (doom-project-p proot))))
|
||||
do (doom-log "Removed %S from projectile cache" proot)
|
||||
and do (remhash proot projectile-projects-cache)
|
||||
and do (remhash proot projectile-projects-cache-time)
|
||||
and do (remhash proot projectile-project-type-cache))
|
||||
(projectile-serialize-cache)))
|
||||
(unless noninteractive
|
||||
(add-hook 'kill-emacs-hook #'doom|cleanup-project-cache))
|
||||
(when (and (bound-and-true-p projectile-projects-cache)
|
||||
(not noninteractive))
|
||||
(cl-loop with blacklist = (mapcar #'file-truename doom-projectile-cache-blacklist)
|
||||
for proot in (hash-table-keys projectile-projects-cache)
|
||||
if (or (not (stringp proot))
|
||||
(>= (length (gethash proot projectile-projects-cache))
|
||||
doom-projectile-cache-limit)
|
||||
(member (substring proot 0 -1) blacklist)
|
||||
(and doom-projectile-cache-purge-non-projects
|
||||
(not (doom-project-p proot))))
|
||||
do (doom-log "Removed %S from projectile cache" proot)
|
||||
and do (remhash proot projectile-projects-cache)
|
||||
and do (remhash proot projectile-projects-cache-time)
|
||||
and do (remhash proot projectile-project-type-cache))
|
||||
(projectile-serialize-cache))))
|
||||
|
||||
;; 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
|
||||
|
|
100
core/core-ui.el
100
core/core-ui.el
|
@ -53,7 +53,7 @@ size.")
|
|||
|
||||
(defvar doom--prefer-theme-elc nil
|
||||
"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-frame nil)
|
||||
|
||||
(defun doom|run-switch-window-hooks ()
|
||||
(let ((gc-cons-threshold doom-gc-cons-upper-limit))
|
||||
(defun doom-run-switch-window-hooks-h ()
|
||||
(let ((gc-cons-threshold most-positive-fixnum))
|
||||
(unless (or doom-inhibit-switch-window-hooks
|
||||
(eq doom--last-window (selected-window))
|
||||
(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)
|
||||
(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
|
||||
(eq doom--last-frame (selected-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'."
|
||||
(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.
|
||||
|
||||
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
|
||||
;; faster (implemented in C). But try to only enable it in editing buffers.
|
||||
(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,
|
||||
;; `window-divider' does not. Available since Emacs 25.1.
|
||||
|
@ -279,23 +279,22 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
|
|||
:config
|
||||
(defvar doom--ediff-saved-wconf nil)
|
||||
;; Restore window config after quitting ediff
|
||||
(defun doom|ediff-save-wconf ()
|
||||
(setq doom--ediff-saved-wconf (current-window-configuration)))
|
||||
(add-hook 'ediff-before-setup-hook #'doom|ediff-save-wconf)
|
||||
|
||||
(defun doom|ediff-restore-wconf ()
|
||||
(when (window-configuration-p doom--ediff-saved-wconf)
|
||||
(set-window-configuration doom--ediff-saved-wconf)))
|
||||
(add-hook 'ediff-quit-hook #'doom|ediff-restore-wconf 'append)
|
||||
(add-hook 'ediff-suspend-hook #'doom|ediff-restore-wconf 'append))
|
||||
(add-hook 'ediff-before-setup-hook
|
||||
(defun doom--ediff-save-wconf-h ()
|
||||
(setq doom--ediff-saved-wconf (current-window-configuration))))
|
||||
(add-hook! '(ediff-quit-hook ediff-suspend-hook)
|
||||
(defun doom--ediff-restore-wconf-h ()
|
||||
(when (window-configuration-p doom--ediff-saved-wconf)
|
||||
(set-window-configuration doom--ediff-saved-wconf)))
|
||||
'append))
|
||||
|
||||
|
||||
(def-package! hl-line
|
||||
;; Highlights the current line
|
||||
:hook ((prog-mode text-mode conf-mode) . hl-line-mode)
|
||||
:config
|
||||
;; I don't need hl-line showing in other windows. This also offers a small
|
||||
;; speed boost when buffer is displayed in multiple windows.
|
||||
;; PERF Not having to render the hl-line overlay in multiple buffers offers a
|
||||
;; tiny performance boost. I also don't need to see it in other buffers.
|
||||
(setq 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.
|
||||
(after! evil
|
||||
(defvar doom-buffer-hl-line-mode nil)
|
||||
|
||||
(defun doom|disable-hl-line ()
|
||||
(when hl-line-mode
|
||||
(setq-local doom-buffer-hl-line-mode t)
|
||||
(hl-line-mode -1)))
|
||||
(add-hook 'evil-visual-state-entry-hook #'doom|disable-hl-line)
|
||||
|
||||
(defun doom|enable-hl-line-maybe ()
|
||||
(when doom-buffer-hl-line-mode
|
||||
(hl-line-mode +1)))
|
||||
(add-hook 'evil-visual-state-exit-hook #'doom|enable-hl-line-maybe)))
|
||||
(add-hook 'evil-visual-state-entry-hook
|
||||
(defun doom-disable-hl-line-h ()
|
||||
(when hl-line-mode
|
||||
(setq-local doom-buffer-hl-line-mode t)
|
||||
(hl-line-mode -1))))
|
||||
(add-hook 'evil-visual-state-exit-hook
|
||||
(defun doom-enable-hl-line-maybe-h ()
|
||||
(when doom-buffer-hl-line-mode
|
||||
(hl-line-mode +1))))))
|
||||
|
||||
|
||||
(def-package! winner
|
||||
|
@ -366,8 +363,8 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
|
|||
"")))
|
||||
|
||||
;;;###package hide-mode-line-mode
|
||||
(add-hook 'completion-list-mode-hook #'hide-mode-line-mode)
|
||||
(add-hook 'Man-mode-hook #'hide-mode-line-mode)
|
||||
(add-hook! '(completion-list-mode-hook Man-mode-hook)
|
||||
#'hide-mode-line-mode)
|
||||
|
||||
;; Better fontification of number literals in code
|
||||
(def-package! highlight-numbers
|
||||
|
@ -384,10 +381,11 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
|
|||
;;; Line numbers
|
||||
|
||||
;; 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|disable-line-numbers () (display-line-numbers-mode -1))
|
||||
(defun doom-enable-line-numbers-h () (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.
|
||||
(def-package! nlinum
|
||||
|
@ -432,12 +430,12 @@ character that looks like a space that `whitespace-mode' won't affect.")
|
|||
str))
|
||||
(setq nlinum-format-function #'doom-nlinum-format-fn)
|
||||
|
||||
(defun doom|init-nlinum-width ()
|
||||
"Calculate line number column width beforehand (optimization)."
|
||||
(setq nlinum--width
|
||||
(length (save-excursion (goto-char (point-max))
|
||||
(format-mode-line "%l")))))
|
||||
(add-hook 'nlinum-mode-hook #'doom|init-nlinum-width))
|
||||
(add-hook 'nlinum-mode-hook
|
||||
(defun doom--init-nlinum-width-h ()
|
||||
"Calculate line number column width beforehand (optimization)."
|
||||
(setq nlinum--width
|
||||
(length (save-excursion (goto-char (point-max))
|
||||
(format-mode-line "%l")))))))
|
||||
|
||||
(def-package! nlinum-hl
|
||||
;; 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
|
||||
|
||||
(defun doom|init-fonts ()
|
||||
(defun doom-init-fonts-h ()
|
||||
"Loads fonts.
|
||||
|
||||
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))
|
||||
(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).
|
||||
|
||||
By default, this uses Apple Color Emoji on MacOS and Symbola on Linux."
|
||||
(when doom-unicode-font
|
||||
(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."
|
||||
(when (and doom-theme (not (memq doom-theme custom-enabled-themes)))
|
||||
(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
|
||||
|
||||
(defun doom|init-ui ()
|
||||
(defun doom-init-ui-h ()
|
||||
"Initialize Doom's user interface by applying all its advice and hooks."
|
||||
(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-hook 'after-change-major-mode-hook #'doom|highlight-non-default-indentation)
|
||||
(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-h)
|
||||
|
||||
;; Initialize custom switch-{buffer,window,frame} hooks:
|
||||
;; + `doom-switch-buffer-hook'
|
||||
;; + `doom-switch-window-hook'
|
||||
;; + `doom-switch-frame-hook'
|
||||
(add-hook 'buffer-list-update-hook #'doom|run-switch-window-hooks)
|
||||
(add-hook 'focus-in-hook #'doom|run-switch-frame-hooks)
|
||||
(add-hook 'buffer-list-update-hook #'doom-run-switch-window-hooks-h)
|
||||
(add-hook 'focus-in-hook #'doom-run-switch-frame-hooks-h)
|
||||
(dolist (fn '(switch-to-next-buffer switch-to-prev-buffer))
|
||||
(advice-add fn :around #'doom-run-switch-to-next-prev-buffer-hooks-a))
|
||||
(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)
|
||||
'after-make-frame-functions
|
||||
'doom-init-ui-hook)
|
||||
#'doom|init-theme)
|
||||
#'doom-init-theme-h)
|
||||
;; 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
|
||||
(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)
|
||||
|
||||
|
||||
;;
|
||||
|
|
72
core/core.el
72
core/core.el
|
@ -231,7 +231,7 @@ original value of `symbol-file'."
|
|||
`auto-mode-alist'. All elements of this alist are checked, meaning you can
|
||||
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'."
|
||||
(when (and buffer-file-name doom-auto-minor-mode-alist)
|
||||
(let ((name buffer-file-name)
|
||||
|
@ -247,7 +247,7 @@ enable multiple minor modes for the same regexp.")
|
|||
(if (string-match-p (caar alist) name)
|
||||
(funcall (cdar alist) 1))
|
||||
(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
|
||||
;; have run. If you want hook functions to be aware of these customizations, add
|
||||
;; them to MODE-local-vars-hook instead.
|
||||
(defun doom|run-local-var-hooks ()
|
||||
"Run MODE-local-vars-hook after local variables are initialized."
|
||||
(run-hook-wrapped (intern-soft (format "%s-local-vars-hook" major-mode))
|
||||
#'doom-try-run-hook))
|
||||
(add-hook 'hack-local-variables-hook #'doom|run-local-var-hooks)
|
||||
(add-hook 'hack-local-variables-hook
|
||||
(defun doom-run-local-var-hooks-h ()
|
||||
"Run MODE-local-vars-hook after local variables are initialized."
|
||||
(run-hook-wrapped (intern-soft (format "%s-local-vars-hook" major-mode))
|
||||
#'doom-try-run-hook)))
|
||||
|
||||
;; If `enable-local-variables' is disabled, then `hack-local-variables-hook' is
|
||||
;; never triggered.
|
||||
(defun doom|run-local-var-hooks-if-necessary ()
|
||||
"Run `doom|run-local-var-hooks' if `enable-local-variables' is disabled."
|
||||
(unless enable-local-variables
|
||||
(doom|run-local-var-hooks)))
|
||||
(add-hook 'after-change-major-mode-hook #'doom|run-local-var-hooks-if-necessary 'append)
|
||||
(add-hook 'after-change-major-mode-hook
|
||||
(defun doom-run-local-var-hooks-if-necessary-h ()
|
||||
"Run `doom-run-local-var-hooks-h' if `enable-local-variables' is disabled."
|
||||
(unless enable-local-variables
|
||||
(doom-run-local-var-hooks-h)))
|
||||
'append)
|
||||
|
||||
(defun doom|create-non-existent-directories ()
|
||||
"Automatically create missing directories when creating new files."
|
||||
(let ((parent-directory (file-name-directory buffer-file-name)))
|
||||
(when (and (not (file-exists-p parent-directory))
|
||||
(y-or-n-p (format "Directory `%s' does not exist! Create it?" parent-directory)))
|
||||
(make-directory parent-directory t))))
|
||||
(add-hook 'find-file-not-found-functions #'doom|create-non-existent-directories)
|
||||
(add-hook 'find-file-not-found-functions
|
||||
(defun doom-create-missing-directories-h ()
|
||||
"Automatically create missing directories when creating new files."
|
||||
(let ((parent-directory (file-name-directory buffer-file-name)))
|
||||
(when (and (not (file-exists-p parent-directory))
|
||||
(y-or-n-p (format "Directory `%s' does not exist! Create it?" parent-directory)))
|
||||
(make-directory parent-directory t)))))
|
||||
|
||||
|
||||
;;
|
||||
|
@ -297,7 +298,7 @@ broken up into:
|
|||
This is already done by the lang/org module, however.
|
||||
|
||||
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.")
|
||||
|
||||
(defvar doom-incremental-first-idle-timer 2
|
||||
|
@ -333,18 +334,17 @@ intervals."
|
|||
reqs t)
|
||||
(doom-log "Finished incremental loading")))))))
|
||||
|
||||
(defun doom|load-packages-incrementally ()
|
||||
"Begin incrementally loading packages in `doom-incremental-packages'.
|
||||
(add-hook 'window-setup-hook
|
||||
(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 (daemonp)
|
||||
(mapc #'require (cdr doom-incremental-packages))
|
||||
(when (integerp doom-incremental-first-idle-timer)
|
||||
(run-with-idle-timer doom-incremental-first-idle-timer
|
||||
nil #'doom-load-packages-incrementally
|
||||
(cdr doom-incremental-packages) t))))
|
||||
|
||||
(add-hook 'window-setup-hook #'doom|load-packages-incrementally)
|
||||
(if (daemonp)
|
||||
(mapc #'require (cdr doom-incremental-packages))
|
||||
(when (integerp doom-incremental-first-idle-timer)
|
||||
(run-with-idle-timer doom-incremental-first-idle-timer
|
||||
nil #'doom-load-packages-incrementally
|
||||
(cdr doom-incremental-packages) t)))))
|
||||
|
||||
|
||||
;;
|
||||
|
@ -392,23 +392,23 @@ Meant to be used with `run-hook-wrapped'."
|
|||
(unless (file-directory-p dir)
|
||||
(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
|
||||
they were loaded at startup.
|
||||
|
||||
If RETURN-P, return the message as a string instead of displaying it."
|
||||
(funcall (if return-p #'format #'message)
|
||||
"Doom loaded %s packages across %d modules in %.03fs"
|
||||
(length package-activated-list)
|
||||
"Doom loaded %d packages across %d modules in %.03fs"
|
||||
(- (length load-path) (length doom--initial-load-path))
|
||||
(if doom-modules (hash-table-count doom-modules) 0)
|
||||
(or doom-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
|
||||
-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)
|
||||
(setq after-init-time (current-time))
|
||||
(dolist (hook (list 'delayed-warnings-hook
|
||||
|
@ -522,7 +522,7 @@ to least)."
|
|||
(require 'core-os)
|
||||
(if noninteractive
|
||||
(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-ui)
|
||||
(require 'core-projects)
|
||||
|
|
14
init.el
14
init.el
|
@ -37,7 +37,7 @@ decrease this. If you experience stuttering, increase this.")
|
|||
|
||||
(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
|
||||
`gc-cons-threshold' can cause random freezes otherwise) and resets
|
||||
`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)
|
||||
;; To speed up minibuffer commands (like helm and ivy), we defer garbage
|
||||
;; 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))
|
||||
(defun doom|restore-garbage-collection ()
|
||||
(defun doom-restore-garbage-collection-h ()
|
||||
;; Defer it so that commands launched from the minibuffer can enjoy the
|
||||
;; benefits.
|
||||
(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-exit-hook #'doom|restore-garbage-collection)
|
||||
(add-hook 'minibuffer-setup-hook #'doom-defer-garbage-collection-h)
|
||||
(add-hook 'minibuffer-exit-hook #'doom-restore-garbage-collection-h)
|
||||
;; GC all sneaky breeky like
|
||||
(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)
|
||||
;; 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
|
||||
;; `doom|restore-startup-optimizations'.
|
||||
;; `doom-restore-startup-optimizations-h'.
|
||||
(setq gc-cons-threshold doom-gc-cons-upper-limit)
|
||||
;; This is consulted on every `require', `load' and various path/io functions.
|
||||
;; You get a minor speed up by nooping this.
|
||||
(setq file-name-handler-alist nil)
|
||||
;; 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
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
(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)
|
||||
|
||||
(advice-add #'cfw:render-button :override #'+calendar*cfw:render-button))
|
||||
|
|
|
@ -121,10 +121,9 @@
|
|||
:defer t
|
||||
:config
|
||||
(setq company-dict-dir (expand-file-name "dicts" doom-private-dir))
|
||||
(defun +company|enable-project-dicts (mode &rest _)
|
||||
"Enable per-project dictionaries."
|
||||
(if (symbol-value mode)
|
||||
(add-to-list 'company-dict-minor-mode-list mode nil #'eq)
|
||||
(setq company-dict-minor-mode-list (delq mode company-dict-minor-mode-list))))
|
||||
(add-hook 'doom-project-hook #'+company|enable-project-dicts))
|
||||
|
||||
(add-hook 'doom-project-hook
|
||||
(defun +company--enable-project-dicts-h (mode &rest _)
|
||||
"Enable per-project dictionaries."
|
||||
(if (symbol-value mode)
|
||||
(add-to-list 'company-dict-minor-mode-list mode nil #'eq)
|
||||
(setq company-dict-minor-mode-list (delq mode company-dict-minor-mode-list))))))
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
;;; completion/helm/autoload/posframe.el -*- lexical-binding: t; -*-
|
||||
|
||||
(add-hook 'helm-cleanup-hook #'+helm|posframe-cleanup)
|
||||
|
||||
;;;###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
|
||||
bottom, which is easier on the eyes on big displays."
|
||||
(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)
|
||||
;;;###autoload
|
||||
(defun +helm-posframe-display (buffer &optional _resume)
|
||||
(defun +helm-posframe-display-fn (buffer &optional _resume)
|
||||
"TODO"
|
||||
(setq helm--buffer-in-new-frame-p t)
|
||||
(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)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +helm|posframe-cleanup ()
|
||||
(defun +helm-posframe-cleanup-h ()
|
||||
"TODO"
|
||||
;; 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.
|
||||
|
@ -60,3 +58,4 @@ bottom, which is easier on the eyes on big displays."
|
|||
;;
|
||||
(posframe-delete +helm--posframe-buffer))
|
||||
|
||||
(add-hook 'helm-cleanup-hook #'+helm-posframe-cleanup-h)
|
||||
|
|
|
@ -11,8 +11,7 @@ silently ignored.
|
|||
This falls back to git-grep (then grep) if none of these available.")
|
||||
|
||||
;; Posframe (requires +childframe)
|
||||
(defvar +helm-posframe-handler
|
||||
#'+helm-poshandler-frame-center-near-bottom
|
||||
(defvar +helm-posframe-handler #'+helm-poshandler-frame-center-near-bottom-fn
|
||||
"The function that determines the location of the childframe. It should return
|
||||
a cons cell representing the X and Y coordinates. See
|
||||
`posframe-poshandler-frame-center' as a reference.")
|
||||
|
@ -113,12 +112,12 @@ be negative.")
|
|||
(set-popup-rule! "^\\*helm" :vslot -100 :size 0.22 :ttl nil)
|
||||
|
||||
;; Hide the modeline
|
||||
(defun +helm|hide-mode-line (&rest _)
|
||||
(defun +helm--hide-mode-line (&rest _)
|
||||
(with-current-buffer (helm-buffer-get)
|
||||
(unless helm-mode-line-string
|
||||
(hide-mode-line-mode +1))))
|
||||
(add-hook 'helm-after-initialize-hook #'+helm|hide-mode-line)
|
||||
(advice-add #'helm-display-mode-line :override #'+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-ag-show-status-default-mode-line :override #'ignore)
|
||||
|
||||
;; Use helpful instead of describe-* to display documentation
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
;;; completion/ido/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defun +ido|init ()
|
||||
(defun +ido-init-h ()
|
||||
(setq ido-ignore-buffers
|
||||
'("\\` " "^\\*ESS\\*" "^\\*Messages\\*" "^\\*Help\\*" "^\\*Buffer"
|
||||
"^\\*.*Completions\\*$" "^\\*Ediff" "^\\*tramp" "^\\*cvs-"
|
||||
|
@ -52,7 +52,7 @@
|
|||
(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)
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
;;;###if (featurep! +childframe)
|
||||
|
||||
;;;###autoload
|
||||
(defun +ivy-display-at-frame-center-near-bottom (str)
|
||||
(defun +ivy-display-at-frame-center-near-bottom-fn (str)
|
||||
"TODO"
|
||||
(ivy-posframe--display str #'+ivy-poshandler-frame-center-near-bottom))
|
||||
(ivy-posframe--display str #'+ivy-poshandler-frame-center-near-bottom-fn))
|
||||
|
||||
;;;###autoload
|
||||
(defun +ivy-poshandler-frame-center-near-bottom (info)
|
||||
(defun +ivy-poshandler-frame-center-near-bottom-fn (info)
|
||||
"TODO"
|
||||
(let ((parent-frame (plist-get info :parent-frame))
|
||||
(pos (posframe-poshandler-frame-center info)))
|
||||
|
|
|
@ -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
|
||||
(defvar +ivy--origin nil)
|
||||
|
||||
(defun +ivy|record-position-maybe ()
|
||||
(defun +ivy--record-position-maybe-fn ()
|
||||
(with-ivy-window
|
||||
(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 ()
|
||||
(when (and (markerp +ivy--origin)
|
||||
(not (equal (with-ivy-window (point-marker)) +ivy--origin)))
|
||||
(with-current-buffer (marker-buffer +ivy--origin)
|
||||
(better-jumper-set-jump +ivy--origin)))
|
||||
(setq +ivy--origin nil))
|
||||
(add-hook 'minibuffer-exit-hook #'+ivy|set-jump-point-maybe)
|
||||
(add-hook 'minibuffer-exit-hook
|
||||
(defun +ivy--set-jump-point-maybe-h ()
|
||||
(when (and (markerp +ivy--origin)
|
||||
(not (equal (with-ivy-window (point-marker)) +ivy--origin)))
|
||||
(with-current-buffer (marker-buffer +ivy--origin)
|
||||
(better-jumper-set-jump +ivy--origin)))
|
||||
(setq +ivy--origin nil)))
|
||||
|
||||
(after! yasnippet
|
||||
(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)))
|
||||
|
||||
;; 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
|
||||
(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
|
||||
|
|
|
@ -47,10 +47,10 @@
|
|||
;; 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
|
||||
;; be reactivated for non-evil users though. Needs more testing!
|
||||
(defun doom|disable-smartparens-navigate-skip-match ()
|
||||
(setq sp-navigate-skip-match nil
|
||||
sp-navigate-consider-sgml-tags nil))
|
||||
(add-hook 'after-change-major-mode-hook #'doom|disable-smartparens-navigate-skip-match)
|
||||
(add-hook 'after-change-major-mode-hook
|
||||
(defun doom-disable-smartparens-navigate-skip-match-h ()
|
||||
(setq sp-navigate-skip-match nil
|
||||
sp-navigate-consider-sgml-tags nil)))
|
||||
|
||||
;; Autopair quotes more conservatively; if I'm next to a word/before another
|
||||
;; quote, I likely don't want to open a new pair.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
(defalias '+literate/reload #'doom/reload)
|
||||
|
||||
;;;###autoload
|
||||
(defun +literate|recompile-maybe ()
|
||||
(defun +literate-recompile-maybe-h ()
|
||||
"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
|
||||
|
|
|
@ -46,4 +46,4 @@ byte-compiled from.")
|
|||
|
||||
;; Recompile our literate config if we modify it
|
||||
(after! org
|
||||
(add-hook 'after-save-hook #'+literate|recompile-maybe))
|
||||
(add-hook 'after-save-hook #'+literate-recompile-maybe-h))
|
||||
|
|
|
@ -192,7 +192,7 @@ more information on modifiers."
|
|||
(funcall orig-fn char)))
|
||||
|
||||
;;;###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
|
||||
`he-dabbrev-beg', so we need to redefine syntax for '/'."
|
||||
(set-syntax-table (let* ((table (make-syntax-table)))
|
||||
|
|
|
@ -36,9 +36,9 @@ directives. By default, this only recognizes C directives.")
|
|||
;; more vim-like behavior
|
||||
evil-symbol-word-search t
|
||||
;; cursor appearance
|
||||
evil-default-cursor '+evil-default-cursor
|
||||
evil-default-cursor '+evil-default-cursor-fn
|
||||
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-visual-state-cursor 'hollow
|
||||
;; 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)))
|
||||
|
||||
;; Done in a hook to ensure the popup rules load as late as possible
|
||||
(defun +evil|init-popup-rules ()
|
||||
(set-popup-rules!
|
||||
'(("^\\*evil-registers" :size 0.3)
|
||||
("^\\*Command Line" :size 8))))
|
||||
(add-hook 'doom-init-modules-hook #'+evil|init-popup-rules)
|
||||
(add-hook 'doom-init-modules-hook
|
||||
(defun +evil--init-popup-rules-h ()
|
||||
(set-popup-rules!
|
||||
'(("^\\*evil-registers" :size 0.3)
|
||||
("^\\*Command Line" :size 8)))))
|
||||
|
||||
;; 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
|
||||
|
@ -65,19 +65,17 @@ directives. By default, this only recognizes C directives.")
|
|||
(defvar +evil--default-cursor-color "#ffffff")
|
||||
(defvar +evil--emacs-cursor-color "#ff9999")
|
||||
|
||||
(defun +evil|update-cursor-color ()
|
||||
(setq +evil--default-cursor-color (face-background 'cursor)
|
||||
+evil--emacs-cursor-color (face-foreground 'warning)))
|
||||
(add-hook 'doom-load-theme-hook #'+evil|update-cursor-color)
|
||||
(add-hook 'doom-load-theme-hook
|
||||
(defun +evil-update-cursor-color-h ()
|
||||
(setq +evil--default-cursor-color (face-background 'cursor)
|
||||
+evil--emacs-cursor-color (face-foreground 'warning))))
|
||||
|
||||
(defun +evil-default-cursor ()
|
||||
(defun +evil-default-cursor-fn ()
|
||||
(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))
|
||||
|
||||
(defun +evil|update-shift-width ()
|
||||
(setq evil-shift-width tab-width))
|
||||
(add-hook 'after-change-major-mode-hook #'+evil|update-shift-width)
|
||||
(setq-hook! 'after-change-major-mode-hook evil-shift-width tab-width)
|
||||
|
||||
|
||||
;; --- keybind fixes ----------------------
|
||||
|
@ -86,26 +84,26 @@ directives. By default, this only recognizes C directives.")
|
|||
;; `evil-delete' in wgrep buffers.
|
||||
(define-key wgrep-mode-map [remap evil-delete] #'+evil-delete))
|
||||
|
||||
(defun +evil|disable-highlights ()
|
||||
"Disable ex search buffer highlights."
|
||||
(when (evil-ex-hl-active-p 'evil-ex-search)
|
||||
(evil-ex-nohighlight)
|
||||
t))
|
||||
(add-hook 'doom-escape-hook #'+evil|disable-highlights)
|
||||
(add-hook 'doom-escape-hook
|
||||
(defun +evil-disable-ex-highlights-h ()
|
||||
"Disable ex search buffer highlights."
|
||||
(when (evil-ex-hl-active-p 'evil-ex-search)
|
||||
(evil-ex-nohighlight)
|
||||
t)))
|
||||
|
||||
|
||||
;; --- 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
|
||||
(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'.
|
||||
(advice-add #'evil-force-normal-state :after #'+evil-escape-a)
|
||||
;; 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)
|
||||
|
||||
;; 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
|
||||
(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 (emacs-lisp-mode . embrace-emacs-lisp-mode-hook)
|
||||
:hook ((lisp-mode emacs-lisp-mode clojure-mode racket-mode)
|
||||
. +evil|embrace-lisp-mode-hook)
|
||||
:hook ((org-mode LaTeX-mode) . +evil|embrace-latex-mode-hook)
|
||||
. +evil-embrace-lisp-mode-hook-h)
|
||||
: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)
|
||||
. +evil|embrace-angle-bracket-modes-hook)
|
||||
. +evil-embrace-angle-bracket-modes-hook-h)
|
||||
:init
|
||||
(after! evil-surround
|
||||
(evil-embrace-enable-evil-surround-integration))
|
||||
:config
|
||||
(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))
|
||||
|
||||
(defun +evil|embrace-lisp-mode-hook ()
|
||||
(defun +evil-embrace-lisp-mode-hook-h ()
|
||||
(push (cons ?f (make-embrace-pair-struct
|
||||
:key ?f
|
||||
:read-function #'+evil--embrace-elisp-fn
|
||||
|
@ -222,7 +220,7 @@ directives. By default, this only recognizes C directives.")
|
|||
:right-regexp ")"))
|
||||
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)
|
||||
(delq ?< evil-embrace-evil-surround-keys))
|
||||
(push (cons ?< (make-embrace-pair-struct
|
||||
|
@ -260,11 +258,11 @@ directives. By default, this only recognizes C directives.")
|
|||
(def-package! evil-exchange
|
||||
:commands evil-exchange
|
||||
:config
|
||||
(defun +evil|escape-exchange ()
|
||||
(when evil-exchange--overlays
|
||||
(evil-exchange-cancel)
|
||||
t))
|
||||
(add-hook 'doom-escape-hook #'+evil|escape-exchange))
|
||||
(add-hook 'doom-escape-hook
|
||||
(defun +evil--escape-exchange-h ()
|
||||
(when evil-exchange--overlays
|
||||
(evil-exchange-cancel)
|
||||
t))))
|
||||
|
||||
|
||||
(def-package! evil-snipe
|
||||
|
|
|
@ -39,13 +39,13 @@
|
|||
;; disable evil-escape in evil-mc; causes unwanted text on invocation
|
||||
(add-to-list 'evil-mc-incompatible-minor-modes 'evil-escape-mode nil #'eq)
|
||||
|
||||
(defun +multiple-cursors|escape-multiple-cursors ()
|
||||
"Clear evil-mc cursors and restore state."
|
||||
(when (evil-mc-has-cursors-p)
|
||||
(evil-mc-undo-all-cursors)
|
||||
(evil-mc-resume-cursors)
|
||||
t))
|
||||
(add-hook 'doom-escape-hook #'+multiple-cursors|escape-multiple-cursors)
|
||||
(add-hook 'doom-escape-hook
|
||||
(defun +multiple-cursors-escape-multiple-cursors-h ()
|
||||
"Clear evil-mc cursors and restore state."
|
||||
(when (evil-mc-has-cursors-p)
|
||||
(evil-mc-undo-all-cursors)
|
||||
(evil-mc-resume-cursors)
|
||||
t)))
|
||||
|
||||
;; Forward declare these so that ex completion and evil-mc support is
|
||||
;; recognized before the autoloaded functions are loaded.
|
||||
|
@ -71,30 +71,30 @@
|
|||
(defvar +mc--compat-evil-prev-state nil)
|
||||
(defvar +mc--compat-mark-was-active nil)
|
||||
|
||||
(defun +multiple-cursors|compat-switch-to-emacs-state ()
|
||||
(when (and (bound-and-true-p evil-mode)
|
||||
(not (memq evil-state '(insert emacs))))
|
||||
(setq +mc--compat-evil-prev-state evil-state)
|
||||
(when (region-active-p)
|
||||
(setq +mc--compat-mark-was-active t))
|
||||
(let ((mark-before (mark))
|
||||
(point-before (point)))
|
||||
(evil-emacs-state 1)
|
||||
(when (or +mc--compat-mark-was-active (region-active-p))
|
||||
(goto-char point-before)
|
||||
(set-mark mark-before)))))
|
||||
(add-hook 'multiple-cursors-mode-enabled-hook #'+multiple-cursors|compat-switch-to-emacs-state)
|
||||
(add-hook 'multiple-cursors-mode-enabled-hook
|
||||
(defun +multiple-cursors-compat-switch-to-emacs-state-h ()
|
||||
(when (and (bound-and-true-p evil-mode)
|
||||
(not (memq evil-state '(insert emacs))))
|
||||
(setq +mc--compat-evil-prev-state evil-state)
|
||||
(when (region-active-p)
|
||||
(setq +mc--compat-mark-was-active t))
|
||||
(let ((mark-before (mark))
|
||||
(point-before (point)))
|
||||
(evil-emacs-state 1)
|
||||
(when (or +mc--compat-mark-was-active (region-active-p))
|
||||
(goto-char point-before)
|
||||
(set-mark mark-before))))))
|
||||
|
||||
(defun +multiple-cursors|compat-back-to-previous-state ()
|
||||
(when +mc--compat-evil-prev-state
|
||||
(unwind-protect
|
||||
(case +mc--compat-evil-prev-state
|
||||
((normal visual) (evil-force-normal-state))
|
||||
(t (message "Don't know how to handle previous state: %S"
|
||||
+mc--compat-evil-prev-state)))
|
||||
(setq +mc--compat-evil-prev-state nil)
|
||||
(setq +mc--compat-mark-was-active nil))))
|
||||
(add-hook 'multiple-cursors-mode-disabled-hook #'+multiple-cursors|compat-back-to-previous-state)
|
||||
(add-hook 'multiple-cursors-mode-disabled-hook
|
||||
(defun +multiple-cursors-compat-back-to-previous-state-h ()
|
||||
(when +mc--compat-evil-prev-state
|
||||
(unwind-protect
|
||||
(case +mc--compat-evil-prev-state
|
||||
((normal visual) (evil-force-normal-state))
|
||||
(t (message "Don't know how to handle previous state: %S"
|
||||
+mc--compat-evil-prev-state)))
|
||||
(setq +mc--compat-evil-prev-state nil)
|
||||
(setq +mc--compat-mark-was-active nil)))))
|
||||
|
||||
;; When running edit-lines, point will return (position + 1) as a result of
|
||||
;; how evil deals with regions
|
||||
|
@ -106,10 +106,10 @@
|
|||
(goto-char (1- (point)))
|
||||
(push-mark (1- (mark))))))
|
||||
|
||||
(defun +multiple-cursors|evil-compat-rect-switch-state ()
|
||||
(if rectangular-region-mode
|
||||
(+multiple-cursors|compat-switch-to-emacs-state)
|
||||
(setq +mc--compat-evil-prev-state nil)))
|
||||
(add-hook 'rectangular-region-mode-hook '+multiple-cursors|evil-compat-rect-switch-state)
|
||||
(add-hook 'rectangular-region-mode-hook
|
||||
(defun +multiple-cursors-evil-compat-rect-switch-state-h ()
|
||||
(if rectangular-region-mode
|
||||
(+multiple-cursors-compat-switch-to-emacs-state-h)
|
||||
(setq +mc--compat-evil-prev-state nil))))
|
||||
|
||||
(defvar mc--default-cmds-to-run-once nil)))
|
||||
|
|
|
@ -41,20 +41,20 @@
|
|||
(global-git-commit-mode +1)
|
||||
(set-yas-minor-mode! 'git-commit-mode)
|
||||
|
||||
(defun +vc|enforce-git-commit-conventions ()
|
||||
"See https://chris.beams.io/posts/git-commit/"
|
||||
(setq fill-column 72
|
||||
git-commit-summary-max-length 50
|
||||
git-commit-style-convention-checks '(overlong-summary-line non-empty-second-line)))
|
||||
(add-hook 'git-commit-mode-hook #'+vc|enforce-git-commit-conventions)
|
||||
(add-hook 'git-commit-mode-hook
|
||||
(defun +vc--enforce-git-commit-conventions-h ()
|
||||
"See https://chris.beams.io/posts/git-commit/"
|
||||
(setq fill-column 72
|
||||
git-commit-summary-max-length 50
|
||||
git-commit-style-convention-checks '(overlong-summary-line non-empty-second-line))))
|
||||
|
||||
(defun +vc|start-in-insert-state-maybe ()
|
||||
"Start git-commit-mode in insert state if in a blank commit message,
|
||||
(add-hook 'git-commit-setup-hook
|
||||
(defun +vc--start-in-insert-state-maybe ()
|
||||
"Start git-commit-mode in insert state if in a blank commit message,
|
||||
otherwise in default state."
|
||||
(when (and (bound-and-true-p evil-mode)
|
||||
(bobp) (eolp))
|
||||
(evil-insert-state)))
|
||||
(add-hook 'git-commit-setup-hook #'+vc|start-in-insert-state-maybe))
|
||||
(when (and (bound-and-true-p evil-mode)
|
||||
(bobp) (eolp))
|
||||
(evil-insert-state)))))
|
||||
|
||||
(after! vc-annotate
|
||||
(set-popup-rules!
|
||||
|
|
|
@ -106,7 +106,7 @@ if it's callable, `apropos' otherwise."
|
|||
;;; Hooks
|
||||
|
||||
;;;###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."
|
||||
(setq imenu-generic-expression
|
||||
`(("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))))
|
||||
|
||||
;;;###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
|
||||
verbosity when editing a file in `doom-private-dir' or `doom-emacs-dir'."
|
||||
(when (and (bound-and-true-p flycheck-mode)
|
||||
|
|
|
@ -34,6 +34,9 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
|
|||
("add-hook" "remove-hook")
|
||||
("add-hook!" "remove-hook!")))
|
||||
|
||||
;; TODO
|
||||
(put 'add-hook 'lisp-indent-function 'defun)
|
||||
|
||||
(setq-hook! 'emacs-lisp-mode-hook
|
||||
tab-width 2
|
||||
;; shorter name in modeline
|
||||
|
@ -51,12 +54,12 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
|
|||
rainbow-delimiters-mode
|
||||
highlight-quoted-mode
|
||||
;; initialization
|
||||
+emacs-lisp|extend-imenu))
|
||||
+emacs-lisp-extend-imenu-h))
|
||||
|
||||
;; 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-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
|
||||
(font-lock-add-keywords
|
||||
|
|
|
@ -803,9 +803,9 @@ compelling reason, so..."
|
|||
auto-fill-mode ; hard line wrapping
|
||||
;; `show-paren-mode' causes flickering with indentation margins made by
|
||||
;; `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...
|
||||
doom|disable-show-trailing-whitespace
|
||||
doom-disable-show-trailing-whitespace-h
|
||||
|
||||
+org|enable-auto-reformat-tables
|
||||
+org|enable-auto-update-cookies
|
||||
|
|
|
@ -50,8 +50,8 @@ called.")
|
|||
sp-point-before-same-p))
|
||||
|
||||
;; Affects pyenv and conda
|
||||
(advice-add #'pythonic-activate :after-while #'+modeline|update-env-in-all-windows)
|
||||
(advice-add #'pythonic-deactivate :after #'+modeline|clear-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-h)
|
||||
|
||||
(setq-hook! 'python-mode-hook tab-width python-indent-offset))
|
||||
|
||||
|
@ -165,8 +165,8 @@ called.")
|
|||
:after python
|
||||
:init
|
||||
(when (featurep! :ui modeline)
|
||||
(add-hook 'pyvenv-post-activate-hooks #'+modeline|update-env-in-all-windows)
|
||||
(add-hook 'pyvenv-pre-deactivate-hooks #'+modeline|clear-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-h))
|
||||
:config
|
||||
(add-hook 'hack-local-variables-hook #'pyvenv-track-virtualenv)
|
||||
(add-to-list 'global-mode-string
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
;; happen once.
|
||||
;;
|
||||
;; rust-mode is still required for `racer'.
|
||||
(defun +rust|init ()
|
||||
"Switch to `rustic-mode', if it's available."
|
||||
(when (require 'rustic nil t)
|
||||
(rustic-mode)))
|
||||
(add-hook 'rust-mode-hook #'+rust|init)
|
||||
(add-hook 'rust-mode-hook
|
||||
(defun +rust-init-h ()
|
||||
"Switch to `rustic-mode', if it's available."
|
||||
(when (require 'rustic nil t)
|
||||
(rustic-mode))))
|
||||
|
||||
(set-docsets! '(rust-mode rustic-mode) "Rust")
|
||||
(when (featurep! +lsp)
|
||||
|
|
|
@ -106,7 +106,7 @@
|
|||
(evil-change-to-initial-state))
|
||||
(goto-char (point-max)))
|
||||
(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)
|
||||
(run-hooks 'eshell-mode-hook)
|
||||
(eshell-mode))
|
||||
|
|
|
@ -73,7 +73,7 @@ You should use `set-eshell-alias!' to change this.")
|
|||
eshell-error-if-no-glob t)
|
||||
|
||||
;; 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
|
||||
(add-hook 'eshell-mode-hook #'+eshell|init)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
;;; term/shell/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###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)
|
||||
|
|
|
@ -36,7 +36,7 @@ If prefix ARG, recreate the term buffer."
|
|||
(goto-char (point-max)))
|
||||
(setenv "PROOT" (or (doom-project-root) default-directory))
|
||||
(with-current-buffer buffer
|
||||
(doom|mark-buffer-as-real)
|
||||
(doom-mark-buffer-as-real-h)
|
||||
(multi-term-internal))
|
||||
(unless (window-live-p window)
|
||||
(when-let (window
|
||||
|
|
|
@ -5,5 +5,5 @@
|
|||
multi-term-switch-after-close 'PREVIOUS)
|
||||
|
||||
;;;###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)
|
||||
|
|
|
@ -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))
|
||||
(let ((buffer (get-buffer-create buffer-name)))
|
||||
(with-current-buffer buffer
|
||||
(doom|mark-buffer-as-real)
|
||||
(doom-mark-buffer-as-real-h)
|
||||
(vterm-mode))
|
||||
(pop-to-buffer buffer)))))
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
:config
|
||||
(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.
|
||||
(add-to-list 'vterm-exit-functions (lambda (buffer) (if buffer (kill-buffer buffer))))
|
||||
;; Modeline serves no purpose in vterm
|
||||
|
|
|
@ -23,15 +23,15 @@
|
|||
(def-package! lsp-ui
|
||||
:hook (lsp-mode . lsp-ui-mode)
|
||||
:init
|
||||
(defun +lsp|init-ui-flycheck-or-flymake ()
|
||||
"Sets up flymake-mode or flycheck-mode, depending on `lsp-prefer-flymake'."
|
||||
(unless (eq :none lsp-prefer-flymake)
|
||||
(if (and (not (version< emacs-version "26.1"))
|
||||
lsp-prefer-flymake)
|
||||
(lsp--flymake-setup))
|
||||
(require 'lsp-ui-flycheck)
|
||||
(lsp-ui-flycheck-enable t)))
|
||||
(add-hook 'lsp-ui-mode-hook #'+lsp|init-ui-flycheck-or-flymake)
|
||||
(add-hook 'lsp-ui-mode-hook
|
||||
(defun +lsp-init-ui-flycheck-or-flymake-h ()
|
||||
"Sets up flymake-mode or flycheck-mode, depending on `lsp-prefer-flymake'."
|
||||
(unless (eq :none lsp-prefer-flymake)
|
||||
(if (and (not (version< emacs-version "26.1"))
|
||||
lsp-prefer-flymake)
|
||||
(lsp--flymake-setup))
|
||||
(require 'lsp-ui-flycheck)
|
||||
(lsp-ui-flycheck-enable t))))
|
||||
:config
|
||||
(setq lsp-prefer-flymake nil
|
||||
lsp-ui-doc-max-height 8
|
||||
|
@ -52,11 +52,11 @@
|
|||
:init
|
||||
;; Make sure that `company-capf' is disabled since it is incompatible with
|
||||
;; `company-lsp' (see lsp-mode#884)
|
||||
(defun +lsp|init-company ()
|
||||
(if (not (bound-and-true-p company-mode))
|
||||
(add-hook 'company-mode-hook #'+lsp|init-company t t)
|
||||
(setq-local company-backends
|
||||
(add-hook 'lsp-mode-hook
|
||||
(defun +lsp-init-company-h ()
|
||||
(if (not (bound-and-true-p company-mode))
|
||||
(add-hook 'company-mode-hook #'+lsp-init-company-h t t)
|
||||
(setq-local company-backends
|
||||
(cons 'company-lsp
|
||||
(remq 'company-capf company-backends)))
|
||||
(remove-hook 'company-mode-hook #'+lsp|init-company t)))
|
||||
(add-hook 'lsp-mode-hook #'+lsp|init-company))
|
||||
(remove-hook 'company-mode-hook #'+lsp-init-company-h t)))))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
;;; tools/magit/autoload.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autoload
|
||||
(defun +magit-display-buffer (buffer)
|
||||
(defun +magit-display-buffer-fn (buffer)
|
||||
"Marries `magit-display-buffer-fullcolumn-most-v1' with
|
||||
`magit-display-buffer-same-window-except-diff-v1', except:
|
||||
|
||||
|
|
|
@ -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
|
||||
;; status screen.
|
||||
(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)
|
||||
|
||||
;; Add --tags switch
|
||||
|
@ -40,11 +40,11 @@ It is passed a user and repository name.")
|
|||
"-p" '("-t" "Fetch all tags" ("-t" "--tags")))
|
||||
|
||||
;; so magit buffers can be switched to (except for process buffers)
|
||||
(defun +magit-buffer-p (buf)
|
||||
(with-current-buffer buf
|
||||
(and (derived-mode-p 'magit-mode)
|
||||
(not (eq major-mode 'magit-process-mode)))))
|
||||
(add-to-list 'doom-real-buffer-functions #'+magit-buffer-p nil #'eq)
|
||||
(add-hook 'doom-real-buffer-functions
|
||||
(defun +magit-buffer-p (buf)
|
||||
(with-current-buffer buf
|
||||
(and (derived-mode-p 'magit-mode)
|
||||
(not (eq major-mode 'magit-process-mode))))))
|
||||
|
||||
;; properly kill leftover magit buffers on quit
|
||||
(define-key magit-status-mode-map [remap magit-mode-bury-buffer] #'+magit/quit)
|
||||
|
|
|
@ -102,7 +102,7 @@ PLIST can have the following properties:
|
|||
;;
|
||||
;;; Bootstrap
|
||||
|
||||
(defun +doom-dashboard|init ()
|
||||
(defun +doom-dashboard-init-h ()
|
||||
"Initializes Doom's dashboard."
|
||||
(unless noninteractive
|
||||
;; 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*")
|
||||
(set-window-buffer nil (doom-fallback-buffer))
|
||||
(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)))
|
||||
;; 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-size-change-functions #'+doom-dashboard|resize)
|
||||
(add-hook 'doom-switch-buffer-hook #'+doom-dashboard|reload-maybe)
|
||||
(add-hook 'delete-frame-functions #'+doom-dashboard|reload-frame)
|
||||
(add-hook 'window-configuration-change-hook #'+doom-dashboard-resize-h)
|
||||
(add-hook 'window-size-change-functions #'+doom-dashboard-resize-h)
|
||||
(add-hook 'doom-switch-buffer-hook #'+doom-dashboard-reload-maybe-h)
|
||||
(add-hook 'delete-frame-functions #'+doom-dashboard-reload-frame-h)
|
||||
;; `persp-mode' integration: update `default-directory' when switching perspectives
|
||||
(add-hook 'persp-created-functions #'+doom-dashboard|record-project)
|
||||
(add-hook 'persp-activated-functions #'+doom-dashboard|detect-project)
|
||||
(add-hook 'persp-before-switch-functions #'+doom-dashboard|record-project)))
|
||||
(add-hook 'persp-created-functions #'+doom-dashboard--persp-record-project-h)
|
||||
(add-hook 'persp-activated-functions #'+doom-dashboard--persp-detect-project-h)
|
||||
(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
|
||||
finally do (setq fringe-indicator-alist alist))
|
||||
;; 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
|
||||
[left-margin mouse-1] #'ignore
|
||||
|
@ -185,7 +185,7 @@ PLIST can have the following properties:
|
|||
;;
|
||||
;;; Hooks
|
||||
|
||||
(defun +doom-dashboard|reposition-point ()
|
||||
(defun +doom-dashboard-reposition-point-h ()
|
||||
"Trap the point in the buttons."
|
||||
(when (region-active-p)
|
||||
(setq deactivate-mark t)
|
||||
|
@ -198,7 +198,7 @@ PLIST can have the following properties:
|
|||
(progn (goto-char (point-min))
|
||||
(forward-button 1))))
|
||||
|
||||
(defun +doom-dashboard|reload-maybe ()
|
||||
(defun +doom-dashboard-reload-maybe-h ()
|
||||
"Reload the dashboard or its state.
|
||||
|
||||
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)
|
||||
(+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,
|
||||
whose dimensions may not be fully initialized by the time this is run."
|
||||
(when (timerp +doom-dashboard--reload-timer)
|
||||
(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)))
|
||||
|
||||
(defun +doom-dashboard|resize (&rest _)
|
||||
(defun +doom-dashboard-resize-h (&rest _)
|
||||
"Recenter the dashboard, and reset its margins and fringes."
|
||||
(let (buffer-list-update-hook
|
||||
window-configuration-change-hook
|
||||
|
@ -247,20 +247,20 @@ whose dimensions may not be fully initialized by the time this is run."
|
|||
2))))
|
||||
?\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
|
||||
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
|
||||
project (which may be different across perspective)."
|
||||
(when (bound-and-true-p persp-mode)
|
||||
(when-let (pwd (persp-parameter 'last-project-root))
|
||||
(+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
|
||||
`+doom-dashboard|detect-project' for more information."
|
||||
`+doom-dashboard--persp-detect-project-h' for more information."
|
||||
(when (bound-and-true-p persp-mode)
|
||||
(set-persp-parameter
|
||||
'last-project-root (doom-project-root)
|
||||
|
@ -305,9 +305,9 @@ controlled by `+doom-dashboard-pwd-policy'."
|
|||
(erase-buffer)
|
||||
(run-hooks '+doom-dashboard-functions)
|
||||
(goto-char pt)
|
||||
(+doom-dashboard|reposition-point))
|
||||
(+doom-dashboard|resize)
|
||||
(+doom-dashboard|detect-project)
|
||||
(+doom-dashboard-reposition-point-h))
|
||||
(+doom-dashboard-resize-h)
|
||||
(+doom-dashboard--persp-detect-project-h)
|
||||
(+doom-dashboard-update-pwd)
|
||||
(current-buffer)))))
|
||||
|
||||
|
@ -387,7 +387,7 @@ controlled by `+doom-dashboard-pwd-policy'."
|
|||
(propertize
|
||||
(+doom-dashboard--center
|
||||
+doom-dashboard--width
|
||||
(doom|display-benchmark 'return))
|
||||
(doom-display-benchmark-h 'return))
|
||||
'face 'font-lock-comment-face)
|
||||
"\n"))
|
||||
|
||||
|
|
|
@ -22,11 +22,11 @@
|
|||
"A list of quit messages, picked randomly by `+doom-quit'. Taken from
|
||||
http://doom.wikia.com/wiki/Quit_messages and elsewhere.")
|
||||
|
||||
(defun +doom-quit (&rest _)
|
||||
(defun +doom-quit-fn (&rest _)
|
||||
(doom-quit-p
|
||||
(format "%s Quit?"
|
||||
(nth (random (length +doom-quit-messages))
|
||||
+doom-quit-messages))))
|
||||
|
||||
;;
|
||||
(setq confirm-kill-emacs #'+doom-quit)
|
||||
(setq confirm-kill-emacs #'+doom-quit-fn)
|
||||
|
|
|
@ -44,15 +44,16 @@
|
|||
(def-package! solaire-mode
|
||||
:defer t
|
||||
:init
|
||||
(defun +doom|solaire-mode-swap-bg-maybe ()
|
||||
(when-let (rule (assq doom-theme +doom-solaire-themes))
|
||||
(require 'solaire-mode)
|
||||
(when (cdr rule)
|
||||
(solaire-mode-swap-bg)
|
||||
(with-eval-after-load 'ansi-color
|
||||
(when-let (color (face-background 'default))
|
||||
(setf (aref ansi-color-names-vector 0) color))))))
|
||||
(add-hook 'doom-load-theme-hook #'+doom|solaire-mode-swap-bg-maybe t)
|
||||
(add-hook 'doom-load-theme-hook
|
||||
(defun +doom--solaire-mode-swap-bg-maybe-h ()
|
||||
(when-let (rule (assq doom-theme +doom-solaire-themes))
|
||||
(require 'solaire-mode)
|
||||
(when (cdr rule)
|
||||
(solaire-mode-swap-bg)
|
||||
(with-eval-after-load 'ansi-color
|
||||
(when-let (color (face-background 'default))
|
||||
(setf (aref ansi-color-names-vector 0) color))))))
|
||||
'append)
|
||||
:config
|
||||
;; fringe can become unstyled when deleting or focusing frames
|
||||
(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
|
||||
;; after eob.
|
||||
(when EMACS26+
|
||||
(defun +doom--line-range ()
|
||||
(defun +doom--line-range-fn ()
|
||||
(cons (line-beginning-position)
|
||||
(cond ((let ((eol (line-end-position)))
|
||||
(and (= eol (point-max))
|
||||
|
@ -77,21 +78,21 @@
|
|||
(= (line-end-position 2) (point-max)))
|
||||
(line-end-position))
|
||||
((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
|
||||
;; we remove them in the minibuffer and which-key popups (they serve no
|
||||
;; purpose there anyway).
|
||||
(defun +doom|disable-fringes-in-minibuffer (&rest _)
|
||||
(set-window-fringes (minibuffer-window) 0 0 nil))
|
||||
(add-hook 'solaire-mode-hook #'+doom|disable-fringes-in-minibuffer)
|
||||
(add-hook 'solaire-mode-hook
|
||||
(defun +doom-disable-fringes-in-minibuffer-h (&rest _)
|
||||
(set-window-fringes (minibuffer-window) 0 0 nil)))
|
||||
|
||||
(def-advice! +doom--no-fringes-in-which-key-buffer-a (&rest _)
|
||||
: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))
|
||||
|
||||
(add-hook! '(minibuffer-setup-hook window-configuration-change-hook)
|
||||
#'+doom|disable-fringes-in-minibuffer)
|
||||
#'+doom-disable-fringes-in-minibuffer-h)
|
||||
|
||||
(solaire-global-mode +1))
|
||||
|
|
|
@ -10,6 +10,15 @@
|
|||
|
||||
;; Use a more primitive todo-keyword detection method in major modes that
|
||||
;; don't use/have a valid syntax table entry for comments.
|
||||
(add-hook!
|
||||
(pug-mode haml-mode)
|
||||
#'+hl-todo|use-face-detection))
|
||||
(add-hook! '(pug-mode-hook haml-mode-hook)
|
||||
(defun +hl-todo--use-face-detection-h ()
|
||||
"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)))))
|
||||
|
|
|
@ -6,10 +6,8 @@
|
|||
(setq highlight-indent-guides-method 'character)
|
||||
:config
|
||||
(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
|
||||
(add-hook 'visual-line-mode-hook #'+indent-guides|disable-maybe)
|
||||
(add-hook 'org-indent-mode-hook #'+indent-guides|disable-maybe))
|
||||
(add-hook! '(visual-line-mode-hook org-indent-mode-hook)
|
||||
(defun +indent-guides-disable-maybe-h ()
|
||||
(when highlight-indent-guides-mode
|
||||
(highlight-indent-guides-mode -1)))))
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
(defvar +modeline--old-bar-height nil)
|
||||
;;;###autoload
|
||||
(defun +modeline|resize-for-font ()
|
||||
(defun +modeline--resize-for-font-h ()
|
||||
"Adjust the modeline's height when the font size is changed by
|
||||
`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))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +modeline|update-env-in-all-windows (&rest _)
|
||||
(defun +modeline-update-env-in-all-windows-h (&rest _)
|
||||
"Update version strings in all buffers."
|
||||
(dolist (window (window-list))
|
||||
(with-selected-window window
|
||||
|
@ -41,7 +41,7 @@ Meant for `doom-change-font-size-hook'."
|
|||
(force-mode-line-update))))
|
||||
|
||||
;;;###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."
|
||||
(dolist (buffer (buffer-list))
|
||||
(with-current-buffer buffer
|
||||
|
|
|
@ -32,17 +32,17 @@
|
|||
(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-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-dashboard-mode-hook #'doom-modeline-set-project-modeline)
|
||||
|
||||
(defun +modeline|hide-in-non-status-buffer ()
|
||||
"Show minimal modeline in magit-status buffer, no modeline elsewhere."
|
||||
(if (eq major-mode 'magit-status-mode)
|
||||
(doom-modeline-set-project-modeline)
|
||||
(hide-mode-line-mode)))
|
||||
(add-hook 'magit-mode-hook #'+modeline|hide-in-non-status-buffer)
|
||||
(add-hook 'magit-mode-hook
|
||||
(defun +modeline--hide-in-non-status-buffer-h ()
|
||||
"Show minimal modeline in magit-status buffer, no modeline elsewhere."
|
||||
(if (eq major-mode 'magit-status-mode)
|
||||
(doom-modeline-set-project-modeline)
|
||||
(hide-mode-line-mode))))
|
||||
|
||||
;; Remove unused segments & extra padding
|
||||
(doom-modeline-def-modeline 'main
|
||||
|
|
|
@ -24,17 +24,16 @@ or triggered from one of `+nav-flash-exclude-commands'."
|
|||
(setq +nav-flash--last-point (cons (point-marker) (selected-window)))))
|
||||
|
||||
;;;###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
|
||||
isn't clear at run-time if the point will be in the correct window/buffer (like
|
||||
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
|
||||
(defalias '+nav-flash|blink-cursor #'+nav-flash-blink-cursor)
|
||||
(defalias '+nav-flash-blink-cursor-h #'+nav-flash-blink-cursor)
|
||||
;;;###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
|
||||
(defalias '+nav-flash-blink-cursor-a #'+nav-flash-blink-cursor-maybe)
|
||||
|
||||
|
|
|
@ -13,12 +13,12 @@
|
|||
(add-hook!
|
||||
'(imenu-after-jump-hook better-jumper-post-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'
|
||||
(add-hook 'org-follow-link-hook #'+nav-flash|delayed-blink-cursor)
|
||||
(add-hook 'org-follow-link-hook #'+nav-flash-delayed-blink-cursor-h)
|
||||
|
||||
;; `saveplace'
|
||||
(advice-add #'save-place-find-file-hook :after #'+nav-flash-blink-cursor-a)
|
||||
|
|
|
@ -42,14 +42,13 @@
|
|||
(after! winner
|
||||
(add-to-list 'winner-boring-buffers neo-buffer-name))
|
||||
|
||||
;; The cursor always sits at bol. `+neotree*fix-cursor' and
|
||||
;; `+neotree*indent-cursor' change that behavior, so that the cursor is always
|
||||
;; on the first non-blank character on the line, in the neo buffer.
|
||||
(defun +neotree*fix-cursor (&rest _)
|
||||
(with-current-buffer neo-global--buffer
|
||||
(+neotree*indent-cursor)))
|
||||
(add-hook 'neo-enter-hook #'+neotree*fix-cursor)
|
||||
|
||||
;; The cursor always sits at bol. `+neotree--fix-cursor-h' and
|
||||
;; `+neotree--indent-cursor-a' change that behavior so that the cursor is
|
||||
;; always on the first non-blank character on the line, in the neo buffer.
|
||||
(add-hook 'neo-enter-hook
|
||||
(defun +neotree--fix-cursor-h (&rest _)
|
||||
(with-current-buffer neo-global--buffer
|
||||
(+neotree*indent-cursor))))
|
||||
(def-advice! +neotree--indent-cursor-a (&rest _)
|
||||
:after '(neotree-next-line neotree-previous-line)
|
||||
(beginning-of-line)
|
||||
|
|
|
@ -22,34 +22,34 @@ to the right fringe.")
|
|||
(def-package! git-gutter
|
||||
:commands (git-gutter:revert-hunk git-gutter:stage-hunk)
|
||||
:init
|
||||
(defun +vc-gutter|init-maybe ()
|
||||
"Enable `git-gutter-mode' in the current buffer.
|
||||
(add-hook! '(text-mode-hook prog-mode-hook conf-mode-hook)
|
||||
(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
|
||||
is deferred until the file is saved. Respects `git-gutter:disabled-modes'."
|
||||
(when (or +vc-gutter-in-remote-files
|
||||
(not (file-remote-p (or buffer-file-name default-directory))))
|
||||
(if (not buffer-file-name)
|
||||
(add-hook 'after-save-hook #'+vc-gutter|init-maybe nil t)
|
||||
(when (and (vc-backend buffer-file-name)
|
||||
(progn
|
||||
(require 'git-gutter)
|
||||
(not (memq major-mode git-gutter:disabled-modes))))
|
||||
(if (and (display-graphic-p)
|
||||
(require 'git-gutter-fringe nil t))
|
||||
(progn
|
||||
(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:clear-function #'git-gutter-fr:clear)
|
||||
(setq-local git-gutter:window-width -1))
|
||||
(setq-local git-gutter:init-function 'nil)
|
||||
(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:window-width 1))
|
||||
(git-gutter-mode +1)
|
||||
(remove-hook 'after-save-hook #'+vc-gutter|init-maybe t)))))
|
||||
(add-hook! (text-mode prog-mode conf-mode)
|
||||
#'+vc-gutter|init-maybe)
|
||||
(when (or +vc-gutter-in-remote-files
|
||||
(not (file-remote-p (or buffer-file-name default-directory))))
|
||||
(if (not buffer-file-name)
|
||||
(add-hook 'after-save-hook #'+vc-gutter-init-maybe-h nil t)
|
||||
(when (and (vc-backend buffer-file-name)
|
||||
(progn
|
||||
(require 'git-gutter)
|
||||
(not (memq major-mode git-gutter:disabled-modes))))
|
||||
(if (and (display-graphic-p)
|
||||
(require 'git-gutter-fringe nil t))
|
||||
(progn
|
||||
(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:clear-function #'git-gutter-fr:clear)
|
||||
(setq-local git-gutter:window-width -1))
|
||||
(setq-local git-gutter:init-function 'nil)
|
||||
(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:window-width 1))
|
||||
(git-gutter-mode +1)
|
||||
(remove-hook 'after-save-hook #'+vc-gutter-init-maybe-h t))))))
|
||||
|
||||
;; standardize default fringe width
|
||||
(if (fboundp 'fringe-mode) (fringe-mode '4))
|
||||
: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)
|
||||
(add-hook 'focus-in-hook #'git-gutter:update-all-windows)
|
||||
|
||||
(defun +vc-gutter|update (&rest _)
|
||||
"Refresh git-gutter on ESC. Return nil to prevent shadowing other
|
||||
(add-hook! :append '(doom-escape-hook doom-switch-window-hook)
|
||||
(defun +vc-gutter-update-h (&rest _)
|
||||
"Refresh git-gutter on ESC. Return nil to prevent shadowing other
|
||||
`doom-escape-hook' hooks."
|
||||
(when git-gutter-mode
|
||||
(ignore (git-gutter))))
|
||||
(add-hook 'doom-escape-hook #'+vc-gutter|update t)
|
||||
|
||||
(when git-gutter-mode
|
||||
(ignore (git-gutter)))))
|
||||
;; update git-gutter when using magit commands
|
||||
(advice-add #'magit-stage-file :after #'+vc-gutter|update)
|
||||
(advice-add #'magit-unstage-file :after #'+vc-gutter|update))
|
||||
(advice-add #'magit-stage-file :after #'+vc-gutter-update-h)
|
||||
(advice-add #'magit-unstage-file :after #'+vc-gutter-update-h))
|
||||
|
||||
|
||||
;; subtle diff indicators in the fringe
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue