unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#51926: 29.0.50; Narrow to defun fails with Javascript async functions
@ 2021-11-17 20:11 Matthias Meulien
  2021-11-18 10:25 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: Matthias Meulien @ 2021-11-17 20:11 UTC (permalink / raw)
  To: 51926


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))





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#51926: 29.0.50; Narrow to defun fails with Javascript async functions
  2021-11-17 20:11 bug#51926: 29.0.50; Narrow to defun fails with Javascript async functions Matthias Meulien
@ 2021-11-18 10:25 ` Lars Ingebrigtsen
  2021-11-18 11:30   ` Matthias Meulien
  2021-11-19 22:22   ` Matthias Meulien
  0 siblings, 2 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2021-11-18 10:25 UTC (permalink / raw)
  To: Matthias Meulien; +Cc: 51926

Matthias Meulien <orontee@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





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#51926: 29.0.50; Narrow to defun fails with Javascript async functions
  2021-11-18 10:25 ` Lars Ingebrigtsen
@ 2021-11-18 11:30   ` Matthias Meulien
  2021-11-19 22:22   ` Matthias Meulien
  1 sibling, 0 replies; 5+ messages in thread
From: Matthias Meulien @ 2021-11-18 11:30 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 51926

[-- Attachment #1: Type: text/plain, Size: 488 bytes --]

> 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.

[-- Attachment #2: Type: text/html, Size: 1005 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#51926: 29.0.50; Narrow to defun fails with Javascript async functions
  2021-11-18 10:25 ` Lars Ingebrigtsen
  2021-11-18 11:30   ` Matthias Meulien
@ 2021-11-19 22:22   ` Matthias Meulien
  2021-11-20  9:21     ` Lars Ingebrigtsen
  1 sibling, 1 reply; 5+ messages in thread
From: Matthias Meulien @ 2021-11-19 22:22 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 51926

Lars Ingebrigtsen <larsi@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





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#51926: 29.0.50; Narrow to defun fails with Javascript async functions
  2021-11-19 22:22   ` Matthias Meulien
@ 2021-11-20  9:21     ` Lars Ingebrigtsen
  0 siblings, 0 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2021-11-20  9:21 UTC (permalink / raw)
  To: Matthias Meulien; +Cc: 51926

Matthias Meulien <orontee@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





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-11-20  9:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-17 20:11 bug#51926: 29.0.50; Narrow to defun fails with Javascript async functions Matthias Meulien
2021-11-18 10:25 ` Lars Ingebrigtsen
2021-11-18 11:30   ` Matthias Meulien
2021-11-19 22:22   ` Matthias Meulien
2021-11-20  9:21     ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).