From fe18640376b1bbbb4e084305abbeee41f137eaa7 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 6 Feb 2024 15:48:39 -0500 Subject: [PATCH] fix: --profile switch in noninteractive sessions This fixes command-line-args getting prematurely cleared out just before being scanned for a --profile switch. Fix: #7457 Co-authored-by: hpfr --- early-init.el | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/early-init.el b/early-init.el index c6e6b4d68..a7fc58d29 100644 --- a/early-init.el +++ b/early-init.el @@ -51,14 +51,14 @@ ;; notable saving in startup time. This let-binding is just a stopgap though, ;; a more complete version of this optimization can be found in lisp/doom.el. (let (file-name-handler-alist) - (let* (;; FIX: Unset `command-line-args' in noninteractive sessions, to - ;; ensure upstream switches aren't misinterpreted. - (command-line-args (unless noninteractive command-line-args)) - ;; I avoid using `command-switch-alist' to process --profile (and - ;; --init-directory) because it is processed too late to change - ;; `user-emacs-directory' in time. - (profile (or (cadr (member "--profile" command-line-args)) - (getenv-internal "DOOMPROFILE")))) + (let (;; FIX: Unset `command-line-args' in noninteractive sessions, to + ;; ensure upstream switches aren't misinterpreted. + (command-line-args (unless noninteractive command-line-args)) + ;; I avoid using `command-switch-alist' to process --profile (and + ;; --init-directory) because it is processed too late to change + ;; `user-emacs-directory' in time. + (profile (or (cadr (member "--profile" command-line-args)) + (getenv-internal "DOOMPROFILE")))) (if (null profile) ;; REVIEW: Backported from Emacs 29. Remove when 28 support is dropped. (let ((init-dir (or (cadr (member "--init-directory" command-line-args))