this post was submitted on 02 Oct 2023
1 points (100.0% liked)

Emacs

314 readers
2 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
 

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. :)

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here