Questions tagged [electric-indent]

15 questions
12
votes
2 answers

Change the behaviour of RET (with electric indent) to only indent the new line, not the previous one

https://stackoverflow.com/questions/27077770/how-do-i-disable-electric-indent-on-ret-but-still-keep-other-electric-characters asks and answers how to disable electric indent when pressing RET. All similar questions also seem to stop at "disable…
AnoE
  • 356
  • 1
  • 11
6
votes
1 answer

Prevent electric-indent-mode from reindenting the current line on RET

I am using the Spacemacs configuration files. When I am typing code, electric-indent-mode reindents the current line whenever I press enter. This often causes the indentation to be incorrect when working in languages like Python or Haskell. Here is…
4
votes
2 answers

How can I enable electric indentation for all modes except some?

I am trying to enable electric-indent-mode for all modes except fundamental-mode, where it is just annoying. In my init file, I have the following: (electric-indent-mode +1) (add-hook 'after-change-major-mode-hook (lambda () (if (eq…
tinskip
  • 41
  • 1
3
votes
1 answer

SML Mode weird indentation

Whenever I hit enter to get to the next line when writing a function for example emacs indents an addition tabs worth of space. I'll try to sketch out the problem: fun pow(x : int, y : int) = ----if y = 0 *hits RET* --------then 1 *hits RET* …
2
votes
1 answer

Changing indent-tabs-mode and electric-indent-mode in a buffer

I want to change indent-tabs-mode and electric-indent-mode to nil. There exist three possibilities setq-default setq-local setq I think setq-default only changes the behaviour for major modes where the variable indent-tabs-mode has not been…
Dilna
  • 1,173
  • 3
  • 10
2
votes
1 answer

New line and indent without electric mode

I have come to hate the inconsistency of the electric indent mode and I haven't much of a clue about how it works anyways, so I've disabled it and am trying to get the desired behavior from scratch. I want emacs to indent me to the previous line's…
2
votes
2 answers

Define key binding for a single mode (Fundamental)

In light that this may be a duplicate, but I did not find the answer to my question scouring this site. The default behavior of GNU Emacs appears to have electric-indent-mode enabled, which is fine almost everywhere. However, I would like to change…
Phoenix
  • 341
  • 1
  • 8
1
vote
1 answer

Why is electric-indent-mode adding extra indentation after pressing return twice in org source blocks?

When I try to write code in source block in Org mode, pressing return once acts as expected while hitting it a second time increases the indentation to two levels if it's currently less than that. Here's an example of how the cursor moves when I…
Ivanna
  • 111
  • 1
1
vote
0 answers

yas-expand doesn't trigger reindent in aggressive-indent-mode

I'm trying to make a call to yas-expand doesn't trigger aggressive-indent. I'm guessing this is because yas-expand, for some reason, doesn't trigger a call to after-change-functions into which aggressive-indent--keep-track-of-changes is added when…
Nordlöw
  • 487
  • 3
  • 12
1
vote
0 answers

web-mode turn off auto indent on yank

How to turn off auto indent on yank in web mode? As far as I understand, I must call remove-hook with the name of the hook and the function. But how too find them?
user4035
  • 1,039
  • 11
  • 24
1
vote
1 answer

Previous indentation is discarded on newline

Let's say I have the following code: void foo(){ ~ } I have marked point with ~. When I press enter the electric indentation works as normal but it doesn't keep the indentation for the previous line. void foo(){ // no indentation on this line …
Nathan
  • 13
  • 3
1
vote
2 answers

Getting electric indent behaviour for added chars to "electric-indent-chars"

I am trying to get electric indent behaviour in bazel BUILD files. These are essentially python files, although the structure is extremely simple. Let me give you an example: cc_binary( name = "hello-world", srcs = ["hello-world.cc"], …
Realraptor
  • 1,253
  • 6
  • 17
0
votes
1 answer

Calling c-electric-brace programmatically

I'm currently extending the tempo.el template insertion system to be sensitive to C styles. Specifically, I want to insert braces using c-electric-brace. How programmatically insertion of braces as either (c-electric-brace "{")) or (c-electric-brace…
Nordlöw
  • 487
  • 3
  • 12
0
votes
2 answers

How to make indentation follow beginning of text in list

I want electric-indent or more generally, hitting ENT, to indent the new line to the beginning of text. I'd like this to work with auto-fill as well. Before: 1. This is a long list item that I'll wrap at 50 chars. This is what happens. 2. Next…
young_souvlaki
  • 526
  • 2
  • 13
0
votes
3 answers

Python and electric-indent: newline autoindent disregards previous blank line

This is (yet) another question related to electric-indent-mode and Python, but since I couldn't find what I address here in the other ones, here we go. I find the behavior of electric-indent-mode quite useful in general, but there is a minor thing…