From 9913acbdc4f22b2d208ea59ce5aec1e3cd722788 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 18 Aug 2024 16:12:42 -0400 Subject: [PATCH] fix: opening tramp paths from command line args Eventually, Emacs will process any files passed to it via the command line, and will do so *really* early in the startup process. These might contain special file paths like TRAMP paths (e.g. /sudo://etc/ssh/ssh_config), so restore `file-name-handler-alist' just for this small portion of startup. --- lisp/doom.el | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lisp/doom.el b/lisp/doom.el index 857df908d..601c5c38a 100644 --- a/lisp/doom.el +++ b/lisp/doom.el @@ -382,6 +382,13 @@ users).") (set-default-toplevel-value 'file-name-handler-alist file-name-handler-alist) ;; Remember it so it can be reset where needed. (put 'file-name-handler-alist 'initial-value old-value) + ;; COMPAT: Eventually, Emacs will process any files passed to it via the + ;; command line, and will do so *really* early in the startup process. + ;; These might contain special file paths like TRAMP paths, so restore + ;; `file-name-handler-alist' just for this portion of startup. + (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))) ;; COMPAT: ...but restore `file-name-handler-alist' later, because it is ;; needed for handling encrypted or compressed files, among other things. (add-hook! 'emacs-startup-hook :depth 101