Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

electric-indent-mode breaks layout #7

Closed
geraldus opened this issue Feb 23, 2016 · 17 comments
Closed

electric-indent-mode breaks layout #7

geraldus opened this issue Feb 23, 2016 · 17 comments

Comments

@geraldus
Copy link

With electric-indent-mode turned on I have to insert newlines with C-j, if I insert newline with RET it causes re-indent of previous line.
C-j places point at line beginning
M-j places point where it would be is press TAB at line beginning (this is the same if I hit RETTAB with disabled electric-indent-mode).
UPDATE: hmmm… looks like M-j is doing the job well.

I believe proper indentation for hamlet files is quite tricky and complicated task (as in Haskell mode), but is there a way to prevent re-indenting of previous lines?

@geraldus
Copy link
Author

To clarify myself let me explain when re-indent occurs:

<table>
  <tbody>
<div>

When I insert newline after <table> it is fine, newline indented one level deeper and I can type <tbody> immediately without any additional actions. Now, I insert newline after <tbody> and it is indented one level deeper again. I type <div> and re-indent it two levels back. Now pressing RET after <div> re-indents it two levels deeper and moves it in context of <tbody>, and newline indented one level deeper than <div>:

<table>
  <tbody>
    <div>RET
      _

@CodyReichert
Copy link
Owner

Hey @geraldus - thanks for the info! I have this pulled up right now, but I'm actually not able to reproduce it - all of the indentation for newlines seem to be working correctly with electric-indent-mode turned on (though I'm probably not reproducing it correctly).

I'll play around with it a bit more; if you have a basic .emacs that I can use to reproduce that would be helpful. I'll leave this open for now in case anyone else hits the issue.

@geraldus
Copy link
Author

I think I would be able to provide minimal init file (: Will try to find some time tomorrow.

@geraldus
Copy link
Author

Hmm… With minimal config I can't reproduce this too! What is really weird that in both cases I have same function bound to RET, namely newline. I also tried to eval easy customizations, but it minimal config case it works fine. Minimal config in my case is:

  • run emacs -Q
  • eval (package initialize)
  • turn-on evil-mode and electric-indent-mode

Here is a list of modes I have in minimal config in hamlet buffer:

Enabled minor modes: Auto-Composition Auto-Compression Auto-Encryption
Blink-Cursor Diff-Auto-Refine Electric-Indent Evil Evil-Local
File-Name-Shadow Font-Lock Global-Eldoc Global-Font-Lock
Global-Undo-Tree Line-Number Menu-Bar Mouse-Wheel Shakespeare Tool-Bar
Tooltip Transient-Mark Undo-Tree

And this is with full config

Enabled minor modes: Async-Bytecomp-Package Auto-Composition Auto-Compression
Auto-Encryption Auto-Revert Blink-Cursor Column-Number Company Diff-Auto-Refine
Electric-Indent Electric-Pair Evil Evil-Local Evil-Surround Fci File-Name-Shadow
Flx-Ido Flycheck Font-Lock Global-Company Global-Eldoc Global-Evil-Surround
Global-Flycheck Global-Font-Lock Global-Git-Commit Global-Hl-Line
Global-Undo-Tree Ido-Everywhere Line-Number Magit-Auto-Revert Menu-Bar
Mouse-Wheel Savehist Shakespeare Shell-Dirtrack Show-Paren Tooltip
Transient-Mark Undo-Tree

(Please excuse me for these lists, but maybe you'll spot something).

@geraldus
Copy link
Author

I've debugged this a bit, with my full config indent-according-to-mode runs sgml-indent-line for some reason (I believe I have never customized sgml related stuff), while with minimal config it is not.

@CodyReichert
Copy link
Owner

Hey @geraldus - no problem, thanks for the additional info. I haven't had a chance to pull this back up with the new info just yet but I hope to this weekend.

FWIW, hamlet-mode does use sgml-mode for indentation and other things. So it's probably correct that sgml-indent-line is running - but it's odd that it's not using it with the minimal config. Do you know what function is running with the minimal config?

@geraldus
Copy link
Author

@CodyReichert yeah, I've already noticed that shakespeare-mode is derived from sgml. I was discouraged by debugging newline step by step, it took so many time and involved so many inner actions :D I can give it a try once again to see what function is used in minimal config.

Meanwhile, can you please check the result of indent-according-to-mode call for given example:

<div>
  <span>
_

where _ determines point position.

Also, please try to debug-on-entry indent-according-to-mode and insert newline, I wonder will indent-according-to-mode be called in your setup.

@geraldus
Copy link
Author

geraldus commented Mar 1, 2016

Ok, if I go this way

  • emacs -Q
  • (package-initialize)
    then sgml-indent-line is used

On other hand

  • emacs -Q
  • (add-to-list 'load-path "~/.emacs.d/elpa/shakespeare-mode-20150708.712/")
  • (require 'shakespeare-mode)
    then back-to-indentation is used in indent-according-to-mode function

In first case issue appears, in second case does not.

@saurabhnanda
Copy link

I can confirm that I'm facing this issue too on spacemacs + Intero.

@CodyReichert
Copy link
Owner

Hey all, thanks again for following up on this issue. I'm unfortunately swamped right now and haven't had time to investigate this at all. I'll happily take any PR's or (more) clues if anyone would like to address this. Otherwise I'll do my best to get to this when I get a slice of time.

I think a couple of the new issues ( #11 ) may be related?

@CodyReichert
Copy link
Owner

Hey @geraldus and @saurabhnanda - a PR was just opened ( #12 ) that should fix some indentation issues. I haven't tried it yet myself, but I hope to today. Are either of you able to give that branch a spin and see if it fixes this specific issue? If so, I'll merge it ASAP.

Thanks again.

@saurabhnanda
Copy link

saurabhnanda commented Sep 1, 2016 via email

@tsukimizake
Copy link
Contributor

@saurabhnanda Hi. I’m the author of the PR.

On ordinary emacs, the fastest way is to copy my patched shakespeare-mode.el, and paste it to an empty emacs buffer, then call M-x eval-buffer. It will load the code to your emacs, and it will work while the process is alive.

I'm not accustomed to spacemacs, but it would be almost the same, maybe.

@CodyReichert
Copy link
Owner

Hey @geraldus - a new version will be on MELPA shortly that should help with these issues. Would you mind giving it a go and letting me know how it works? It works great for me, but I was unable to reproduce the original issue.

Closing for now, but feel free to re-open or continue the discussion.

@geraldus
Copy link
Author

geraldus commented Sep 25, 2016

@CodyReichert sorry for such long delay. I'll try to check it out soon (I do not have Yesod projects right now)!

@Qqwy
Copy link

Qqwy commented Sep 26, 2018

Sooo... any progress here?

@CodyReichert
Copy link
Owner

@Qqwy - it should be fixed AFAIK since #12. Are you still having an issue? Re-open a new issue if you can (lot of info here already).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants