Hello Emacs users, I’m currently trying to re-do my own emacs configuration but after facing thousands of issues, indenting buffers is the one thing that’s going to turn me bald in a matter of hours.

I’m trying to work with multiple languages, Go, Rust, Python, JS/TS, etc. The one thing I haven’t figured out correctly is proper indentation without having to do keyboard gymnastics. I know that Emacs is more of a DIY thing, so any light shed here would be of great help.

I’ve already tried (add-hook …), using the :config section in my (use-package go-mode) declarations and more but none of them are having any visible effect.

Furthermore, I saw this issue with Go and I heavily suspect other programming languages won’t come out as clean as I think.

Every time I edit a Go file, when adding a new line to anything that needs indentation (e.g: a function body, if, for, etc.) Two “4 spaces” tabs are inserted no matter what. Even when I press the `` key I have to backspace ALWAYS, also some closing delimiters like }) don’t align properly, but I suspect that’s another issue maybe fixed by puni.

The “best” thing I could do to prevent newlines from getting messed up on creation was turning off electric-indent, I’ve heard mixed opinions on that, some say it’s great, some say it’s terrible, I don’t really know. Without electric-indent I don’t have to backspace two tabs on a newline, but TAB still creates those two tabs, even when my modeline reports (TABx4). Here is a snippet of the important stuff in my configuration file.

(setq-default c-basic-offset 4
              tab-width 4
              indent-tabs-mode t
              standard-indent 4)

;; jsjsjsjs
(electric-pair-mode 1)

;; Disable electric-indent messing up my code >:(
(setq electric-indent-inhibit t
      electric-indent-mode nil)

If any of you could spare your elisp-fu powers to me, I would be extremely thankful. Thanks for your time in advance. :)