From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs 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) Message-ID: References: <878tjasgom.fsf@calancha-pc> <87h8xyutc3.fsf@calancha-pc> <83inib393n.fsf@gnu.org> <87lgn4j8ko.fsf@calancha-pc> <8360e71k5p.fsf@gnu.org> <83wp6nz4ce.fsf@gnu.org> <83tw1ryvqa.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Trace: blaine.gmane.org 1501663815 12334 195.159.176.226 (2 Aug 2017 08:50:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 2 Aug 2017 08:50:15 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: 27844@debbugs.gnu.org, Tino Calancha To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Aug 02 10:50:10 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dcpM0-0002sw-Qn for geb-bug-gnu-emacs@m.gmane.org; Wed, 02 Aug 2017 10:50:09 +0200 Original-Received: from localhost ([::1]:46103 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcpM6-0005iA-TO for geb-bug-gnu-emacs@m.gmane.org; Wed, 02 Aug 2017 04:50:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcpLz-0005ga-F1 for bug-gnu-emacs@gnu.org; Wed, 02 Aug 2017 04:50:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcpLu-0005sR-IF for bug-gnu-emacs@gnu.org; Wed, 02 Aug 2017 04:50:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:34975) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dcpLu-0005sD-Ey for bug-gnu-emacs@gnu.org; Wed, 02 Aug 2017 04:50:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dcpLu-0003v4-6A for bug-gnu-emacs@gnu.org; Wed, 02 Aug 2017 04:50:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 02 Aug 2017 08:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27844 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 27844-submit@debbugs.gnu.org id=B27844.150166379915053 (code B ref 27844); Wed, 02 Aug 2017 08:50:02 +0000 Original-Received: (at 27844) by debbugs.gnu.org; 2 Aug 2017 08:49:59 +0000 Original-Received: from localhost ([127.0.0.1]:37652 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dcpLp-0003uf-J7 for submit@debbugs.gnu.org; Wed, 02 Aug 2017 04:49:57 -0400 Original-Received: from mail-io0-f177.google.com ([209.85.223.177]:37272) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dcpLn-0003uP-K9 for 27844@debbugs.gnu.org; Wed, 02 Aug 2017 04:49:56 -0400 Original-Received: by mail-io0-f177.google.com with SMTP id c74so17772018iod.4 for <27844@debbugs.gnu.org>; Wed, 02 Aug 2017 01:49:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=D6VL/nHR01ntgnuAoF6QZPBcf8hQkyZQLYDn+9+MsNI=; b=Hs3CCBafpnNorN6QTrmSl3aSIUqsamGDBqE9OHM1piWhH9sI86g4FxG0J1niXbU0qR mUU2p8KdFbjoWqB9AbaXDTQVhdW5zmnH+nsMU535NY+TGKogu/9X87GEt62BcjeIuAdS qsHipnMiazI/E1LG0D5Iw0wlUDc7s9jNk2L1SzWGrW4iSn4XCx+8dfNAhb/TfAkiEYIM Buth2f4OdEBpK3t2UJdSqRlrvP3HI/v6elFa8iwWgxEyfxVa6+bUDPhjpdAya+2kW9gg 7/u/TpT8wZ8mS8GKULyYLRdo0TJcn38TvogVMGiASW0F3V2DrvLSeNFdZfZYX3SHdyIa f9ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=D6VL/nHR01ntgnuAoF6QZPBcf8hQkyZQLYDn+9+MsNI=; b=CIBazJcwewU9IN62JbhqtCTMj2PQvff23JEglc32+qOMti7qh/Ue0gA4Kc8k9DNqev eqoqzDlOu0NAh5ei16N5Ag584uw4CmIJy/zjqshMqNjxd4i5MxjCDut8GvZfB0KQ11l4 UNR2BcvKNNmt1emtqsdKcLC9crMHhc6slp08IMQlryc8frhckVcVbsCVf8Xs3ExwiSst bgyiBoYqDO45JFSQ2w+5a5Fw1Dql8+i5VD4JCEt7JU69NtVgIXTgLkSTCRHSndLrdJth NT7ysE1yvI5/YrBVINgyHm2fymvn4Mgn8iPuJuFlOuc6zU/w+fUkJ17tSWG82CdneHY5 X9mQ== X-Gm-Message-State: AIVw111Ypxfi5eDrSW+iRTzuUdvkkv0YfBzkIw5jd2wy59FLqnyx3Cca LCIq0AVqjSd3/w== X-Received: by 10.107.12.70 with SMTP id w67mr28663144ioi.298.1501663789589; Wed, 02 Aug 2017 01:49:49 -0700 (PDT) Original-Received: from calancha-pc (170.224.128.101.dy.bbexcite.jp. [101.128.224.170]) by smtp.gmail.com with ESMTPSA id d201sm1748621itb.0.2017.08.02.01.49.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Aug 2017 01:49:48 -0700 (PDT) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc In-Reply-To: <83tw1ryvqa.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:135240 Archived-At: On Tue, 1 Aug 2017, Eli Zaretskii wrote: >> From: Tino Calancha >> Date: Wed, 2 Aug 2017 01:04:20 +0900 (JST) >> cc: Tino Calancha , 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 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