4

I am editing a dead simple JSON file:

{
   "foo": "bar"
}

Here's what I see:

enter image description here

Doing a C-h m I see the following minor modes running alongside JSON mode:

Enabled minor modes: Auto-Composition Auto-Compression Auto-Encryption                    
Column-Number File-Name-Shadow Font-Lock Global-Font-Lock                                 
Global-Hl-Line Global-Linum Js2 Line-Number Linum Mouse-Wheel Openwith                    
Tool-Bar Tooltip Transient-Mark  

The following problem is reported when the cursor is on : character:

missing ; before statement

The entire "bar" string value is also highlight red. Is the problem related to js-lint running alongside JSON?

3
  • Sure looks like a bug. Consider reporting it to the maintainer of the JSON support library you are using (which you don't mention, although we can see js-lint in the mode line). Did you try adding a SPC char before the : (shouldn't be needed, obviously - just a thought).
    – Drew
    Oct 12, 2015 at 16:43
  • @Drew SPC makes no difference. This is embarrassing but I don't know what js-lint means. Looking at my .emacs it appears I am using json-mode: github.com/joshwnj/json-mode/blob/master/json-mode.el. How can I get more information about the major mode employed (like C-h m does for the minor modes)? Oct 12, 2015 at 19:50
  • 1
    C-h m tells you about both major and minor modes. C-h f json-mode tells you about it also, and provides a link to the file that defines it. In that file it is likely that you will find contact info for the maintainer. But you already have that from the GitHub page for the library. Contact Josh Johnston with a recipe to reproduce the bug.
    – Drew
    Oct 13, 2015 at 2:05

1 Answer 1

3

I have the same problem. Turns out I'm using js2-mode as minor-mode for js-mode

(add-hook 'js-mode-hook 'js2-minor-mode)

Everything is ok after remove above code from my .emacs.el

Another option is to add js2-minor-mode only if it's not json-mode

(add-hook 
  'js-mode-hook
    '(lambda () 
      (unless (eq major-mode 'json-mode) 
              (js2-minor-mode))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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