From 94410ce1d5ff93da4fb1df96abdb70c65141ff7d Mon Sep 17 00:00:00 2001 From: Lin Sun Date: Mon, 8 Apr 2024 06:59:21 +0000 Subject: [PATCH] Support more time options for `ls-lisp--sanitize-switches' (bug#70271) * lisp/ls-lisp.el (ls-lisp--sanitize-switches): more time options * test/lisp/ls-lisp-tests.el: test case for bug#70271 --- lisp/ls-lisp.el | 3 +++ test/lisp/ls-lisp-tests.el | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/lisp/ls-lisp.el b/lisp/ls-lisp.el index d09b53b1cc..ae4a43797f 100644 --- a/lisp/ls-lisp.el +++ b/lisp/ls-lisp.el @@ -873,6 +873,7 @@ ls-lisp--sanitize-switches (let ((lsflags '(("-a" . "--all") ("-A" . "--almost-all") ("-B" . "--ignore-backups") + ("-c" . "--time=ctime") ("-C" . "--color") ("-F" . "--classify") ("-G" . "--no-group") @@ -883,7 +884,9 @@ ls-lisp--sanitize-switches ("-r" . "--reverse") ("-R" . "--recursive") ("-s" . "--size") + ("-t" . "--sort=time") ("-S" . "--sort.*[ \\\t]") + ("-u" . "--time=atime") ("" . "--group-directories-first") ("" . "--author") ("" . "--escape") diff --git a/test/lisp/ls-lisp-tests.el b/test/lisp/ls-lisp-tests.el index 77046871ea..81e3e163c9 100644 --- a/test/lisp/ls-lisp-tests.el +++ b/test/lisp/ls-lisp-tests.el @@ -29,6 +29,42 @@ (require 'ls-lisp) (require 'dired) +(ert-deftest ls-lisp-test-bug70271 () + "Test for https://debbugs.gnu.org/70271 ." + (ert-with-temp-file + fpath + :suffix "bug70271" + (let* ((dir (file-name-directory fpath)) + (attributes (file-attributes fpath)) + (dired-find-subdir t) + ls-lisp-use-insert-directory-program buf ts) + (unwind-protect + (progn + (setq ts (file-attribute-access-time attributes)) + (with-current-buffer + (dired-internal-noselect dir "-la --time=ctime") + (setq buf (current-buffer) + str (format-time-string "%H:%M" ts)) + (should (search-forward-regexp str nil t)) + (kill-buffer)) + (setq ts (- (float-time) 60)) + (set-file-times fpath ts) + (with-current-buffer + (dired-internal-noselect dir "-la --sort=time") + (setq buf (current-buffer) + str (format-time-string "%H:%M" ts)) + (should (search-forward-regexp str nil t)) + (kill-buffer)) + (setq ts (- (float-time) 120)) + (set-file-times fpath ts) + (with-current-buffer + (dired-internal-noselect dir "-la --time=atime") + (setq buf (current-buffer) + str (format-time-string "%H:%M" ts)) + (should (search-forward-regexp str nil t)) + (kill-buffer))) + (when (buffer-live-p buf) (kill-buffer buf)))))) + (ert-deftest ls-lisp-test-bug27762 () "Test for https://debbugs.gnu.org/27762 ." (let* ((dir source-directory) -- 2.20.5