From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#41649: 27.0.91; beginning-of-defun doesn't work inside React markup in js-jsx-mode Date: 2 Jun 2020 17:12:21 -0000 Organization: muc.de e.V. Message-ID: <20200602171221.19097.qmail@mail.muc.de> References: Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="42765"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: tin/2.4.4-20191224 ("Millburn") (FreeBSD/11.3-RELEASE-p9 (amd64)) Cc: 41649@debbugs.gnu.org To: Brian Leung Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jun 02 19:13:11 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 1jgATP-000B2k-JV for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 02 Jun 2020 19:13:11 +0200 Original-Received: from localhost ([::1]:32774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgATO-0000co-M7 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 02 Jun 2020 13:13:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgATG-0000af-R1 for bug-gnu-emacs@gnu.org; Tue, 02 Jun 2020 13:13:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57512) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jgATG-0000wJ-I5 for bug-gnu-emacs@gnu.org; Tue, 02 Jun 2020 13:13:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jgATG-0002f0-CG for bug-gnu-emacs@gnu.org; Tue, 02 Jun 2020 13:13:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 02 Jun 2020 17:13: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.159111794610182 (code B ref 41649); Tue, 02 Jun 2020 17:13:02 +0000 Original-Received: (at 41649) by debbugs.gnu.org; 2 Jun 2020 17:12:26 +0000 Original-Received: from localhost ([127.0.0.1]:40825 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jgASg-0002eA-BY for submit@debbugs.gnu.org; Tue, 02 Jun 2020 13:12:26 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:40760 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1jgASd-0002e0-Tr for 41649@debbugs.gnu.org; Tue, 02 Jun 2020 13:12:24 -0400 Original-Received: (qmail 19098 invoked by uid 3782); 2 Jun 2020 17:12:21 -0000 In-Reply-To: X-Newsgroups: gnu.emacs.bug 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:181418 Archived-At: 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).