GNU bug report logs - #51926
29.0.50; Narrow to defun fails with Javascript async functions

Previous Next

Package: emacs;

Reported by: Matthias Meulien <orontee <at> gmail.com>

Date: Wed, 17 Nov 2021 20:12:02 UTC

Severity: normal

Found in version 29.0.50

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 51926 in the body.
You can then email your comments to 51926 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#51926; Package emacs. (Wed, 17 Nov 2021 20:12:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Matthias Meulien <orontee <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 17 Nov 2021 20:12:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Matthias Meulien <orontee <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.50; Narrow to defun fails with Javascript async functions
Date: Wed, 17 Nov 2021 21:11:35 +0100
1. Create a buffer and enable `js-mode' in that buffer
2. Enter the following function definition:

async function test_async() {
  return true;
}

3. Move cursor past the "f" of the "function" keyword.

4. Call `narrow-to-defun' (C-x n d) and observe that the buffer now
displays the following:

function test_async() {
    // nothing to do
}

This is wrong (async has disappeared).



In GNU Emacs 29.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0)
 of 2021-11-14 built on carbon
Repository revision: 2ff42ad0e8468a5979a8c5db90333d9c2949bd2e
Repository branch: dev/mm
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Debian GNU/Linux 11 (bullseye)

Configured using:
 'configure --with-native-compilation'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
X11 XDBE XIM XPM GTK3 ZLIB

Important settings:
  value of $LANG: fr_FR.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: JavaScript

Minor modes in effect:
  subword-mode: t
  display-line-numbers-mode: t
  highlight-changes-mode: t
  shell-dirtrack-mode: t
  eglot--managed-mode: t
  flymake-mode: t
  minions-mode: t
  desktop-save-mode: t
  save-place-mode: t
  electric-pair-mode: t
  icomplete-mode: t
  global-so-long-mode: t
  global-auto-revert-mode: t
  auto-insert-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-layout-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tab-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  window-divider-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t
  hs-minor-mode: t

Load-path shadows:
/home/matthias/.config/emacs/elpa/transient-20211029.1405/transient hides /usr/local/share/emacs/29.0.50/lisp/transient
/home/matthias/.config/emacs/elpa/dictionary-20201001.1727/dictionary hides /usr/local/share/emacs/29.0.50/lisp/net/dictionary

Features:
(shadow sort mail-extr gnus-msg emacsbug sendmail
display-fill-column-indicator cus-start crm log-view pcvs-util
reftex-dcr reftex reftex-loaddefs reftex-vars tex-mode pulse misearch
multi-isearch shortdoc help-fns radix-tree hideshow cap-words superword
subword js hl-line whitespace add-log bug-reference display-line-numbers
hilit-chg follow mule-util vc-dir dired-aux flyspell ox-odt rng-loc
rng-uri rng-parse rng-match rng-dt rng-util rng-pttrn nxml-parse nxml-ns
nxml-enc xmltok nxml-util ox-latex ox-icalendar org-agenda ox-html table
ox-ascii ox-publish ox goto-addr org-element avl-tree generator ol-eww
eww xdg url-queue mm-url ol-rmail ol-mhe ol-irc ol-info ol-gnus nnselect
gnus-search eieio-opt speedbar ezimage dframe gnus-art mm-uu mml2015
mm-view mml-smime smime dig gnus-sum shr kinsoku svg dom ol-docview
doc-view jka-compr image-mode exif ol-bibtex ol-bbdb ol-w3m ol-doi
org-link-doi vc-mtn vc-hg vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs vc
bash-completion shell eglot array jsonrpc ert ewoc debug backtrace xref
flymake-proc flymake compile pcase project imenu avoid minions
carbon-custom cus-edit cus-load gnus-demon nntp gnus-group gnus-undo
gnus-start gnus-dbus dbus xml gnus-cloud nnimap nnmail mail-source utf7
netrc parse-time gnus-spec gnus-win nnoo gnus-int gnus-range message
yank-media rmc puny rfc822 mml mml-sec epa derived epg rfc6068
epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader gnus nnheader gnus-util rmail rmail-loaddefs
rfc2047 rfc2045 ietf-drums mail-utils mm-util mail-prsvr wid-edit
gnus-dired dired-x dired dired-loaddefs org-capture org-refile org ob
ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-footnote org-src
ob-comint org-pcomplete pcomplete comint ansi-color ring org-list
org-faces org-entities org-version ob-emacs-lisp ob-core ob-eval
org-table oc-basic bibtex iso8601 time-date ol org-keys oc org-compat
org-macs org-loaddefs format-spec find-func cal-menu calendar
cal-loaddefs dictionary link connection advice markdown-mode
edit-indirect color thingatpt noutline outline skeleton find-file vc-git
diff-mode easy-mmode vc-dispatcher ispell comp comp-cstr warnings rx
cl-extra help-mode desktop frameset server bookmark text-property-search
pp saveplace elec-pair icomplete so-long autorevert filenotify
autoinsert cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align
cc-engine cc-vars cc-defs generic-x face-remap proof-site
proof-autoloads info package browse-url url url-proxy url-privacy
url-expand url-methods url-history url-cookie url-domsuf url-util
mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core
cl-macs eieio-loaddefs password-cache json map url-vars seq gv subr-x
byte-opt bytecomp byte-compile cconv cl-loaddefs cl-lib iso-transl
tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
cairo move-toolbar gtk x-toolkit x multi-tty make-network-process
native-compile emacs)

Memory information:
((conses 16 590905 90110)
 (symbols 48 35955 4)
 (strings 32 140075 9035)
 (string-bytes 1 4717821)
 (vectors 16 74556)
 (vector-slots 8 2007615 281998)
 (floats 8 625 647)
 (intervals 56 15481 1242)
 (buffers 992 74))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51926; Package emacs. (Thu, 18 Nov 2021 10:26:02 GMT) Full text and rfc822 format available.

Message #8 received at 51926 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Matthias Meulien <orontee <at> gmail.com>
Cc: 51926 <at> debbugs.gnu.org
Subject: Re: bug#51926: 29.0.50; Narrow to defun fails with Javascript async
 functions
Date: Thu, 18 Nov 2021 11:25:36 +0100
Matthias Meulien <orontee <at> gmail.com> writes:

> 4. Call `narrow-to-defun' (C-x n d) and observe that the buffer now
> displays the following:
>
> function test_async() {
>     // nothing to do
> }
>
> This is wrong (async has disappeared).

Yup; I can reproduce this in Emacs 29, too.  I've poked at it now, and
it's surprisingly difficult to fix this, due to the way these functions
are constructed.  But I think I've got it working now in Emacs 29.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 29.1, send any further explanations to 51926 <at> debbugs.gnu.org and Matthias Meulien <orontee <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 18 Nov 2021 10:26:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51926; Package emacs. (Thu, 18 Nov 2021 11:31:02 GMT) Full text and rfc822 format available.

Message #13 received at 51926 <at> debbugs.gnu.org (full text, mbox):

From: Matthias Meulien <orontee <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 51926 <at> debbugs.gnu.org
Subject: Re: bug#51926: 29.0.50;
 Narrow to defun fails with Javascript async functions
Date: Thu, 18 Nov 2021 12:30:24 +0100
[Message part 1 (text/plain, inline)]
> Yup; I can reproduce this in Emacs 29, too.  I've poked at it now, and
> it's surprisingly difficult to fix this, due to the way these functions
> are constructed.


I must confess I tried to fix it before I create the bug report (as I
usually do since I feel like maintainers are already quite busy...) but
gave up: There are so many regexps to match the function keyword, the
cache, etc.


But I think I've got it working now in Emacs 29.


Thanks a lot! I'll test this this evening.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51926; Package emacs. (Fri, 19 Nov 2021 22:23:01 GMT) Full text and rfc822 format available.

Message #16 received at 51926 <at> debbugs.gnu.org (full text, mbox):

From: Matthias Meulien <orontee <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 51926 <at> debbugs.gnu.org
Subject: Re: bug#51926: 29.0.50; Narrow to defun fails with Javascript async
 functions
Date: Fri, 19 Nov 2021 23:22:19 +0100
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Yup; I can reproduce this in Emacs 29, too.  I've poked at it now, and
> it's surprisingly difficult to fix this, due to the way these functions
> are constructed.  But I think I've got it working now in Emacs 29.

I pulled last HEAD of master which includes:

   6cad3dc75e..: Lars Ingebrigtsen 2021-11-18 Fix `narrow-to-defun' in
   "async function" in js-mode

Unfortunately it has improved but it doesn't always work as
expected. With a buffer with following content:

async function test() {
    // cursor here
}

it now works when cursor is on the first line ("async function test...")
AND not after the opening brace. After that brace, on first line or
second line, it fails...
-- 
Matthias




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#51926; Package emacs. (Sat, 20 Nov 2021 09:23:02 GMT) Full text and rfc822 format available.

Message #19 received at 51926 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Matthias Meulien <orontee <at> gmail.com>
Cc: 51926 <at> debbugs.gnu.org
Subject: Re: bug#51926: 29.0.50; Narrow to defun fails with Javascript async
 functions
Date: Sat, 20 Nov 2021 10:21:50 +0100
Matthias Meulien <orontee <at> gmail.com> writes:

> Unfortunately it has improved but it doesn't always work as
> expected. With a buffer with following content:
>
> async function test() {
>     // cursor here
> }
>
> it now works when cursor is on the first line ("async function test...")
> AND not after the opening brace. After that brace, on first line or
> second line, it fails...

Hm, I thought I had tested that case...  Oh!  When fixing a compilation
warning, I messed up that code path.  This should work better now.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 18 Dec 2021 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 91 days ago.

Previous Next


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