3

When using js-mode (or js2-mode) on Emacs 25.1 (in Debian 9) to edit some large files, any attempt to insert text after some "random" point in the file fails with an elisp stack trace:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  looking-at(nil)
  c-state-semi-safe-place(269817)
  c-literal-limits(nil nil t)
  c-context-line-break()
  funcall-interactively(c-context-line-break)
  call-interactively(c-context-line-break nil nil)
  command-execute(c-context-line-break)

Why and how can it be fixed?

3

It turned out that my personal config (and those of the people I tested this with) manually bound C-m to c-context-line-break in js-mode. So the right answer is to not do this (and leave it as newline-and-indent.) Silly me.

Original "workaround":

The looking-at(nil) gave a pretty good hint that this was a cc-mode regex left unset by js-mode and js2-mode. An Edebug session quickly showed that the culprit was c-block-comment-start-regexp.

So, to fix it, I just defined that variable in a hook in ~/.emacs. For example, for js-mode:

(add-hook 'js-mode-hook (lambda () (setq c-block-comment-start-regexp "/\\*")))
  • 1
    Arguably, the bug is that js-mode uses c-context-line-break even tho it's not a "cc-mode". – Stefan Feb 18 '18 at 0:05
  • This might be worth reporting to maintainers of js-mode. – DoMiNeLa10 Feb 18 '18 at 14:56
  • @DoMiNeLa10: Good point. I've sent the maintainer a note. – Brad Spencer Feb 18 '18 at 17:45
  • Ha, and guess what. It turns out that it's my configuration (and those of everyone else I had try this out, by chance) that binds C-m to c-context-line-break! Oops. Well, I guess I'll fix this the right way by not doing that. – Brad Spencer Feb 18 '18 at 17:48

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.