6

I think you'll get what you want with (setq-default electric-indent-inhibit t) This was meant as a variable for major-modes (rather than for users), but it should take care of your use-case as well.


2

In a terminal the value of [(return)] doesn't apply. You need to use (kbd "RET") instead. (or probably other variations would do, but not [(return)]).


1

Those major modes like python-mode and haskell-mode set (or should set) electric-indent-inhibit.


1

electric-indent-mode is turnedd on by default since Emacs 24.4, according to C-u C-h n 24.4. Fundamental mode is not an ordinary major mode, it's the default major mode for temporary buffers and Emacs creates lots of temporary buffers all the time, such as when you use minibuffer/echo area and make network requests. For example, right now I have 20 buffers ...


1

This is a partial answer to your question, as I could not yet figure out, how to run a hook on fundamental-mode only, but please read on. With the following command, you can activate the Enter behaviour you like. Just run this command with M-x from the current buffer. (It enables this keybinding in all buffers with the same major-mode) (defun my-...


1

I see the need for this every day. The current behavior is really annoying, to the point of distracting me from the flow of writing code productively. I have entered the previous code: def example(): if True: print("Electricity") Entering a newline lines up the next line with the beginning of the print statement. To start a new definition, I ...


1

Typing [control j] instead of RET should jump to the beginning of line when electric-indent-mode is on. If EIM is off, RET jumps to the BOL and C-j to indent.


1

AFAICT what you're seeing is perfectly normal behavior. After if x = 0 sml-mode doesn't know you're about to write then (because it doesn't pay attention to types or even distinguishes between variables and numbers), so it presumes you might be about to write an argument that you might pass to the function 0 [we know 0 can't be a function, but sml-mode ...


1

This is happening because the function electric-indent-post-self-insert-function calls (delete-horizontal-space t) at the end of the line. The only way around this that I see is to copy the code of that function to your dotfile, remove that line, and add/remove the hook post-self-insert-hook. This would be a lot of work, and will probably leave all your ...


1

If your major mode derives from python-mode, than you likely need to make it (setq-local electric-indent-inhibit nil) As for why it's non-nil: python-mode sets this vars to a non-nil value because electric-indent is usually undesirable when indentation is syntactically significant (as in Python).


1

I actually don't need/want most of the electricity. A solution which involves turning off electric-indent-mode but somehow activating the "add whitespace for new lines" feature would be fine with me. This approach might be of interest: In programming modes I invariably want RET to invoke indent-new-comment-line or its mode-specific analogue, which always ...


Only top voted, non community-wiki answers of a minimum length are eligible