Subject: bug#75170: add-to-alist: new function

From: Stefan Monnier <[email-masked]>
Date: Tue, 21 Jan 2025 18:08:07 -0500

I don't have much to add to this discussion except:

- I personally dislike `add-to-list` because I think that conflating
  symbols with variables is a bad practice (e.g. because it is
  incompatible with lexical scoping).

- Yet, it works OK for configuration, which always involves
  global/dynamic variables anyway, and where `push` is not great and
  `cl-pushnew` often requires `:test #'equal`.

- I think we should try and provide better support (in general) for
  unloading packages, and this means improving support for undoing
  top-level operations.  We currently support `defalias` and friends
  fairly well, `defvar` and friends tolerably, but we fail miserably for
  most other things.  So maybe something like an `add-to-alist` dedicated
  to top-level operations, which records the change somewhere
  (e.g. `load-history`) so we can undo it when unloading, would be
  an improvement.  Of course it would make a lot of sense to do it
  together with similar operations to add an element to a list, to add
  a property to a symbol, to add an advice, to add a function on a hook,
  ... so it's probably worth thinking of a more general way to provide
  those operations than doing it one at a time.

- Stefan