[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat 3eea42d9b5 2/5: Add compat-call gv test
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat 3eea42d9b5 2/5: Add compat-call gv test |
Date: |
Tue, 3 Jan 2023 19:57:25 -0500 (EST) |
branch: externals/compat
commit 3eea42d9b59b05a3416990d23cb545506eb27043
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Add compat-call gv test
---
NEWS.org | 1 -
compat-26.el | 3 +--
compat-tests.el | 16 ++++++++++++++++
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/NEWS.org b/NEWS.org
index a1ee354020..168caa123e 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -13,7 +13,6 @@
new calling convention you can use ~(compat-call assoc KEY ALIST)~.
- Deprecate all ~compat-*~ prefixed functions. Instead use the aforementioned
~compat-call~ or ~compat-function~ macros.
-- The ~compat-alist-get~ generalized variable has been deprecated.
- Deprecate ~compat-help.el~ and ~compat-font-lock.el~
- Drop support for Emacs 24.3
diff --git a/compat-26.el b/compat-26.el
index 4cd8173819..f2a0cc90f2 100644
--- a/compat-26.el
+++ b/compat-26.el
@@ -146,9 +146,8 @@ from the absolute start of the buffer, disregarding the
narrowing."
(compat--alist-get-full-elisp key alist default remove testfn)
(alist-get key alist default remove)))
-(gv-define-expander compat-alist-get
+(gv-define-expander compat--alist-get
(lambda (do key alist &optional default remove testfn)
- (warn "The compat-alist-get gv has been deprecated")
(macroexp-let2 macroexp-copyable-p k key
(gv-letplace (getter setter) alist
(macroexp-let2 nil p `(compat--internal-assoc ,k ,getter ,testfn)
diff --git a/compat-tests.el b/compat-tests.el
index a8d5dd331c..278a06e465 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -638,6 +638,22 @@ being compared against."
(ought 'd 0 '((1 . a) (2 . b) (3 . c)) 'd) ;default value
(ought 'd 2 '((1 . a) (2 . b) (3 . c)) 'd nil #'ignore))
+(ert-deftest compat-call-alist-get-gv ()
+ "Test if the `compat-call alist-get' can be used as a generalised variable."
+ (let ((alist-1 (list (cons 1 "one")
+ (cons 2 "two")
+ (cons 3 "three")))
+ (alist-2 (list (cons "one" 1)
+ (cons "two" 2)
+ (cons "three" 3))))
+ (setf (compat-call alist-get 1 alist-1) "eins")
+ (should (equal (compat-call alist-get 1 alist-1) "eins"))
+ (setf (compat-call alist-get 2 alist-1 nil 'remove) nil)
+ (should (equal alist-1 '((1 . "eins") (3 . "three"))))
+ (setf (compat-call alist-get "one" alist-2 nil nil #'string=) "eins")
+ (should (equal (compat-call alist-get "one" alist-2 nil nil #'string=)
+ "eins"))))
+
(ert-deftest compat-alist-get-gv ()
"Test if the `compat-alist-get' can be used as a generalised variable."
(let ((alist-1 (list (cons 1 "one")