1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-27 15:52:00 -08:00

Add gv-define-expander for plist-get

It is necessary to make plist-get as a generalized variable, and this
definition allows user to use setf and other useful functions on
plist-get.

* lisp/emacs-lisp/gv.el: Add gv-define-expander for plist-get

* lisp/emacs-lisp/gv-tests.el: Add new tests for plist-get
This commit is contained in:
Naoya Yamashita 2020-09-09 09:52:39 +09:00 committed by Stefan Monnier
parent 4064d07445
commit 66509f2ead
2 changed files with 51 additions and 0 deletions

View file

@ -417,6 +417,17 @@ The return value is the last VAL in the list.
`(delq ,p ,getter))))))
,v))))))))))
(gv-define-expander plist-get
(lambda (do plist prop)
(macroexp-let2 macroexp-copyable-p key prop
(gv-letplace (getter setter) plist
(macroexp-let2 nil p `(cdr (plist-member ,getter ,key))
(funcall do
`(car ,p)
(lambda (val)
`(if ,p
(setcar ,p ,val)
,(funcall setter `(cons ,key (cons ,val ,getter)))))))))))
;;; Some occasionally handy extensions.