From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Berman via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#70594: 30.0.50; Error when tabbing with only one active widget Date: Fri, 26 Apr 2024 14:43:42 +0200 Message-ID: <87r0esl2f5.fsf@gmx.net> Reply-To: Stephen Berman 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="27603"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 70594@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 26 14:45:22 2024 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 1s0Kx6-0006ym-CG for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 26 Apr 2024 14:45:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s0Kwk-0002Go-6U; Fri, 26 Apr 2024 08:44:58 -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 1s0Kwj-0002GK-3n for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2024 08:44:57 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s0Kwi-0002G1-Qx for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2024 08:44:56 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s0Kx0-0002FH-8S for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2024 08:45:14 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stephen Berman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 26 Apr 2024 12:45:09 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 70594 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.17141354778192 (code B ref -1); Fri, 26 Apr 2024 12:45:09 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Apr 2024 12:44:37 +0000 Original-Received: from localhost ([127.0.0.1]:34287 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s0KwC-00026U-Sg for submit@debbugs.gnu.org; Fri, 26 Apr 2024 08:44:34 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:40106) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s0Kw3-00023T-Vz for submit@debbugs.gnu.org; Fri, 26 Apr 2024 08:44:21 -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 1s0Kvc-00026i-LH for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2024 08:43:49 -0400 Original-Received: from mout.gmx.net ([212.227.17.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s0Kva-00019U-Hq for bug-gnu-emacs@gnu.org; Fri, 26 Apr 2024 08:43:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1714135423; x=1714740223; i=stephen.berman@gmx.net; bh=BEdgv7fx58enB9EUtCxHBkiZrWYP6sCrKsmmfTS7+a0=; h=X-UI-Sender-Class:From:To:Subject:Date:Message-ID:MIME-Version: Content-Type:cc:content-transfer-encoding:content-type:date:from: message-id:mime-version:reply-to:subject:to; b=Tmp9Tp0Rp4NJ9N1QGW1gar2XidSvml4jLUEjiMGbultJHdFr8kak0DryeE2yQQVf 0UGCcN4ov26w6eBt5C2u0e5AFgRt8kTdCFPYQjROMquBbVit/YgfSh7V/Fk1EI8aF F+Za1pRMDJsWksryEXn9i/Ro0jxEa50PULFMF8oBWau1C0rM7HEUz+r9yyLxA5m8T mCWq3X0mx74usuEqi2NhIBu2KsoyLk9tedyA1cXGNTz42h6hW6LwMlZztCs/nRl+4 Ga1VBOOY4hyE/Ij970Dp3s205zNVJJzv2Dndsa5f1bVcx020knkGWXRjRsf+Oe8BI el6UTPfy3O5l8ewY8Q== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from strobelfs ([94.134.94.5]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MUGeB-1s8LW80aSB-00RJdN for ; Fri, 26 Apr 2024 14:43:43 +0200 X-Provags-ID: V03:K1:FiuTLSCd20owfLxmbq4i65DJ/ASTbEc4MaOZSuEhIv8r2Ief3/D Eo2WRd8ot47HDxwZax4fsFcF8/EexoihdXD0DgvtwAF+FlhZqO+jpQPMQWh01aqUnSX0H5K Az2/oW9noUXqXMuhI/dYXeG4oifYqi6OGy04EDCvW9auA4rEuT3Pt2OosCFT9MdTVDoRtQJ mI9EFDvOx0vrmgQVcM4cQ== UI-OutboundReport: notjunk:1;M01:P0:xJJMHECmHe0=;XDNQmkXkpL/iEGTBDFy3S9pZkg5 4JooTvo+zt4qUrrMfvRdgNvioZmi6EgBjOnaeM/iOX1czjUpqz9RZuekLeTsdSA9k6HVqA0Y8 2g9WnE8iLZgAyz4evl0GWyK/9M5o5BBq2t0Vm8K8Qgz+Tgqjsse6l2HvoLzQFfTzLTitCg9q8 6eH/tCkCr+fl7Baf0IkOEl8EKfk2YvdqH9oB6OqDJeWpbi6bweN27cEdUCUZY3TDVuYe8QBHx EOaAk8290J05f0u370uAELRN2IG6C3dnOJme+DH917woPPBMAKo7CAQPYRQZ0b2GzVrI0uPk9 OjFZ8Cs5eegKB4Oh+XnZ+nG1/Tt2QWJB+AWCGHdsnYeI4RE3Hw1Jmmuo8AessUP51qywpzzcW WXkop+oNrH0VqW8FVkw40BDJvjpwUUTUDjeIoTJgBjbQSv9rvyT+ZB2A/LJunaoLPmgs8BBgT +h4XRLCj8+71w6Uslccp8c1wU9qJqkEjJ8amrfImMjgwRt3JoQ1yFXYGh9tYebB2oqcMzQIFm 3F3ZHU6tpAqBJX4ftiPNtMCKyeTVWng4r4SmmWkHX1+cFpOvl35lDmRvZBB3w18Ba7R2arI6R kfxSXQaxSNd0Hu3YCDcafPVCGazRx/m0fjjrOk5mNvfMwr4z2uMsMdm3iaQJjcAGuXqaK11i0 +PM/eTDP+D2OO1TWRhifzw813syceOWuTYf5TKSotnpPAGOzRegp5BTChw4omivvD/z+c9ux7 3Mlt+5DfSTFU/H1CO8gPFlX2dg6xCc2ttvE+d+WbKC9WM4iUFabYBg/+WOcwO4WaPkynkkxs Received-SPF: pass client-ip=212.227.17.21; 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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:283988 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Commit 91333dacfa1, which adds the feature of optionally skipping over inactive widgets when tabbing (bug#70413), fails to handle buffers that contain only one active widget; in that case, pressing TAB or S-TAB raises the error "No buttons or fields found". To reproduce: 0. emacs -Q 1. Load the attached file widget-test.el and then type `M-x my-widget-test'. 2. In the buffer "*My Widget Test*" repeatedly press TAB and S-TAB and observe that point moves successively between the active radio buttons labelled "One" and "Two" and the active push button "Submit", but skips the inactive push button "Reset", since the user option widget-skip-inactive is enabled. 3. Now press (via RET or mouse-click) the "Submit" button, which makes the radio buttons and the "Submit" button inactive and the "Reset" button active. 4. Pressing TAB once moves point to the "Reset" button, then pressing TAB again moves point to BOB and raises the error "No buttons or fields found". Likewise, pressing S-TAB once moves point to "Reset", then pressing S-TAB again moves to EOB and raises the same error. The attached patched fixes this bug. In addition, when only one widget is active and point is on it, since pressing TAB or S-TAB does not move point, the informational message "Only one tabable widget" is displayed. The original code in widget-move contained separate loops to handle forward and backward movement and this involved some code duplication. The changes to this code to fix the bug would have required further duplication, so I took the opportunity to parameterize the directionality, allowing handling both directions in a single loop. This shortens the code and IMO makes the similarities and differences in the handling easier to see. Configured using: 'configure '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 LCMS2 LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=widget-test.el Content-Transfer-Encoding: quoted-printable (custom-set-variables '(widget-skip-inactive t)) (defun my-widget-test () (interactive) (switch-to-buffer "*My Widget Test*") (kill-all-local-variables) (let ((inhibit-read-only t)) (erase-buffer)) (remove-overlays) (setq my-radio-widget (widget-create 'radio-button-choice '(item "One") '(item "Two"))) (setq my-submit-button (widget-create 'push-button :notify (lambda (widget &rest _) (widget-apply my-radio-widget :deactivate) (widget-apply my-reset-button :activate) (widget-apply widget :deactivate)) "Submit")) (setq my-reset-button (widget-create 'push-button :notify (lambda (widget &rest _) (when (widget-value my-radio-widget) (widget-value-set my-radio-widget nil)) (widget-apply my-radio-widget :activate) (widget-apply my-submit-button :activate) (widget-apply widget :deactivate)) "Reset")) (widget-apply my-reset-button :deactivate) (use-local-map widget-keymap) (widget-setup)) --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Description: widget-move patch diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index dc481d4d0a5..407309c3429 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -1263,42 +1263,40 @@ widget-move ARG may be negative to move backward. When the second optional argument is non-nil, nothing is shown in the echo area." - (let ((wrapped 0) - (number arg) - (old (widget-tabable-at))) - ;; Forward. - (while (> arg 0) - (cond ((eobp) - (goto-char (point-min)) - (setq wrapped (1+ wrapped))) - (widget-use-overlay-change - (goto-char (next-overlay-change (point)))) - (t - (forward-char 1))) - (and (= wrapped 2) - (eq arg number) - (error "No buttons or fields found")) - (let ((new (widget-tabable-at))) - (when new - (unless (eq new old) - (setq arg (1- arg)) - (setq old new))))) - ;; Backward. - (while (< arg 0) - (cond ((bobp) - (goto-char (point-max)) - (setq wrapped (1+ wrapped))) - (widget-use-overlay-change - (goto-char (previous-overlay-change (point)))) - (t - (backward-char 1))) - (and (= wrapped 2) - (eq arg number) - (error "No buttons or fields found")) - (let ((new (widget-tabable-at))) - (when new - (unless (eq new old) - (setq arg (1+ arg)))))) + (let* ((wrapped 0) + (number arg) + (fwd (> arg 0)) ; widget-forward is caller. + (bwd (< arg 0)) ; widget-backward is caller. + (old (widget-tabable-at)) + (tabable (if old 1 0)) + pos) + (catch 'one + (while (> (abs arg) 0) + (cond ((or (and fwd (eobp)) (and bwd (bobp))) + (goto-char (cond (fwd (point-min)) + (bwd (point-max)))) + (setq wrapped (1+ wrapped))) + (widget-use-overlay-change + (goto-char (cond (fwd (next-overlay-change (point))) + (bwd (previous-overlay-change (point)))))) + (t + (cond (fwd (forward-char 1)) + (bwd (backward-char 1))))) + (and (= wrapped 2) + (eq arg number) + (if (= tabable 1) + (progn + (goto-char pos) + (throw 'one (message "Only one tabable widget"))) + (error "No buttons or fields found"))) + (let ((new (widget-tabable-at))) + (when new + (if (eq new old) + (setq pos (point)) + (cl-incf tabable) + (setq arg (cond (fwd (1- arg)) + (bwd (1+ arg)))) + (setq old new)))))) (let ((new (widget-tabable-at))) (while (and (eq (widget-tabable-at) new) (not (bobp))) (backward-char))) --=-=-=--