GNU bug report logs - #64283
29.0.91; js-mode's mark-defun does not work correctly when functions have a comment on top

Previous Next

Package: emacs;

Reported by: Daniel Martín <mardani29 <at> yahoo.es>

Date: Sun, 25 Jun 2023 13:07:01 UTC

Severity: normal

Found in version 29.0.91

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Yuan Fu <casouri <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Dmitry Gutov <dmitry <at> gutov.dev>, 64283 <at> debbugs.gnu.org, Daniel Martín <mardani29 <at> yahoo.es>
Subject: bug#64283: 29.0.91; js-mode's mark-defun does not work correctly when functions have a comment on top
Date: Wed, 28 Jun 2023 13:11:43 -0700

> On Jun 27, 2023, at 4:01 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
>> From: Yuan Fu <casouri <at> gmail.com>
>> Date: Mon, 26 Jun 2023 18:42:41 -0700
>> Cc: Eli Zaretskii <eliz <at> gnu.org>,
>> Dmitry Gutov <dmitry <at> gutov.dev>,
>> 64283 <at> debbugs.gnu.org
>> 
>>> 
>>> What I see is that, after 4489450f37deafb013b1f0fc00c89f0973fda14a,
>>> defun movement may be subtly broken if beginning-of-defun-function does
>>> not return non-nil when it found the beginning of a defun.  One of the
>>> affected modes is js-mode, but who knows if there are more out there.
>>> 
>>> We could either revert 4489450f37deafb013b1f0fc00c89f0973fda14a, because
>>> of the incompatibilities it may cause (Yuan, what is the bug it tries to
>>> fix?), or maybe adjust js-mode so that it follows the documentation of
>>> beginning-of-defun-function and returns non-nil when it found the
>>> beginning of a defun.  I've attached a patch that follows this second
>>> approach, with some unit tests.  It fixes the bug on my side.
>>> 
>>> <0001-Make-js-beginning-of-defun-return-non-nil-on-success.patch>
>> 
>> The original problem that I tried to solve is that sometimes end-of-defun-function was called when point isn’t at the beginning of a defun, contrary to what the documentation claims. 
>> 
>> I first find out about it when writing defun movement functions for tree-sitter, but if you revert the commit now tree-sitter defun functions wouldn’t break: they have change quite a bit since then and treesit-end-of-defun don’t need to be called at the beginning of the defun anymore.
> 
> Thanks.
> 
> Do you (or anyone else) see a problem with the alternative proposed by
> Daniel?  If not, I'd prefer not to revert at this stage, but instead
> to apply the simple fix Daniel suggested.

I don’t see any problem :-)

Yuan



This bug report was last modified 1 year and 324 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.