Handle 'dired' called with -Al switches (bug#80711)

* lisp/dired.el (dired-internal-noselect): After reading in
directory, check whether there was an 'ls' error instead of
checking for file entries, since there may be none is the -Al
switches (or just -l) were used.
(dired--display-ls-error): Ensure the 'ls' error buffer is a live buffer.

* lisp/files.el (insert-directory-clean): Ensure deletion of
"//DIRED-OPTIONS//" line when using -Al switches (or just -l).
This commit is contained in:
Stephen Berman
2026-04-11 11:01:05 +02:00
parent 52e484742d
commit 6a90e0ee32
2 changed files with 8 additions and 12 deletions

View File

@@ -1456,16 +1456,12 @@ The return value is the target column for the file names."
(let ((failed t))
(unwind-protect
(progn (dired-readin)
;; Check for file entries (they are listed below the
;; directory name and (if present) wildcard lines).
(while (and (skip-syntax-forward "\s")
(looking-at "\\(.+:$\\|wildcard\\)"))
(forward-line))
(unless (eobp)
(unless (and dired--ls-error-buffer
(get-buffer "*ls error*"))
(setq failed nil)))
;; No file entries indicates an `ls' error, and `dired-readin'
;; can fail if parent directories are inaccessible. In either
;; case don't leave the Dired buffer around.
;; If either `dired-readin' failed (e.g. if parent directories
;; are inaccessible) or `ls' errored, don't leave the Dired
;; buffer around.
(when failed
(kill-buffer buffer)
(setq buffer nil))))
@@ -4112,8 +4108,8 @@ See `%s' for other alternatives and more information."))
(search-backward "Warning (dired)")))))
(defun dired--display-ls-error ()
"Pop up a buffer displaying the current `ls' error, if any."
(when dired--ls-error-buffer
"Pop up the buffer displaying the current `ls' error, if any."
(when (buffer-live-p dired--ls-error-buffer)
(let* ((errwin (display-buffer dired--ls-error-buffer)))
(fit-window-to-buffer errwin))
(setq dired--ls-error-buffer nil)))

View File

@@ -8340,7 +8340,7 @@ Valid wildcards are `*', `?', `[abc]' and `[a-z]'."
;; Take care of the case where the ls output contains a
;; "//DIRED-OPTIONS//"-line, but no "//DIRED//"-line
;; and we went one line too far back (see above).
(unless (bobp) (forward-line 1)))
(forward-line 1))
(if (let ((case-fold-search nil)) (looking-at "//DIRED-OPTIONS//"))
(delete-region (point) (progn (forward-line 1) (point))))))