gregsexton / origami.el

A folding minor mode for Emacs
510 stars 41 forks source link

Flawed support for Allman / BSD / GNU-style brace-placement? (Braces on a line by themselves.) #119

Open Heathcliff77 opened 6 months ago

Heathcliff77 commented 6 months ago

I am experiencing that origami behaves poorly when dealing with code where braces are placed on a line by themselves. See the gif-recording below, the command I issue is origami-recursively-toggle-node

Origami folds nicely when braces are placed according to K&R style, but poorly for Allman / BSD / GNU-style. For example, trying to fold the if on line 6 folds the entire function foo(), which is not what you would expect or want to happen.

Peek 2024-03-21 12-43

gregsexton commented 6 months ago

Put the point on the brace you want to fold. There are commands that can help with this, such as origami-forward-fold.

Heathcliff77 commented 6 months ago

Hello Greg, I'm happy to see such a quick reply.

My standpoint is that if origami was working properly, it would be possible to have the cursor placed at the beginning of L6 and issue a command that would fold the body of the if, not the entire function foo().

Is such behavior possible with origami? If so, can you elaborate how to achieve that?