From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 03 00:37:58 2024 Received: (at submit) by debbugs.gnu.org; 3 Sep 2024 04:37:58 +0000 Received: from localhost ([127.0.0.1]:56225 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1slLIj-0003xu-Tb for submit@debbugs.gnu.org; Tue, 03 Sep 2024 00:37:58 -0400 Received: from lists.gnu.org ([209.51.188.17]:40502) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1slLIi-0003xn-BT for submit@debbugs.gnu.org; Tue, 03 Sep 2024 00:37:57 -0400 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 1slLHi-0002Wc-17 for bug-gnu-emacs@gnu.org; Tue, 03 Sep 2024 00:36:54 -0400 Received: from mail-qv1-xf31.google.com ([2607:f8b0:4864:20::f31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1slLHf-0001jc-QX for bug-gnu-emacs@gnu.org; Tue, 03 Sep 2024 00:36:53 -0400 Received: by mail-qv1-xf31.google.com with SMTP id 6a1803df08f44-6c35427935eso17107756d6.3 for ; Mon, 02 Sep 2024 21:36:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codefu-org.20230601.gappssmtp.com; s=20230601; t=1725338209; x=1725943009; darn=gnu.org; h=to:date:message-id:subject:mime-version:content-transfer-encoding :from:from:to:cc:subject:date:message-id:reply-to; bh=LYbWqHztkU6SCpA6+mIEleAOyES49lUYKyni0l0daDY=; b=su/F4gZCly0yYqqNFcVXXaqM9Q6EdB1Nd8t4QH+CiqZ9/fDD8Qcv8KKahuhPrfidzi OIVdSzAcU5Q15QpAAodb2cP8y9gz+BTjYOJjYlq9lN2DmnADQQ1E/1+0lno+/rb+aB7K jzZPtHNvD2xQCDg2mg22Qy0A9OGi9NcwatxznGM8dmoDvCl27oPnO4UJspghFpedRfII YoEy57LU8Zo1NqFuKcR9rDt1Ad/5ttfAL/P724KbDggd7F6HT3Z6ALl7FOlvNBkUk1Dg 60d3pEFNblwMMHosC2rfYm6zlfPXJDPpVfOuAkmJOg/YyDOE6TFyBCjCLa8q1C9ySesy syJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725338209; x=1725943009; h=to:date:message-id:subject:mime-version:content-transfer-encoding :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LYbWqHztkU6SCpA6+mIEleAOyES49lUYKyni0l0daDY=; b=SuTR4th3F7UBGgBYGq128QRxayNmaqAi32KQE6GCiRU06j3gMhEdEqY5IglseyP0f+ VBKioXMlQqf4JFIGODAUTGZD5KuoFD3sgTmBjBGrx3bb2iUCpzi1ceB0Dj/hpbrlboW4 Gvujow61TrLGj/fM+O1ixtVluRjwo3D6gLbiBP4j/ZdHOa7Z8+xocldRy3t4Jj/3uvSE 3qKaIu9ancmAYHqWkxeYUoIJugu8SeqMAMHO3xJ34zxUZnsBVFfNGHBKmGz7awfG2yL1 Yb2FZV5mV23hPbfhFklmhldGskP0ZNy7U8TJNK95yjJjypLNOFAqMpwgR6hTqHKGNgtJ 3iBQ== X-Gm-Message-State: AOJu0Yx/8/0hU/qYlOqySW17EzdX6u6216N41sSvSt/dTL7BlK30aMSz j5l75L/BFDP59X+PuieIsabmAFBxTbOHsVKzBusY+3OIDwV8K1pX6v7cLveu/4L+tfqO6aPV7Lo = X-Google-Smtp-Source: AGHT+IHfLO4pt6D96Ce8rkqfXqBd36fIEA7Jah76LAil9BtwCjzfYOhqsHpajdXEpWoPSIv4l6t7fA== X-Received: by 2002:a05:6214:468f:b0:6c3:6556:70a3 with SMTP id 6a1803df08f44-6c36556722amr59984036d6.14.1725338209047; Mon, 02 Sep 2024 21:36:49 -0700 (PDT) Received: from smtpclient.apple ([2604:5500:3160:3900:944e:c8e3:22e9:7c35]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6c350a4235bsm37653746d6.72.2024.09.02.21.36.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Sep 2024 21:36:48 -0700 (PDT) From: Dale Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\)) Subject: 31.0.50; widget-move fails when widget starts at the second character in the buffer Message-Id: <69D92478-019F-4703-95F9-E31DE3FE32C2@codefu.org> Date: Mon, 2 Sep 2024 23:36:35 -0500 To: bug-gnu-emacs@gnu.org X-Mailer: Apple Mail (2.3776.700.51) Received-SPF: none client-ip=2607:f8b0:4864:20::f31; envelope-from=dale@codefu.org; helo=mail-qv1-xf31.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) I think changes in commit 94dec95 (bug#69943) broke `widget-move' in a = customize buffer when trying to move to the first widget in a buffer = when that first widget starts at the second character in the buffer. = Here's some code to reproduce (tested in IELM): (let* ((first-wid (progn (widget-forward 1) (point)))) (print (format "First widget at %S" first-wid)) (cl-assert (and (numberp first-wid) (>=3D first-wid 1))) (with-current-buffer (customize-group 'editing) (narrow-to-region (1- first-wid) (point-max)) (goto-char (point-min)) (widget-forward 1) (print (format "Expected to be at %S, point=3D%S" first-wid = (point))))) On my Emacs I get: "First widget at 33" "Expected to be at 33, point=3D32" I think this happens because of this code near the end of `widget-move' = (which is called by `widget-forward'): (let ((new (widget-tabable-at))) (while (and (eq (widget-tabable-at) new) (not (bobp))) (backward-char))) (unless (bobp) (forward-char))) In my test case, as we enter the while loop point is at the start of the = first widget (AKA "new"). We are not yet at beginning of buffer, so it = moves point back one character. Now we are at beginning of buffer, but = that doesn't matter: the `eq' test fails first, and the loop ends. However, the `forward-char' never runs because we are indeed at = beginning of buffer now. I think this `forward-char' should have been = run to put point back on the start of the widget. Bug#70594 also recently modified code around here, but I don't *think* = that's relevant. In case you're wondering, this comes up because I use link-hint[1], = which narrows a customize buffer in exactly the way shown above. [1]: https://github.com/noctuid/link-hint.el Please let me know if I can provide any more information! Best regards, Dale In GNU Emacs 31.0.50 (build 1, aarch64-apple-darwin23.6.0, NS appkit-2487.70 Version 14.6.1 (Build 23G93)) of 2024-09-01 built on mymacRepository revision: 0f98515cec1298bc82c589b5f8565503900b806d Repository branch: master Windowing system distributor 'Apple', version 10.3.2487 System Description: macOS 14.6.1 Configured using: 'configure --without-x --with-xwidgets --with-json --with-tree-sitter = --without-imagemagick --with-xpm --with-jpeg --with-tiff --with-gif = --with-png --with-rsvg --with-webp --with-sqlite3 --with-cairo = --with-xml2 --with-gnutls --with-zlib --with-modules --with-threads = --with-native-compilation --with-ns --enable-ns-self-contained 'CFLAGS=3D = -D_DARWIN_UNLIMITED_SELECT=3D1 -DFD_SETSIZE=3D10240'' From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 03 07:14:00 2024 Received: (at 72995) by debbugs.gnu.org; 3 Sep 2024 11:14:01 +0000 Received: from localhost ([127.0.0.1]:59139 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1slRTs-0008P3-UO for submit@debbugs.gnu.org; Tue, 03 Sep 2024 07:14:00 -0400 Received: from mout.gmx.net ([212.227.17.22]:58553) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1slRSz-0008NX-MM for 72995@debbugs.gnu.org; Tue, 03 Sep 2024 07:13:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1725361901; x=1725966701; i=stephen.berman@gmx.net; bh=W31lnTqkfB+xIG6TBVhIva3ty86ahGO4wN8rSv5ZRVY=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=tmDpxsI7HroroenrvgQjjVVwZSWLC7ycIDjRhU88F9n0iFIRxEJjSw4fs1oC0oNe vn29gAYYWXr78GAAoc4rbquju1kKKj5QZMoFs4dJpUmqAjPbELHAOnb9reUOWhvwq QW2W6YwIRsikShwQTlmea4XCjmJ3llrSgreU5uczEf+7gfLMF1yUCSbgWsKLnK6sQ kji/hAZs7o89o2GEfBvxGrvMHkHaW9JKruKjCnTa+dZsLuQx7zXKvJbzQdRO6AxgZ iBtSxVM9silA9+BWWL1HlNyHk/OTM7TOvfNe6Id3UqWxnI7hnDqk7NQAH0S9yrB/q 3uePMfVNKMvamd25Ug== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from strobelfs ([88.130.50.98]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M5fIQ-1sihMN2FOU-007FCX; Tue, 03 Sep 2024 13:11:41 +0200 From: Stephen Berman To: Dale Subject: Re: bug#72995: 31.0.50; widget-move fails when widget starts at the second character in the buffer In-Reply-To: <69D92478-019F-4703-95F9-E31DE3FE32C2@codefu.org> (dale@codefu.org's message of "Mon, 2 Sep 2024 23:36:35 -0500") References: <69D92478-019F-4703-95F9-E31DE3FE32C2@codefu.org> Date: Tue, 03 Sep 2024 13:11:40 +0200 Message-ID: <87wmjtoutv.fsf@gmx.net> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:A8O8TSCeblbL7N4wyLRAnw2KDuNoBr7uL90noowJmmY8E+yTVcC wWoMbaywdL1EBknEdzz/WL9w8KlvMyKslSd5VVaLf39seiKg9g/X/c+4gkKA5cG1ARBFz+Z dRLOch9JPt86XPGHSBzBM7fYbWRfxKRVZjtPtfwRx6g8m5lejYShnOWmzrY6PUaVwoXRIx3 Cz5/t7hSImNoOGlpytsNg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:dB6znlhkHvo=;4U+nYv7JUxjTT/Qbtjqf2SE9f3P WL3foirvbmCFN1er11GoluF1GzRIUseeYjP8wUbkby/EwFZvudflhKb/8ZaaW2lMi4n/u+pUV thVLHejee5mhRORyiUDWaL0K8zeD6LoNDGxlQ6nXt/tj7XMhzTopGLXp0l+jr9jrEiwIq5xxw SgadtILjQpTLWT8ay66zAioJSIrc+n83foQ4ii9OErRPstneX1fMZJviqqQPB5zIMRHAEr7YZ tpeb9eQG7tPU4dRcnxD7MO6hTqjTdzAntSt9N7C6pSziL6GW+AKpsfPrwHpEqcYD84RkCTZb/ xqevqUXaXO9W7c8k8Yi1hXzfW1FA+7bilUEQYwXfAAs1rvYM3hcUHXUppGaGoh4KYlVg+MQx+ x8r9RHenNKq6etpHYtla6naEbBq2YeEDg1UuXpAxRW2EnUvM8kEMT2u9hrFd5+pJ4tF3JMfAr G7Rsj1tpLq54z2WhyHbNWhCkYLIbHei6cWjCWobbvrMBGYK14QJR5/Sq5Tsia7cQ90eQCtg+r qhzZRXtHP5qa4HYuuY/Uc+qZdo/f8QZjz/Fsmr53wCGDRXmc+ti0bQ/i5YwXc8InePX6Pk06L 3iQm8X3Hk7NyJ1bqqVFfK2eQlU5iSKE302gsQc1tIGR6nDahHuBPWyezWpuSsHbbbZte0t7db chWM8Rt1VjxwUEtFr+lawKUCe3RKITbht+S/iZqBNKpOywNPC3Mzz1B78pW0R+7tFQg4B2tDi N/lo0DumUAk1NSSEXZChwF19V4S6tm6Qiyvnuc3AAMwma5pHvr3zQ1gMgnvnXksHy01d9MUae Syy3O8rPnialcO1/HfUO5Ghg== X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 72995 Cc: 72995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On Mon, 2 Sep 2024 23:36:35 -0500 Dale wrote: > I think changes in commit 94dec95 (bug#69943) broke `widget-move' in a > customize buffer when trying to move to the first widget in a buffer when that > first widget starts at the second character in the buffer. Here's some code > to reproduce (tested in IELM): > > (let* ((first-wid (progn (widget-forward 1) (point)))) > (print (format "First widget at %S" first-wid)) > (cl-assert (and (numberp first-wid) (>= first-wid 1))) > (with-current-buffer (customize-group 'editing) > (narrow-to-region (1- first-wid) (point-max)) > (goto-char (point-min)) > (widget-forward 1) > (print (format "Expected to be at %S, point=%S" first-wid (point))))) > > On my Emacs I get: > > "First widget at 33" > > "Expected to be at 33, point=32" > > I think this happens because of this code near the end of `widget-move' (which > is called by `widget-forward'): > > (let ((new (widget-tabable-at))) > (while (and (eq (widget-tabable-at) new) (not (bobp))) > (backward-char))) > (unless (bobp) (forward-char))) > > In my test case, as we enter the while loop point is at the start of the first > widget (AKA "new"). We are not yet at beginning of buffer, so it moves point > back one character. Now we are at beginning of buffer, but that doesn't > matter: the `eq' test fails first, and the loop ends. > > However, the `forward-char' never runs because we are indeed at beginning of > buffer now. I think this `forward-char' should have been run to put point > back on the start of the widget. > > Bug#70594 also recently modified code around here, but I don't *think* that's > relevant. > > In case you're wondering, this comes up because I use link-hint[1], which > narrows a customize buffer in exactly the way shown above. > > [1]: https://github.com/noctuid/link-hint.el > > Please let me know if I can provide any more information! Thanks for the bug report, which indeed shows a use case that the change in commit 94dec95 fails to account for. The reason that commit conditionalized the call to forward-char was to ensure that tabbing puts point at the start of the widget, but your case shows using just (bobp) as the condition is insufficient (I used that because the existing unit test for widget-move has the first widget starting at BOB). I think the following patch closes this gap: diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index e7e6351fcab..7eec06297ce 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -1336,7 +1336,7 @@ widget-move (let ((new (widget-tabable-at))) (while (and (eq (widget-tabable-at) new) (not (bobp))) (backward-char))) - (unless (bobp) (forward-char))) + (unless (and (widget-tabable-at) (bobp)) (forward-char))) (unless suppress-echo (widget-echo-help (point))) (run-hooks 'widget-move-hook)) Can you confirm that this fixes your use case? If so, I think it should go into emacs-30, since that's where the faulty commit first appeared. I'll also add a unit test for this case. Steve Berman From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 03 08:36:56 2024 Received: (at 72995) by debbugs.gnu.org; 3 Sep 2024 12:36:57 +0000 Received: from localhost ([127.0.0.1]:59356 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1slSmG-0002OS-Jz for submit@debbugs.gnu.org; Tue, 03 Sep 2024 08:36:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38642) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1slSmE-0002OB-MV for 72995@debbugs.gnu.org; Tue, 03 Sep 2024 08:36:55 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1slSl7-0006gF-Pu; Tue, 03 Sep 2024 08:35:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=x1J5A/s4PUEHyzxEb0UQa5UDiFC4m+7+Xd2QU0cNJtM=; b=aKFe+2E/JW/B qDoGtLbaU8ahPM0wGjpMFDqg70aYRvKRMvNxHyTsM0aMDpDjPM2mZw21G+CKBB8AQVdPaLSvxe52k 9asvi3t3ca5tV9bxeaTWPntk5C0MHDSgiHWgc/+Iw0ZzVyJf6kDOa0RsOCJNsM484NhezgfM1rEEX rC1Rko262Go6Gsc6uNS5X7iGypvXAKJA28HkvOvdND9VCPAru0v76fe/qPVijlYQRBJ/H1UlMrb4H qmP7UD2iH7CfrjgJq4Jf57P6MVS4cd5eA1eeeXXXBJcFhb/pLLBFyTXfNjm2rvQz64vFk/8dPghcU qB5mzB4RG3v2SG03yA057w==; Date: Tue, 03 Sep 2024 15:35:29 +0300 Message-Id: <86o7547w4u.fsf@gnu.org> From: Eli Zaretskii To: Dale , Stephen Berman In-Reply-To: <69D92478-019F-4703-95F9-E31DE3FE32C2@codefu.org> (message from Dale on Mon, 2 Sep 2024 23:36:35 -0500) Subject: Re: bug#72995: 31.0.50; widget-move fails when widget starts at the second character in the buffer References: <69D92478-019F-4703-95F9-E31DE3FE32C2@codefu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 72995 Cc: 72995@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Dale > Date: Mon, 2 Sep 2024 23:36:35 -0500 > > I think changes in commit 94dec95 (bug#69943) broke `widget-move' in a customize buffer when trying to move to the first widget in a buffer when that first widget starts at the second character in the buffer. Here's some code to reproduce (tested in IELM): > > (let* ((first-wid (progn (widget-forward 1) (point)))) > (print (format "First widget at %S" first-wid)) > (cl-assert (and (numberp first-wid) (>= first-wid 1))) > (with-current-buffer (customize-group 'editing) > (narrow-to-region (1- first-wid) (point-max)) > (goto-char (point-min)) > (widget-forward 1) > (print (format "Expected to be at %S, point=%S" first-wid (point))))) > > On my Emacs I get: > > "First widget at 33" > > "Expected to be at 33, point=32" > > I think this happens because of this code near the end of `widget-move' (which is called by `widget-forward'): > > (let ((new (widget-tabable-at))) > (while (and (eq (widget-tabable-at) new) (not (bobp))) > (backward-char))) > (unless (bobp) (forward-char))) > > In my test case, as we enter the while loop point is at the start of the first widget (AKA "new"). We are not yet at beginning of buffer, so it moves point back one character. Now we are at beginning of buffer, but that doesn't matter: the `eq' test fails first, and the loop ends. > > However, the `forward-char' never runs because we are indeed at beginning of buffer now. I think this `forward-char' should have been run to put point back on the start of the widget. > > Bug#70594 also recently modified code around here, but I don't *think* that's relevant. > > In case you're wondering, this comes up because I use link-hint[1], which narrows a customize buffer in exactly the way shown above. > > [1]: https://github.com/noctuid/link-hint.el > > Please let me know if I can provide any more information! > > Best regards, > Dale Stephen, could you please look into this? From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 14 03:45:03 2024 Received: (at 72995) by debbugs.gnu.org; 14 Sep 2024 07:45:03 +0000 Received: from localhost ([127.0.0.1]:44693 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1spNSo-0003HB-Lz for submit@debbugs.gnu.org; Sat, 14 Sep 2024 03:45:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48316) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1spNSm-0003GO-UT for 72995@debbugs.gnu.org; Sat, 14 Sep 2024 03:45:01 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1spNSW-0001j6-GS; Sat, 14 Sep 2024 03:44:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=H5qTNxQ7Xa/PoVQ1CaGLKZZI8/zKaTOJhvSFRHjqJn8=; b=O0J02yklrJx0 jQaf2xNORM7bU4JH+9akkgBz5bWk0FV/nvyZbrdpF+lUx3HL2wYHN7ZIImSOQ6/ooIpwxgUSccXlf zZM1NtbWpzrQFY56VUSaoZxNu9o44hZE7yLWrm5RNQXNwYncbZdBZyN2oxX/w8GB14gf69ycaOIoW 9R2N+8M9cNTNJ/V7d4jBtKZNnKpwsi44j12LKD905uu39Fyu+AwnBRKQ+Znd6SUd/GcfQn1yf7ysF uKtz8tItliawwDa2jxaxH1kKXo03P0gFuUOj6E8IpSXOYSOojctA+ZaP8LGS8YBjJuN2HOFEpg3cd Ee0yB8M7mmwaoVGiHvIJqQ==; Date: Sat, 14 Sep 2024 10:44:42 +0300 Message-Id: <865xqyisr9.fsf@gnu.org> From: Eli Zaretskii To: Stephen Berman In-Reply-To: <87wmjtoutv.fsf@gmx.net> (bug-gnu-emacs@gnu.org) Subject: Re: bug#72995: 31.0.50; widget-move fails when widget starts at the second character in the buffer References: <69D92478-019F-4703-95F9-E31DE3FE32C2@codefu.org> <87wmjtoutv.fsf@gmx.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 72995 Cc: 72995@debbugs.gnu.org, dale@codefu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Cc: 72995@debbugs.gnu.org > Date: Tue, 03 Sep 2024 13:11:40 +0200 > From: Stephen Berman via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > On Mon, 2 Sep 2024 23:36:35 -0500 Dale wrote: > > > I think changes in commit 94dec95 (bug#69943) broke `widget-move' in a > > customize buffer when trying to move to the first widget in a buffer when that > > first widget starts at the second character in the buffer. Here's some code > > to reproduce (tested in IELM): > > > > (let* ((first-wid (progn (widget-forward 1) (point)))) > > (print (format "First widget at %S" first-wid)) > > (cl-assert (and (numberp first-wid) (>= first-wid 1))) > > (with-current-buffer (customize-group 'editing) > > (narrow-to-region (1- first-wid) (point-max)) > > (goto-char (point-min)) > > (widget-forward 1) > > (print (format "Expected to be at %S, point=%S" first-wid (point))))) > > > > On my Emacs I get: > > > > "First widget at 33" > > > > "Expected to be at 33, point=32" > > > > I think this happens because of this code near the end of `widget-move' (which > > is called by `widget-forward'): > > > > (let ((new (widget-tabable-at))) > > (while (and (eq (widget-tabable-at) new) (not (bobp))) > > (backward-char))) > > (unless (bobp) (forward-char))) > > > > In my test case, as we enter the while loop point is at the start of the first > > widget (AKA "new"). We are not yet at beginning of buffer, so it moves point > > back one character. Now we are at beginning of buffer, but that doesn't > > matter: the `eq' test fails first, and the loop ends. > > > > However, the `forward-char' never runs because we are indeed at beginning of > > buffer now. I think this `forward-char' should have been run to put point > > back on the start of the widget. > > > > Bug#70594 also recently modified code around here, but I don't *think* that's > > relevant. > > > > In case you're wondering, this comes up because I use link-hint[1], which > > narrows a customize buffer in exactly the way shown above. > > > > [1]: https://github.com/noctuid/link-hint.el > > > > Please let me know if I can provide any more information! > > Thanks for the bug report, which indeed shows a use case that the change > in commit 94dec95 fails to account for. The reason that commit > conditionalized the call to forward-char was to ensure that tabbing puts > point at the start of the widget, but your case shows using just (bobp) > as the condition is insufficient (I used that because the existing unit > test for widget-move has the first widget starting at BOB). I think the > following patch closes this gap: > > diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el > index e7e6351fcab..7eec06297ce 100644 > --- a/lisp/wid-edit.el > +++ b/lisp/wid-edit.el > @@ -1336,7 +1336,7 @@ widget-move > (let ((new (widget-tabable-at))) > (while (and (eq (widget-tabable-at) new) (not (bobp))) > (backward-char))) > - (unless (bobp) (forward-char))) > + (unless (and (widget-tabable-at) (bobp)) (forward-char))) > (unless suppress-echo > (widget-echo-help (point))) > (run-hooks 'widget-move-hook)) > > Can you confirm that this fixes your use case? If so, I think it should > go into emacs-30, since that's where the faulty commit first appeared. > I'll also add a unit test for this case. Steve, do you think this should be installed on the emacs-30 branch now, even though we had no response from Dale? If so, please install, and thanks. From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 14 06:47:41 2024 Received: (at 72995-done) by debbugs.gnu.org; 14 Sep 2024 10:47:41 +0000 Received: from localhost ([127.0.0.1]:44914 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1spQJY-0005E6-N9 for submit@debbugs.gnu.org; Sat, 14 Sep 2024 06:47:41 -0400 Received: from mout.gmx.net ([212.227.17.20]:54667) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1spQJV-0005Dr-1S for 72995-done@debbugs.gnu.org; Sat, 14 Sep 2024 06:47:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1726310835; x=1726915635; i=stephen.berman@gmx.net; bh=fG4rRqsdaFSc4pDVWVjj5L5utUjRcqMa52k2wg2pnVU=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=jhuHcjluSZLxnosWDJsS5GAz1PtvOmgZ2mBmQLVqstY/XA2Nlml9+LP1J41WE3cg jTlM2OILJpEcs+imYfMbUVxHmo3gvxJkG8onf4rrnNAsYDN1rWopVzoMXH84T4szr J28OrXeYtuE3m2JryMYZSQB38eXFIZn3nmmNBFBbQp5V/w8NnHlXfbx0ZS24B7wx+ MxddwdIb1nYfT2zyrsDe14DsA/pVro0/HTmwJCuurLxPDhzReuSQMEUSFbBpxQNw2 Dym9z+Iyalxt55zCyItczlsm5SbauM4BLDwh0W8a2j05sZgcFOkIDeQneXAy6zBOL rggWRNABIaybgA7Y9Q== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from strobelfssd ([88.130.50.178]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M6Daq-1sw20o41Pc-00EmKd; Sat, 14 Sep 2024 12:47:15 +0200 From: Stephen Berman To: Eli Zaretskii Subject: Re: bug#72995: 31.0.50; widget-move fails when widget starts at the second character in the buffer In-Reply-To: <865xqyisr9.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 14 Sep 2024 10:44:42 +0300") References: <69D92478-019F-4703-95F9-E31DE3FE32C2@codefu.org> <87wmjtoutv.fsf@gmx.net> <865xqyisr9.fsf@gnu.org> Date: Sat, 14 Sep 2024 12:47:13 +0200 Message-ID: <8734m2ikb2.fsf@gmx.net> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:UxB8RtVcalogEUoq/8xjsKvV4aG2xVeMMnJ8VGAmL6bWdgP9c0k sDqvbvgPVtNozOSK8tG8DI600WF2OYHEmB4BXbZU/mNqKryF/v7pn6HHTdxg5dxImUm5uEc ZHY4tBsa9QvqLqyT9krDfHVH78AQP3Uv9VmWrx8zDsC48igpPgU4CI3EQFkaEc2yv9Ck27I CKWUoP1DKkPN+bp9Dr4Ew== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:FtsnMuyV2nU=;YdGViF9o1YzMGFozosWRHskkLpW bCbT7NSJX1LcrCmJqUXCjA46mkBIps6L6dce9cYGOvyuGofFFWwW37sSmCJgpNDWaMc4StTOX l8puC0ut/ETbjVjkShDKvZPmo3KPFUgB7WSqauP4CoJTT+KJ+lJ0bRs/Qdhk+prAM0KUqE+7/ geXGur13z59JOaqvDth/V9ydmFtxNUR0WA+9F9YRhcS1vqzKLb2cOZjhLBvVUEBo572X/MGgD ZxVVWpwkGxcT7N09JcIHHWH8kqiPnqbjYyqWmbTPNkP+EKHpHBXh0X/qtWeJaN3t4Hcw7cC+z PPhqIHhUc4JEZG1khTiTzNZWF7w/l67P3jAghliHgKoNsgluu44rL/kNCGvdwLR720NH4J+lN r6LhHVTc/+dyr3Mk7eCPwM65nB/oNEmOnZ01J8sX+/nM2CJQTyeBNxx6r40u/n2DfqunF+q1c 4sjMYxvLyOXwXKVnlKKrn0CqUWTL6T+CG+qLNhOcNcjgQzdXVV04tmmqnm6pe/tE1ObqWgEaO fU6bjrkLYAubc5F7GY5R4NNDSJKelDNj6F2Ybhyk/ey20h5sUQmdUuVNo3d60bhEC7bUey+Q4 0pxYhny3HUo+NOyweoJjxr+1V8Ukp5cjbLGuUXO0kREsl3ULW6q9aJvrL9m7WfsQaMeEWMBqC xEr6v3/AqE99h9HyF4G/3IBr+jl6Emrzoy9FJxqIK4cn2p0Es5LQqqjQxsE6QnInvRo8dQvGD v0hmTMrNlfXsG9MQKjNbHGBH12AYr+S4dIzer4q+6INOtzpBp1uyiyh90h81dr7rAKll2cvCK uCBmRCXa/Jik7PY8YAS4dicQ== Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 72995-done Cc: 72995-done@debbugs.gnu.org, dale@codefu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On Sat, 14 Sep 2024 10:44:42 +0300 Eli Zaretskii wrote: >> Cc: 72995@debbugs.gnu.org >> Date: Tue, 03 Sep 2024 13:11:40 +0200 >> From: Stephen Berman via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >> >> On Mon, 2 Sep 2024 23:36:35 -0500 Dale wrote: >> >> > I think changes in commit 94dec95 (bug#69943) broke `widget-move' in = a >> > customize buffer when trying to move to the first widget in a buffer = when that >> > first widget starts at the second character in the buffer. Here's so= me code >> > to reproduce (tested in IELM): >> > >> > (let* ((first-wid (progn (widget-forward 1) (point)))) >> > (print (format "First widget at %S" first-wid)) >> > (cl-assert (and (numberp first-wid) (>=3D first-wid 1))) >> > (with-current-buffer (customize-group 'editing) >> > (narrow-to-region (1- first-wid) (point-max)) >> > (goto-char (point-min)) >> > (widget-forward 1) >> > (print (format "Expected to be at %S, point=3D%S" first-wid (poin= t))))) >> > >> > On my Emacs I get: >> > >> > "First widget at 33" >> > >> > "Expected to be at 33, point=3D32" >> > >> > I think this happens because of this code near the end of `widget-mov= e' (which >> > is called by `widget-forward'): >> > >> > (let ((new (widget-tabable-at))) >> > (while (and (eq (widget-tabable-at) new) (not (bobp))) >> > (backward-char))) >> > (unless (bobp) (forward-char))) >> > >> > In my test case, as we enter the while loop point is at the start of = the first >> > widget (AKA "new"). We are not yet at beginning of buffer, so it mov= es point >> > back one character. Now we are at beginning of buffer, but that does= n't >> > matter: the `eq' test fails first, and the loop ends. >> > >> > However, the `forward-char' never runs because we are indeed at begin= ning of >> > buffer now. I think this `forward-char' should have been run to put = point >> > back on the start of the widget. >> > >> > Bug#70594 also recently modified code around here, but I don't *think= * that's >> > relevant. >> > >> > In case you're wondering, this comes up because I use link-hint[1], w= hich >> > narrows a customize buffer in exactly the way shown above. >> > >> > [1]: https://github.com/noctuid/link-hint.el >> > >> > Please let me know if I can provide any more information! >> >> Thanks for the bug report, which indeed shows a use case that the chang= e >> in commit 94dec95 fails to account for. The reason that commit >> conditionalized the call to forward-char was to ensure that tabbing put= s >> point at the start of the widget, but your case shows using just (bobp) >> as the condition is insufficient (I used that because the existing unit >> test for widget-move has the first widget starting at BOB). I think th= e >> following patch closes this gap: >> >> diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el >> index e7e6351fcab..7eec06297ce 100644 >> --- a/lisp/wid-edit.el >> +++ b/lisp/wid-edit.el >> @@ -1336,7 +1336,7 @@ widget-move >> (let ((new (widget-tabable-at))) >> (while (and (eq (widget-tabable-at) new) (not (bobp))) >> (backward-char))) >> - (unless (bobp) (forward-char))) >> + (unless (and (widget-tabable-at) (bobp)) (forward-char))) >> (unless suppress-echo >> (widget-echo-help (point))) >> (run-hooks 'widget-move-hook)) >> >> Can you confirm that this fixes your use case? If so, I think it shoul= d >> go into emacs-30, since that's where the faulty commit first appeared. >> I'll also add a unit test for this case. > > Steve, do you think this should be installed on the emacs-30 branch > now, even though we had no response from Dale? Yes, and I intended to ask today if I should do that, but you beat me to the punch :). The reason I wanted confirmation is that I cannot reproduce the problem via ielm as in the OP, so perhaps there's more involved. But with `M-x customize-group RET editing' and evaluating the sexp in the Customize buffer, the problem is apparent, and is reproducible without Customize but just by using simple widgets (that's what the test I added does). So it is definitely a regression and should be fixed in emacs-30. > If so, please > install, and thanks. Done in commit d509a356997 to emacs-30 and closing the bug. (If there's something I missed having to do with ielm, we can reopen the bug.) Steve Berman From unknown Mon Aug 11 12:54:53 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 12 Oct 2024 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator