all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* hideshow bug with json-mode
@ 2015-05-06 17:37 Andrew Pennebaker
  2015-05-06 20:45 ` Robert Thorpe
  2015-05-07 13:20 ` Michael Heerdegen
  0 siblings, 2 replies; 7+ messages in thread
From: Andrew Pennebaker @ 2015-05-06 17:37 UTC (permalink / raw)
  To: Emacs Help

If I don't carefully position my cursor right on the opening curly brace,
then hideshow toggles the parent block instead of the current line's block.

package.json:

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

Steps to reproduce:

M-g g 3
M-x hs-toggle-hiding RET

Expected:

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

Observed:

{ ... }

This problem only happens in certain major modes; python-mode with
hs-minor-mode works as expected, whereas json-mode with hs-minor-mode
features this problem.

Any suggestions for configuration to work around this problem? I considered
adding advice to automatically go to the end of line before toggling, but
this doesn't work when re-showing the block, as the cursor needs to be on
the brace ({), but before the ellipsis (...).

-- 
Cheers,
Andrew


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: hideshow bug with json-mode
  2015-05-06 17:37 hideshow bug with json-mode Andrew Pennebaker
@ 2015-05-06 20:45 ` Robert Thorpe
  2015-05-07  2:35   ` Andrew Pennebaker
  2015-05-07 13:20 ` Michael Heerdegen
  1 sibling, 1 reply; 7+ messages in thread
From: Robert Thorpe @ 2015-05-06 20:45 UTC (permalink / raw)
  To: Andrew Pennebaker; +Cc: help-gnu-emacs

Andrew Pennebaker <andrew.pennebaker@gmail.com> writes:

> If I don't carefully position my cursor right on the opening curly brace,
> then hideshow toggles the parent block instead of the current line's block.

That looks like a bug in json-mode.  I think that mode doesn't setup the
syntax table correctly.

That said, I just downloaded https://github.com/joshwnj/json-mode (I
assume that's the one you're using) and ran that, and it worked
correctly.

Have you tried it with emacs -q ?

BR,
Rob



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: hideshow bug with json-mode
  2015-05-06 20:45 ` Robert Thorpe
@ 2015-05-07  2:35   ` Andrew Pennebaker
  2015-05-07  2:37     ` Andrew Pennebaker
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Pennebaker @ 2015-05-07  2:35 UTC (permalink / raw)
  To: Robert Thorpe; +Cc: Emacs Help

Odd, I'm using the latest version of json-mode and still observing the
problem. I'll file a bug.

I wonder if I'm not describing the test case clearly enough. Make sure

* the major-mode is json-mode
* cursor is on line 3, at column 0 or anywhere besides columns 16/17 where
the curly brace lives
* use hs-toggle-hiding
* file contents are:

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

On my machine, toggling on line 3 before the curly brace collapses the
parent like this:

{ ... }

which gets nasty in a larger JSON document, when all I want collapsed is
this:

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

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.

On Wed, May 6, 2015 at 3:45 PM, Robert Thorpe <rt@robertthorpeconsulting.com
> wrote:

> Andrew Pennebaker <andrew.pennebaker@gmail.com> writes:
>
> > If I don't carefully position my cursor right on the opening curly brace,
> > then hideshow toggles the parent block instead of the current line's
> block.
>
> That looks like a bug in json-mode.  I think that mode doesn't setup the
> syntax table correctly.
>
> That said, I just downloaded https://github.com/joshwnj/json-mode (I
> assume that's the one you're using) and ran that, and it worked
> correctly.
>
> Have you tried it with emacs -q ?
>
> BR,
> Rob
>



-- 
Cheers,
Andrew


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: hideshow bug with json-mode
  2015-05-07  2:35   ` Andrew Pennebaker
@ 2015-05-07  2:37     ` Andrew Pennebaker
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Pennebaker @ 2015-05-07  2:37 UTC (permalink / raw)
  To: Robert Thorpe; +Cc: Emacs Help

I observe the problem even with emacs -Q.

The problem presents itself in json-mode and nxml-mode, too!

On Wed, May 6, 2015 at 9:35 PM, Andrew Pennebaker <
andrew.pennebaker@gmail.com> wrote:

> Odd, I'm using the latest version of json-mode and still observing the
> problem. I'll file a bug.
>
> I wonder if I'm not describing the test case clearly enough. Make sure
>
> * the major-mode is json-mode
> * cursor is on line 3, at column 0 or anywhere besides columns 16/17 where
> the curly brace lives
> * use hs-toggle-hiding
> * file contents are:
>
> {
>   "name": "dotfiles",
>   "repository": {
>     "type": "git"
>   }
> }
>
> On my machine, toggling on line 3 before the curly brace collapses the
> parent like this:
>
> { ... }
>
> which gets nasty in a larger JSON document, when all I want collapsed is
> this:
>
> {
>   "name": "dotfiles",
>   "repository": { ... }
> }
>
> 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.
>
> On Wed, May 6, 2015 at 3:45 PM, Robert Thorpe <
> rt@robertthorpeconsulting.com> wrote:
>
>> Andrew Pennebaker <andrew.pennebaker@gmail.com> writes:
>>
>> > If I don't carefully position my cursor right on the opening curly
>> brace,
>> > then hideshow toggles the parent block instead of the current line's
>> block.
>>
>> That looks like a bug in json-mode.  I think that mode doesn't setup the
>> syntax table correctly.
>>
>> That said, I just downloaded https://github.com/joshwnj/json-mode (I
>> assume that's the one you're using) and ran that, and it worked
>> correctly.
>>
>> Have you tried it with emacs -q ?
>>
>> BR,
>> Rob
>>
>
>
>
> --
> Cheers,
> Andrew
>



-- 
Cheers,
Andrew


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: hideshow bug with json-mode
  2015-05-06 17:37 hideshow bug with json-mode Andrew Pennebaker
  2015-05-06 20:45 ` Robert Thorpe
@ 2015-05-07 13:20 ` Michael Heerdegen
  2015-05-07 14:02   ` Andrew Pennebaker
  1 sibling, 1 reply; 7+ messages in thread
From: Michael Heerdegen @ 2015-05-07 13:20 UTC (permalink / raw)
  To: help-gnu-emacs

Andrew Pennebaker <andrew.pennebaker@gmail.com> writes:

> This problem only happens in certain major modes; python-mode with
> hs-minor-mode works as expected, whereas json-mode with hs-minor-mode
> features this problem.

AFAIK hideshow does not work out of the box with every mode.  It's
possible that it needs configuration to make it work (see
`hs-special-modes-alist').  Are you sure that the affected modes are
supported?


HTH,

Michael.




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: hideshow bug with json-mode
  2015-05-07 13:20 ` Michael Heerdegen
@ 2015-05-07 14:02   ` Andrew Pennebaker
  2015-05-07 20:50     ` Robert Thorpe
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Pennebaker @ 2015-05-07 14:02 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: Emacs Help

yafolding <https://github.com/zenozeng/yafolding.el> seems to fix this
problem for both JSON and XML files.

On Thu, May 7, 2015 at 8:20 AM, Michael Heerdegen <michael_heerdegen@web.de>
wrote:

> Andrew Pennebaker <andrew.pennebaker@gmail.com> writes:
>
> > This problem only happens in certain major modes; python-mode with
> > hs-minor-mode works as expected, whereas json-mode with hs-minor-mode
> > features this problem.
>
> AFAIK hideshow does not work out of the box with every mode.  It's
> possible that it needs configuration to make it work (see
> `hs-special-modes-alist').  Are you sure that the affected modes are
> supported?
>
>
> HTH,
>
> Michael.
>
>
>


-- 
Cheers,
Andrew


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: hideshow bug with json-mode
  2015-05-07 14:02   ` Andrew Pennebaker
@ 2015-05-07 20:50     ` Robert Thorpe
  0 siblings, 0 replies; 7+ messages in thread
From: Robert Thorpe @ 2015-05-07 20:50 UTC (permalink / raw)
  To: Andrew Pennebaker; +Cc: michael_heerdegen, help-gnu-emacs

Try evaluating the following line:
(push '(json-mode "{" "}" "/[*/]" nil) hs-special-modes-alist)
Then try your example.

Probably, the reason yafolding works is because it's indentation based.
Hide-show is based on syntax, so it needs information from the mode on
the syntax of blocks.

When you say that nXML mode doesn't work, what do you mean?  What XML
code did you use to try it?

BR,
Robert Thorpe

Andrew Pennebaker <andrew.pennebaker@gmail.com> writes:
> yafolding <https://github.com/zenozeng/yafolding.el> seems to fix this
> problem for both JSON and XML files.
>
> On Thu, May 7, 2015 at 8:20 AM, Michael Heerdegen <michael_heerdegen@web.de>
> wrote:
>
>> Andrew Pennebaker <andrew.pennebaker@gmail.com> writes:
>>
>> > This problem only happens in certain major modes; python-mode with
>> > hs-minor-mode works as expected, whereas json-mode with hs-minor-mode
>> > features this problem.
>>
>> AFAIK hideshow does not work out of the box with every mode.  It's
>> possible that it needs configuration to make it work (see
>> `hs-special-modes-alist').  Are you sure that the affected modes are
>> supported?
>>
>>
>> HTH,
>>
>> Michael.
>>
>>
>>



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-05-07 20:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-06 17:37 hideshow bug with json-mode Andrew Pennebaker
2015-05-06 20:45 ` Robert Thorpe
2015-05-07  2:35   ` Andrew Pennebaker
2015-05-07  2:37     ` Andrew Pennebaker
2015-05-07 13:20 ` Michael Heerdegen
2015-05-07 14:02   ` Andrew Pennebaker
2015-05-07 20:50     ` Robert Thorpe

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.