From 9ae4cb9f5675039f227fee4b77aedd9fee65d741 Mon Sep 17 00:00:00 2001 From: James Cherti <60946298+jamescherti@users.noreply.github.com> Date: Sun, 2 Feb 2025 21:17:15 -0500 Subject: [PATCH] Restore `file-name-handler-alist' when processing command-line --- early-init.el | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/early-init.el b/early-init.el index 17f4954..7ad2698 100644 --- a/early-init.el +++ b/early-init.el @@ -102,6 +102,13 @@ When set to non-nil, Emacs will automatically call `package-initialize' and (list (rassq 'jka-compr-handler old-value)))) ;; Ensure the new value persists through any current let-binding. (put 'file-name-handler-alist 'initial-value old-value) + ;; Emacs processes command-line files very early in startup. These files may + ;; include special paths like TRAMP paths, so restore + ;; `file-name-handler-alist' for this stage of initialization. + (define-advice command-line-1 (:around (fn args-left) respect-file-handlers) + (let ((file-name-handler-alist + (if args-left old-value file-name-handler-alist))) + (funcall fn args-left))) ;; Remember the old value to reset it as needed. (add-hook 'emacs-startup-hook (lambda ()