emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 7420b6dcc3: Fix `pr-interface'


From: Robert Pluim
Subject: emacs-29 7420b6dcc3: Fix `pr-interface'
Date: Fri, 6 Jan 2023 04:07:47 -0500 (EST)

branch: emacs-29
commit 7420b6dcc379617ca9691049c16bfb2d158f9496
Author: Robert Pluim <rpluim@gmail.com>
Commit: Robert Pluim <rpluim@gmail.com>

    Fix `pr-interface'
    
    `pr-interface' specifies `inline' for its menu items, which is not
    necessary, but it causes `widget-choice-value-create' to bug
    out.  (Bug#60501)
    
    * lisp/wid-edit.el (widget-choice-value-create): Allow the value to be
    a non-list.
    * test/lisp/wid-edit-tests.el (widget-test-handle-spurious-inline):
    Add test to ensure that unnecessary :inline is allowed.
---
 lisp/wid-edit.el            |  4 +++-
 test/lisp/wid-edit-tests.el | 16 ++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index 798db9f9dd..60bd2baa6f 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -2220,7 +2220,9 @@ But if NO-TRUNCATE is non-nil, include them."
             (if (widget-get current :inline)
                 (setq val value
                       fun :match-inline)
-              (setq val (car value)
+              (setq val (if (consp value)
+                            (car value)
+                          value)
                     fun :match))
           (setq val value
                 fun :match))
diff --git a/test/lisp/wid-edit-tests.el b/test/lisp/wid-edit-tests.el
index 3f5fcea0c3..b379c7c91a 100644
--- a/test/lisp/wid-edit-tests.el
+++ b/test/lisp/wid-edit-tests.el
@@ -267,6 +267,22 @@ return nil, even with a non-nil bubblep argument."
       (should child)
       (should (equal (widget-value widget) '(1 "One"))))))
 
+;; Bug#60501
+(ert-deftest widget-test-handle-spurious-inline ()
+  "Test the we can create a menu widget with an unnecessary :inline"
+  (with-temp-buffer
+    (widget-insert "Testing.\n\n")
+    (let* ((widget (widget-create 'menu-choice
+                                  :inline t
+                                  :value "*scratch*"
+                                  '(choice-item "*scratch*")))
+           (child (car (widget-get widget :children))))
+      (widget-insert "\n")
+      (use-local-map widget-keymap)
+      (widget-setup)
+      (should child)
+      (should (string-equal (widget-value widget) "*scratch*")))))
+
 (ert-deftest widget-test-option-can-handle-choice ()
   "Test that we can create a option widget with a choice correctly."
   (with-temp-buffer



reply via email to

[Prev in Thread] Current Thread [Next in Thread]