[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#27844: 26.0.50; Dired w/ eshell-ls doesn't support wildcards in file
From: |
Tino Calancha |
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) |
User-agent: |
Alpine 2.20 (DEB 67 2015-01-07) |
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