haskell / haskell-mode

Emacs mode for Haskell
http://haskell.github.io/haskell-mode/
GNU General Public License v3.0
1.32k stars 339 forks source link

haskell-indentation-indent-region and smartparens interact poorly #796

Open rpglover64 opened 8 years ago

rpglover64 commented 8 years ago

Calling a smartparens command like sp-raise-sexp or sp-forward-slurp calls indent-region which calls haskell-indentation-indent-region, which indents the region exactly 1 space, which is almost never what is wanted.

I think this is a misfeature in haskell-indentation-indent-region.

gracjan commented 8 years ago

Region indentation can be considered unimplemented feature. We do not have that working yet.

rpglover64 commented 8 years ago

Then it would be more useful if region indentation did absolutely nothing.

gracjan commented 8 years ago

@rpglover64: Are you able to submit a unit test in tests/haskell-indentation-tests.el that shows the broken behavior?

rpglover64 commented 8 years ago

Not in the style of the file (i.e. not using haskell-indentation-check); AFAICT, haskell-indentation-find-indentations is behaving correctly, and that's what the file is testing.

I personally worked around this by redefining haskell-indentation-indent-region to do nothing.

gracjan commented 8 years ago

It is expected that there will be more check styles.

gracjan commented 8 years ago

Noted the need of indent-region in #1032. And closing this particular issue because it seems that smartparens has a flag to work around haskell-mode missing feature.

khanage commented 8 years ago

What is the flag that works around this @gracjan?

gracjan commented 8 years ago

The flag is in smart parens.

bergey commented 8 years ago

@khanage From my answer to https://github.com/haskell/haskell-mode/issues/1031:

(add-to-list 'sp-no-reindent-after-kill-modes 'haskell-mode)

That works for sp-kill-sexp. It doesn't work (in my quick test) for sp-raise-sexp or sp-forward-slurp. Maybe smartparens should apply sp-no-reindent-after-kill-modes to these functions also; I'm not certain. I think #1032 covers the issue from haskell-mode perspective.

gracjan commented 8 years ago

Reopening as this does not seem to be solved good enough with #1032 (i.e. I have bad feelings but no proof yet).

gracjan commented 8 years ago

Yes, sp-forward-slurp-sexp usually bound to C-right calls indent-region-function without looking at sp-no-reindent-after-kill-modes and messes up the layout.

gracjan commented 8 years ago

smartparens will also interact poorly even if haskell-indent-region is implemented properly. Consider:

foo = (h $ do abc
              def
              ghi)

And now use sp-splice-sexp M-s-d inside the parentheses:

foo = h $ do abc
              def
              ghi

Layout is already messed up and even properly implemented haskell-indent-region cannot salvage the meaning of this program.

peterbecich commented 3 years ago

This may be a fix; works for me: https://gist.github.com/unhammer/edd926fff70af71d1c77ed73461d55a9#file-init-haskell-el-L112-L133