Starting at Emacs 24.4 (I think), c-j and ret have been swapped, so indent is now called after ret. And those indents in text mode are indent-relative, so, when you paste indented code, the code is pasted in a diagonal instead of aligned:
# copied code
line1
line2
line3
# pasted
line1
line2
line3
I can solve that setting electric-indent-mode
off (flip/flop command), but I like the indent-relative behavior while I am writing in text mode. I want to switch it off only while pasting text.
Does anyone have code I could use to set a paste shortcut that call electric-indent-mode, paste from clipboard and set on again electric-indent-mode?
I would appreciate any didactic explanation of the code, so I can remember my forgotten elisp.