unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Tino Calancha <tino.calancha@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 27844@debbugs.gnu.org, Tino Calancha <tino.calancha@gmail.com>
Subject: 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)	[thread overview]
Message-ID: <alpine.DEB.2.20.1708021749120.29825@calancha-pc> (raw)
In-Reply-To: <83tw1ryvqa.fsf@gnu.org>



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





  reply	other threads:[~2017-08-02  8:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2017-08-04 13:15                   ` Eli Zaretskii
2017-07-29  9:05 ` Eli Zaretskii
2017-08-06  4:30   ` Tino Calancha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1708021749120.29825@calancha-pc \
    --to=tino.calancha@gmail.com \
    --cc=27844@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).