From ff4a2e046a66f7b364ad570c7dce11dab4987155 Mon Sep 17 00:00:00 2001 From: Madhu Date: Tue, 5 Nov 2024 07:19:55 +0530 Subject: [PATCH] minibuffer.el: (read-file-name-default): avoid setting incorrect default-directory * minibuffer.el: (read-file-name-default): bind default-directory (in dynamic scope) instead of modifying it. try to bind it to a valid directory. (e.g. don't set it to a url when calling (ffap) at a url). --- lisp/minibuffer.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index c970752ec2a..672f7b2b318 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -3668,10 +3668,11 @@ read-file-name-default ;; changing `default-directory' in the current buffer, ;; we don't let-bind it. (let ((dir (file-name-as-directory - (expand-file-name dir)))) + (expand-file-name dir))) + (default-directory (if (file-name-absolute-p dir) + dir default-directory))) (minibuffer-with-setup-hook (lambda () - (setq default-directory dir) ;; When the first default in `minibuffer-default' ;; duplicates initial input `insdef', ;; reset `minibuffer-default' to nil. -- 2.46.0.27.gfa3b914457