bug#81509: 31.0.91; Calling dired on nonexistent directory changes current buffer
Stephen Berman via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email protected]>
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 28 Jul 2026 20:04:32 +0530 (IST) Madhu <[email protected]> wrote: > * Stephen Berman <[email protected]> <[email protected]> > Wrote on Tue, 28 Jul 2026 15:55:29 +0200 >> This behavior is a by-product of 3b7d9e37ce0c. (BTW, the nonexistent >> directory doesn't have to be represented by a wildcard in the sense of a >> shell glob (e.g. *nonexist*), i.e. C-x d /tmp/a/nonexist also shows the >> same behavior. But /tmp/a/nonexist is a wildcard in the sense of >> insert-directory and maybe that's what the OP meant.) Before that >> change, when attempting to visit in Dired a nonexistent directory, >> insert-directory signalled an error, which short-circuited the Dired >> command, so that the current buffer when the Dired command was invoked >> remained current. Since 3b7d9e37ce0c, ls errors, such as trying to >> display a nonexistent directory, are now shown in a special buffer after >> completing the Dired command, as you observed. But the Dired commands >> use `pop-to-buffer-same-window' and >> `switch-to-buffer-other-{window,frame,tab}' and calling these with a >> nonexistent directory - i.e. with nil - as argument makes another buffer >> current. I agree this is surprising behavior. The attached patch >> prevents this, i.e., the buffer that was current when the Dired command >> was invoked remains current when the directory to be visited is >> nonexistent. Madhu, can you confirm? > > Thanks, the patch works as expected, --Regards, Madhu Thanks for confirming, now pushed to emacs-31. >> Eli, if this patch DTRT for Madhu can it be installed in emacs-31, since >> the undesirable behavior was due to changes there? > > PS btw did you have any special display buffer rules to recommend for > *ls-error*? If you mean to change how it's currently displayed, no: the function I wrote for that (dired--display-ls-error) does the simplest reasonable thing I could think of (displaying the error message on the same frame in a window just large enough to see the entire message). Steve Berman