changeset 21833:a9d4f3acae4e

(dired-sort-toggle): Handle spaces in dired-actual-switches.
author Richard M. Stallman <rms@gnu.org>
date Wed, 29 Apr 1998 05:06:46 +0000
parents daf559874709
children 8ba41a7b6464
files lisp/dired.el
diffstat 1 files changed, 16 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/dired.el	Wed Apr 29 05:02:34 1998 +0000
+++ b/lisp/dired.el	Wed Apr 29 05:06:46 1998 +0000
@@ -2389,16 +2389,22 @@
   ;; Toggle between sort by date/name.  Reverts the buffer.
   (setq dired-actual-switches
 	(let (case-fold-search)
-	  (concat
-	   "-l"
-	   (dired-replace-in-string (concat "[-lt"
-					    dired-ls-sorting-switches "]")
-				    ""
-				    dired-actual-switches)
-	   (if (string-match (concat "[t" dired-ls-sorting-switches "]")
-			     dired-actual-switches)
-	       ""
-	     "t"))))
+	  (if (string-match " " dired-actual-switches)
+	      ;; New toggle scheme: add/remove a trailing " -t"
+	      (if (string-match " -t\\'" dired-actual-switches)
+		  (dired-replace-in-string " -t\\'" "" dired-actual-switches)
+		(concat dired-actual-switches " -t"))
+	    ;; old toggle scheme: look for some 't' switch and add/remove it
+	    (concat
+	     "-l"
+	     (dired-replace-in-string (concat "[-lt"
+					      dired-ls-sorting-switches "]")
+				      ""
+				      dired-actual-switches)
+	     (if (string-match (concat "[t" dired-ls-sorting-switches "]")
+			       dired-actual-switches)
+		 ""
+	       "t")))))
   (dired-sort-set-modeline)
   (revert-buffer))