Subject: Re: bug#27631: dired a/*/b

From: Tino Calancha <[email-masked]>
Date: Thu, 3 Aug 2017 13:38:37 +0900 (JST)

On Wed, 2 Aug 2017, Stefan Monnier wrote:

>>> Maybe make dired and list-directory deal with wildcards in positions like
>>> ~/.config/chromium/Default/*/menkifleemblimdogmoihpfopnplikde/
>> Thank you for the report.
>> IMO, this is a nice thing to have.
>> It must be possible to extend the current code so that
>> dired might handle wildcards in the directory part.
>
> I'm not sure the recent patch for this fix is the right approach.
> The old code already used the shell to do the wildcard expansion, so why
> not just adjust the old code.
>
> Here's some starting patch.
Thank you for the patch.
Part of the complexity of the original patch is to provide this new
feature in _tramp_ connections as well;  your patch does the thing
well (see patch below) in the local machine but it fails in remote 
ones.

--8<-----------------------------cut here---------------start------------->8---
commit 21f02469bf5ef3733e3705e9836a7d91f625ce11
Author: Tino Calancha <[email-masked]>
Date:   Thu Aug 3 13:20:40 2017 +0900

     Apply some minor tweaks

diff --git a/lisp/dired.el b/lisp/dired.el
index 211b622fd9..7862d0405c 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -1100,7 +1100,7 @@ dired-readin-insert
        (while (not (file-directory-p dir))
          (setq dir (directory-file-name dir))
          (let ((n (file-name-nondirectory dir)))
-          (setq file-list (mapcar (lambda (f) (concat n "/" f)) file-list)))
+          (setq file-list (mapcar (lambda (f) (concat n (and (not (string= "" f)) "/") f)) file-list)))
          (setq dir (file-name-directory dir)))
        (setq default-directory dir))
      (if (and (equal "" (file-name-nondirectory dir))
@@ -1258,6 +1258,8 @@ dired-insert-directory
  	 ;; as indicated by `ls-lisp-use-insert-directory-program'.
  	 (not (and (featurep 'ls-lisp)
  		   (null ls-lisp-use-insert-directory-program)))
+         (not (and (featurep 'eshell)
+                   (bound-and-true-p eshell-ls-use-in-dired)))
  	 (or (if (eq dired-use-ls-dired 'unspecified)
  		 ;; Check whether "ls --dired" gives exit code 0, and
  		 ;; save the answer in `dired-use-ls-dired'.
@@ -1335,9 +1337,7 @@ dired-insert-directory
  	  (setq content-point (point)))
  	(when wildcard
  	  ;; Insert "wildcard" line where "total" line would be for a full dir.
-	  (insert "  wildcard " (or (cdr-safe (insert-directory-wildcard-in-dir-p dir))
-                                    (file-name-nondirectory dir))
-                  "\n")))
+	  (insert "  wildcard " (car-safe file-list) "\n")))
        (dired-insert-set-properties content-point (point)))))

  (defun dired-insert-set-properties (beg end)
--8<-----------------------------cut here---------------end--------------->8---