Refactor doom core files
This commit is contained in:
parent
49e6e68a07
commit
57579b883b
7 changed files with 86 additions and 84 deletions
|
@ -78,15 +78,15 @@ fundamental-mode) for performance sake."
|
||||||
|
|
||||||
(electric-indent-mode -1) ; enabled by default in Emacs 25+. No thanks.
|
(electric-indent-mode -1) ; enabled by default in Emacs 25+. No thanks.
|
||||||
|
|
||||||
;; revert buffers for changed files
|
|
||||||
(def-package! autorevert
|
(def-package! autorevert
|
||||||
|
;; revert buffers for changed files
|
||||||
:after-call after-find-file
|
:after-call after-find-file
|
||||||
:config
|
:config
|
||||||
(setq auto-revert-verbose nil)
|
(setq auto-revert-verbose nil)
|
||||||
(global-auto-revert-mode +1))
|
(global-auto-revert-mode +1))
|
||||||
|
|
||||||
;; persist variables across sessions
|
|
||||||
(def-package! savehist
|
(def-package! savehist
|
||||||
|
;; persist variables across sessions
|
||||||
:defer 1
|
:defer 1
|
||||||
:after-call post-command-hook
|
:after-call post-command-hook
|
||||||
:config
|
:config
|
||||||
|
@ -105,8 +105,8 @@ savehist file."
|
||||||
else if item collect it)))
|
else if item collect it)))
|
||||||
(add-hook 'kill-emacs-hook #'doom|unpropertize-kill-ring))
|
(add-hook 'kill-emacs-hook #'doom|unpropertize-kill-ring))
|
||||||
|
|
||||||
;; persistent point location in buffers
|
|
||||||
(def-package! saveplace
|
(def-package! saveplace
|
||||||
|
;; persistent point location in buffers
|
||||||
:after-call (after-find-file dired-initial-position-hook)
|
:after-call (after-find-file dired-initial-position-hook)
|
||||||
:config
|
:config
|
||||||
(setq save-place-file (concat doom-cache-dir "saveplace"))
|
(setq save-place-file (concat doom-cache-dir "saveplace"))
|
||||||
|
@ -117,8 +117,8 @@ savehist file."
|
||||||
:after-while #'doom*recenter-on-load-saveplace)
|
:after-while #'doom*recenter-on-load-saveplace)
|
||||||
(save-place-mode +1))
|
(save-place-mode +1))
|
||||||
|
|
||||||
;; Keep track of recently opened files
|
|
||||||
(def-package! recentf
|
(def-package! recentf
|
||||||
|
;; Keep track of recently opened files
|
||||||
:defer 1
|
:defer 1
|
||||||
:after-call after-find-file
|
:after-call after-find-file
|
||||||
:commands recentf-open-files
|
:commands recentf-open-files
|
||||||
|
@ -152,9 +152,9 @@ savehist file."
|
||||||
;;
|
;;
|
||||||
;; Packages
|
;; Packages
|
||||||
|
|
||||||
;; Auto-close delimiters and blocks as you type. It's more powerful than that,
|
|
||||||
;; but that is all Doom uses it for.
|
|
||||||
(def-package! smartparens
|
(def-package! smartparens
|
||||||
|
;; Auto-close delimiters and blocks as you type. It's more powerful than that,
|
||||||
|
;; but that is all Doom uses it for.
|
||||||
:after-call (doom-exit-buffer-hook after-find-file)
|
:after-call (doom-exit-buffer-hook after-find-file)
|
||||||
:commands (sp-pair sp-local-pair sp-with-modes)
|
:commands (sp-pair sp-local-pair sp-with-modes)
|
||||||
:config
|
:config
|
||||||
|
@ -192,8 +192,9 @@ savehist file."
|
||||||
|
|
||||||
(smartparens-global-mode +1))
|
(smartparens-global-mode +1))
|
||||||
|
|
||||||
;; Automatic detection of indent settings
|
|
||||||
(def-package! dtrt-indent
|
(def-package! dtrt-indent
|
||||||
|
;; Automatic detection of indent settings
|
||||||
:unless noninteractive
|
:unless noninteractive
|
||||||
:defer t
|
:defer t
|
||||||
:init
|
:init
|
||||||
|
@ -207,8 +208,10 @@ savehist file."
|
||||||
#'doom|detect-indentation)
|
#'doom|detect-indentation)
|
||||||
:config
|
:config
|
||||||
(setq dtrt-indent-verbosity (if doom-debug-mode 2 0))
|
(setq dtrt-indent-verbosity (if doom-debug-mode 2 0))
|
||||||
(add-to-list 'dtrt-indent-hook-generic-mapping-list '(t tab-width))
|
;; always keep tab-width up-to-date
|
||||||
|
(push '(t tab-width) dtrt-indent-hook-generic-mapping-list)
|
||||||
|
|
||||||
|
(defvar dtrt-indent-run-after-smie)
|
||||||
(defun doom*fix-broken-smie-modes (orig-fn arg)
|
(defun doom*fix-broken-smie-modes (orig-fn arg)
|
||||||
"Some smie modes throw errors when trying to guess their indentation, like
|
"Some smie modes throw errors when trying to guess their indentation, like
|
||||||
`nim-mode'. This prevents them from leaving Emacs in a broken state."
|
`nim-mode'. This prevents them from leaving Emacs in a broken state."
|
||||||
|
@ -224,8 +227,9 @@ savehist file."
|
||||||
(funcall orig-fn arg))))
|
(funcall orig-fn arg))))
|
||||||
(advice-add #'dtrt-indent-mode :around #'doom*fix-broken-smie-modes))
|
(advice-add #'dtrt-indent-mode :around #'doom*fix-broken-smie-modes))
|
||||||
|
|
||||||
;; Branching undo
|
|
||||||
(def-package! undo-tree
|
(def-package! undo-tree
|
||||||
|
;; Branching & persistent undo
|
||||||
:after-call (doom-exit-buffer-hook after-find-file)
|
:after-call (doom-exit-buffer-hook after-find-file)
|
||||||
:config
|
:config
|
||||||
(setq undo-tree-auto-save-history t
|
(setq undo-tree-auto-save-history t
|
||||||
|
@ -264,16 +268,12 @@ savehist file."
|
||||||
(advice-add #'undo-tree-save-history :around #'doom*compress-undo-tree-history))
|
(advice-add #'undo-tree-save-history :around #'doom*compress-undo-tree-history))
|
||||||
|
|
||||||
|
|
||||||
;;
|
|
||||||
;; Autoloaded Plugins
|
|
||||||
;;
|
|
||||||
|
|
||||||
;; `command-log-mode'
|
;; `command-log-mode'
|
||||||
(setq command-log-mode-auto-show t
|
(setq command-log-mode-auto-show t
|
||||||
command-log-mode-open-log-turns-on-mode t
|
command-log-mode-open-log-turns-on-mode t
|
||||||
command-log-mode-is-global t)
|
command-log-mode-is-global t)
|
||||||
|
|
||||||
;; `expand-region'
|
|
||||||
(def-package! expand-region
|
(def-package! expand-region
|
||||||
:commands (er/contract-region er/mark-symbol er/mark-word)
|
:commands (er/contract-region er/mark-symbol er/mark-word)
|
||||||
:config
|
:config
|
||||||
|
@ -284,6 +284,7 @@ savehist file."
|
||||||
(advice-add #'evil-escape :before #'doom*quit-expand-region)
|
(advice-add #'evil-escape :before #'doom*quit-expand-region)
|
||||||
(advice-add #'doom/escape :before #'doom*quit-expand-region))
|
(advice-add #'doom/escape :before #'doom*quit-expand-region))
|
||||||
|
|
||||||
|
|
||||||
;; `helpful' --- a better *help* buffer
|
;; `helpful' --- a better *help* buffer
|
||||||
(define-key! 'global
|
(define-key! 'global
|
||||||
[remap describe-function] #'helpful-callable
|
[remap describe-function] #'helpful-callable
|
||||||
|
@ -291,8 +292,9 @@ savehist file."
|
||||||
[remap describe-variable] #'helpful-variable
|
[remap describe-variable] #'helpful-variable
|
||||||
[remap describe-key] #'helpful-key)
|
[remap describe-key] #'helpful-key)
|
||||||
|
|
||||||
;; `ws-butler' --- a better `delete-trailing-whitespaces'
|
|
||||||
(def-package! ws-butler
|
(def-package! ws-butler
|
||||||
|
;; a less intrusive `delete-trailing-whitespaces' on save
|
||||||
:after-call (after-find-file)
|
:after-call (after-find-file)
|
||||||
:config
|
:config
|
||||||
(setq ws-butler-global-exempt-modes
|
(setq ws-butler-global-exempt-modes
|
||||||
|
|
|
@ -56,10 +56,15 @@ If any hook returns non-nil, all hooks after it are ignored.")
|
||||||
which-key-min-display-lines 6
|
which-key-min-display-lines 6
|
||||||
which-key-side-window-slot -10)
|
which-key-side-window-slot -10)
|
||||||
:config
|
:config
|
||||||
;; embolden local bindings
|
;; general improvements to which-key readability
|
||||||
(set-face-attribute 'which-key-local-map-description-face nil :weight 'bold)
|
(set-face-attribute 'which-key-local-map-description-face nil :weight 'bold)
|
||||||
(which-key-setup-side-window-bottom)
|
(which-key-setup-side-window-bottom)
|
||||||
(setq-hook! 'which-key-init-buffer-hook line-spacing 3)
|
(setq-hook! 'which-key-init-buffer-hook line-spacing 3)
|
||||||
|
(defun doom*no-fringes-in-which-key-buffer (&rest _)
|
||||||
|
(doom|no-fringes-in-minibuffer)
|
||||||
|
(set-window-fringes (get-buffer-window which-key--buffer) 0 0 nil))
|
||||||
|
(advice-add 'which-key--show-buffer-side-window :after #'doom*no-fringes-in-which-key-buffer)
|
||||||
|
|
||||||
(which-key-mode +1))
|
(which-key-mode +1))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -304,8 +304,8 @@ to least)."
|
||||||
(defmacro def-package! (name &rest plist)
|
(defmacro def-package! (name &rest plist)
|
||||||
"This is a thin wrapper around `use-package'."
|
"This is a thin wrapper around `use-package'."
|
||||||
`(use-package ,name
|
`(use-package ,name
|
||||||
,@(append (if (memq name doom-disabled-packages) `(:disabled t))
|
,@(if (memq name doom-disabled-packages) `(:disabled t))
|
||||||
plist)))
|
,@plist))
|
||||||
|
|
||||||
(defmacro def-package-hook! (package when &rest body)
|
(defmacro def-package-hook! (package when &rest body)
|
||||||
"Reconfigures a package's `def-package!' block.
|
"Reconfigures a package's `def-package!' block.
|
||||||
|
|
|
@ -47,18 +47,18 @@
|
||||||
|
|
||||||
;; Projectile root-searching functions can cause an infinite loop on TRAMP
|
;; Projectile root-searching functions can cause an infinite loop on TRAMP
|
||||||
;; connections, so disable them.
|
;; connections, so disable them.
|
||||||
(defun doom*projectile-locate-dominating-file (orig-fn &rest args)
|
(defun doom*projectile-locate-dominating-file (orig-fn file name)
|
||||||
"Don't traverse the file system if on a remote connection."
|
"Don't traverse the file system if on a remote connection."
|
||||||
(unless (file-remote-p default-directory)
|
(unless (file-remote-p default-directory)
|
||||||
(apply orig-fn args)))
|
(funcall orig-fn file name)))
|
||||||
(advice-add #'projectile-locate-dominating-file :around #'doom*projectile-locate-dominating-file)
|
(advice-add #'projectile-locate-dominating-file :around #'doom*projectile-locate-dominating-file)
|
||||||
|
|
||||||
(defun doom*projectile-cache-current-file (orig-fun &rest args)
|
(defun doom*projectile-cache-current-file (orig-fn)
|
||||||
"Don't cache ignored files."
|
"Don't cache ignored files."
|
||||||
(unless (cl-loop for path in (projectile-ignored-directories)
|
(unless (cl-loop for path in (projectile-ignored-directories)
|
||||||
if (string-prefix-p (or buffer-file-name "") (expand-file-name path))
|
if (string-prefix-p (or buffer-file-name "") (expand-file-name path))
|
||||||
return t)
|
return t)
|
||||||
(apply orig-fun args)))
|
(funcall orig-fn)))
|
||||||
(advice-add #'projectile-cache-current-file :around #'doom*projectile-cache-current-file))
|
(advice-add #'projectile-cache-current-file :around #'doom*projectile-cache-current-file))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,11 @@ shorter major mode name in the mode-line. See `doom|set-mode-name'.")
|
||||||
window-resize-pixelwise t
|
window-resize-pixelwise t
|
||||||
frame-resize-pixelwise t)
|
frame-resize-pixelwise t)
|
||||||
|
|
||||||
(fset #'yes-or-no-p #'y-or-n-p) ; y/n instead of yes/no
|
;; y/n instead of yes/no
|
||||||
|
(fset #'yes-or-no-p #'y-or-n-p)
|
||||||
|
|
||||||
|
;; Truly silence startup message
|
||||||
|
(fset #'display-startup-echo-area-message #'ignore)
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
@ -100,7 +104,7 @@ shorter major mode name in the mode-line. See `doom|set-mode-name'.")
|
||||||
(add-hook 'completion-list-mode-hook #'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 'Man-mode-hook #'hide-mode-line-mode)
|
||||||
|
|
||||||
;; `highlight-numbers' -- better number literal fontification in code
|
;; `highlight-numbers' --- better number literal fontification in code
|
||||||
(def-package! highlight-numbers
|
(def-package! highlight-numbers
|
||||||
:hook (prog-mode . highlight-numbers-mode)
|
:hook (prog-mode . highlight-numbers-mode)
|
||||||
:config (setq highlight-numbers-generic-regexp "\\_<[[:digit:]]+\\(?:\\.[0-9]*\\)?\\_>"))
|
:config (setq highlight-numbers-generic-regexp "\\_<[[:digit:]]+\\(?:\\.[0-9]*\\)?\\_>"))
|
||||||
|
@ -113,10 +117,11 @@ shorter major mode name in the mode-line. See `doom|set-mode-name'.")
|
||||||
;; Especially in parentheses-drunk languages like Lisp.
|
;; Especially in parentheses-drunk languages like Lisp.
|
||||||
(setq rainbow-delimiters-max-face-count 3)
|
(setq rainbow-delimiters-max-face-count 3)
|
||||||
|
|
||||||
;; `restart-emacs'
|
;; `restart-emacs' --- provides a simple mechanism for restarting Emacs and
|
||||||
|
;; daemons interactively.
|
||||||
(setq restart-emacs--args (list "--restore"))
|
(setq restart-emacs--args (list "--restore"))
|
||||||
|
|
||||||
;; `visual-fill-column' For a distractions-free-like UI, that dynamically
|
;; `visual-fill-column' --- for a distractions-free-like UI, that dynamically
|
||||||
;; resizes margins and can center a buffer.
|
;; resizes margins and can center a buffer.
|
||||||
(setq visual-fill-column-center-text t
|
(setq visual-fill-column-center-text t
|
||||||
visual-fill-column-width
|
visual-fill-column-width
|
||||||
|
@ -143,8 +148,9 @@ shorter major mode name in the mode-line. See `doom|set-mode-name'.")
|
||||||
(add-hook 'isearch-mode-hook #'doom|disable-ui-keystrokes)
|
(add-hook 'isearch-mode-hook #'doom|disable-ui-keystrokes)
|
||||||
(add-hook 'isearch-mode-end-hook #'doom|enable-ui-keystrokes)
|
(add-hook 'isearch-mode-end-hook #'doom|enable-ui-keystrokes)
|
||||||
|
|
||||||
;; Highlights the current line
|
|
||||||
(def-package! hl-line ; built-in
|
(def-package! hl-line ; built-in
|
||||||
|
;; Highlights the current line
|
||||||
:hook ((prog-mode text-mode conf-mode) . hl-line-mode)
|
:hook ((prog-mode text-mode conf-mode) . hl-line-mode)
|
||||||
:config
|
:config
|
||||||
;; I don't need hl-line showing in other windows. This also offers a small
|
;; I don't need hl-line showing in other windows. This also offers a small
|
||||||
|
@ -180,14 +186,16 @@ shorter major mode name in the mode-line. See `doom|set-mode-name'.")
|
||||||
(add-hook 'evil-visual-state-entry-hook #'doom|disable-hl-line)
|
(add-hook 'evil-visual-state-entry-hook #'doom|disable-hl-line)
|
||||||
(add-hook 'evil-visual-state-exit-hook #'doom|enable-hl-line-maybe)))
|
(add-hook 'evil-visual-state-exit-hook #'doom|enable-hl-line-maybe)))
|
||||||
|
|
||||||
;; undo/redo changes to Emacs' window layout
|
|
||||||
(def-package! winner
|
(def-package! winner
|
||||||
|
;; undo/redo changes to Emacs' window layout
|
||||||
:after-call doom-exit-window-hook
|
:after-call doom-exit-window-hook
|
||||||
:preface (defvar winner-dont-bind-my-keys t) ; I'll bind keys myself
|
:preface (defvar winner-dont-bind-my-keys t) ; I'll bind keys myself
|
||||||
:config (winner-mode +1))
|
:config (winner-mode +1))
|
||||||
|
|
||||||
;; highlight matching delimiters
|
|
||||||
(def-package! paren
|
(def-package! paren
|
||||||
|
;; highlight matching delimiters
|
||||||
:after-call (after-find-file doom-exit-buffer-hook)
|
:after-call (after-find-file doom-exit-buffer-hook)
|
||||||
:init
|
:init
|
||||||
(defun doom|disable-show-paren-mode ()
|
(defun doom|disable-show-paren-mode ()
|
||||||
|
@ -199,6 +207,7 @@ shorter major mode name in the mode-line. See `doom|set-mode-name'.")
|
||||||
show-paren-when-point-inside-paren t)
|
show-paren-when-point-inside-paren t)
|
||||||
(show-paren-mode +1))
|
(show-paren-mode +1))
|
||||||
|
|
||||||
|
|
||||||
;; The native border "consumes" a pixel of the fringe on righter-most splits,
|
;; The native border "consumes" a pixel of the fringe on righter-most splits,
|
||||||
;; `window-divider' does not. Available since Emacs 25.1.
|
;; `window-divider' does not. Available since Emacs 25.1.
|
||||||
(setq-default window-divider-default-places t
|
(setq-default window-divider-default-places t
|
||||||
|
@ -206,12 +215,8 @@ shorter major mode name in the mode-line. See `doom|set-mode-name'.")
|
||||||
window-divider-default-right-width 1)
|
window-divider-default-right-width 1)
|
||||||
(add-hook 'doom-init-ui-hook #'window-divider-mode)
|
(add-hook 'doom-init-ui-hook #'window-divider-mode)
|
||||||
|
|
||||||
;; remove prompt if the file is opened in other clients
|
|
||||||
(defun server-remove-kill-buffer-hook ()
|
|
||||||
(remove-hook 'kill-buffer-query-functions #'server-kill-buffer-query-function))
|
|
||||||
(add-hook 'server-visit-hook #'server-remove-kill-buffer-hook)
|
|
||||||
|
|
||||||
;; `whitespace-mode' (built-in)
|
;; `whitespace-mode'
|
||||||
(setq whitespace-line-column nil
|
(setq whitespace-line-column nil
|
||||||
whitespace-style
|
whitespace-style
|
||||||
'(face indentation tabs tab-mark spaces space-mark newline newline-mark
|
'(face indentation tabs tab-mark spaces space-mark newline newline-mark
|
||||||
|
@ -384,7 +389,8 @@ frame's window-system, the theme will be reloaded.")
|
||||||
;; fonts
|
;; fonts
|
||||||
(add-hook 'doom-init-ui-hook #'doom|init-fonts)
|
(add-hook 'doom-init-ui-hook #'doom|init-fonts)
|
||||||
;; themes
|
;; themes
|
||||||
(add-hook 'doom-init-ui-hook #'doom|init-theme)
|
(unless (daemonp)
|
||||||
|
(add-hook 'doom-init-ui-hook #'doom|init-theme))
|
||||||
(add-hook 'after-make-frame-functions #'doom|reload-theme-in-frame-maybe)
|
(add-hook 'after-make-frame-functions #'doom|reload-theme-in-frame-maybe)
|
||||||
(add-hook 'after-delete-frame-functions #'doom|reload-theme-maybe)
|
(add-hook 'after-delete-frame-functions #'doom|reload-theme-maybe)
|
||||||
|
|
||||||
|
@ -394,20 +400,16 @@ frame's window-system, the theme will be reloaded.")
|
||||||
|
|
||||||
;; simple name in frame title
|
;; simple name in frame title
|
||||||
(setq frame-title-format '("%b – Doom Emacs"))
|
(setq frame-title-format '("%b – Doom Emacs"))
|
||||||
|
;; relegate tooltips to echo area only
|
||||||
;; draw me like one of your French editors
|
(tooltip-mode -1)
|
||||||
(tooltip-mode -1) ; relegate tooltips to echo area only
|
|
||||||
|
|
||||||
;; a good indicator that Emacs isn't frozen
|
;; a good indicator that Emacs isn't frozen
|
||||||
(add-hook 'doom-init-ui-hook #'blink-cursor-mode)
|
(add-hook 'doom-init-ui-hook #'blink-cursor-mode)
|
||||||
;; Make `next-buffer', `other-buffer', etc. ignore unreal buffers.
|
;; Make `next-buffer', `other-buffer', etc. ignore unreal buffers.
|
||||||
(add-to-list 'default-frame-alist (cons 'buffer-predicate #'doom-buffer-frame-predicate))
|
(add-to-list 'default-frame-alist '(buffer-predicate . doom-buffer-frame-predicate))
|
||||||
|
|
||||||
;; Prevent the glimpse of un-styled Emacs by setting these early.
|
;; Prevent the glimpse of un-styled Emacs by setting these early.
|
||||||
(add-to-list 'default-frame-alist '(tool-bar-lines 0))
|
(add-to-list 'default-frame-alist '(tool-bar-lines 0))
|
||||||
(add-to-list 'default-frame-alist '(menu-bar-lines 0))
|
(add-to-list 'default-frame-alist '(menu-bar-lines 0))
|
||||||
(add-to-list 'default-frame-alist '(vertical-scroll-bars))
|
(add-to-list 'default-frame-alist '(vertical-scroll-bars))
|
||||||
|
|
||||||
;; prompts the user for confirmation when deleting a non-empty frame
|
;; prompts the user for confirmation when deleting a non-empty frame
|
||||||
(global-set-key [remap delete-frame] #'doom/delete-frame)
|
(global-set-key [remap delete-frame] #'doom/delete-frame)
|
||||||
|
|
||||||
|
@ -442,13 +444,13 @@ instead). Meant for `kill-buffer-query-functions'."
|
||||||
(add-hook 'after-change-major-mode-hook #'doom|set-mode-name)
|
(add-hook 'after-change-major-mode-hook #'doom|set-mode-name)
|
||||||
(add-hook 'after-change-major-mode-hook #'doom|highlight-non-default-indentation)
|
(add-hook 'after-change-major-mode-hook #'doom|highlight-non-default-indentation)
|
||||||
(add-hook 'compilation-filter-hook #'doom|apply-ansi-color-to-compilation-buffer)
|
(add-hook 'compilation-filter-hook #'doom|apply-ansi-color-to-compilation-buffer)
|
||||||
;;
|
|
||||||
(run-hook-wrapped 'doom-init-ui-hook #'doom-try-run-hook))
|
(run-hook-wrapped 'doom-init-ui-hook #'doom-try-run-hook))
|
||||||
|
|
||||||
(add-hook 'emacs-startup-hook #'doom|init-ui)
|
(add-hook 'emacs-startup-hook #'doom|init-ui)
|
||||||
|
|
||||||
|
|
||||||
;; Fixes/hacks
|
|
||||||
;;
|
;;
|
||||||
|
;; Fixes/hacks
|
||||||
|
|
||||||
;; doesn't exist in terminal Emacs; we define it to prevent errors
|
;; doesn't exist in terminal Emacs; we define it to prevent errors
|
||||||
(unless (fboundp 'define-fringe-bitmap)
|
(unless (fboundp 'define-fringe-bitmap)
|
||||||
|
@ -481,11 +483,6 @@ instead). Meant for `kill-buffer-query-functions'."
|
||||||
(advice-add #'delete-backward-char :around #'doom*silence-motion-errors)
|
(advice-add #'delete-backward-char :around #'doom*silence-motion-errors)
|
||||||
(advice-add #'backward-kill-sentence :around #'doom*silence-motion-errors)
|
(advice-add #'backward-kill-sentence :around #'doom*silence-motion-errors)
|
||||||
|
|
||||||
(defun doom*no-fringes-in-which-key-buffer (&rest _)
|
|
||||||
(doom|no-fringes-in-minibuffer)
|
|
||||||
(set-window-fringes (get-buffer-window which-key--buffer) 0 0 nil))
|
|
||||||
(advice-add 'which-key--show-buffer-side-window :after #'doom*no-fringes-in-which-key-buffer)
|
|
||||||
|
|
||||||
;; Switch to `doom-fallback-buffer' if on last real buffer
|
;; Switch to `doom-fallback-buffer' if on last real buffer
|
||||||
(advice-add #'kill-this-buffer :around #'doom*switch-to-fallback-buffer-maybe)
|
(advice-add #'kill-this-buffer :around #'doom*switch-to-fallback-buffer-maybe)
|
||||||
|
|
||||||
|
|
46
core/core.el
46
core/core.el
|
@ -16,10 +16,8 @@ line or use --debug-init to enable this.")
|
||||||
(defconst doom-version "2.0.9"
|
(defconst doom-version "2.0.9"
|
||||||
"Current version of DOOM emacs.")
|
"Current version of DOOM emacs.")
|
||||||
|
|
||||||
(defconst EMACS26+
|
(defconst EMACS26+ (> emacs-major-version 25))
|
||||||
(eval-when-compile (not (version< emacs-version "26"))))
|
(defconst EMACS27+ (> emacs-major-version 26))
|
||||||
(defconst EMACS27+
|
|
||||||
(eval-when-compile (not (version< emacs-version "27"))))
|
|
||||||
|
|
||||||
(defconst IS-MAC (eq system-type 'darwin))
|
(defconst IS-MAC (eq system-type 'darwin))
|
||||||
(defconst IS-LINUX (eq system-type 'gnu/linux))
|
(defconst IS-LINUX (eq system-type 'gnu/linux))
|
||||||
|
@ -27,15 +25,14 @@ line or use --debug-init to enable this.")
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
(defvar doom-emacs-dir
|
(defvar doom-emacs-dir user-emacs-directory
|
||||||
(eval-when-compile (file-truename user-emacs-directory))
|
|
||||||
"The path to this emacs.d directory. Must end in a slash.")
|
"The path to this emacs.d directory. Must end in a slash.")
|
||||||
|
|
||||||
(defvar doom-core-dir (concat doom-emacs-dir "core/")
|
(defvar doom-core-dir (concat doom-emacs-dir "core/")
|
||||||
"Where essential files are stored.")
|
"The root directory of core Doom files.")
|
||||||
|
|
||||||
(defvar doom-modules-dir (concat doom-emacs-dir "modules/")
|
(defvar doom-modules-dir (concat doom-emacs-dir "modules/")
|
||||||
"The main directory where Doom modules are stored.")
|
"The root directory for Doom's modules.")
|
||||||
|
|
||||||
(defvar doom-local-dir (concat doom-emacs-dir ".local/")
|
(defvar doom-local-dir (concat doom-emacs-dir ".local/")
|
||||||
"Root directory for local Emacs files. Use this as permanent storage for files
|
"Root directory for local Emacs files. Use this as permanent storage for files
|
||||||
|
@ -125,19 +122,21 @@ module init.el files, but before their config.el files are loaded.")
|
||||||
else (except for `window-setup-hook').")
|
else (except for `window-setup-hook').")
|
||||||
|
|
||||||
(defvar doom-reload-hook nil
|
(defvar doom-reload-hook nil
|
||||||
"A list of hooks to run when `doom//reload-load-path' is called.")
|
"A list of hooks to run when `doom/reload' is called.")
|
||||||
|
|
||||||
(defvar doom-load-theme-hook nil
|
(defvar doom-load-theme-hook nil
|
||||||
"Hook run when the theme (and font) is initialized (or reloaded
|
"Hook run after the theme is loaded with `load-theme' or reloaded with
|
||||||
with `doom/reload-theme').")
|
`doom/reload-theme'.")
|
||||||
|
|
||||||
(defvar doom-exit-window-hook nil
|
(defvar doom-exit-window-hook nil
|
||||||
"Hook run before `switch-window' or `switch-frame' are called. See
|
"Hook run before `switch-window' or `switch-frame' are called.
|
||||||
`doom-enter-window-hook'.")
|
|
||||||
|
Also see `doom-enter-window-hook'.")
|
||||||
|
|
||||||
(defvar doom-enter-window-hook nil
|
(defvar doom-enter-window-hook nil
|
||||||
"Hook run after `switch-window' or `switch-frame' are called. See
|
"Hook run after `switch-window' or `switch-frame' are called.
|
||||||
`doom-exit-window-hook'.")
|
|
||||||
|
Also see `doom-exit-window-hook'.")
|
||||||
|
|
||||||
(defvar doom-exit-buffer-hook nil
|
(defvar doom-exit-buffer-hook nil
|
||||||
"Hook run after `switch-to-buffer', `pop-to-buffer' or `display-buffer' are
|
"Hook run after `switch-to-buffer', `pop-to-buffer' or `display-buffer' are
|
||||||
|
@ -152,9 +151,11 @@ called. The buffer to be switched to is current when these hooks run.
|
||||||
Also see `doom-exit-buffer-hook'.")
|
Also see `doom-exit-buffer-hook'.")
|
||||||
|
|
||||||
(defvar doom-inhibit-switch-buffer-hooks nil
|
(defvar doom-inhibit-switch-buffer-hooks nil
|
||||||
"Letvar for inhibiting `doom-enter-buffer-hook' and `doom-exit-buffer-hook'.")
|
"Letvar for inhibiting `doom-enter-buffer-hook' and `doom-exit-buffer-hook'.
|
||||||
|
Do not set this directly.")
|
||||||
(defvar doom-inhibit-switch-window-hooks nil
|
(defvar doom-inhibit-switch-window-hooks nil
|
||||||
"Letvar for inhibiting `doom-enter-window-hook' and `doom-exit-window-hook'.")
|
"Letvar for inhibiting `doom-enter-window-hook' and `doom-exit-window-hook'.
|
||||||
|
Do not set this directly.")
|
||||||
|
|
||||||
(defun doom*switch-window-hooks (orig-fn window &optional norecord)
|
(defun doom*switch-window-hooks (orig-fn window &optional norecord)
|
||||||
(if (or doom-inhibit-switch-window-hooks
|
(if (or doom-inhibit-switch-window-hooks
|
||||||
|
@ -290,9 +291,6 @@ original value of `symbol-file'."
|
||||||
(funcall orig-fn symbol type)))
|
(funcall orig-fn symbol type)))
|
||||||
(advice-add #'symbol-file :around #'doom*symbol-file)
|
(advice-add #'symbol-file :around #'doom*symbol-file)
|
||||||
|
|
||||||
;; Truly silence startup message
|
|
||||||
(fset #'display-startup-echo-area-message #'ignore)
|
|
||||||
|
|
||||||
;; Don't garbage collect to speed up minibuffer commands
|
;; Don't garbage collect to speed up minibuffer commands
|
||||||
(defun doom|defer-garbage-collection ()
|
(defun doom|defer-garbage-collection ()
|
||||||
(setq gc-cons-threshold doom-gc-cons-upper-limit))
|
(setq gc-cons-threshold doom-gc-cons-upper-limit))
|
||||||
|
@ -306,13 +304,13 @@ original value of `symbol-file'."
|
||||||
;; Bootstrap helpers
|
;; Bootstrap helpers
|
||||||
|
|
||||||
(defun doom-try-run-hook (hook)
|
(defun doom-try-run-hook (hook)
|
||||||
"Run HOOK (a hook function), but marks thrown errors to make it a little
|
"Run HOOK (a hook function), but handle errors better, to make debugging
|
||||||
easier to tell where the came from.
|
issues easier.
|
||||||
|
|
||||||
Meant to be used with `run-hook-wrapped'."
|
Meant to be used with `run-hook-wrapped'."
|
||||||
|
(let ((gc-cons-threshold doom-gc-cons-upper-limit))
|
||||||
(when doom-debug-mode
|
(when doom-debug-mode
|
||||||
(message "Running doom hook: %s" hook))
|
(message "Running doom hook: %s" hook))
|
||||||
(let ((gc-cons-threshold doom-gc-cons-upper-limit))
|
|
||||||
(condition-case e
|
(condition-case e
|
||||||
(funcall hook)
|
(funcall hook)
|
||||||
((debug error)
|
((debug error)
|
||||||
|
@ -400,9 +398,9 @@ The overall load order of Doom is as follows:
|
||||||
`doom-init-hook'
|
`doom-init-hook'
|
||||||
Module config.el files
|
Module config.el files
|
||||||
~/.doom.d/config.el
|
~/.doom.d/config.el
|
||||||
|
`doom-post-init-hook'
|
||||||
`after-init-hook'
|
`after-init-hook'
|
||||||
`emacs-startup-hook'
|
`emacs-startup-hook'
|
||||||
`doom-post-init-hook' (at end of `emacs-startup-hook')
|
|
||||||
|
|
||||||
Module load order is determined by your `doom!' block. See `doom-modules-dirs'
|
Module load order is determined by your `doom!' block. See `doom-modules-dirs'
|
||||||
for a list of all recognized module trees. Order defines precedence (from most
|
for a list of all recognized module trees. Order defines precedence (from most
|
||||||
|
|
18
init.el
18
init.el
|
@ -41,17 +41,17 @@ decrease this. If you experience stuttering, increase this.")
|
||||||
"Resets garbage collection settings to reasonable defaults (a large
|
"Resets garbage collection settings to reasonable defaults (a large
|
||||||
`gc-cons-threshold' can cause random freezes otherwise) and resets
|
`gc-cons-threshold' can cause random freezes otherwise) and resets
|
||||||
`file-name-handler-alist'."
|
`file-name-handler-alist'."
|
||||||
(setq-default file-name-handler-alist doom--file-name-handler-alist)
|
(setq file-name-handler-alist doom--file-name-handler-alist)
|
||||||
;; Do it on an idle timer to defer the possible GC pause, and to give deferred
|
;; Do this on idle timer to defer a possible GC pause that could result; also
|
||||||
;; packages the opportunity to take advantage of these optimizations.
|
;; allows deferred packages to take advantage of these optimizations.
|
||||||
(run-with-idle-timer
|
(run-with-idle-timer
|
||||||
3 nil (lambda () (setq-default gc-cons-threshold doom-gc-cons-threshold))))
|
3 nil (lambda () (setq-default gc-cons-threshold doom-gc-cons-threshold))))
|
||||||
|
|
||||||
|
|
||||||
(if (or after-init-time noninteractive)
|
(if (or after-init-time noninteractive)
|
||||||
(setq gc-cons-threshold doom-gc-cons-threshold)
|
(setq gc-cons-threshold doom-gc-cons-threshold)
|
||||||
;; A big contributor to long startup times is the garbage collector, so we up
|
;; A big contributor to startup times is garbage collection. We up the gc
|
||||||
;; its memory threshold, temporarily and reset it later in
|
;; threshold to temporarily prevent it from running, then reset it later in
|
||||||
;; `doom|disable-startup-optimizations'.
|
;; `doom|disable-startup-optimizations'.
|
||||||
(setq gc-cons-threshold doom-gc-cons-upper-limit)
|
(setq gc-cons-threshold doom-gc-cons-upper-limit)
|
||||||
;; This is consulted on every `require', `load' and various file reading
|
;; This is consulted on every `require', `load' and various file reading
|
||||||
|
@ -61,11 +61,11 @@ decrease this. If you experience stuttering, increase this.")
|
||||||
(add-hook 'emacs-startup-hook #'doom|restore-startup-optimizations))
|
(add-hook 'emacs-startup-hook #'doom|restore-startup-optimizations))
|
||||||
|
|
||||||
|
|
||||||
;; Ensure Doom is always running out of this file's directory
|
;; Ensure Doom is running out of this file's directory
|
||||||
(setq user-emacs-directory (file-name-directory load-file-name))
|
(setq user-emacs-directory (file-name-directory load-file-name))
|
||||||
;; In noninteractive sessions, we hope that non-byte-compiled files will take
|
;; In noninteractive sessions, prioritize non-byte-compiled source files to
|
||||||
;; precedence over byte-compiled ones, however, if you're getting odd recursive
|
;; prevent stale, byte-compiled code from running. However, if you're getting
|
||||||
;; load errors, it may help to set this to nil.
|
;; recursive load errors, it may help to set this to nil.
|
||||||
(setq load-prefer-newer noninteractive)
|
(setq load-prefer-newer noninteractive)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue