GNU bug report logs -
#27844
26.0.50; Dired w/ eshell-ls doesn't support wildcards in file name
Previous Next
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.
Full log
View this message in rfc822 format
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
This bug report was last modified 7 years and 296 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.