[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Garbage collect and buffer-undo-list
From: |
Stefan Monnier |
Subject: |
Re: Garbage collect and buffer-undo-list |
Date: |
Sat, 13 Mar 2021 14:01:24 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> I know the garbage collector trims buffer-undo-list. Does it collect the
> cons cell if there are other references to that object (other than
> buffer-undo-list)?
No, it can't.
If you want to keep a reference to some of those cons-cells but still
want the GC to collect them when the undo-log is trimmed, then you need
to use a weak reference. We don't currently have plain "weak
references" in ELisp, but we do have hash-tables whose keys and/or
values can be weak references (that's what I used in
`undo-equiv-table`).
Stefan