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#72995: 31.0.50; widget-move fails when widget starts at the second character in the buffer Date: Sat, 14 Sep 2024 12:47:13 +0200 Message-ID: <8734m2ikb2.fsf@gmx.net> References: <69D92478-019F-4703-95F9-E31DE3FE32C2@codefu.org> <87wmjtoutv.fsf@gmx.net> <865xqyisr9.fsf@gnu.org> Reply-To: Stephen Berman Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34926"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 72995-done@debbugs.gnu.org, dale@codefu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Sep 14 12:48:18 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 1spQK9-0008v3-FA for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 14 Sep 2024 12:48:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1spQJo-0006Ub-IY; Sat, 14 Sep 2024 06:47:56 -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 1spQJl-0006UE-CQ for bug-gnu-emacs@gnu.org; Sat, 14 Sep 2024 06:47:53 -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 1spQJk-0008SX-FE for bug-gnu-emacs@gnu.org; Sat, 14 Sep 2024 06:47:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=fG4rRqsdaFSc4pDVWVjj5L5utUjRcqMa52k2wg2pnVU=; b=tfnm9s1fwVQAd5TfqQA/SoQbh4lG5fxAwXlu2VVPCzyeQg5JTxMBMY4aJ1cQ9q+zi88mLfXmyy5rLiXTgSe27hbQl74kG08qL/mEPIZye9PMK/OhBMRtaoXkfCb40qNsAA/VmvaEiFBKk3DL1kJYpTUbi6xX4ZP7D8VaOG4Xen90+F+Fa5ZU8WzuEmwS53FxTJ9osgFVyQZdyNkrx7wzfsUMrNg6KOjUXRSxbKGWd/6RWqYRoa9ynFeGEyuJkox2/B8eNxXgjCTDGIZOFUyeP7e2lcSaXVzYfd7pN1pXVYcRu52CqLsnrIRa5qK/OvCnywHdk6m6DL+0tSktKJ1Kww==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1spQJu-0005Ex-LJ for bug-gnu-emacs@gnu.org; Sat, 14 Sep 2024 06:48:02 -0400 Resent-From: Stephen Berman Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Sat, 14 Sep 2024 10:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 72995 X-GNU-PR-Package: emacs Mail-Followup-To: 72995@debbugs.gnu.org, stephen.berman@gmx.net, dale@codefu.org Original-Received: via spool by 72995-done@debbugs.gnu.org id=D72995.172631086120099 (code D ref 72995); Sat, 14 Sep 2024 10:48:02 +0000 Original-Received: (at 72995-done) by debbugs.gnu.org; 14 Sep 2024 10:47:41 +0000 Original-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 Original-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 Original-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 In-Reply-To: <865xqyisr9.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 14 Sep 2024 10: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dIzer4q+6INOtzpBp1uyiyh90h81dr7rAKll2cvC 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:291726 Archived-At: 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