From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Brian Leung Newsgroups: gmane.emacs.bugs Subject: bug#41649: 27.0.91; beginning-of-defun doesn't work inside React markup in js-jsx-mode Date: Tue, 2 Jun 2020 10:27:38 -0700 Message-ID: References: <20200602171221.19097.qmail@mail.muc.de> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000080137005a71d3cc9" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="111977"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 41649@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jun 02 19:29:09 2020 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 1jgAir-000SzT-95 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 02 Jun 2020 19:29:09 +0200 Original-Received: from localhost ([::1]:55544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgAiq-0002u6-Br for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 02 Jun 2020 13:29:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43702) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgAik-0002tz-Li for bug-gnu-emacs@gnu.org; Tue, 02 Jun 2020 13:29:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57529) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jgAik-0004zD-CG for bug-gnu-emacs@gnu.org; Tue, 02 Jun 2020 13:29:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jgAik-00031x-9G for bug-gnu-emacs@gnu.org; Tue, 02 Jun 2020 13:29:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Brian Leung Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 02 Jun 2020 17:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41649 X-GNU-PR-Package: emacs Original-Received: via spool by 41649-submit@debbugs.gnu.org id=B41649.159111890511606 (code B ref 41649); Tue, 02 Jun 2020 17:29:02 +0000 Original-Received: (at 41649) by debbugs.gnu.org; 2 Jun 2020 17:28:25 +0000 Original-Received: from localhost ([127.0.0.1]:40842 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jgAi6-000315-68 for submit@debbugs.gnu.org; Tue, 02 Jun 2020 13:28:25 -0400 Original-Received: from mail-ej1-f45.google.com ([209.85.218.45]:33137) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jgAi4-00030s-Fs for 41649@debbugs.gnu.org; Tue, 02 Jun 2020 13:28:21 -0400 Original-Received: by mail-ej1-f45.google.com with SMTP id n24so13581395ejd.0 for <41649@debbugs.gnu.org>; Tue, 02 Jun 2020 10:28:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DK2FiD0jBIeuoVp/+3K1XAfq7RQtHhrgLWoKQbs7SZw=; b=qwEn98tbF4Q1xeczGRipubDNkAokcbaKC21ewLIEJpiGzAb5gdtW9bOCfROMzDvVUW hqh7T7W8ro6ljkqJ0HNnUhVsRU/PTimiLk1bOqGzrY3OQUDlDxbN/XV4Hwp+CTLPqMnX PO4KYdKlufANbEtXnWTzODbWkyXka2VS/9Vq8TxxK1jtlt3nKNp05IYaVWqOBvKB3zXo XR8rLNseGAK7JDwbzAaV0TcbaDMnrDrhnx22ld7bOoUhbMU4+tHdmdPpCe22rar0rdjD it9cTPx4aLwRvYCLj3d+V29fjL5pL0BzgbtsbFTkrqKgjiXb8BnhB3bMur8ejJ7PDeJ6 P9WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DK2FiD0jBIeuoVp/+3K1XAfq7RQtHhrgLWoKQbs7SZw=; b=FMTxqLQyPGiJIxpffn27qVBlIzbiBZgqs9081f7qS1qJwtRMojA4CaQy8FzhkwRVlN FXQyNAG2lx49KQUHXZl6IArSlT+R1AWHRtS5plISg3um14OfSCiZk53gB/rG08jNxeun OlmeewERabHtqHXC832KrCm0rFIa7t5CHVPZ9LAWF1wA1xIbpA1e7t6s3/TOqfR9tKD/ 3WR6G4cLS+O87hF3mj2sI5AgdedaAzNX+caIRC5UZf120FQ4mwXj8S6epb/EY70WBBEs MhPMSbJW8Z/uSTR3HIMLuA9HB5vV2G1p29c9drYB0dO55EbpBVybwR48iaLr0f5wOfLS 6yNw== X-Gm-Message-State: AOAM531g6MGNGUpiF6ECwTfJUz3MHsBNumfx+BzBOFu+jb6LGnNUHOmJ qBf0qR5qyC//g3bNXqXtCeJL1DuqVjdWjlacdeo= X-Google-Smtp-Source: ABdhPJzIOQN/q4d+YND0cRgQZI9HgSv/7E6XNxTcVRhTUvvh2YaIU3CFCfsy3v5bn09k3QJpAD/qYnx5suXkRahGJVA= X-Received: by 2002:a17:906:3e15:: with SMTP id k21mr7579807eji.525.1591118894468; Tue, 02 Jun 2020 10:28:14 -0700 (PDT) In-Reply-To: <20200602171221.19097.qmail@mail.muc.de> 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" Xref: news.gmane.io gmane.emacs.bugs:181419 Archived-At: --00000000000080137005a71d3cc9 Content-Type: text/plain; charset="UTF-8" > Daniel, what is going on, here? Is this just a simple coding error, > where the second c-init-language-vars should have been removed at some > stage? I wasn't sure if js-beginning-of-defun was preferred here since it does not seem to detect ES2015 arrow functions like what is used here, whereas c-beginning-of-defun handles them fine outside of ReactJS cases: if you try M-: js-beginning-of-defun on my React example, point moves straight from the class declaration to the imports, which is not desirable. Should I file a separate ticket for that? On Tue, Jun 2, 2020 at 10:12 AM Alan Mackenzie wrote: > Hello Brian. > > In article you wrote: > > [-- text/plain, encoding 7bit, charset: UTF-8, 44 lines --] > > > With a file App.js that looks like: > > > import * as React from "react"; > > import { render } from "react-dom"; > > > const App = () => { > > return ( > >
> >

hello

> > > >
> > ); > > }; > > > render(, document.getElementById("root")); > > > > If you open the file in JS mode (Emacs 27), and move point inside of > > "abc", calling > > > M-: (c-beginning-of-defun) > > That looks like a strange thing to do. JS mode has its own > js-beginning-of-defun. > > But wait - beginning-of-defun-function is set to c-beginning-of-defun, > which is probably why you reported the bug the way you did. > > c-beginning-of-defun won't work, because a suitable member or derivative > of CC Mode hasn't been fully initialised. > > > gives the following error: > > > Debugger entered--Lisp error: (wrong-type-argument hash-table-p nil) > > copy-hash-table(nil) > > c-forward-<>-arglist(nil) > > c-backward-<>-arglist(nil nil) > > c-looking-at-decl-block(99 nil) > > c-most-enclosing-decl-block((117 99 88 (40 . 50))) > > c-widen-to-enclosing-decl-scope((117 99 88 (40 . 50)) 1 234) > > c-beginning-of-defun() > > eval((c-beginning-of-defun) t) > > eval-expression((c-beginning-of-defun) nil nil 127) > > funcall-interactively(eval-expression (c-beginning-of-defun) nil nil > 127) > > call-interactively(eval-expression nil nil) > > command-execute(eval-expression) > > > Manually invoking C-M-a inside the double quotes should end the same way. > > It does. > > The problem seems to stem from the top-level function #'js-mode. Early > on, it invokes > > (c-init-language-vars js-mode) > > , which initialises the CC Mode language variables to (mostly) their > Java Mode values. js-mode continues by overwriting the local value of > quite a few of these variables, including beginning-of-defun-function. > > js-mode then invokes > > (c-init-language-vars js-mode) > > a second time, which initialises the language variables again, in > particular, those variables which just got a local value, including > beginning-of-defun-function. > > Daniel, what is going on, here? Is this just a simple coding error, > where the second c-init-language-vars should have been removed at some > stage? > > > In GNU Emacs 27.0.91 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20) > > Windowing system distributor 'The X.Org Foundation', version > 11.0.12008000 > > System Description: NixOS 20.09 (Nightingale) > > -- > Alan Mackenzie (Nuremberg, Germany). > > --00000000000080137005a71d3cc9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
> Daniel, what is going on, here?=C2=A0 Is this just a = simple coding error,
> where the second c-init-language-vars should h= ave been removed at some
> stage?

I was= n't sure if js-beginning-of-defun was preferred here since it does not = seem to detect ES2015 arrow functions like what is used here, whereas c-beg= inning-of-defun handles them fine outside of ReactJS cases: if you try M-: = js-beginning-of-defun on my React example, point moves straight from the cl= ass declaration to the imports, which is not desirable. Should I file a sep= arate ticket for that?

On Tue, Jun 2, 2020 at 10:12 AM Alan Macken= zie <acm@muc.de> wrote:
Hello Brian.

In article <mailman.928.1591034465.2541.bug-gnu-emacs@gnu.or= g> you wrote:
> [-- text/plain, encoding 7bit, charset: UTF-8, 44 lines --]

> With a file App.js that looks like:

> import * as React from "react";
> import { render } from "react-dom";

> const App =3D () =3D> {
>=C2=A0 =C2=A0return (
>=C2=A0 =C2=A0 =C2=A0<div>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0<h1 id=3D"abc">hello</h1&= gt;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0<SearchParams />
>=C2=A0 =C2=A0 =C2=A0</div>
>=C2=A0 =C2=A0);
> };

> render(<App />, document.getElementById("root"));


> If you open the file in JS mode (Emacs 27), and move point inside of > "abc", calling

> M-: (c-beginning-of-defun)

That looks like a strange thing to do.=C2=A0 JS mode has its own
js-beginning-of-defun.

But wait - beginning-of-defun-function is set to c-beginning-of-defun,
which is probably why you reported the bug the way you did.

c-beginning-of-defun won't work, because a suitable member or derivativ= e
of CC Mode hasn't been fully initialised.

> gives the following error:

> Debugger entered--Lisp error: (wrong-type-argument hash-table-p nil) >=C2=A0 =C2=A0copy-hash-table(nil)
>=C2=A0 =C2=A0c-forward-<>-arglist(nil)
>=C2=A0 =C2=A0c-backward-<>-arglist(nil nil)
>=C2=A0 =C2=A0c-looking-at-decl-block(99 nil)
>=C2=A0 =C2=A0c-most-enclosing-decl-block((117 99 88 (40 . 50)))
>=C2=A0 =C2=A0c-widen-to-enclosing-decl-scope((117 99 88 (40 . 50)) 1 23= 4)
>=C2=A0 =C2=A0c-beginning-of-defun()
>=C2=A0 =C2=A0eval((c-beginning-of-defun) t)
>=C2=A0 =C2=A0eval-expression((c-beginning-of-defun) nil nil 127)
>=C2=A0 =C2=A0funcall-interactively(eval-expression (c-beginning-of-defu= n) nil nil 127)
>=C2=A0 =C2=A0call-interactively(eval-expression nil nil)
>=C2=A0 =C2=A0command-execute(eval-expression)

> Manually invoking C-M-a inside the double quotes should end the same w= ay.

It does.

The problem seems to stem from the top-level function #'js-mode.=C2=A0 = Early
on, it invokes

=C2=A0 =C2=A0 (c-init-language-vars js-mode)

, which initialises the CC Mode language variables to (mostly) their
Java Mode values.=C2=A0 js-mode continues by overwriting the local value of=
quite a few of these variables, including beginning-of-defun-function.

js-mode then invokes

=C2=A0 =C2=A0 (c-init-language-vars js-mode)

a second time, which initialises the language variables again, in
particular, those variables which just got a local value, including
beginning-of-defun-function.

Daniel, what is going on, here?=C2=A0 Is this just a simple coding error, where the second c-init-language-vars should have been removed at some
stage?

> In GNU Emacs 27.0.91 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.= 20)
> Windowing system distributor 'The X.Org Foundation', version 1= 1.0.12008000
> System Description: NixOS 20.09 (Nightingale)

--
Alan Mackenzie (Nuremberg, Germany).

--00000000000080137005a71d3cc9--