mirror of
https://gitlab.com/dwt1/dotfiles.git
synced 2026-04-24 03:50:24 +10:00
Updating Doom Emacs.
This commit is contained in:
@@ -54,6 +54,9 @@ examples.
|
||||
It is recommended you don't set specify a font-size, as to inherit `doom-font's
|
||||
size.")
|
||||
|
||||
(defvar doom-unicode-extra-fonts nil
|
||||
"Fonts to inject into the unicode charset before `doom-unicode-font'.")
|
||||
|
||||
|
||||
;;
|
||||
;;; Custom hooks
|
||||
@@ -85,45 +88,51 @@ size.")
|
||||
(defvar doom--last-frame nil)
|
||||
|
||||
(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))
|
||||
(let ((doom-inhibit-switch-window-hooks t))
|
||||
(run-hooks 'doom-switch-window-hook)
|
||||
(setq doom--last-window (selected-window))))))
|
||||
(unless (or doom-inhibit-switch-window-hooks
|
||||
(eq doom--last-window (selected-window))
|
||||
(minibufferp))
|
||||
(let ((gc-cons-threshold most-positive-fixnum)
|
||||
(doom-inhibit-switch-window-hooks t)
|
||||
(inhibit-redisplay t))
|
||||
(run-hooks 'doom-switch-window-hook)
|
||||
(setq doom--last-window (selected-window)))))
|
||||
|
||||
(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))
|
||||
(let ((doom-inhibit-switch-frame-hooks t))
|
||||
(let ((gc-cons-threshold most-positive-fixnum)
|
||||
(doom-inhibit-switch-frame-hooks t))
|
||||
(run-hooks 'doom-switch-frame-hook)
|
||||
(setq doom--last-frame (selected-frame)))))
|
||||
|
||||
(defun doom-run-switch-buffer-hooks-a (orig-fn buffer-or-name &rest args)
|
||||
(let ((gc-cons-threshold most-positive-fixnum))
|
||||
(if (or doom-inhibit-switch-buffer-hooks
|
||||
(eq (current-buffer) (get-buffer buffer-or-name))
|
||||
(and (eq orig-fn #'switch-to-buffer) (car args)))
|
||||
(apply orig-fn buffer-or-name args)
|
||||
(let ((doom-inhibit-switch-buffer-hooks t))
|
||||
(when-let (buffer (apply orig-fn buffer-or-name args))
|
||||
(with-current-buffer (if (windowp buffer)
|
||||
(window-buffer buffer)
|
||||
buffer)
|
||||
(run-hooks 'doom-switch-buffer-hook))
|
||||
buffer)))))
|
||||
(if (or doom-inhibit-switch-buffer-hooks
|
||||
(and buffer-or-name
|
||||
(eq (current-buffer)
|
||||
(get-buffer buffer-or-name)))
|
||||
(and (eq orig-fn #'switch-to-buffer) (car args)))
|
||||
(apply orig-fn buffer-or-name args)
|
||||
(let ((gc-cons-threshold most-positive-fixnum)
|
||||
(doom-inhibit-switch-buffer-hooks t)
|
||||
(inhibit-redisplay t))
|
||||
(when-let (buffer (apply orig-fn buffer-or-name args))
|
||||
(with-current-buffer (if (windowp buffer)
|
||||
(window-buffer buffer)
|
||||
buffer)
|
||||
(run-hooks 'doom-switch-buffer-hook))
|
||||
buffer))))
|
||||
|
||||
(defun doom-run-switch-to-next-prev-buffer-hooks-a (orig-fn &rest args)
|
||||
(let ((gc-cons-threshold most-positive-fixnum))
|
||||
(if doom-inhibit-switch-buffer-hooks
|
||||
(apply orig-fn args)
|
||||
(let ((doom-inhibit-switch-buffer-hooks t))
|
||||
(when-let (buffer (apply orig-fn args))
|
||||
(with-current-buffer buffer
|
||||
(run-hooks 'doom-switch-buffer-hook))
|
||||
buffer)))))
|
||||
(if doom-inhibit-switch-buffer-hooks
|
||||
(apply orig-fn args)
|
||||
(let ((gc-cons-threshold most-positive-fixnum)
|
||||
(doom-inhibit-switch-buffer-hooks t)
|
||||
(inhibit-redisplay t))
|
||||
(when-let (buffer (apply orig-fn args))
|
||||
(with-current-buffer buffer
|
||||
(run-hooks 'doom-switch-buffer-hook))
|
||||
buffer))))
|
||||
|
||||
(defun doom-protect-fallback-buffer-h ()
|
||||
"Don't kill the scratch buffer. Meant for `kill-buffer-query-functions'."
|
||||
@@ -135,10 +144,11 @@ size.")
|
||||
e.g. If you indent with spaces by default, tabs will be highlighted. If you
|
||||
indent with tabs, spaces at BOL are highlighted.
|
||||
|
||||
Does nothing if `whitespace-mode' is already active or the current buffer is
|
||||
read-only or not file-visiting."
|
||||
Does nothing if `whitespace-mode' or 'global-whitespace-mode' is already
|
||||
active or if the current buffer is read-only or not file-visiting."
|
||||
(unless (or (eq major-mode 'fundamental-mode)
|
||||
buffer-read-only
|
||||
(bound-and-true-p global-whitespace-mode)
|
||||
(null buffer-file-name))
|
||||
(require 'whitespace)
|
||||
(set (make-local-variable 'whitespace-style)
|
||||
@@ -156,6 +166,10 @@ read-only or not file-visiting."
|
||||
;; Simpler confirmation prompt when killing Emacs
|
||||
(setq confirm-kill-emacs #'doom-quit-p)
|
||||
|
||||
;; Don't prompt for confirmation when we create a new file or buffer (assume the
|
||||
;; user knows what they're doing).
|
||||
(setq confirm-nonexistent-file-or-buffer nil)
|
||||
|
||||
(setq uniquify-buffer-name-style 'forward
|
||||
;; no beeping or blinking please
|
||||
ring-bell-function #'ignore
|
||||
@@ -173,7 +187,12 @@ read-only or not file-visiting."
|
||||
|
||||
(setq hscroll-margin 2
|
||||
hscroll-step 1
|
||||
scroll-conservatively 10
|
||||
;; Emacs spends too much effort recentering the screen if you scroll the
|
||||
;; cursor more than N lines past window edges (where N is the settings of
|
||||
;; `scroll-conservatively'). This is especially slow in larger files
|
||||
;; during large-scale scrolling commands. If kept over 100, the window is
|
||||
;; never automatically recentered.
|
||||
scroll-conservatively 101
|
||||
scroll-margin 0
|
||||
scroll-preserve-screen-position t
|
||||
;; Reduce cursor lag by a tiny bit by not auto-adjusting `window-vscroll'
|
||||
@@ -195,12 +214,18 @@ read-only or not file-visiting."
|
||||
;;
|
||||
;;; Cursor
|
||||
|
||||
;; Don't blink the cursor, it's too distracting.
|
||||
;; The blinking cursor is distracting, but also interferes with cursor settings
|
||||
;; in some minor modes that try to change it buffer-locally (like treemacs) and
|
||||
;; can cause freezing for folks (esp on macOS) with customized & color cursors.
|
||||
(blink-cursor-mode -1)
|
||||
|
||||
;; Don't blink the paren matching the one at point, it's too distracting.
|
||||
(setq blink-matching-paren nil)
|
||||
|
||||
;; Some terminals offer two different cursors: a “visible” static cursor and a
|
||||
;; “very visible” blinking one. By default, Emacs uses the very visible cursor
|
||||
;; and switches to it when you start or resume Emacs. If `visible-cursor' is nil
|
||||
;; when Emacs starts or resumes, it uses the normal cursor.
|
||||
(setq visible-cursor nil)
|
||||
|
||||
;; Don't stretch the cursor to fit wide characters, it is disorienting,
|
||||
@@ -214,8 +239,6 @@ read-only or not file-visiting."
|
||||
;; Make `next-buffer', `other-buffer', etc. ignore unreal buffers.
|
||||
(push '(buffer-predicate . doom-buffer-frame-predicate) default-frame-alist)
|
||||
|
||||
(setq confirm-nonexistent-file-or-buffer t)
|
||||
|
||||
(defadvice! doom--switch-to-fallback-buffer-maybe-a (&rest _)
|
||||
"Switch to `doom-fallback-buffer' if on last real buffer.
|
||||
|
||||
@@ -261,9 +284,6 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
|
||||
(setq indicate-buffer-boundaries nil
|
||||
indicate-empty-lines nil)
|
||||
|
||||
;; remove continuation arrow on right fringe
|
||||
(delq! 'continuation fringe-indicator-alist 'assq)
|
||||
|
||||
|
||||
;;
|
||||
;;; Windows/frames
|
||||
@@ -272,40 +292,53 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
|
||||
(setq frame-title-format '("%b – Doom Emacs")
|
||||
icon-title-format frame-title-format)
|
||||
|
||||
;; Don't resize emacs in steps, it looks weird.
|
||||
;; Don't resize windows & frames in steps; it's prohibitive to prevent the user
|
||||
;; from resizing it to exact dimensions, and looks weird.
|
||||
(setq window-resize-pixelwise t
|
||||
frame-resize-pixelwise t)
|
||||
|
||||
(unless EMACS27+ ; We already do this in early-init.el
|
||||
;; Disable tool and scrollbars; Doom encourages keyboard-centric workflows, so
|
||||
;; these are just clutter (the scrollbar also impacts Emacs' performance).
|
||||
(push '(menu-bar-lines . 0) default-frame-alist)
|
||||
(push '(tool-bar-lines . 0) default-frame-alist)
|
||||
(push '(vertical-scroll-bars) default-frame-alist))
|
||||
(unless (assq 'menu-bar-lines default-frame-alist)
|
||||
;; We do this in early-init.el too, but in case the user is on Emacs 26 we do
|
||||
;; it here too: disable tool and scrollbars, as Doom encourages
|
||||
;; keyboard-centric workflows, so these are just clutter (the scrollbar also
|
||||
;; impacts performance).
|
||||
(add-to-list 'default-frame-alist '(menu-bar-lines . 0))
|
||||
(add-to-list 'default-frame-alist '(tool-bar-lines . 0))
|
||||
(add-to-list 'default-frame-alist '(vertical-scroll-bars)))
|
||||
|
||||
;; Sets `ns-appearance' and `ns-transparent-titlebar' on GUI frames (and fixes
|
||||
;; mismatching text color in the frame title)
|
||||
(when IS-MAC
|
||||
;; These are disabled directly through their frame parameters, to avoid the
|
||||
;; extra work their minor modes do, but we have to unset these variables
|
||||
;; ourselves, otherwise users will have to cycle them twice to re-enable them.
|
||||
(setq menu-bar-mode nil
|
||||
tool-bar-mode nil
|
||||
scroll-bar-mode nil)
|
||||
|
||||
(when! IS-MAC
|
||||
;; Curse Lion and its sudden but inevitable fullscreen mode!
|
||||
;; NOTE Meaningless to railwaycat's emacs-mac build
|
||||
(setq ns-use-native-fullscreen nil
|
||||
;; Visit files opened outside of Emacs in existing frame, rather than a
|
||||
;; new one
|
||||
ns-pop-up-frames nil)
|
||||
(setq ns-use-native-fullscreen nil)
|
||||
|
||||
;; Sets ns-transparent-titlebar and ns-appearance frame parameters as is
|
||||
;; appropriate for the loaded theme.
|
||||
;; Visit files opened outside of Emacs in existing frame, not a new one
|
||||
(setq ns-pop-up-frames nil)
|
||||
|
||||
;; Sets `ns-transparent-titlebar' and `ns-appearance' frame parameters so
|
||||
;; window borders will match the enabled theme.
|
||||
(and (or (daemonp)
|
||||
(display-graphic-p))
|
||||
(require 'ns-auto-titlebar nil t)
|
||||
(ns-auto-titlebar-mode +1))
|
||||
|
||||
(add-hook! 'after-make-frame-functions
|
||||
(defun doom-init-menu-bar-in-gui-frames-h (frame)
|
||||
"On MacOS, the menu bar isn't part of the frame. Disabling it makes MacOS
|
||||
treat Emacs as a non-application window."
|
||||
(when (display-graphic-p frame)
|
||||
(set-frame-parameter frame 'menu-bar-lines 1)))))
|
||||
;; HACK On MacOS, disabling the menu bar makes MacOS treat Emacs as a
|
||||
;; non-application window -- which means it doesn't automatically capture
|
||||
;; focus when it is started, among other things. We enable menu-bar-lines
|
||||
;; there, but we still want it disabled in terminal frames because there
|
||||
;; it activates an ugly menu bar.
|
||||
(add-hook! '(window-setup-hook after-make-frame-functions)
|
||||
(defun doom-init-menu-bar-in-gui-frames-h (&optional frame)
|
||||
"Re-enable menu-bar-lines in GUI frames."
|
||||
(when-let (frame (or frame (selected-frame)))
|
||||
(when (display-graphic-p frame)
|
||||
(set-frame-parameter frame 'menu-bar-lines 1))))))
|
||||
|
||||
;; The native border "consumes" a pixel of the fringe on righter-most splits,
|
||||
;; `window-divider' does not. Available since Emacs 25.1.
|
||||
@@ -314,18 +347,21 @@ treat Emacs as a non-application window."
|
||||
window-divider-default-right-width 1)
|
||||
(add-hook 'doom-init-ui-hook #'window-divider-mode)
|
||||
|
||||
;; Prompt the user for confirmation when deleting a non-empty frame
|
||||
(global-set-key [remap delete-frame] #'doom/delete-frame)
|
||||
;; Prompt for confirmation when deleting a non-empty frame; a last line of
|
||||
;; defense against accidental loss of work.
|
||||
(global-set-key [remap delete-frame] #'doom/delete-frame-with-prompt)
|
||||
|
||||
;; always avoid GUI
|
||||
(setq use-dialog-box nil)
|
||||
;; Don't display floating tooltips; display their contents in the echo-area.
|
||||
(if (bound-and-true-p tooltip-mode) (tooltip-mode -1))
|
||||
;; native linux tooltips are ugly
|
||||
;; Don't display floating tooltips; display their contents in the echo-area,
|
||||
;; because native tooltips are ugly.
|
||||
(when (bound-and-true-p tooltip-mode)
|
||||
(tooltip-mode -1))
|
||||
;; ...especially on linux
|
||||
(when IS-LINUX
|
||||
(setq x-gtk-use-system-tooltips nil))
|
||||
|
||||
;; Favor vertical splits over horizontal ones
|
||||
;; Favor vertical splits over horizontal ones. Screens are usually wide.
|
||||
(setq split-width-threshold 160
|
||||
split-height-threshold nil)
|
||||
|
||||
@@ -334,11 +370,11 @@ treat Emacs as a non-application window."
|
||||
;;; Minibuffer
|
||||
|
||||
;; Allow for minibuffer-ception. Sometimes we need another minibuffer command
|
||||
;; _while_ we're in the minibuffer.
|
||||
;; while we're in the minibuffer.
|
||||
(setq enable-recursive-minibuffers t)
|
||||
|
||||
;; Show current key-sequence in minibuffer, like vim does. Any feedback after
|
||||
;; typing is better UX than no feedback at all.
|
||||
;; Show current key-sequence in minibuffer ala 'set showcmd' in vim. Any
|
||||
;; feedback after typing is better UX than no feedback at all.
|
||||
(setq echo-keystrokes 0.02)
|
||||
|
||||
;; Expand the minibuffer to fit multi-line text displayed in the echo-area. This
|
||||
@@ -348,7 +384,7 @@ treat Emacs as a non-application window."
|
||||
max-mini-window-height 0.15)
|
||||
|
||||
;; Typing yes/no is obnoxious when y/n will do
|
||||
(fset #'yes-or-no-p #'y-or-n-p)
|
||||
(advice-add #'yes-or-no-p :override #'y-or-n-p)
|
||||
|
||||
;; Try really hard to keep the cursor from getting stuck in the read-only prompt
|
||||
;; portion of the minibuffer.
|
||||
@@ -387,42 +423,36 @@ treat Emacs as a non-application window."
|
||||
(set-window-configuration doom--ediff-saved-wconf)))))
|
||||
|
||||
|
||||
(use-package! goto-addr
|
||||
:hook (text-mode . goto-address-mode)
|
||||
:hook (prog-mode . goto-address-prog-mode)
|
||||
:config
|
||||
(define-key goto-address-highlight-keymap (kbd "RET") #'goto-address-at-point))
|
||||
|
||||
|
||||
(use-package! hl-line
|
||||
;; Highlights the current line
|
||||
:hook ((prog-mode text-mode conf-mode) . hl-line-mode)
|
||||
:hook ((prog-mode text-mode conf-mode special-mode) . hl-line-mode)
|
||||
:config
|
||||
;; 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)
|
||||
|
||||
;; Disable `hl-line' in evil-visual mode (temporarily). `hl-line' can make the
|
||||
;; selection region harder to see while in evil visual mode.
|
||||
(after! evil
|
||||
(defvar doom-buffer-hl-line-mode nil)
|
||||
(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))))))
|
||||
;; Temporarily disable `hl-line' when selection is active, since it doesn't
|
||||
;; serve much purpose when the selection is so much more visible.
|
||||
(defvar doom--hl-line-mode nil)
|
||||
|
||||
(add-hook! '(evil-visual-state-entry-hook activate-mark-hook)
|
||||
(defun doom-disable-hl-line-h ()
|
||||
(when hl-line-mode
|
||||
(setq-local doom--hl-line-mode t)
|
||||
(hl-line-mode -1))))
|
||||
|
||||
(add-hook! '(evil-visual-state-exit-hook deactivate-mark-hook)
|
||||
(defun doom-enable-hl-line-maybe-h ()
|
||||
(when doom--hl-line-mode
|
||||
(hl-line-mode +1)))))
|
||||
|
||||
|
||||
(use-package! winner
|
||||
;; undo/redo changes to Emacs' window layout
|
||||
:after-call after-find-file doom-switch-window-hook
|
||||
:preface (defvar winner-dont-bind-my-keys t) ; I'll bind keys myself
|
||||
:config (winner-mode +1)
|
||||
:hook (doom-first-buffer . winner-mode)
|
||||
:config
|
||||
(appendq! winner-boring-buffers
|
||||
'("*Compile-Log*" "*inferior-lisp*" "*Fuzzy Completions*"
|
||||
"*Apropos*" "*Help*" "*cvs*" "*Buffer List*" "*Ibuffer*"
|
||||
@@ -431,13 +461,12 @@ treat Emacs as a non-application window."
|
||||
|
||||
(use-package! paren
|
||||
;; highlight matching delimiters
|
||||
:after-call after-find-file doom-switch-buffer-hook
|
||||
:hook (doom-first-buffer . show-paren-mode)
|
||||
:config
|
||||
(setq show-paren-delay 0.1
|
||||
show-paren-highlight-openparen t
|
||||
show-paren-when-point-inside-paren t
|
||||
show-paren-when-point-in-periphery t)
|
||||
(show-paren-mode +1))
|
||||
show-paren-when-point-in-periphery t))
|
||||
|
||||
|
||||
;;;###package whitespace
|
||||
@@ -461,13 +490,31 @@ treat Emacs as a non-application window."
|
||||
all-the-icons-wicon
|
||||
all-the-icons-material
|
||||
all-the-icons-alltheicon)
|
||||
:init
|
||||
(defadvice! doom--disable-all-the-icons-in-tty-a (orig-fn &rest args)
|
||||
"Return a blank string in tty Emacs, which doesn't support multiple fonts."
|
||||
:around #'all-the-icons-insert
|
||||
(if (display-multi-font-p)
|
||||
(apply orig-fn args)
|
||||
"")))
|
||||
:preface
|
||||
(setq doom-unicode-extra-fonts
|
||||
(list "Weather Icons"
|
||||
"github-octicons"
|
||||
"FontAwesome"
|
||||
"all-the-icons"
|
||||
"file-icons"
|
||||
"Material Icons"))
|
||||
:config
|
||||
(cond ((daemonp)
|
||||
(defadvice! doom--disable-all-the-icons-in-tty-a (orig-fn &rest args)
|
||||
"Return a blank string in tty Emacs, which doesn't support multiple fonts."
|
||||
:around '(all-the-icons-octicon all-the-icons-material
|
||||
all-the-icons-faicon all-the-icons-fileicon
|
||||
all-the-icons-wicon all-the-icons-alltheicon)
|
||||
(if (or (not after-init-time) (display-multi-font-p))
|
||||
(apply orig-fn args)
|
||||
"")))
|
||||
((not (display-graphic-p))
|
||||
(defadvice! doom--disable-all-the-icons-in-tty-a (&rest _)
|
||||
"Return a blank string for tty users."
|
||||
:override '(all-the-icons-octicon all-the-icons-material
|
||||
all-the-icons-faicon all-the-icons-fileicon
|
||||
all-the-icons-wicon all-the-icons-alltheicon)
|
||||
""))))
|
||||
|
||||
;;;###package hide-mode-line-mode
|
||||
(add-hook! '(completion-list-mode-hook Man-mode-hook)
|
||||
@@ -486,10 +533,6 @@ treat Emacs as a non-application window."
|
||||
;; languages like Lisp.
|
||||
(setq rainbow-delimiters-max-face-count 3)
|
||||
|
||||
;;;###package pos-tip
|
||||
(setq pos-tip-internal-border-width 6
|
||||
pos-tip-border-width 1)
|
||||
|
||||
|
||||
;;
|
||||
;;; Line numbers
|
||||
@@ -497,16 +540,16 @@ treat Emacs as a non-application window."
|
||||
;; Explicitly define a width to reduce computation
|
||||
(setq-default display-line-numbers-width 3)
|
||||
|
||||
;; Show absolute line numbers for narrowed regions
|
||||
;; Show absolute line numbers for narrowed regions makes it easier to tell the
|
||||
;; buffer is narrowed, and where you are, exactly.
|
||||
(setq-default display-line-numbers-widen t)
|
||||
|
||||
;; Enable line numbers in most text-editing modes
|
||||
;; Enable line numbers in most text-editing modes. We avoid
|
||||
;; `global-display-line-numbers-mode' because there are many special and
|
||||
;; temporary modes where we don't need/want them.
|
||||
(add-hook! '(prog-mode-hook text-mode-hook conf-mode-hook)
|
||||
#'display-line-numbers-mode)
|
||||
|
||||
(defun doom-enable-line-numbers-h () (display-line-numbers-mode +1))
|
||||
(defun doom-disable-line-numbers-h () (display-line-numbers-mode -1))
|
||||
|
||||
|
||||
;;
|
||||
;;; Theme & font
|
||||
@@ -514,35 +557,44 @@ treat Emacs as a non-application window."
|
||||
;; Underline looks a bit better when drawn lower
|
||||
(setq x-underline-at-descent-line t)
|
||||
|
||||
;; DEPRECATED In Emacs 27
|
||||
(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-h'.")
|
||||
|
||||
(defun doom-init-fonts-h ()
|
||||
"Loads `doom-font'."
|
||||
(cond (doom-font
|
||||
(cl-pushnew
|
||||
(cons 'font
|
||||
(cond ((stringp doom-font) doom-font)
|
||||
((fontp doom-font) (font-xlfd-name doom-font))
|
||||
((signal 'wrong-type-argument (list '(fontp stringp)
|
||||
doom-font)))))
|
||||
default-frame-alist
|
||||
:key #'car :test #'eq))
|
||||
((display-graphic-p)
|
||||
(setq font-use-system-font t
|
||||
doom-font (face-attribute 'default :font)))))
|
||||
(cond
|
||||
(doom-font
|
||||
(cl-pushnew
|
||||
;; Avoiding `set-frame-font' because it does a lot of extra, expensive
|
||||
;; work we can avoid by setting the font frame parameter instead.
|
||||
(cons 'font
|
||||
(cond ((stringp doom-font) doom-font)
|
||||
((fontp doom-font) (font-xlfd-name doom-font))
|
||||
((signal 'wrong-type-argument (list '(fontp stringp)
|
||||
doom-font)))))
|
||||
default-frame-alist
|
||||
:key #'car :test #'eq))
|
||||
((display-graphic-p)
|
||||
;; We try our best to record your system font, so `doom-big-font-mode'
|
||||
;; can still use it to compute a larger font size with.
|
||||
(setq font-use-system-font t
|
||||
doom-font (face-attribute 'default :font)))))
|
||||
|
||||
(defun doom-init-extra-fonts-h (&optional frame)
|
||||
"Loads `doom-variable-pitch-font',`doom-serif-font' and `doom-unicode-font'."
|
||||
(condition-case e
|
||||
(with-selected-frame (or frame (selected-frame))
|
||||
(when doom-font
|
||||
(set-face-attribute 'fixed-pitch nil :font doom-font))
|
||||
(when doom-serif-font
|
||||
(set-face-attribute 'fixed-pitch-serif nil :font doom-serif-font))
|
||||
(when doom-variable-pitch-font
|
||||
(set-face-attribute 'variable-pitch nil :font doom-variable-pitch-font))
|
||||
(when (and doom-unicode-font (fboundp 'set-fontset-font))
|
||||
(set-fontset-font t 'unicode doom-unicode-font nil 'prepend)))
|
||||
(when (fboundp 'set-fontset-font)
|
||||
(dolist (font (append doom-unicode-extra-fonts (doom-enlist doom-unicode-font)))
|
||||
(set-fontset-font t 'unicode font nil 'prepend))))
|
||||
((debug error)
|
||||
(if (string-prefix-p "Font not available: " (error-message-string e))
|
||||
(lwarn 'doom-ui :warning
|
||||
@@ -554,29 +606,54 @@ behavior). Do not set this directly, this is let-bound in `doom-init-theme-h'.")
|
||||
"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))
|
||||
(let ((doom--prefer-theme-elc t))
|
||||
(let ((doom--prefer-theme-elc t)) ; DEPRECATED in Emacs 27
|
||||
(load-theme doom-theme t)))))
|
||||
|
||||
(defadvice! doom--run-load-theme-hooks-a (theme &optional _no-confirm no-enable)
|
||||
"Set up `doom-load-theme-hook' to run after `load-theme' is called."
|
||||
:after-while #'load-theme
|
||||
(unless no-enable
|
||||
(setq doom-theme theme
|
||||
doom-init-theme-p t)
|
||||
(run-hooks 'doom-load-theme-hook)))
|
||||
(defadvice! doom--load-theme-a (orig-fn theme &optional no-confirm no-enable)
|
||||
"Run `doom-load-theme-hook' on `load-theme' and fix its issues.
|
||||
|
||||
(defadvice! doom--prefer-compiled-theme-a (orig-fn &rest args)
|
||||
"Make `load-theme' prioritize the byte-compiled theme for a moderate boost in
|
||||
startup (or theme switch) time, so long as `doom--prefer-theme-elc' is non-nil."
|
||||
1. Disable previously enabled themes.
|
||||
2. Don't let face-remapping screw up loading the new theme
|
||||
(*cough*`mixed-pitch-mode').
|
||||
3. Record the current theme in `doom-theme'."
|
||||
:around #'load-theme
|
||||
(if (or (null after-init-time)
|
||||
doom--prefer-theme-elc)
|
||||
(cl-letf* ((old-locate-file (symbol-function 'locate-file))
|
||||
((symbol-function 'locate-file)
|
||||
(lambda (filename path &optional _suffixes predicate)
|
||||
(funcall old-locate-file filename path '("c" "") predicate))))
|
||||
(apply orig-fn args))
|
||||
(apply orig-fn args)))
|
||||
;; HACK Run `load-theme' from an estranged buffer, where we can be assured
|
||||
;; that buffer-local face remaps (by `mixed-pitch-mode', for instance)
|
||||
;; won't interfere with changing themes.
|
||||
(with-temp-buffer
|
||||
(when-let (result (funcall orig-fn theme no-confirm no-enable))
|
||||
(unless no-enable
|
||||
(setq doom-theme theme
|
||||
doom-init-theme-p t)
|
||||
;; `load-theme' doesn't disable previously enabled themes, which seems
|
||||
;; like what you'd want. You could always use `enable-theme' to activate
|
||||
;; multiple themes instead.
|
||||
(mapc #'disable-theme (remq theme custom-enabled-themes))
|
||||
(run-hooks 'doom-load-theme-hook))
|
||||
result)))
|
||||
|
||||
(when! (not EMACS27+)
|
||||
;; DEPRECATED `doom--load-theme-a' handles this for us after the theme is
|
||||
;; loaded, but this only works on Emacs 27+. Disabling old themes
|
||||
;; must be done *before* the theme is loaded in Emacs 26.
|
||||
(defadvice! doom--disable-previous-themes-a (theme &optional _no-confirm no-enable)
|
||||
"Disable other themes when loading a new one."
|
||||
:before #'load-theme
|
||||
(unless no-enable
|
||||
(mapc #'disable-theme custom-enabled-themes)))
|
||||
|
||||
;; DEPRECATED Not needed in Emacs 27
|
||||
(defadvice! doom--prefer-compiled-theme-a (orig-fn &rest args)
|
||||
"Have `load-theme' prioritize the byte-compiled theme.
|
||||
This offers a moderate boost in startup (or theme switch) time, so long as
|
||||
`doom--prefer-theme-elc' is non-nil."
|
||||
:around #'load-theme
|
||||
(if (or (null after-init-time)
|
||||
doom--prefer-theme-elc)
|
||||
(letf! (defun locate-file (filename path &optional _suffixes predicate)
|
||||
(funcall locate-file filename path '("c" "") predicate))
|
||||
(apply orig-fn args))
|
||||
(apply orig-fn args))))
|
||||
|
||||
|
||||
;;
|
||||
@@ -590,9 +667,13 @@ startup (or theme switch) time, so long as `doom--prefer-theme-elc' is non-nil."
|
||||
(add-hook 'after-change-major-mode-hook #'doom-highlight-non-default-indentation-h 'append)
|
||||
|
||||
;; Initialize custom switch-{buffer,window,frame} hooks:
|
||||
;;
|
||||
;; + `doom-switch-buffer-hook'
|
||||
;; + `doom-switch-window-hook'
|
||||
;; + `doom-switch-frame-hook'
|
||||
;;
|
||||
;; These should be done as late as possible, as not to prematurely trigger
|
||||
;; hooks during startup.
|
||||
(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))
|
||||
@@ -617,19 +698,27 @@ startup (or theme switch) time, so long as `doom--prefer-theme-elc' is non-nil."
|
||||
;;; Fixes/hacks
|
||||
|
||||
;; Doom doesn't support `customize' and it never will. It's a clumsy interface
|
||||
;; for something that should be configured from only one place ($DOOMDIR), so we
|
||||
;; disable them.
|
||||
(put 'customize 'disabled "Doom doesn't support `customize', configure Emacs from $DOOMDIR/config.el instead")
|
||||
;; that sets variables at a time where it can be easily and unpredictably
|
||||
;; overwritten. Configure things from your $DOOMDIR instead.
|
||||
(dolist (sym '(customize-option customize-browse customize-group customize-face
|
||||
customize-rogue customize-saved customize-apropos
|
||||
customize-changed customize-unsaved customize-variable
|
||||
customize-set-value customize-customized customize-set-variable
|
||||
customize-apropos-faces customize-save-variable
|
||||
customize-apropos-groups customize-apropos-options
|
||||
customize-changed-options customize-save-customized))
|
||||
(put sym 'disabled "Doom doesn't support `customize', configure Emacs from $DOOMDIR/config.el instead"))
|
||||
(put 'customize-themes 'disabled "Set `doom-theme' or use `load-theme' in $DOOMDIR/config.el instead")
|
||||
|
||||
;; doesn't exist in terminal Emacs; we define it to prevent errors
|
||||
;; Doesn't exist in terminal Emacs, so we define it to prevent void-function
|
||||
;; errors emitted from packages that blindly try to use it.
|
||||
(unless (fboundp 'define-fringe-bitmap)
|
||||
(fset 'define-fringe-bitmap #'ignore))
|
||||
|
||||
(after! whitespace
|
||||
(defun doom-disable-whitespace-mode-in-childframes-a (orig-fn)
|
||||
"`whitespace-mode' inundates child frames with whitspace markers, so disable
|
||||
it to fix all that visual noise."
|
||||
"`whitespace-mode' inundates child frames with whitespace markers, so
|
||||
disable it to fix all that visual noise."
|
||||
(unless (frame-parameter nil 'parent-frame)
|
||||
(funcall orig-fn)))
|
||||
(add-function :around whitespace-enable-predicate #'doom-disable-whitespace-mode-in-childframes-a))
|
||||
|
||||
Reference in New Issue
Block a user