From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eshel Yaron via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#72759: 31.0.50; Emacs hangs with open-paren-in-column-0-is-defun-start set to nil Date: Thu, 22 Aug 2024 17:49:22 +0200 Message-ID: References: <868qwou8pv.fsf@gnu.org> <861q2gu56u.fsf@gnu.org> <86msl4slwv.fsf@gnu.org> Reply-To: Eshel Yaron Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25109"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 72759@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 22 17:50:47 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 1shA5H-0006JE-L0 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 22 Aug 2024 17:50:47 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1shA4y-00041s-I6; Thu, 22 Aug 2024 11:50:29 -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 1shA4u-00040o-F4 for bug-gnu-emacs@gnu.org; Thu, 22 Aug 2024 11:50:24 -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 1shA4l-0002Q8-VA for bug-gnu-emacs@gnu.org; Thu, 22 Aug 2024 11:50:23 -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=ui/wS4NheDZ5OxQ25xQyn1SnFuimShCneASwj9ywwzM=; b=hN+TSH4czCCORAse6dmOG2dFfxJj+QpPKwkb4jQfU1yV1FGdPCJsdJMkk6BYDVldC8cgpRBv/6wsueodzFARNvuS3j+IsuI29QBHPHcJHi12earryIxj1HPia6J84tkHd67kYzqc7ikEf7cXYGKqk5LanboTZ01K3yPTLZVCOgPbxTbvVG0KfgjUrdqvfCRHanqzc3ASJRf1kpLunF7spF7WwvvSXZDvJBx1TJGBRNbGEa2MIfZ6f1TmXgIeTqxsx64MKws2BkpzU5Ux5HitBUMlTPlixsRiBESvPvQm2AXQH9CzRe/bMuvImJMEv51Ay3LOOiMcArdjkbp9mn225g==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1shA5V-0006eg-Mm for bug-gnu-emacs@gnu.org; Thu, 22 Aug 2024 11:51:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eshel Yaron Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 22 Aug 2024 15:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72759 X-GNU-PR-Package: emacs Original-Received: via spool by 72759-submit@debbugs.gnu.org id=B72759.172434181525510 (code B ref 72759); Thu, 22 Aug 2024 15:51:01 +0000 Original-Received: (at 72759) by debbugs.gnu.org; 22 Aug 2024 15:50:15 +0000 Original-Received: from localhost ([127.0.0.1]:38251 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1shA4l-0006dN-9U for submit@debbugs.gnu.org; Thu, 22 Aug 2024 11:50:15 -0400 Original-Received: from mail.eshelyaron.com ([107.175.124.16]:53210 helo=eshelyaron.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1shA4h-0006dD-GD for 72759@debbugs.gnu.org; Thu, 22 Aug 2024 11:50:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1724341765; bh=HVzdqMKVxKAUbRpxgoX8tq2xRpCUEaD7fQ5cK8DrV1o=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Tng42Cxq46xKcCg9AA/L8bmwPebczP6PjHXg9VvCLG4zDhrBDC2mzB7moho2w5zV3 Dl2WLOcJSUl6hClxOtaYxm/LSg2Yi+/oESou47U20+5nJpBAJJLL4WPtUiPRgLu+7+ Tj712yWR8QEo2z51N0BPpEm/48zfks6GNv+M1sN6d+47z7f6dMmigI1O0KABq/+/Sa v5ril5jsal9QulHV7vuVeEmqu+JQsRr8QsnG9LQH79q7suixaSAJbszJanG5VfP4oA bjsQhYe6EcCOQTkviQp5YWzvUpF06mCp56/5KbLKx6u4N481NbC2SxWgOSUnWW5smn yQ38u5+xry4Bw== In-Reply-To: <86msl4slwv.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 22 Aug 2024 16:54:24 +0300") 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:290544 Archived-At: Hi, Eli Zaretskii writes: >> From: Eshel Yaron >> Cc: 72759@debbugs.gnu.org >> Date: Thu, 22 Aug 2024 14:37:01 +0200 >> >> Eli Zaretskii writes: >> >> > Would it make sense to have checkdoc-next-docstring bind >> > open-paren-in-column-0-is-defun-start to a non-nil value? >> >> Not entirely: the difference in behavior of beginning-of-defun is >> unexpected, and may prove problematic in other cases as well, so it >> would be best to fix the root cause IMO. Namely, in >> beginning-of-defun-raw, the fallback cond clause fails to move forward >> over an sexp that does starts after the beginning of the line. > > How do you propose to fix the root cause, when Emacs fails to > correctly identify the beginning of a defun? Suppose we'd want to fix > the condition of this loop: > >>> (while (and (not (setq found (checkdoc--next-docstring))) >>> (beginning-of-defun -1))) > > so it doesn't infloop -- how would you go about that, when > beginning-of-defun doesn't move and you are not at BOB? After taking another look, ISTM that the problem is that checkdoc assumes that beginning-of-defun either advances point or returns nil, but since beginning-of-defun unconditionally moves to the beginning of the line, it can in fact find a defun ahead of point (and thus return non-nil) but then move back to the beginning of the line, so point is unchanged. So the assumption in checkdoc doesn't always hold when open-paren-in-column-0-is-defun-start is nil. This assumption should still hold, however, for beginning-of-defun-raw, which doesn't go back to the beginning of the line. This suggests the following change, which indeed seems to fix the hang: diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el index 949ca6b74ad..65226d8ee44 100644 --- a/lisp/emacs-lisp/checkdoc.el +++ b/lisp/emacs-lisp/checkdoc.el @@ -981,7 +981,7 @@ checkdoc-next-docstring Return nil if there are no more doc strings." (let (found) (while (and (not (setq found (checkdoc--next-docstring))) - (beginning-of-defun -1))) + (beginning-of-defun-raw -1))) found)) (defun checkdoc--next-docstring ()