Skip to content

Commit 66fd4bf

Browse files
committed
Add: Removing properties from plists
1 parent cf5d93a commit 66fd4bf

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

README.org

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,20 @@ Using ~-select~ from =dash.el= seems to be the fastest way:
608608
(a-merge numbers more-numbers)) ;; => ((three . 3) (two . 2) (one . 1))
609609
#+END_SRC
610610

611+
**** Property lists (plists) :plists:
612+
613+
***** Removing properties
614+
615+
[[https://www.reddit.com/r/emacs/comments/aupifm/what_is_the_best_way_to_do_plistremove/eh9xom5/][According to Stefan Monnier]]:
616+
617+
#+BEGIN_QUOTE
618+
The plist design in Elisp was based on the idea that you shouldn't distinguish an entry with a nil value from an entry that's absent. Hence =plist-remove= is not needed because you can do ~(plist-put PLIST PROP nil)~ instead.
619+
620+
Of course, in the mean time, =plist-member= appeared, breaking the design, so this answer is probably not 100% satisfactory, but I still think you'll generally be better off if you can ignore the difference between =nil= and "absent".
621+
#+END_QUOTE
622+
623+
If you do need to remove a key and value from a plist, you could use =cl-remf= or =map-delete= (the former probably being faster).
624+
611625
*** Libraries :libraries:
612626
:PROPERTIES:
613627
:TOC: :depth 0

index.html

Lines changed: 34 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)