[snip: I hope the context can be seen on the bug-list] * Stefan Monnier > IIRC the `setq` is really there to set the value of `default-directory` > during the whole duration of the completion, not just during the setup hook. > This is needed/used if the user modifies the minibuffer's content to > hold only a relative file name, at which point we need that default > directory info in order to perform completions. Ah yes I missed that, (though I haven't worked out yet how it works) > The let+setq could be simplified to > > (let ((default-directory dir)) > > but none of the code within this `let` uses `default-directory` since > there are only calls to `car/cdr`, `setq`, and `set-syntax-table`, none > of which touch file names, so we may as well remove the > (setq default-directory dir) instead. I still think the default-difectory should be let-bound so the binding is undone when the dynamic scope exits. I have not worked out where the default-directory is being restored to the original value, but i know it is possible for the global value to be set incorrectly (e.g. after a M-: (debug), quit - -in the recursive minibuffer which would do a non-local exit.) > I'm leaning towards declaring the `shell-command` behavior above as > a feature rather than a bug. We could avoid still binding default-directory to a non-directory. Using the logic of expand-file-name, how about the following: [shouldn't binding it before the call to `minibuffer-with-setup-hook' be equivalent to a top level let in a hypothetical (with-minibuffer-setup-hook FN &body BODY), or setting it via FN]