mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-27 07:37:33 +00:00
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.
This commit is contained in:
parent
7c3593f817
commit
c0df64db08
@ -243,6 +243,9 @@ scope during the evaluation of TEST-SEXP."
|
||||
|
||||
;;; 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 @@ instead."
|
||||
(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))
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user