2

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.

1 Answer 1

1

This should only happen in a text-terminal, (where "pasting" ends up simply sending the text char by char to Emacs as if you had typed those characters).

Since Emacs-25, this should not be an issue any more because it uses the "bracketed paste" support from the text-terminal (such that the terminal sends special escape sequences before and after the pasted text).

There is no need to configure it either: "it just works".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .