From c175ad52faae49a10a7c04c79a7ca88d68c551b4 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Tue, 20 Jul 2021 16:16:09 +0200 Subject: Make dired-guess-default return all matching programs * lisp/dired-x.el (dired-guess-default): Return all matching programs (bug#48071). --- test/lisp/dired-x-tests.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/lisp/dired-x-tests.el') diff --git a/test/lisp/dired-x-tests.el b/test/lisp/dired-x-tests.el index 5b51c997e36..98754b19b4e 100644 --- a/test/lisp/dired-x-tests.el +++ b/test/lisp/dired-x-tests.el @@ -49,5 +49,17 @@ (sort (dired-get-marked-files 'local) #'string<)))) (delete-directory dir 'recursive)))) +(ert-deftest dired-guess-default () + (let ((dired-guess-shell-alist-user nil) + (dired-guess-shell-alist-default + '(("\\.png\\'" "display") + ("\\.gif\\'" "display" "xloadimage") + ("\\.gif\\'" "feh") + ("\\.jpe?g\\'" "xloadimage")))) + (should (equal (dired-guess-default '("/tmp/foo.png")) "display")) + (should (equal (dired-guess-default '("/tmp/foo.gif")) + '("display" "xloadimage" "feh"))))) + + (provide 'dired-x-tests) ;; dired-x-tests.el ends here -- cgit v1.2.3 From bc0aca059dbfe8cd485d9591f36efb70a2a6272e Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Wed, 21 Jul 2021 13:04:06 +0200 Subject: Fix dired-guess-default logic after previous change * lisp/dired-x.el (dired-guess-default): Restore previous logic -- require matches for all files (bug#48071). --- lisp/dired-x.el | 7 ++++--- test/lisp/dired-x-tests.el | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'test/lisp/dired-x-tests.el') diff --git a/lisp/dired-x.el b/lisp/dired-x.el index 2d91b5a9e8d..073923e09c9 100644 --- a/lisp/dired-x.el +++ b/lisp/dired-x.el @@ -979,9 +979,10 @@ See `dired-guess-shell-alist-user'." #'append (mapcar #'cdr (seq-filter (lambda (elem) - (seq-some (lambda (file) - (string-match-p (car elem) file)) - files)) + (seq-every-p + (lambda (file) + (string-match-p (car elem) file)) + files)) (append dired-guess-shell-alist-user dired-guess-shell-alist-default))) nil)))) diff --git a/test/lisp/dired-x-tests.el b/test/lisp/dired-x-tests.el index 98754b19b4e..003923d60fa 100644 --- a/test/lisp/dired-x-tests.el +++ b/test/lisp/dired-x-tests.el @@ -58,8 +58,9 @@ ("\\.jpe?g\\'" "xloadimage")))) (should (equal (dired-guess-default '("/tmp/foo.png")) "display")) (should (equal (dired-guess-default '("/tmp/foo.gif")) - '("display" "xloadimage" "feh"))))) - + '("display" "xloadimage" "feh"))) + (should (equal (dired-guess-default '("/tmp/foo.png" "/tmp/foo.txt")) + nil)))) (provide 'dired-x-tests) ;; dired-x-tests.el ends here -- cgit v1.2.3