From 088fec0a1f8bf2ff5182d93ff48063cc17193037 Mon Sep 17 00:00:00 2001 From: Stephen Berman Date: Sat, 2 Sep 2023 23:22:01 +0200 Subject: [PATCH] Fix and extend applying substitution in widget-choose * lisp/wid-edit.el (widget-choose): Iterate only over proper lists when applying substitution (bug#64046, Message #53). With simple item definitions, apply substitution only to the item text, not to its value (bug#64046, Message #86). Apply substitution also to the widget title (bug#64046, Message #92). --- lisp/wid-edit.el | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index ae060c92d0e..d18d721f7ed 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -282,16 +282,20 @@ The user is asked to choose between each NAME from ITEMS. If ITEMS has simple item definitions, then this function returns the VALUE of the chosen element. If ITEMS is a keymap, then the return value is the symbol in the key vector, as in the argument of `define-key'." - ;; Apply quote substitution to customize choice menu item text, - ;; whether it occurs in a widget buffer or in a popup menu. + ;; Apply substitution to choice menu title and item text, whether it + ;; occurs in a widget buffer or in a popup menu. (let ((items (mapc (lambda (x) - (when (consp x) - (dotimes (i (1- (length x))) - (when (stringp (nth i x)) - (setcar (nthcdr i x) - (substitute-command-keys - (car (nthcdr i x)))))))) - items))) + (if (proper-list-p x) + (dotimes (i (1- (length x))) + (when (stringp (nth i x)) + (setcar (nthcdr i x) + (substitute-command-keys + (car (nthcdr i x)))))) + ;; ITEMS has simple item definitions. + (when (and (consp x) (stringp (car x))) + (setcar x (substitute-command-keys (car x)))))) + items)) + (title (substitute-command-keys title))) (cond ((and (< (length items) widget-menu-max-size) event (display-popup-menus-p)) ;; Mouse click. -- 2.39.2