add-to-list doesn't refresh item, it only checks for existence of item by
equal or custom comparison function:
(add-to-list 'tramp-methods '("gssh" (tramp-login-program "gcloud compute ssh")) nil (lambda (a b) (equal (car a) (car b))))
What way can I replace definition in a list, that handles presence/absence of item and support custom comparison function?
tramp-methods is an association list. Is there something to set key/value with replacing existing entry?
UPDATE I found
cl-adjoin but they don't replace, only adds if not there...
UPDATE 2 Found exactly same question: https://stackoverflow.com/questions/10063195/replace-item-in-association-list-in-elisp
There is no build-in library function that handles replacement of existing items with custom key/test function & that handles missing item case...
The close solution:
(setq tramp-methods (cons '("gssh" (tramp-login-program "compute ssh 2")) (cl-remove "gssh" tramp-methods :key 'car :test 'equal)))
I wonder if there is some
cl-union is the most closed so far, but it has undefined behavior when elements are equal...