From 10c03d9fc0a1469f52cc9ba1deaa74c3a4e4524c Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Sat, 25 Oct 2025 19:27:08 -0700 Subject: [PATCH] Adjust sorting of format help output --- clash/clash.lisp | 2 +- clash/format.lisp | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/clash/clash.lisp b/clash/clash.lisp index 0062209..911804c 100644 --- a/clash/clash.lisp +++ b/clash/clash.lisp @@ -473,7 +473,7 @@ list of trash directories that were present in INFOS." (clingon:make-option :flag :key :quiet - :description "suppress print matches (use with -t)" + :description "don't print matches (use with -t)" :short-name #\q :long-name "quiet")))) diff --git a/clash/format.lisp b/clash/format.lisp index cb708b5..949d2f0 100644 --- a/clash/format.lisp +++ b/clash/format.lisp @@ -156,7 +156,7 @@ instead." :type string :initform "" :documentation "The used-passed format string.")) - (:default-initargs :parameter "FORMAT-CONTROL") + (:default-initargs :parameter "FORMAT") (:documentation "Option that takes a format string.")) (defmethod clingon:initialize-option ((option option-format-string) &key) @@ -231,6 +231,12 @@ parse-format-string)." when extra-action do (funcall extra-action (aref objs-arr index))))) +(defun format-code-name-less-p (c1 c2) + "Return non-nil if C2 sorts after C1 (both are format code names)." + (if (equalp c1 c2) + (and (not (eql c1 c2)) (upper-case-p c2)) + (char-lessp c1 c2))) + (defun print-format-info (stream &rest name-directive-pairs) (format stream "~ Format strings use C-style and printf-style escape sequences. Each character @@ -251,8 +257,9 @@ the initial % character)~%") The recognized printf-style sequences for ~A are: \"%%\" - a literal % *\"%#\" - the index of the current item (used when prompting)~%" name) - do (dolist (code (sort (copy-list directive) #'char-lessp - :key #'format-code-name)) + do (dolist (code (stable-sort + (copy-list directive) #'format-code-name-less-p + :key #'format-code-name)) (with-slots (name doc padder) code (format stream " ~:[ ~;*~]\"%~A\"~@[ - ~A~]~%" padder name doc)))