branch: externals/compat commit ac0ff4c7eb28f8065d8a0c3edc8761f20a6d4d9c Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
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 d9d152791f..43dc9d1408 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 de86214f85..ece115c2d7 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) #'<))