branch: externals/transient commit e9a636d3c7cbb9ac43ea4a08a1c252a02c7c3460 Author: Jonas Bernoulli <jo...@bernoul.li> Commit: Jonas Bernoulli <jo...@bernoul.li>
transient--insert-suffix: Handle duplicated insertion using coordinates When the suffix being inserted is already part of the menu, we remove the existing entry and then insert a new entry. In some cases we could avoid these two steps and just do nothing, but it would likely be more expensive and certainly more complicated to determine whether we can skip the two steps than it is to just do them. When the same suffix is added twice at the same coordinates (e.g., because the same form ends up being evaluated twice), this resulted in an error because the entry that is removed in this case also is the pointer to the insertion location, and removing it invalidates it. So we have to lookup the coordinates again, after the removal. Closes #400. Closes #401. (We cannot use `pcase-setq' because that wasn't added until Emacs 28.1 and Compat does not backport it. Also, it turns out this is the exception to my rule to never set more than one variable using a single `setq' form.) Co-authored-by: Evgeny Boykov <arts...@list.ru> --- lisp/transient.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/transient.el b/lisp/transient.el index eb4dcb468f..67b806b7ae 100644 --- a/lisp/transient.el +++ b/lisp/transient.el @@ -1569,7 +1569,9 @@ Intended for use in a group's `:setup-children' function." :command))) (equal (transient--suffix-predicate suf) (transient--suffix-predicate conflict))))) - (transient-remove-suffix prefix key)) + (transient-remove-suffix prefix key) + (let ((eg (transient--locate-child prefix loc))) + (setq elt (car eg) group (cadr eg)))) (let ((mem (memq elt (aref group 2)))) (pcase-exhaustive action ('insert (setcdr mem (cons elt (cdr mem)))