How do I completely disable all auto-indentation in Emacs? I need to disable it at least for Fundamental mode, but I'm fine with it being disabled globally for the current session.
Please read the rest of this question before declaring it a duplicate. All the other answers I've found are for much more targeted disabling of indentation. I really want to completely disable all auto-indentation for the whole session.
Setting electric-layout-mode
to nil
does not work.
Details
Sometimes I like to compose large Git commit messages with my Windows ASCII text editor. These messages frequently have bullet lists, code blocks, or other things where the precise formatting in my source document is meaningful. My codebase is on Linux, and I connect to the box using a text-only SSH client. When Git enters Emacs for editing the commit message, I want to be able to copy the source commit message to the Windows clipboard then paste it using Windows paste commands. From the perspective of Emacs, I'm typing what was found in the Windows text file. Unfortunately, when Emacs sees indented lines, it adds its own auto-indentation, so I get this huge triangle of whitespace along the left edge of the buffer.
I'm using GNU Emacs 24.3.1.
Workaround
My current workaround is to transfer my Windows text file to a filesystem that's mounted by my Linux host, load the file into Emacs, then use kill and yank to transfer the content. This is a bit clunky.
Example
Here's an example block of text:
a
- b
c
d
Here is how it appears when I paste that into Emacs-under-ssh via MSWin paste:
a
- b
c
d
If I press C-h l
after doing the paste, here is what I see. Note that the newlines are input using C-j
, not RET
.
a C-j C-j SPC SPC - SPC b C-j SPC SPC SPC SPC c C-j
SPC SPC SPC SPC d C-j C-h l
hack-local-variables-hook
-- to essentially undo what other major-modes set as part of their standard initialization.fundamental-mode
is just a little function insidesimple.el
-- i.e.,(kill-all-local-variables) (run-mode-hooks)
.M-x find-function RET fundamental-mode RET
-- you can modify/create your own as needed; however, if you change the name, it will not be used by some functions -- so consider keeping the same name.:set paste
? That basically says "don't touch the pasted text in any way". Which also includes auto-indentation.