all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards in file name
@ 2017-07-27  3:27 Tino Calancha
  2017-07-27  9:23 ` Tino Calancha
  2017-07-29  9:05 ` Eli Zaretskii
  0 siblings, 2 replies; 13+ messages in thread
From: Tino Calancha @ 2017-07-27  3:27 UTC (permalink / raw)
  To: 27844


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@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





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards in file name
  2017-07-27  3:27 bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards in file name Tino Calancha
@ 2017-07-27  9:23 ` Tino Calancha
  2017-07-29  9:06   ` Eli Zaretskii
  2017-07-29  9:05 ` Eli Zaretskii
  1 sibling, 1 reply; 13+ messages in thread
From: Tino Calancha @ 2017-07-27  9:23 UTC (permalink / raw)
  To: 27844

Tino Calancha <tino.calancha@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@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





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards in file name
  2017-07-27  3:27 bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards in file name Tino Calancha
  2017-07-27  9:23 ` Tino Calancha
@ 2017-07-29  9:05 ` Eli Zaretskii
  2017-08-06  4:30   ` Tino Calancha
  1 sibling, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2017-07-29  9:05 UTC (permalink / raw)
  To: Tino Calancha; +Cc: 27844

> From: Tino Calancha <tino.calancha@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@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.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards in file name
  2017-07-27  9:23 ` Tino Calancha
@ 2017-07-29  9:06   ` Eli Zaretskii
  2017-08-01  3:00     ` Tino Calancha
  0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2017-07-29  9:06 UTC (permalink / raw)
  To: Tino Calancha; +Cc: 27844

> From: Tino Calancha <tino.calancha@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?





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards in file name
  2017-07-29  9:06   ` Eli Zaretskii
@ 2017-08-01  3:00     ` Tino Calancha
  2017-08-01 13:40       ` Eli Zaretskii
  0 siblings, 1 reply; 13+ messages in thread
From: Tino Calancha @ 2017-08-01  3:00 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 27844

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Tino Calancha <tino.calancha@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.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards in file name
  2017-08-01  3:00     ` Tino Calancha
@ 2017-08-01 13:40       ` Eli Zaretskii
  2017-08-01 14:06         ` Tino Calancha
  0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2017-08-01 13:40 UTC (permalink / raw)
  To: Tino Calancha; +Cc: 27844

> From: Tino Calancha <tino.calancha@gmail.com>
> Cc: 27844@debbugs.gnu.org
> Date: Tue, 01 Aug 2017 12:00:39 +0900
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >> From: Tino Calancha <tino.calancha@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.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards in file name
  2017-08-01 13:40       ` Eli Zaretskii
@ 2017-08-01 14:06         ` Tino Calancha
  2017-08-01 15:37           ` Eli Zaretskii
  0 siblings, 1 reply; 13+ messages in thread
From: Tino Calancha @ 2017-08-01 14:06 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 27844, Tino Calancha



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.







^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards in file name
  2017-08-01 14:06         ` Tino Calancha
@ 2017-08-01 15:37           ` Eli Zaretskii
  2017-08-01 16:04             ` Tino Calancha
  0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2017-08-01 15:37 UTC (permalink / raw)
  To: Tino Calancha; +Cc: 27844

> From: Tino Calancha <tino.calancha@gmail.com>
> Date: Tue, 1 Aug 2017 23:06:01 +0900 (JST)
> cc: Tino Calancha <tino.calancha@gmail.com>, 27844@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?





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards in file name
  2017-08-01 15:37           ` Eli Zaretskii
@ 2017-08-01 16:04             ` Tino Calancha
  2017-08-01 18:43               ` Eli Zaretskii
  0 siblings, 1 reply; 13+ messages in thread
From: Tino Calancha @ 2017-08-01 16:04 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 27844, Tino Calancha



On Tue, 1 Aug 2017, Eli Zaretskii wrote:

>> From: Tino Calancha <tino.calancha@gmail.com>
>> Date: Tue, 1 Aug 2017 23:06:01 +0900 (JST)
>> cc: Tino Calancha <tino.calancha@gmail.com>, 27844@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.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards in file name
  2017-08-01 16:04             ` Tino Calancha
@ 2017-08-01 18:43               ` Eli Zaretskii
  2017-08-02  8:49                 ` Tino Calancha
  0 siblings, 1 reply; 13+ messages in thread
From: Eli Zaretskii @ 2017-08-01 18:43 UTC (permalink / raw)
  To: Tino Calancha; +Cc: 27844

> From: Tino Calancha <tino.calancha@gmail.com>
> Date: Wed, 2 Aug 2017 01:04:20 +0900 (JST)
> cc: Tino Calancha <tino.calancha@gmail.com>, 27844@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.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards in file name
  2017-08-01 18:43               ` Eli Zaretskii
@ 2017-08-02  8:49                 ` Tino Calancha
  2017-08-04 13:15                   ` Eli Zaretskii
  0 siblings, 1 reply; 13+ messages in thread
From: Tino Calancha @ 2017-08-02  8:49 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 27844, Tino Calancha



On Tue, 1 Aug 2017, Eli Zaretskii wrote:

>> From: Tino Calancha <tino.calancha@gmail.com>
>> Date: Wed, 2 Aug 2017 01:04:20 +0900 (JST)
>> cc: Tino Calancha <tino.calancha@gmail.com>, 27844@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@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





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards in file name
  2017-08-02  8:49                 ` Tino Calancha
@ 2017-08-04 13:15                   ` Eli Zaretskii
  0 siblings, 0 replies; 13+ messages in thread
From: Eli Zaretskii @ 2017-08-04 13:15 UTC (permalink / raw)
  To: Tino Calancha; +Cc: 27844

> From: Tino Calancha <tino.calancha@gmail.com>
> Date: Wed, 2 Aug 2017 17:49:45 +0900 (JST)
> cc: Tino Calancha <tino.calancha@gmail.com>, 27844@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.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards in file name
  2017-07-29  9:05 ` Eli Zaretskii
@ 2017-08-06  4:30   ` Tino Calancha
  0 siblings, 0 replies; 13+ messages in thread
From: Tino Calancha @ 2017-08-06  4:30 UTC (permalink / raw)
  To: 27844-done

Eli Zaretskii <eliz@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)





^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-08-06  4:30 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-27  3:27 bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards in file name Tino Calancha
2017-07-27  9:23 ` Tino Calancha
2017-07-29  9:06   ` Eli Zaretskii
2017-08-01  3:00     ` Tino Calancha
2017-08-01 13:40       ` Eli Zaretskii
2017-08-01 14:06         ` Tino Calancha
2017-08-01 15:37           ` Eli Zaretskii
2017-08-01 16:04             ` Tino Calancha
2017-08-01 18:43               ` Eli Zaretskii
2017-08-02  8:49                 ` Tino Calancha
2017-08-04 13:15                   ` Eli Zaretskii
2017-07-29  9:05 ` Eli Zaretskii
2017-08-06  4:30   ` Tino Calancha

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.