all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jordon Biondo <jordon.biondo@appropos.com>
To: 22063@debbugs.gnu.org
Subject: bug#22063: 25.0.50; js-mode, incorrect indentation of functions with keyword names
Date: Mon, 30 Nov 2015 14:00:17 -0500	[thread overview]
Message-ID: <F64BDFDC-FCAB-436E-8FB9-DC514452F724@appropos.com> (raw)


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	other threads:[~2015-11-30 19:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-30 19:00 Jordon Biondo [this message]
2015-12-01  3:42 ` bug#22063: 25.0.50; js-mode, incorrect indentation of functions with keyword names Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F64BDFDC-FCAB-436E-8FB9-DC514452F724@appropos.com \
    --to=jordon.biondo@appropos.com \
    --cc=22063@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.