From ac0ff4c7eb28f8065d8a0c3edc8761f20a6d4d9c Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Fri, 17 May 2024 18:32:45 +0200 Subject: value<: Compare buffers by name --- compat-30.el | 6 ++++++ compat-tests.el | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/compat-30.el b/compat-30.el index d9d1527..43dc9d1 100644 --- a/compat-30.el +++ b/compat-30.el @@ -256,6 +256,12 @@ Other types are considered unordered and the return value will be ‘nil’." ((or (and (stringp a) (stringp b)) (and (symbolp a) (symbolp b))) (string< a b)) + ((and (bufferp a) (bufferp b)) + (setq a (buffer-name a) + b (buffer-name b)) + (cond + ((and a b) (string< a b)) + (b t))) ((and (listp a) (listp b)) (while (and (consp a) (consp b) (equal (car a) (car b))) (setq a (cdr a) b (cdr b))) diff --git a/compat-tests.el b/compat-tests.el index de86214..ece115c 100644 --- a/compat-tests.el +++ b/compat-tests.el @@ -1810,7 +1810,9 @@ (compat--should-value< [1 2] [2 3]) (compat--should-value< [1 2 3] [2]) (compat--should-value< [0 1 2] [0 2 3]) - (compat--should-value< [0 1 2 3] [0 2])) + (compat--should-value< [0 1 2 3] [0 2]) + ;; Buffers are compared by name + (compat--should-value< (get-buffer-create "a") (get-buffer-create "b"))) (ert-deftest compat-sort () (should-equal (list 1 2 3) (sort (list 1 2 3) #'<)) -- cgit v1.0