diff options
| -rw-r--r-- | compat-29.el | 4 | ||||
| -rw-r--r-- | compat-tests.el | 28 |
2 files changed, 30 insertions, 2 deletions
diff --git a/compat-29.el b/compat-29.el index f8a6630..86ea558 100644 --- a/compat-29.el +++ b/compat-29.el @@ -189,7 +189,7 @@ signalled. If NOERROR, the non-loop parts of the chain is returned." (push func chain)) chain)))) -(compat-defun buffer-match-p (condition buffer-or-name &optional arg) ;; <UNTESTED> +(compat-defun buffer-match-p (condition buffer-or-name &optional arg) ;; <compat-tests:buffer-match-p> "Return non-nil if BUFFER-OR-NAME matches CONDITION. CONDITION is either: - the symbol t, to always match, @@ -245,7 +245,7 @@ CONDITION is either: (throw 'match t))))))) (funcall match (list condition)))) -(compat-defun match-buffers (condition &optional buffers arg) ;; <UNTESTED> +(compat-defun match-buffers (condition &optional buffers arg) ;; <compat-tests:match-buffers> "Return a list of buffers that match CONDITION. See `buffer-match' for details on CONDITION. By default all buffers are checked, this can be restricted by passing an diff --git a/compat-tests.el b/compat-tests.el index e79cff2..8ba2819 100644 --- a/compat-tests.el +++ b/compat-tests.el @@ -80,6 +80,34 @@ (setq list (funcall sym list "first" 1 #'string=)) (should (eq (compat-call plist-get list "first" #'string=) 1)))) +(ert-deftest buffer-match-p () + (with-current-buffer (get-buffer-create "*compat-test-buffer*") + (js-mode)) + (let ((b "*compat-test-buffer*")) + (should (buffer-match-p t b)) + (should-not (buffer-match-p nil b)) + (should (buffer-match-p "compat" b)) + (should (buffer-match-p #'always b)) + (should-not (buffer-match-p #'ignore b)) + (should (buffer-match-p '(derived-mode . prog-mode) b)) + (should-not (buffer-match-p '(derived-mode . text-mode) b)) + (should (buffer-match-p '(major-mode . js-mode) b)) + (should-not (buffer-match-p '(major-mode . prog-mode) b)) + (should (buffer-match-p '(not (major-mode . prog-mode)) b)) + (should (buffer-match-p '(and (major-mode . js-mode) "compat" t) b)) + (should (buffer-match-p '(or (major-mode . css-mode) "foo" t) b)))) + +(ert-deftest match-buffers () + (let ((b1 (get-buffer-create "*compat-buffer-js*")) + (b2 (get-buffer-create "*compat-buffer-css*")) + (b3 (get-buffer-create "*compat-buffer-text*"))) + (with-current-buffer b1 (js-mode)) + (with-current-buffer b2 (css-mode)) + (with-current-buffer b3 (text-mode)) + (should-equal (list b2 b1) + (match-buffers '(or (major-mode . css-mode) (major-mode . js-mode)) + (list b1 b2 b3))))) + (ert-deftest thing-at-mouse () (save-window-excursion (with-temp-buffer |
