From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.bugs Subject: bug#64046: 30.0.50; Quoting in customize choice tags Date: Tue, 13 Jun 2023 16:02:57 +0200 Message-ID: <87v8frihny.fsf@gmx.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29032"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 64046@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jun 13 16:04:18 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q94d7-0007HG-O1 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 13 Jun 2023 16:04:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q94cw-00081i-38; Tue, 13 Jun 2023 10:04:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q94cs-00081V-W5 for bug-gnu-emacs@gnu.org; Tue, 13 Jun 2023 10:04:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q94cs-0000CJ-NY for bug-gnu-emacs@gnu.org; Tue, 13 Jun 2023 10:04:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q94cs-0000Bb-JB for bug-gnu-emacs@gnu.org; Tue, 13 Jun 2023 10:04:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stephen Berman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 13 Jun 2023 14:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 64046 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.1686664987607 (code B ref -1); Tue, 13 Jun 2023 14:04:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 13 Jun 2023 14:03:07 +0000 Original-Received: from localhost ([127.0.0.1]:42600 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q94by-00009i-HS for submit@debbugs.gnu.org; Tue, 13 Jun 2023 10:03:07 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:53092) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q94bw-00009a-0v for submit@debbugs.gnu.org; Tue, 13 Jun 2023 10:03:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q94bv-0007re-RS for bug-gnu-emacs@gnu.org; Tue, 13 Jun 2023 10:03:03 -0400 Original-Received: from mout.gmx.net ([212.227.17.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q94bt-0008PC-GO for bug-gnu-emacs@gnu.org; Tue, 13 Jun 2023 10:03:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=s31663417; t=1686664978; x=1687269778; i=stephen.berman@gmx.net; bh=n1zxSOkPLjFIWDEi+i7IiQcpM5HAEXo300oxlkXwtMs=; h=X-UI-Sender-Class:From:To:Subject:Date; b=NcOMWHOyitYfmqzf4vnmqDVem0NpbKUqClDSx1/f8+6zae1P47dYN8VgIu98zYOVZ6H++vO 4zZMF05KbspmCF2UK1L/iCeJ5CGDRV02ZDJ1AESdvHKzF3haiNUElZEiNOJH/7EX6yztRkWUt tL2WRNeA2xu2YqKAzK8VfNqCfREvgW66DN5k26ZmeNkDN+4ok+tZOzgLV5jUFsHvpal1E/c4j O7MR4IcwXMigNcPRx5Zjnd9i9Il03qXToDmR4m7U1lNgaVEe51cNNxnfBIgDadsydV0bwjz2H 4FQD/36EcbIy+RT9d68yUv8xuQDCmZZPtmtlQIRxrRGbRTi8dN0A== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from strobelfssd ([89.246.37.154]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MfpSb-1pcTkJ2aPB-00gD9D for ; Tue, 13 Jun 2023 16:02:58 +0200 X-Provags-ID: V03:K1:4MpQi8JI+bvd0YZQcczEdqxstOedutLch3MHRV0G6WWzL8Q6CZa dWiGFZOo+gupuKKtLii/9Ywc6c2+zL1ROMSJXVfz7tK4nieWxOpC+TbA/cHaH4fIB3jW838 Wgsf4ArbQpTiyCkTwXcijVGLdSCReREgprMENa8cjn52w+YZ1h7L5dB7vrMfVM1Ma+I3v97 8DdpW7ZZtVBwLuAuPeL6Q== UI-OutboundReport: notjunk:1;M01:P0:t6Ngau6LwHs=;NrEvJXtg2R+fEgX20rcUJZehnU4 nN9N/55i3pmHCp2t6Awvph+ZC4NbDOjuuSWhYO//03oLBmAN24Q6EHc28lV7/3aqCL6TFRFad kOMbP70ob3iJb9l1f7Yogm3wbwWlClbJy7c9wuP51fa14hD0cy5PB7R4F77TLZLcT4pgLtFZx YtpPosSa/0Lfl/EGRVp2FmwZfWuqcUCdqtoT79AD0hq9oWGT7bZ6Q58bpFtmMQaAAqAbllQoP n9KFn7VeQdO7AoSVFTHUGQNdNMZ/DQdX/c1Wrpg58Xocr6HlIR4Abibpj290Hri+oK6Mr+Xoc LYv8tf+uYHKVSNSVbeU5HBD3BMghqGFxad/BF8CXMVAYDbrVdB1FUu4CUAqvk2oSOkTH7sg4W 20W7adqrdfawDvuIUX8DqUGT4nQgxVOhsQrcl79WNxlWhlnEgTaSmDnP4LQ5QhxIdH2fHWUKq 536mU7LJuCyxpwHojOyt4eLznpWVaQyicpggnxjnZyjk8re2A7svb8YDk8zIKKzqpzqiyXvYB RNY78rK//SI9skLELoUWKLNA92T9BDDO2ma9P18F7rJdlOrDI/wvCJOmlKy/ph2Fo4dLweG29 I2CzBM/somxmKfFV8qOdyklkzbNr31RJk6JdanAPBnWBFWlgGnD9reXMMM2XhR/6lR3elepJP r9eMhkqsjiE+Q/rCz2SmuOeD806r24R7IzKADTkouUiewhGwiiFWYR1tDz9knGTW3W8Kcv5+F 1E4m5UBjm0iyl2B3o4D4TTN64sGwnG9n4NPLx68Pr/thzR9fBzqe0qn+y8N5wZflCkS+GX3c Received-SPF: pass client-ip=212.227.17.20; envelope-from=stephen.berman@gmx.net; helo=mout.gmx.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:263321 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 0. emacs -Q 1. Evaluate the following defcustom: (defcustom my-test "a" "Test." :type '(choice (string :tag "Use `a'" "a") (string :tag "Use `b'" "b"))) 2. M-x customize-option RET my-test RET 3. In the buffer *Customize Option: My Test* note that in the string "Use =E2=80=98a=E2=80=99" following the "Value Menu" button the quote ma= rks are in the "curve" style (=E2=80=98=E2=80=99). 4. Put point on the "Value Menu" button and type RET. 5. The buffer " widget-choose" contains these lines: 0 =3D Use =E2=80=98a=E2=80=99 1 =3D Use =E2=80=98b=E2=80=99 Note that the quote marks in this buffer are also in the "curve" style. 6. With the mouse pointer over the "Value Menu" button press mouse-1, popping up a menu titled "Choice" containing these items: Use `a' Use `b' Note that the quote marks in this menu are in the "grave" style (`') instead of the "curve" style. The use of the "curve" style in the " widget-choose" buffer is due to commit bd3b426ebb7a60045839e97c9da9bfd249fab1f1, but that commit did not take popup menus into account. The attached patch does so. Since the status quo ante long predates emacs-29 and this is just a stylistic bug, I made the patch against master. In this patch I chose to apply substitute-command-keys just once at the beginning of the function `widget-choose', rather than several times within the function, but I restricted its application to item tags, so other uses of the ITEMS argument should not be affected (and my brief testing hasn't found any problem with the patch). The patch also takes the opportunity to replace two unnecessary uses of `let*' in `widget-choose', in one case by `let' and in the other by foregoing let-bound variables altogether and just using the values in place, since they occur only once each in the lines immediately following the eliminated `let*'. In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.17.6) of 2023-06-13 built on strobelfssd Repository revision: ba349aa32e98a53146794197c316f4765598ddbd Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101008 System Description: Linux From Scratch r11.3-100-systemd Configured using: 'configure -C --with-xwidgets 'CFLAGS=3D-Og -g3' PKG_CONFIG_PATH=3D/opt/qt5/lib/pkgconfig' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM XINPUT2 XPM XWIDGETS GTK3 ZLIB --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Description: widget-choose patch Content-Transfer-Encoding: quoted-printable diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index cafd0ad0a4d..bc070c9933f 100644 =2D-- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -281,71 +281,75 @@ widget-choose If ITEMS has simple item definitions, then this function returns the VALU= E of the chosen element. If ITEMS is a keymap, then the return value is the s= ymbol in the key vector, as in the argument of `define-key'." - (cond ((and (< (length items) widget-menu-max-size) - event (display-popup-menus-p)) - ;; Mouse click. - (if (keymapp items) - ;; Modify the keymap prompt, and then restore the old one, i= f any. - (let ((prompt (keymap-prompt items))) - (unwind-protect - (progn - (setq items (delete prompt items)) - (push title (cdr items)) - ;; Return just the first element of the list of even= ts. - (car (x-popup-menu event items))) - (setq items (delete title items)) - (when prompt - (push prompt (cdr items))))) - (x-popup-menu event (list title (cons "" items))))) - ((or widget-menu-minibuffer-flag - (> (length items) widget-menu-max-shortcuts)) - (when (keymapp items) - (setq items (widget--simplify-menu items))) - ;; Read the choice of name from the minibuffer. - (setq items (cl-remove-if 'stringp items)) - (let ((val (completing-read (concat title ": ") items nil t))) - (if (stringp val) - (let ((try (try-completion val items))) - (when (stringp try) - (setq val try)) - (cdr (assoc val items)))))) - (t - (when (keymapp items) - (setq items (widget--simplify-menu items))) - ;; Construct a menu of the choices - ;; and then use it for prompting for a single character. - (let* ((next-digit ?0) - alist choice some-choice-enabled value) - (with-current-buffer (get-buffer-create " widget-choose") - (erase-buffer) - (insert "Available choices:\n\n") - (while items - (setq choice (pop items)) - (when (consp choice) - (let* ((name (substitute-command-keys (car choice))) - (function (cdr choice))) - (insert (format "%c =3D %s\n" next-digit name)) - (push (cons next-digit function) alist) - (setq some-choice-enabled t))) - ;; Allocate digits to disabled alternatives - ;; so that the digit of a given alternative never varies. - (setq next-digit (1+ next-digit))) - (insert "\nC-g =3D Quit") - (goto-char (point-min)) - (forward-line)) - (or some-choice-enabled - (error "None of the choices is currently meaningful")) - (save-window-excursion - ;; Select window to be able to scroll it from minibuffer - (with-selected-window - (display-buffer (get-buffer " widget-choose") - '(display-buffer-in-direction - (direction . bottom) - (window-height . fit-window-to-buffer)= )) - (setq value (read-char-choice - (format "%s: " title) - (mapcar #'car alist))))) - (cdr (assoc value alist)))))) + ;; Apply quote substitution to all customize choice tags, whether + ;; they occur in a widget buffer or in a popup menu. + (let ((items (mapc (lambda (x) + (when (and (consp x) (char-or-string-p (car x))) + (setcar x (substitute-command-keys (car x))))) + items))) + (cond ((and (< (length items) widget-menu-max-size) + event (display-popup-menus-p)) + ;; Mouse click. + (if (keymapp items) + ;; Modify the keymap prompt, and then restore the old one,= if any. + (let ((prompt (keymap-prompt items))) + (unwind-protect + (progn + (setq items (delete prompt items)) + (push title (cdr items)) + ;; Return just the first element of the list of ev= ents. + (car (x-popup-menu event items))) + (setq items (delete title items)) + (when prompt + (push prompt (cdr items))))) + (x-popup-menu event (list title (cons "" items))))) + ((or widget-menu-minibuffer-flag + (> (length items) widget-menu-max-shortcuts)) + (when (keymapp items) + (setq items (widget--simplify-menu items))) + ;; Read the choice of name from the minibuffer. + (setq items (cl-remove-if 'stringp items)) + (let ((val (completing-read (concat title ": ") items nil t))) + (if (stringp val) + (let ((try (try-completion val items))) + (when (stringp try) + (setq val try)) + (cdr (assoc val items)))))) + (t + (when (keymapp items) + (setq items (widget--simplify-menu items))) + ;; Construct a menu of the choices + ;; and then use it for prompting for a single character. + (let ((next-digit ?0) + alist choice some-choice-enabled value) + (with-current-buffer (get-buffer-create " widget-choose") + (erase-buffer) + (insert "Available choices:\n\n") + (while items + (setq choice (pop items)) + (when (consp choice) + (insert (format "%c =3D %s\n" next-digit (car choice))= ) + (push (cons next-digit (cdr choice)) alist) + (setq some-choice-enabled t)) + ;; Allocate digits to disabled alternatives + ;; so that the digit of a given alternative never varies. + (setq next-digit (1+ next-digit))) + (insert "\nC-g =3D Quit") + (goto-char (point-min)) + (forward-line)) + (or some-choice-enabled + (error "None of the choices is currently meaningful")) + (save-window-excursion + ;; Select window to be able to scroll it from minibuffer + (with-selected-window + (display-buffer (get-buffer " widget-choose") + '(display-buffer-in-direction + (direction . bottom) + (window-height . fit-window-to-buffe= r))) + (setq value (read-char-choice + (format "%s: " title) + (mapcar #'car alist))))) + (cdr (assoc value alist))))))) ;;; Widget text specifications. ;; --=-=-=--