Minor refactors & reformatting
This commit is contained in:
parent
c517be8e69
commit
affd076d53
5 changed files with 40 additions and 47 deletions
|
@ -334,8 +334,8 @@ Some items are not supported by the `nsm.el' module."
|
|||
comp-async-env-modifier-form ',(bound-and-true-p comp-async-env-modifier-form)
|
||||
comp-deferred-compilation-black-list ',(bound-and-true-p comp-deferred-compilation-black-list))
|
||||
(with-eval-after-load 'undo-tree
|
||||
;; undo-tree throws errors because `buffer-undo-tree' isn't
|
||||
;; correctly initialized
|
||||
;; HACK `undo-tree' throws errors because `buffer-undo-tree'
|
||||
;; isn't correctly initialized
|
||||
(setq-default buffer-undo-tree (make-undo-tree)))
|
||||
(ignore-errors
|
||||
(delete-directory ,(expand-file-name "auto-save-list" doom-emacs-dir) 'parents)))
|
||||
|
|
|
@ -236,8 +236,9 @@ list remains lean."
|
|||
"Build the trampolines we need to prevent hanging."
|
||||
(when (featurep 'comp)
|
||||
;; HACK The following list was obtained by running 'doom build', waiting for
|
||||
;; it to hang, then checking the eln-cache for trampolines. We simulate
|
||||
;; running 'doom build' twice by compiling the trampolines then restarting.
|
||||
;; it to hang, then checking the eln-cache for trampolines. We
|
||||
;; simulate running 'doom build' twice by compiling the trampolines
|
||||
;; then restarting.
|
||||
(let (restart)
|
||||
(dolist (f '(abort-recursive-edit
|
||||
describe-buffer-bindings
|
||||
|
@ -258,7 +259,7 @@ list remains lean."
|
|||
(unless (doom--find-eln-file
|
||||
(concat comp-native-version-dir "/"
|
||||
(comp-trampoline-filename f)))
|
||||
(print! "Compiling trampoline for %s" f)
|
||||
(print! (info "Compiling trampoline for %s") f)
|
||||
(comp-trampoline-compile f)
|
||||
(setq restart t)))
|
||||
(when restart
|
||||
|
|
|
@ -91,7 +91,8 @@ possible."
|
|||
delete-old-versions t ; clean up after itself
|
||||
kept-old-versions 5
|
||||
kept-new-versions 5
|
||||
backup-directory-alist (list (cons "." (concat doom-cache-dir "backup/"))))
|
||||
backup-directory-alist (list (cons "." (concat doom-cache-dir "backup/")))
|
||||
tramp-backup-directory-alist backup-directory-alist)
|
||||
|
||||
;; But turn on auto-save, so we have a fallback in case of crashes or lost data.
|
||||
;; Use `recover-file' or `recover-session' to recover them.
|
||||
|
@ -102,6 +103,7 @@ possible."
|
|||
auto-save-include-big-deletions t
|
||||
;; ...but have directories set up in case we use it.
|
||||
auto-save-list-file-prefix (concat doom-cache-dir "autosave/")
|
||||
tramp-auto-save-directory (concat doom-cache-dir "tramp-autosave/")
|
||||
auto-save-file-name-transforms
|
||||
(list (list "\\`/[^/]*:\\([^/]*/\\)*\\([^/]*\\)\\'"
|
||||
;; Prefix tramp autosaves to prevent conflicts with local ones
|
||||
|
@ -542,8 +544,8 @@ files, so we replace calls to `pp' with the much faster `prin1'."
|
|||
(add-to-list 'so-long-variable-overrides '(save-place-alist . nil))
|
||||
;; Text files could possibly be too long too
|
||||
(add-to-list 'so-long-target-modes 'text-mode)
|
||||
;; But disable everything else that may be unnecessary/expensive for large
|
||||
;; or wide buffers.
|
||||
;; But disable everything else that may be unnecessary/expensive for large or
|
||||
;; wide buffers.
|
||||
(appendq! so-long-minor-modes
|
||||
'(flycheck-mode
|
||||
flyspell-mode
|
||||
|
@ -559,20 +561,11 @@ files, so we replace calls to `pp' with the much faster `prin1'."
|
|||
hl-fill-column-mode))
|
||||
(defun doom-buffer-has-long-lines-p ()
|
||||
;; HACK Fix #2183: `so-long-detected-long-line-p' tries to parse comment
|
||||
;; syntax, but in some buffers comment state isn't initialized,
|
||||
;; leading to a wrong-type-argument: stringp error.
|
||||
;; syntax, but in some buffers comment state isn't initialized, leading
|
||||
;; to a wrong-type-argument: stringp error.
|
||||
(unless (bound-and-true-p visual-line-mode)
|
||||
(let ((so-long-skip-leading-comments (bound-and-true-p comment-use-syntax))
|
||||
;; HACK If visual-line-mode is on, then false positives are more
|
||||
;; likely, so up the threshold. More so in text-mode, since long
|
||||
;; paragraphs are the norm.
|
||||
(so-long-threshold
|
||||
(if visual-line-mode
|
||||
(* so-long-threshold
|
||||
(if (derived-mode-p 'text-mode)
|
||||
4
|
||||
2))
|
||||
so-long-threshold)))
|
||||
(let ((so-long-skip-leading-comments
|
||||
(bound-and-true-p comment-use-syntax)))
|
||||
(so-long-detected-long-line-p))))
|
||||
(setq so-long-predicate #'doom-buffer-has-long-lines-p))
|
||||
|
||||
|
|
|
@ -125,6 +125,25 @@ unreadable. Returns the names of envvars that were changed."
|
|||
(default-value 'shell-file-name)))
|
||||
env)))
|
||||
|
||||
(defun doom-run-hook-on (hook-var triggers)
|
||||
"Configure HOOK-VAR to be invoked exactly once after init whenever any of the
|
||||
TRIGGERS are invoked. Once HOOK-VAR gets triggered, it resets to nil.
|
||||
|
||||
HOOK-VAR is a quoted hook.
|
||||
|
||||
TRIGGERS is a list of quoted hooks and/or sharp-quoted functions."
|
||||
(let ((fn (intern (format "%s-h" hook-var))))
|
||||
(fset
|
||||
fn (lambda (&rest _)
|
||||
(when after-init-time
|
||||
(run-hook-wrapped hook-var #'doom-try-run-hook)
|
||||
(set hook-var nil))))
|
||||
(put hook-var 'permanent-local t)
|
||||
(dolist (on triggers)
|
||||
(if (functionp on)
|
||||
(advice-add on :before fn)
|
||||
(add-hook on fn)))))
|
||||
|
||||
|
||||
;;
|
||||
;;; Functional library
|
||||
|
@ -487,25 +506,6 @@ advised)."
|
|||
(put ',fn 'permanent-local-hook t)
|
||||
(add-hook sym #',fn ,append))))))
|
||||
|
||||
(defmacro add-hook-trigger! (hook-var &rest targets)
|
||||
"Configure HOOK-VAR to be invoked exactly once after init whenever any of the
|
||||
TARGETS are invoked. Once HOOK-VAR gets triggered, it resets to nil.
|
||||
|
||||
HOOK-VAR is a quoted hook.
|
||||
|
||||
TARGETS is a list of quoted hooks and/or sharp-quoted functions."
|
||||
`(let ((fn (intern (format "%s-h" ,hook-var))))
|
||||
(fset
|
||||
fn (lambda (&rest _)
|
||||
(when after-init-time
|
||||
(run-hook-wrapped ,hook-var #'doom-try-run-hook)
|
||||
(set ,hook-var nil))))
|
||||
(put ,hook-var 'permanent-local t)
|
||||
(dolist (on (list ,@targets))
|
||||
(if (functionp on)
|
||||
(advice-add on :before fn)
|
||||
(add-hook on fn)))))
|
||||
|
||||
(defmacro add-hook! (hooks &rest rest)
|
||||
"A convenience macro for adding N functions to M hooks.
|
||||
|
||||
|
|
13
core/core.el
13
core/core.el
|
@ -374,7 +374,7 @@ config.el instead."
|
|||
(defun doom-run-local-var-hooks-h ()
|
||||
"Run MODE-local-vars-hook after local variables are initialized."
|
||||
(unless doom-inhibit-local-var-hooks
|
||||
(set (make-local-variable 'doom-inhibit-local-var-hooks) t)
|
||||
(setq-local doom-inhibit-local-var-hooks t)
|
||||
(run-hook-wrapped (intern-soft (format "%s-local-vars-hook" major-mode))
|
||||
#'doom-try-run-hook)))
|
||||
|
||||
|
@ -563,9 +563,8 @@ to least)."
|
|||
;; interactive session. If they do, make sure they're properly initialized
|
||||
;; when they do.
|
||||
(autoload 'doom-initialize-packages "core-packages")
|
||||
(autoload 'doom-initialize-core-packages "core-packages")
|
||||
(with-eval-after-load 'package (require 'core-packages))
|
||||
(with-eval-after-load 'straight (doom-initialize-packages))
|
||||
(eval-after-load 'package '(require 'core-packages))
|
||||
(eval-after-load 'straight '(doom-initialize-packages))
|
||||
|
||||
;; Bootstrap our GC manager
|
||||
(add-hook 'doom-first-input-hook #'gcmh-mode)
|
||||
|
@ -574,9 +573,9 @@ to least)."
|
|||
(add-hook 'after-change-major-mode-hook #'doom-run-local-var-hooks-h)
|
||||
(add-hook 'emacs-startup-hook #'doom-load-packages-incrementally-h)
|
||||
(add-hook 'window-setup-hook #'doom-display-benchmark-h)
|
||||
(add-hook-trigger! 'doom-first-buffer-hook 'after-find-file 'doom-switch-buffer-hook)
|
||||
(add-hook-trigger! 'doom-first-file-hook 'after-find-file 'dired-initial-position-hook)
|
||||
(add-hook-trigger! 'doom-first-input-hook 'pre-command-hook)
|
||||
(doom-run-hook-on 'doom-first-buffer-hook '(after-find-file doom-switch-buffer-hook))
|
||||
(doom-run-hook-on 'doom-first-file-hook '(after-find-file dired-initial-position-hook))
|
||||
(doom-run-hook-on 'doom-first-input-hook '(pre-command-hook))
|
||||
(if doom-debug-p (doom-debug-mode +1))
|
||||
|
||||
;; Load core/core-*.el, the user's private init.el, then their config.el
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue