aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2024-05-17 18:32:45 +0200
committerDaniel Mendler <mail@daniel-mendler.de>2024-05-17 18:32:45 +0200
commitac0ff4c7eb28f8065d8a0c3edc8761f20a6d4d9c (patch)
tree3402339f3ef1812f6048268b0a37195323d40c89
parent84641a11e87e68d3c5e37d2be45cc6777301b211 (diff)
value<: Compare buffers by name
-rw-r--r--compat-30.el6
-rw-r--r--compat-tests.el4
2 files changed, 9 insertions, 1 deletions
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) #'<))