GNU bug report logs - #27844
26.0.50; Dired w/ eshell-ls doesn't support wildcards in file name

Previous Next

Package: emacs;

Reported by: Tino Calancha <tino.calancha <at> gmail.com>

Date: Thu, 27 Jul 2017 03:28:01 UTC

Severity: minor

Found in version 26.0.50

Done: Tino Calancha <tino.calancha <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 27844 in the body.
You can then email your comments to 27844 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#27844; Package emacs. (Thu, 27 Jul 2017 03:28:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tino Calancha <tino.calancha <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 27 Jul 2017 03:28:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.0.50; Dired w/ eshell-ls doesn't support wildcards in file name
Date: Thu, 27 Jul 2017 12:27:05 +0900
Dired with eshell-ls doesn't handle wildcards in file names.
emacs -Q -l em-ls -eval "(customize-set-variable 'eshell-ls-use-in-dired t)"

I)
M-: (dired source-directory) RET
C-x d lisp/*.el RET

II)
;; Following works but it shows full file name, instead of the
;; more common relative file name.
C-x d lisp/simple.el RET

--8<-----------------------------cut here---------------start------------->8---
commit 8826109f3b619b59b7d68afa55e446e0c487ca76
Author: Tino Calancha <tino.calancha <at> gmail.com>
Date:   Thu Jul 27 12:21:15 2017 +0900

    Dired w/ eshell-ls: Handle shell wildcards in file name
    
    * lisp/eshell/em-ls.el (eshell-ls--insert-directory):
    Use eshell-extended-glob (Bug#27844).
    * test/lisp/dired-tests.el (dired-test-bug27844): Add test.

diff --git a/lisp/eshell/em-ls.el b/lisp/eshell/em-ls.el
index 79799db30b..48f3874bf7 100644
--- a/lisp/eshell/em-ls.el
+++ b/lisp/eshell/em-ls.el
@@ -241,6 +241,8 @@ dired-flag
 
 ;;; Functions:
 
+(declare-function eshell-extended-glob "em-glob" (glob))
+
 (defun eshell-ls--insert-directory
   (orig-fun file switches &optional wildcard full-directory-p)
   "Insert directory listing for FILE, formatted according to SWITCHES.
@@ -273,11 +275,18 @@ eshell-ls--insert-directory
                 (set 'font-lock-buffers
                      (delq (current-buffer)
                            (symbol-value 'font-lock-buffers)))))
+          (require 'em-glob)
           (let ((insert-func 'insert)
                 (error-func 'insert)
                 (flush-func 'ignore)
+                (target ; Expand the shell wildcards if any.
+                 (if (and (atom file)
+                          (string-match "[[?*]" file)
+                          (not (file-exists-p file)))
+                     (mapcar #'file-relative-name (eshell-extended-glob file))
+                   (file-relative-name file)))
                 eshell-ls-dired-initial-args)
-            (eshell-do-ls (append switches (list file)))))))))
+            (eshell-do-ls (append switches (list target)))))))))
 
 (defsubst eshell/ls (&rest args)
   "An alias version of `eshell-do-ls'."
diff --git a/test/lisp/dired-tests.el b/test/lisp/dired-tests.el
index 601d65768b..16086b97a9 100644
--- a/test/lisp/dired-tests.el
+++ b/test/lisp/dired-tests.el
@@ -188,5 +188,24 @@
       (customize-set-variable 'eshell-ls-use-in-dired orig)
       (and (buffer-live-p buf) (kill-buffer)))))
 
+
+(ert-deftest dired-test-bug27844 ()
+  "Test for http://debbugs.gnu.org/27844 ."
+  (require 'em-ls)
+  (let ((orig eshell-ls-use-in-dired)
+        (dired-use-ls-dired 'unspecified)
+        buf insert-directory-program)
+    (unwind-protect
+        (progn
+          (customize-set-variable 'eshell-ls-use-in-dired t)
+          (setq buf (dired (expand-file-name "lisp/*.el" source-directory)))
+          (dired-toggle-marks)
+          (should (cdr (dired-get-marked-files)))
+          (kill-buffer buf)
+          (setq buf (dired (expand-file-name "lisp/subr.el" source-directory)))
+          (should (looking-at "subr\\.el")))
+      (customize-set-variable 'eshell-ls-use-in-dired orig)
+      (and (buffer-live-p buf) (kill-buffer)))))
+
 (provide 'dired-tests)
 ;; dired-tests.el ends here

--8<-----------------------------cut here---------------end--------------->8---

In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2017-07-26
Repository revision: e1e8d2e229f48b3cee765f7cf27ae04ee4401d85




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27844; Package emacs. (Thu, 27 Jul 2017 09:24:02 GMT) Full text and rfc822 format available.

Message #8 received at 27844 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: 27844 <at> debbugs.gnu.org
Subject: Re: bug#27844: 26.0.50;
 Dired w/ eshell-ls doesn't support wildcards in file name
Date: Thu, 27 Jul 2017 18:23:08 +0900
Tino Calancha <tino.calancha <at> gmail.com> writes:

> Dired with eshell-ls doesn't handle wildcards in file names.
>  
>  ;;; Functions:
>  
> +(declare-function eshell-extended-glob "em-glob" (glob))
> +
>  (defun eshell-ls--insert-directory
>    (orig-fun file switches &optional wildcard full-directory-p)
>    "Insert directory listing for FILE, formatted according to SWITCHES.
> @@ -273,11 +275,18 @@ eshell-ls--insert-directory
>                  (set 'font-lock-buffers
>                       (delq (current-buffer)
>                             (symbol-value 'font-lock-buffers)))))
> +          (require 'em-glob)
>            (let ((insert-func 'insert)
>                  (error-func 'insert)
>                  (flush-func 'ignore)
> +                (target ; Expand the shell wildcards if any.
> +                 (if (and (atom file)
> +                          (string-match "[[?*]" file)
> +                          (not (file-exists-p file)))
> +                     (mapcar #'file-relative-name (eshell-extended-glob file))
> +                   (file-relative-name file)))
>                  eshell-ls-dired-initial-args)
`eshell-extended-glob' returns a list of matches on success, otherwise
it returns FILE;  if no match i think we should signal an error.

--8<-----------------------------cut here---------------start------------->8---
commit 22f4516a6081c57363790694a11e5f9fe3f84c70
Author: Tino Calancha <tino.calancha <at> gmail.com>
Date:   Thu Jul 27 18:08:17 2017 +0900

    Dired w/ eshell-ls: Handle shell wildcards in file name
    
    * lisp/eshell/em-ls.el (eshell-ls--insert-directory):
    Use eshell-extended-glob (Bug#27844).
    * test/lisp/dired-tests.el (dired-test-bug27844): Add test.

diff --git a/lisp/eshell/em-ls.el b/lisp/eshell/em-ls.el
index 79799db30b..2e0b16db75 100644
--- a/lisp/eshell/em-ls.el
+++ b/lisp/eshell/em-ls.el
@@ -241,6 +241,8 @@ dired-flag
 
 ;;; Functions:
 
+(declare-function eshell-extended-glob "em-glob" (glob))
+
 (defun eshell-ls--insert-directory
   (orig-fun file switches &optional wildcard full-directory-p)
   "Insert directory listing for FILE, formatted according to SWITCHES.
@@ -273,11 +275,21 @@ eshell-ls--insert-directory
                 (set 'font-lock-buffers
                      (delq (current-buffer)
                            (symbol-value 'font-lock-buffers)))))
+          (require 'em-glob)
           (let ((insert-func 'insert)
                 (error-func 'insert)
                 (flush-func 'ignore)
+                (target ; Expand the shell wildcards if any.
+                 (if (and (atom file)
+                          (string-match "[[?*]" file)
+                          (not (file-exists-p file)))
+                     (let ((matches (eshell-extended-glob file)))
+                       (if (consp matches)
+                           (mapcar #'file-relative-name matches)
+                         (user-error (format "%s: No files matching wildcard" file))))
+                   (file-relative-name file)))
                 eshell-ls-dired-initial-args)
-            (eshell-do-ls (append switches (list file)))))))))
+            (eshell-do-ls (append switches (list target)))))))))
 
 (defsubst eshell/ls (&rest args)
   "An alias version of `eshell-do-ls'."

--8<-----------------------------cut here---------------end--------------->8---
In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2017-07-27
Repository revision: 28faa94f1c423091bb34c2776eabe9ae83e5b4fc




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27844; Package emacs. (Sat, 29 Jul 2017 09:06:01 GMT) Full text and rfc822 format available.

Message #11 received at 27844 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 27844 <at> debbugs.gnu.org
Subject: Re: bug#27844: 26.0.50;
 Dired w/ eshell-ls doesn't support wildcards in file name
Date: Sat, 29 Jul 2017 12:05:03 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Date: Thu, 27 Jul 2017 12:27:05 +0900
> 
> 
> Dired with eshell-ls doesn't handle wildcards in file names.
> emacs -Q -l em-ls -eval "(customize-set-variable 'eshell-ls-use-in-dired t)"
> 
> I)
> M-: (dired source-directory) RET
> C-x d lisp/*.el RET
> 
> II)
> ;; Following works but it shows full file name, instead of the
> ;; more common relative file name.
> C-x d lisp/simple.el RET
> 
> --8<-----------------------------cut here---------------start------------->8---
> commit 8826109f3b619b59b7d68afa55e446e0c487ca76
> Author: Tino Calancha <tino.calancha <at> gmail.com>
> Date:   Thu Jul 27 12:21:15 2017 +0900
> 
>     Dired w/ eshell-ls: Handle shell wildcards in file name
>     
>     * lisp/eshell/em-ls.el (eshell-ls--insert-directory):
>     Use eshell-extended-glob (Bug#27844).
>     * test/lisp/dired-tests.el (dired-test-bug27844): Add test.

LGTM, thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27844; Package emacs. (Sat, 29 Jul 2017 09:08:02 GMT) Full text and rfc822 format available.

Message #14 received at 27844 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 27844 <at> debbugs.gnu.org
Subject: Re: bug#27844: 26.0.50;
 Dired w/ eshell-ls doesn't support wildcards in file name
Date: Sat, 29 Jul 2017 12:06:52 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Date: Thu, 27 Jul 2017 18:23:08 +0900
> 
> `eshell-extended-glob' returns a list of matches on success, otherwise
> it returns FILE;  if no match i think we should signal an error.

Whether this should be an error or just FILE is a matter of personal
preferences, I think.  Some shells behave this way, others the other
way.  So either we should leave your original patch as it was, or
introduce a defcustom to produce an error if the user so wants.

WDYT?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27844; Package emacs. (Tue, 01 Aug 2017 03:01:02 GMT) Full text and rfc822 format available.

Message #17 received at 27844 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 27844 <at> debbugs.gnu.org
Subject: Re: bug#27844: 26.0.50;
 Dired w/ eshell-ls doesn't support wildcards in file name
Date: Tue, 01 Aug 2017 12:00:39 +0900
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Tino Calancha <tino.calancha <at> gmail.com>
>> Date: Thu, 27 Jul 2017 18:23:08 +0900
>> 
>> `eshell-extended-glob' returns a list of matches on success, otherwise
>> it returns FILE;  if no match i think we should signal an error.
>
> Whether this should be an error or just FILE is a matter of personal
> preferences, I think.  Some shells behave this way, others the other
> way.  So either we should leave your original patch as it was, or
> introduce a defcustom to produce an error if the user so wants.
Indeed such defcustom already does exist: eshell-error-if-no-glob
(default to nil).
You can see at the end of `eshell-extended-glob':
(if eshell-error-if-no-glob
	    (error "No matches found: %s" glob)
	  glob)

John designed this package very well.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27844; Package emacs. (Tue, 01 Aug 2017 13:41:02 GMT) Full text and rfc822 format available.

Message #20 received at 27844 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 27844 <at> debbugs.gnu.org
Subject: Re: bug#27844: 26.0.50;
 Dired w/ eshell-ls doesn't support wildcards in file name
Date: Tue, 01 Aug 2017 16:40:02 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Cc: 27844 <at> debbugs.gnu.org
> Date: Tue, 01 Aug 2017 12:00:39 +0900
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> From: Tino Calancha <tino.calancha <at> gmail.com>
> >> Date: Thu, 27 Jul 2017 18:23:08 +0900
> >> 
> >> `eshell-extended-glob' returns a list of matches on success, otherwise
> >> it returns FILE;  if no match i think we should signal an error.
> >
> > Whether this should be an error or just FILE is a matter of personal
> > preferences, I think.  Some shells behave this way, others the other
> > way.  So either we should leave your original patch as it was, or
> > introduce a defcustom to produce an error if the user so wants.
> Indeed such defcustom already does exist: eshell-error-if-no-glob
> (default to nil).
> You can see at the end of `eshell-extended-glob':
> (if eshell-error-if-no-glob
> 	    (error "No matches found: %s" glob)
> 	  glob)

I'm confused: I wasn't commenting on what eshell-extended-glob does, I
was commenting about your code:

  +                     (let ((matches (eshell-extended-glob file)))
  +                       (if (consp matches)
  +                           (mapcar #'file-relative-name matches)
  +                         (user-error (format "%s: No files matching wildcard" file))))
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

If eshell-extended-glob already signals an error when it's TRT, why do
you need to signal an error if Eshell doesn't?  What am I missing?

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27844; Package emacs. (Tue, 01 Aug 2017 14:07:01 GMT) Full text and rfc822 format available.

Message #23 received at 27844 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 27844 <at> debbugs.gnu.org, Tino Calancha <tino.calancha <at> gmail.com>
Subject: Re: bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards
 in file name
Date: Tue, 1 Aug 2017 23:06:01 +0900 (JST)

On Tue, 1 Aug 2017, Eli Zaretskii wrote:

> I'm confused: I wasn't commenting on what eshell-extended-glob does, I
> was commenting about your code:
>
>  +                     (let ((matches (eshell-extended-glob file)))
>  +                       (if (consp matches)
>  +                           (mapcar #'file-relative-name matches)
>  +                         (user-error (format "%s: No files matching wildcard" file))))
>                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> If eshell-extended-glob already signals an error when it's TRT, why do
> you need to signal an error if Eshell doesn't?  What am I missing?
I prefer to throw an error because looks familiar compared with
what i see when using GNU/ls.
If i try:
C-x d ~/emacs-master/lisp/*.Z RET

I) with GNU/ls or with ls-lisp:
i get an error and i read in the echo area:
Reading directory: No such file or directory, ~/emacs-master/lisp/*Z

II) with eshell-ls:
I actualy get a Dired buffer with an entry (the directory itself).

I rather prefer if II) behaves as I) regardless on 
'eshell-error-if-no-glob', that means, my second patch with the 
user-error.






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27844; Package emacs. (Tue, 01 Aug 2017 15:38:02 GMT) Full text and rfc822 format available.

Message #26 received at 27844 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 27844 <at> debbugs.gnu.org
Subject: Re: bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards
 in file name
Date: Tue, 01 Aug 2017 18:37:37 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Date: Tue, 1 Aug 2017 23:06:01 +0900 (JST)
> cc: Tino Calancha <tino.calancha <at> gmail.com>, 27844 <at> debbugs.gnu.org
> 
> > If eshell-extended-glob already signals an error when it's TRT, why do
> > you need to signal an error if Eshell doesn't?  What am I missing?
> I prefer to throw an error because looks familiar compared with
> what i see when using GNU/ls.
> If i try:
> C-x d ~/emacs-master/lisp/*.Z RET
> 
> I) with GNU/ls or with ls-lisp:
> i get an error and i read in the echo area:
> Reading directory: No such file or directory, ~/emacs-master/lisp/*Z
> 
> II) with eshell-ls:
> I actualy get a Dired buffer with an entry (the directory itself).
> 
> I rather prefer if II) behaves as I) regardless on 
> 'eshell-error-if-no-glob', that means, my second patch with the 
> user-error.

So we are back to the same issue: this is IMO a user preference, and
you are accustomed to one of the possible behaviors.  And since you
want the behavior to be independent on an already existing user
option, I'm not sure how to proceed.  Maybe you could start by
explaining why you don't want eshell-error-if-no-glob to control this?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27844; Package emacs. (Tue, 01 Aug 2017 16:05:02 GMT) Full text and rfc822 format available.

Message #29 received at 27844 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 27844 <at> debbugs.gnu.org, Tino Calancha <tino.calancha <at> gmail.com>
Subject: Re: bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards
 in file name
Date: Wed, 2 Aug 2017 01:04:20 +0900 (JST)

On Tue, 1 Aug 2017, Eli Zaretskii wrote:

>> From: Tino Calancha <tino.calancha <at> gmail.com>
>> Date: Tue, 1 Aug 2017 23:06:01 +0900 (JST)
>> cc: Tino Calancha <tino.calancha <at> gmail.com>, 27844 <at> debbugs.gnu.org
>>
>>> If eshell-extended-glob already signals an error when it's TRT, why do
>>> you need to signal an error if Eshell doesn't?  What am I missing?
>> I prefer to throw an error because looks familiar compared with
>> what i see when using GNU/ls.
>> If i try:
>> C-x d ~/emacs-master/lisp/*.Z RET
>>
>> I) with GNU/ls or with ls-lisp:
>> i get an error and i read in the echo area:
>> Reading directory: No such file or directory, ~/emacs-master/lisp/*Z
>>
>> II) with eshell-ls:
>> I actualy get a Dired buffer with an entry (the directory itself).
>>
>> I rather prefer if II) behaves as I) regardless on
>> 'eshell-error-if-no-glob', that means, my second patch with the
>> user-error.
>
> So we are back to the same issue: this is IMO a user preference, and
> you are accustomed to one of the possible behaviors.  And since you
> want the behavior to be independent on an already existing user
> option, I'm not sure how to proceed.  Maybe you could start by
> explaining why you don't want eshell-error-if-no-glob to control this?
1) I am imaging one user in a system without an external 'ls' installed.

2) This hypothetical user wants to use Dired;  after searching the web,
   find s?he could do it via eshell.

3) I assume this user is not interested in the eshell internals: just want
   to have Dired running without complications.  That means
   'eshell-error-if-no-glob' keeps its default, nil.

For this guy is more informative to get an error after s?he dired
~/emacs/lisp/*.Z saying that nothing matched the wildcard.  Getting the
Dired buffer with the listing of '~/emacs/lisp' is confuse and requires 
some time to understand the situation.  Furthermore, s?he could do the
same operation in another machine, one with an external "ls" installed,
and observe a different result.

I like the idea that Dired behaves uniformsly regardless on if we are 
using an external 'ls' or an elisp emulation of it.

That said, i am OK with showing the Dired buffer ie, let 
eshell-error-if-no-glob to decide the situation, if you like more.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27844; Package emacs. (Tue, 01 Aug 2017 18:45:02 GMT) Full text and rfc822 format available.

Message #32 received at 27844 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 27844 <at> debbugs.gnu.org
Subject: Re: bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards
 in file name
Date: Tue, 01 Aug 2017 21:43:41 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Date: Wed, 2 Aug 2017 01:04:20 +0900 (JST)
> cc: Tino Calancha <tino.calancha <at> gmail.com>, 27844 <at> debbugs.gnu.org
> 
> 1) I am imaging one user in a system without an external 'ls' installed.
> 
> 2) This hypothetical user wants to use Dired;  after searching the web,
>     find s?he could do it via eshell.
> 
> 3) I assume this user is not interested in the eshell internals: just want
>     to have Dired running without complications.  That means
>     'eshell-error-if-no-glob' keeps its default, nil.

How about binding eshell-error-if-no-glob to non-nil when eshell/ls is
called from Dired, then?

> I like the idea that Dired behaves uniformsly regardless on if we are 
> using an external 'ls' or an elisp emulation of it.

That's an unreachable ideal, because there are too many versions of
'ls' out there.  GNU 'ls' is just one of them.  And sometimes the
error comes from the shell which expands wildcards, not from 'ls'
itself.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27844; Package emacs. (Wed, 02 Aug 2017 08:50:02 GMT) Full text and rfc822 format available.

Message #35 received at 27844 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 27844 <at> debbugs.gnu.org, Tino Calancha <tino.calancha <at> gmail.com>
Subject: Re: bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards
 in file name
Date: Wed, 2 Aug 2017 17:49:45 +0900 (JST)

On Tue, 1 Aug 2017, Eli Zaretskii wrote:

>> From: Tino Calancha <tino.calancha <at> gmail.com>
>> Date: Wed, 2 Aug 2017 01:04:20 +0900 (JST)
>> cc: Tino Calancha <tino.calancha <at> gmail.com>, 27844 <at> debbugs.gnu.org
>>
>> 1) I am imaging one user in a system without an external 'ls' installed.
>>
>> 2) This hypothetical user wants to use Dired;  after searching the web,
>>     find s?he could do it via eshell.
>>
>> 3) I assume this user is not interested in the eshell internals: just want
>>     to have Dired running without complications.  That means
>>     'eshell-error-if-no-glob' keeps its default, nil.
>
> How about binding eshell-error-if-no-glob to non-nil when eshell/ls is
> called from Dired, then?
It sounds good.
Updated patch:

--8<-----------------------------cut here---------------start------------->8---
commit 4654a88f53450e680a10e63a010ffbcbeedfef3e
Author: Tino Calancha <tino.calancha <at> gmail.com>
Date:   Wed Aug 2 17:46:50 2017 +0900

    Dired w/ eshell-ls: Handle shell wildcards in file name

    * lisp/eshell/em-ls.el (eshell-ls--insert-directory):
    Use eshell-extended-glob (Bug#27844).
    * test/lisp/dired-tests.el (dired-test-bug27844): Add test.

diff --git a/lisp/eshell/em-ls.el b/lisp/eshell/em-ls.el
index 39f03ffb79..38e38132bf 100644
--- a/lisp/eshell/em-ls.el
+++ b/lisp/eshell/em-ls.el
@@ -243,6 +243,9 @@ dired-flag

 ;;; Functions:

+(declare-function eshell-extended-glob "em-glob" (glob))
+(defvar eshell-error-if-no-glob)
+
 (defun eshell-ls--insert-directory
   (orig-fun file switches &optional wildcard full-directory-p)
   "Insert directory listing for FILE, formatted according to SWITCHES.
@@ -275,14 +278,22 @@ eshell-ls--insert-directory
                 (set 'font-lock-buffers
                      (delq (current-buffer)
                            (symbol-value 'font-lock-buffers)))))
-          (let ((insert-func 'insert)
-                (error-func 'insert)
-                (flush-func 'ignore)
-                (switches
-                 (append eshell-ls-dired-initial-args
-                         (and (or (consp dired-directory) wildcard) (list "-d"))
-                         switches)))
-            (eshell-do-ls (nconc switches (list file)))))))))
+          (require 'em-glob)
+          (let* ((insert-func 'insert)
+                 (error-func 'insert)
+                 (flush-func 'ignore)
+                 (eshell-error-if-no-glob t)
+                 (target ; Expand the shell wildcards if any.
+                  (if (and (atom file)
+                           (string-match "[[?*]" file)
+                           (not (file-exists-p file)))
+                      (mapcar #'file-relative-name (eshell-extended-glob file))
+                    (file-relative-name file)))
+                 (switches
+                  (append eshell-ls-dired-initial-args
+                          (and (or (consp dired-directory) wildcard) (list "-d"))
+                          switches)))
+            (eshell-do-ls (nconc switches (list target)))))))))


 (declare-function eshell-extended-glob "em-glob" (glob))
diff --git a/test/lisp/eshell/em-ls-tests.el b/test/lisp/eshell/em-ls-tests.el
index 71a555d1ea..8e7b91d979 100644
--- a/test/lisp/eshell/em-ls-tests.el
+++ b/test/lisp/eshell/em-ls-tests.el
@@ -75,6 +75,24 @@
       (customize-set-variable 'eshell-ls-use-in-dired orig)
       (and (buffer-live-p buf) (kill-buffer)))))

+(ert-deftest em-ls-test-bug27844 ()
+  "Test for http://debbugs.gnu.org/27844 ."
+  (let ((orig eshell-ls-use-in-dired)
+        (dired-use-ls-dired 'unspecified)
+        buf insert-directory-program)
+    (unwind-protect
+        (progn
+          (customize-set-variable 'eshell-ls-use-in-dired t)
+          (setq buf (dired (expand-file-name "lisp/*.el" source-directory)))
+          (dired-toggle-marks)
+          (should (cdr (dired-get-marked-files)))
+          (kill-buffer buf)
+          (setq buf (dired (expand-file-name "lisp/subr.el" source-directory)))
+          (should (looking-at "subr\\.el")))
+      (customize-set-variable 'eshell-ls-use-in-dired orig)
+      (and (buffer-live-p buf) (kill-buffer)))))
+
+
 (provide 'em-ls-test)

 ;;; em-ls-tests.el ends here
--8<-----------------------------cut here---------------end--------------->8---
In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2017-08-02 built
Repository revision: e82c4f56e6f9a6bce4098698b17fa45dcc5bbd25




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27844; Package emacs. (Fri, 04 Aug 2017 13:17:02 GMT) Full text and rfc822 format available.

Message #38 received at 27844 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 27844 <at> debbugs.gnu.org
Subject: Re: bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards
 in file name
Date: Fri, 04 Aug 2017 16:15:16 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Date: Wed, 2 Aug 2017 17:49:45 +0900 (JST)
> cc: Tino Calancha <tino.calancha <at> gmail.com>, 27844 <at> debbugs.gnu.org
> 
> > How about binding eshell-error-if-no-glob to non-nil when eshell/ls is
> > called from Dired, then?
> It sounds good.
> Updated patch:

Fine with me, thanks.




Reply sent to Tino Calancha <tino.calancha <at> gmail.com>:
You have taken responsibility. (Sun, 06 Aug 2017 04:31:02 GMT) Full text and rfc822 format available.

Notification sent to Tino Calancha <tino.calancha <at> gmail.com>:
bug acknowledged by developer. (Sun, 06 Aug 2017 04:31:02 GMT) Full text and rfc822 format available.

Message #43 received at 27844-done <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: 27844-done <at> debbugs.gnu.org
Subject: Re: bug#27844: 26.0.50;
 Dired w/ eshell-ls doesn't support wildcards in file name
Date: Sun, 06 Aug 2017 13:30:06 +0900
Eli Zaretskii <eliz <at> gnu.org> writes:

>>     Dired w/ eshell-ls: Handle shell wildcards in file name
>>     
>>     * lisp/eshell/em-ls.el (eshell-ls--insert-directory):
>>     Use eshell-extended-glob (Bug#27844).
>>     * test/lisp/dired-tests.el (dired-test-bug27844): Add test.
>
> LGTM, thanks.
Pushed fix into master branch as commit
c0df64db08b58cdac37cb38c16f2ba2f097fae92
(Dired w/ eshell-ls: Handle shell wildcards in file name)




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 03 Sep 2017 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 235 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.