dev: merging from main

This commit is contained in:
Matt Nish-Lapidus 2024-04-18 11:25:17 -04:00
commit 08d20c7e62
11 changed files with 75 additions and 91 deletions

View file

@ -301,7 +301,7 @@ list remains lean."
(setq want-native-compile nil))
(and (or want-byte-compile want-native-compile)
(or (file-newer-than-file-p repo-dir build-dir)
(file-exists-p (straight--modified-dir (or local-repo package)))
(file-exists-p (straight--modified-dir package))
(cl-loop with outdated = nil
for file in (doom-files-in build-dir :match "\\.el$" :full t)
if (or (if want-byte-compile (doom-packages--elc-file-outdated-p file))

View file

@ -143,11 +143,11 @@ tell you about it. Very annoying. This prevents that."
(letf! ((#'sit-for #'ignore))
(apply fn args)))
;; HACK Emacs generates long file paths for its auto-save files; long =
;; `auto-save-list-file-prefix' + `buffer-file-name'. If too long, the
;; filesystem will murder your family. To appease it, I compress
;; `buffer-file-name' to a stable 40 characters.
;; TODO PR this upstream; should be a universal issue!
;; HACK: Emacs generates long file paths for its auto-save files; long =
;; `auto-save-list-file-prefix' + `buffer-file-name'. If too long, the
;; filesystem will murder your family. To appease it, I compress
;; `buffer-file-name' to a stable 40 characters.
;; TODO: PR this upstream; should be a universal issue!
(defadvice! doom-make-hashed-auto-save-file-name-a (fn)
"Compress the auto-save file name so paths don't get too long."
:around #'make-auto-save-file-name
@ -156,7 +156,7 @@ tell you about it. Very annoying. This prevents that."
;; Don't do anything for non-file-visiting buffers. Names
;; generated for those are short enough already.
(null buffer-file-name)
;; If an alternate handler exists for this path, bow out. Most of
;; If an alternate handler exists for this path, bow out. Most of
;; them end up calling `make-auto-save-file-name' again anyway, so
;; we still achieve this advice's ultimate goal.
(find-file-name-handler buffer-file-name
@ -165,8 +165,8 @@ tell you about it. Very annoying. This prevents that."
(sha1 buffer-file-name))))
(funcall fn)))
;; HACK ...does the same for Emacs backup files, but also packages that use
;; `make-backup-file-name-1' directly (like undo-tree).
;; HACK: ...does the same for Emacs backup files, but also packages that use
;; `make-backup-file-name-1' directly (like undo-tree).
(defadvice! doom-make-hashed-backup-file-name-a (fn file)
"A few places use the backup file name so paths don't get too long."
:around #'make-backup-file-name-1
@ -191,7 +191,7 @@ tell you about it. Very annoying. This prevents that."
;; Favor spaces over tabs. Pls dun h8, but I think spaces (and 4 of them) is a
;; more consistent default than 8-space tabs. It can be changed on a per-mode
;; basis anyway (and is, where tabs are the canonical style, like go-mode).
;; basis anyway (and is, where tabs are the canonical style, like `go-mode').
(setq-default indent-tabs-mode nil
tab-width 4)
@ -269,19 +269,20 @@ tell you about it. Very annoying. This prevents that."
;; Only prompts for confirmation when buffer is unsaved.
revert-without-query (list "."))
;; `auto-revert-mode' and `global-auto-revert-mode' would, normally, abuse the
;; heck out of file watchers _or_ aggressively poll your buffer list every X
;; seconds. Too many watchers can grind Emacs to a halt if you preform
;; expensive or batch processes on files outside of Emacs (e.g. their mtime
;; changes), and polling your buffer list is terribly inefficient as your
;; buffer list grows into the hundreds.
;; PERF: `auto-revert-mode' and `global-auto-revert-mode' would, normally,
;; abuse the heck out of file watchers _or_ aggressively poll your buffer
;; list every X seconds. Too many watchers can grind Emacs to a halt if you
;; preform expensive or batch processes on files outside of Emacs (e.g.
;; their mtime changes), and polling your buffer list is terribly
;; inefficient as your buffer list grows into the hundreds.
;;
;; Doom does this lazily instead. i.e. All visible buffers are reverted
;; immediately when a) a file is saved or b) Emacs is refocused (after using
;; another app). Meanwhile, buried buffers are reverted only when they are
;; switched to. This way, Emacs only ever has to operate on, at minimum, a
;; single buffer and, at maximum, ~10 buffers (after all, when do you ever
;; have more than 10 windows in any single frame?).
;; Doom does this lazily instead. i.e. All visible buffers are reverted
;; immediately when a) a file is saved or b) Emacs is refocused (after using
;; another app). Meanwhile, buried buffers are reverted only when they are
;; switched to. This way, Emacs only ever has to operate on, at minimum, a
;; single buffer and, at maximum, ~10 x F buffers, where F = number of open
;; frames (after all, when do you ever have more than 10 windows in any
;; single frame?).
(defun doom-auto-revert-buffer-h ()
"Auto revert current buffer, if necessary."
(unless (or auto-revert-mode (active-minibuffer-window))

View file

@ -246,29 +246,29 @@ TRIGGER-HOOK is a list of quoted hooks and/or sharp-quoted functions."
(fset
fn (lambda (&rest _)
;; Only trigger this after Emacs has initialized.
(when (and after-init-time
(not running?)
(when (and (not running?)
(not (doom-context-p 'init))
(or (daemonp)
;; In some cases, hooks may be lexically unset to
;; inhibit them during expensive batch operations on
;; buffers (such as when processing buffers
;; internally). In these cases we should assume this
;; hook wasn't invoked interactively.
;; internally). In that case assume this hook was
;; invoked non-interactively.
(and (boundp hook)
(symbol-value hook))))
(setq running? t) ; prevent infinite recursion
(doom-run-hooks hook-var)
(set hook-var nil))))
(cond ((daemonp)
;; In a daemon session we don't need all these lazy loading
;; shenanigans. Just load everything immediately.
(add-hook 'after-init-hook fn 'append))
((eq hook 'find-file-hook)
;; Advise `after-find-file' instead of using `find-file-hook'
;; because the latter is triggered too late (after the file has
;; opened and modes are all set up).
(advice-add 'after-find-file :before fn '((depth . -101))))
((add-hook hook fn -101)))
(when (daemonp)
;; In a daemon session we don't need all these lazy loading shenanigans.
;; Just load everything immediately.
(add-hook 'server-after-make-frame-hook fn 'append))
(if (eq hook 'find-file-hook)
;; Advise `after-find-file' instead of using `find-file-hook' because
;; the latter is triggered too late (after the file has opened and
;; modes are all set up).
(advice-add 'after-find-file :before fn '((depth . -101)))
(add-hook hook fn -101))
fn)))
(defun doom-compile-functions (&rest fns)

View file

@ -256,7 +256,7 @@ uses a straight or package.el command directly).")
(alist-get 'straight packages)
(doom--ensure-straight recipe pin))
(doom--ensure-core-packages
(seq-filter (fn! (eq (plist-get % :type) 'core))
(seq-filter (fn! (eq (plist-get (cdr %) :type) 'core))
packages)))))
(defun doom-initialize-packages (&optional force-p)

View file

@ -101,34 +101,40 @@
;;; Disable UI elements early
;; PERF,UI: Doom strives to be keyboard-centric, so I consider these UI elements
;; clutter. Initializing them also costs a morsel of startup time. What's
;; more, the menu bar exposes functionality that Doom doesn't endorse. Perhaps
;; one day Doom will support these, but today is not that day. By disabling
;; them early, we save Emacs some time.
;; more, the menu bar exposes functionality that Doom doesn't endorse or
;; police. Perhaps one day Doom will support these, but today is not that day.
;; By disabling them early, we save Emacs some time.
;; HACK: I intentionally avoid calling `menu-bar-mode', `tool-bar-mode', and
;; `scroll-bar-mode' because their manipulation of frame parameters can
;; trigger/queue a superfluous (and expensive, depending on the window system)
;; frame redraw at startup.
;; frame redraw at startup. The variables must be set to `nil' as well so
;; users don't have to call the functions twice to re-enable them.
(push '(menu-bar-lines . 0) default-frame-alist)
(push '(tool-bar-lines . 0) default-frame-alist)
(push '(vertical-scroll-bars) default-frame-alist)
;; And set these to nil so users don't have to toggle the modes twice to
;; reactivate them.
(setq menu-bar-mode nil
tool-bar-mode nil
scroll-bar-mode nil)
;; FIX: 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, so enable the menu-bar for
;; GUI frames, but keep it disabled in terminal frames because there it
;; unavoidably activates an ugly, in-frame menu bar.
(eval-when! doom--system-macos-p
(add-hook! '(window-setup-hook after-make-frame-functions)
(defun doom-restore-menu-bar-in-gui-frames-h (&optional frame)
(when-let (frame (or frame (selected-frame)))
(when (display-graphic-p frame)
(set-frame-parameter frame 'menu-bar-lines 1))))))
;; HACK: The menu-bar needs special treatment on MacOS. On Linux and Windows
;; (and TTY frames in MacOS), the menu-bar takes up valuable in-frame real
;; estate -- so we disable it -- but on MacOS (GUI frames only) the menu bar
;; lives outside of the frame, on the MacOS menu bar, which is acceptable, but
;; disabling Emacs' menu-bar also makes MacOS treat Emacs GUI frames like
;; non-application windows (e.g. it won't capture focus on activation, among
;; other things), so the menu-bar should be preserved there.
;;
(when doom--system-macos-p
;; NOTE: The correct way to disable this hack is to toggle `menu-bar-mode' (or
;; put it on a hook). Don't try to undo the hack below, as it may change
;; without warning, but will always respect `menu-bar-mode'.
(setcdr (assq 'menu-bar-lines default-frame-alist) 'tty)
(add-hook! 'after-make-frame-functions
(defun doom--init-menu-bar-on-macos-h (&optional frame)
(if (eq (frame-parameter frame 'menu-bar-lines) 'tty)
(set-frame-parameter frame 'menu-bar-lines
(if (display-graphic-p frame) 1 0))))))
;;; Encodings
;; Contrary to what many Emacs users have in their configs, you don't need more