bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#22063: 25.0.50; js-mode, incorrect indentation of functions with key


From: Jordon Biondo
Subject: bug#22063: 25.0.50; js-mode, incorrect indentation of functions with keyword names
Date: Mon, 30 Nov 2015 14:00:17 -0500

js-mode will incorrectly indent chained function calls when the function
shares a name with a keyword. This is particularly problematic when
writing js code using the ES6 Promise API which contains a `catch`
function.

The following example contains the correct, desired indentation:

Foobar
    .find()
    .then((foo) => {
        return 1;
    })
    .catch((err) => {
        return 2;
    })
    .then((num) => {
        console.log(num);
    });

The following example shows how Emacs currently indents the above code:

Foobar
    .find()
    .then((foo) => {
        return 1;
    })
    .catch((err) => {
        return 2;
    })
        .then((num) => {
            console.log(num);
        });

This is caused by the function being named `catch` which the current
indentation support falsely assumes is the catch keyword. If you were to
change the code from `.catch` to `.catch2` it would indent correctly.
This problem is not limited to only the `catch` keyword.



In GNU Emacs 25.0.50.1 (x86_64-apple-darwin14.4.0, NS appkit-1348.17 Version 
10.10.4 (Build 14E46))
of 2015-07-14 on Jordons-MacBook-Pro.local
Repository revision: 894a90671b9ebc37fb56abfcef6e422e954d6460
Configured using:
`configure --prefix=/usr/local/Cellar/emacs/HEAD
--enable-locallisppath=/usr/local/share/emacs/site-lisp
--infodir=/usr/local/Cellar/emacs/HEAD/share/info/emacs --without-dbus
--without-gnutls --with-ns --disable-ns-self-contained'

Configured features:
ACL LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Javascript

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Quit [2 times]
Mark set
Making completion list... [3 times]

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message dired format-spec
rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util help-fns mail-prsvr mail-utils js advice json imenu thingatpt
cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
cc-vars cc-defs term/xterm xterm byte-opt gv bytecomp byte-compile
cl-extra help-mode easymenu seq cl-loaddefs pcase cl-lib cconv time-date
mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel ns-win term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame 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 charscript case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote cocoa ns multi-tty
make-network-process emacs)

Memory information:
((conses 16 111616 7362)
(symbols 48 21847 0)
(miscs 40 83 155)
(strings 32 22480 4769)
(string-bytes 1 758400)
(vectors 16 12850)
(vector-slots 8 399482 2718)
(floats 8 130 402)
(intervals 56 233 0)
(buffers 976 14))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]