0

My global tab-width is set to 4. But in elisp-mode I get 6 spaces per tab in indentation. So the code after auto indenting looks like this:

(defun new-eshell ()
      (interactive)
      (when (one-window-on-screen-p)
            (let* ((lines (window-body-height))
                        (new-window (split-window-vertically (floor (* 0.7 lines)))))
                  (select-window new-window)
                  (buffer-name (eshell "eshell"))
                  )))

How can I set the indentation to 2 spaces?

Update: info for NickD

After I type C-h m I get this:

Enabled minor modes: Auto-Composition Auto-Compression Auto-Encryption
Cl-Old-Struct-Compat Delete-Selection Diff-Auto-Refine Display-Time
Eldoc Electric-Indent File-Name-Shadow Font-Lock Global-Eldoc
Global-Font-Lock Global-Undo-Tree Ivy Line-Number Menu-Bar Mouse-Wheel
Override-Global Pyvenv Shell-Dirtrack Tooltip Transient-Mark Undo-Tree
Yas Yas-Global

(Information about these minor modes follows the major mode info.)

Emacs-Lisp mode defined in ‘elisp-mode.el’:
Major mode for editing Lisp code to run in Emacs.

Doing the same in emacs -Q gives 2 spaces. So, something is wrong with the configs.

8
  • 1
    What does C-h v lisp-body-indent RET say?
    – NickD
    Sep 12, 2020 at 14:16
  • @NickD lisp-body-indent is a variable defined in ‘lisp-mode.el’. Its value is 2
    – user4035
    Sep 12, 2020 at 16:31
  • What exactly are you typing in? Are you typing TABs or are you letting the mode decide the indentation?
    – NickD
    Sep 12, 2020 at 18:11
  • @NickD I am typing <Tab>.
    – user4035
    Sep 13, 2020 at 7:17
  • So why not type anything and let the mode decide the indentation? If you press RET at the end of the first line, does it not indent 2 spaces automatically on the next line?
    – NickD
    Sep 13, 2020 at 12:50

1 Answer 1

1

The error was here: (setq lisp-indent-offset 6). Changed it to (setq lisp-indent-offset 2) and it started to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.