json-emacs/json-mode

hideshow often toggles the parent by mistake

mcandre opened this issue · 3 comments

I like using hideshow to fold my code. This works well in several modes such as python-mode. But when I try to toggle JSON data in json-mode, I observe a problem.

Steps to reproduce

package.json:

{
  "name": "dotfiles",
  "repository": {
    "type": "git"
  }
}

Go to line 3, any column except 16/17 where the curly brace lives. When you attempt to toggle the repository value, hs-minor-mode toggles the parent instead.

$ emacs -Q package.json
M-x json-mode
M-x hs-minor-mode
M-g g 3
hs-toggle-hiding

Expected

{
  "name": "dotfiles",
  "repository": { ... }
}

Observed

{ ... }

System

$ find $HOME/.emacs.d/.cask -type d -name '*json-mode*'
/Users/andrew/.emacs.d/.cask/24.4.1/elpa/json-mode-20150413.1948

$ emacs --version
GNU Emacs 24.4.1
Copyright (C) 2014 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

$ system_profiler SPSoftwareDataType | grep 'System Version'
    System Software Overview:
      System Version: OS X 10.10.3 (14D136)

Thanks for lodging this issue. I've often thought it would be useful to be able to fold json but haven't yet got around to looking into it :)

taku0 commented

hs-toggle-hiding hides the parent in other modes including c-mode, emacs-lisp-mode, and python-mode.

cough