0

I have a very simple .emacs file in my home directory, I'm trying to get it to indent 3 spaces when I hit tab. instead I always get 2 spaces, which is the default behavior. It seems to completely ignore my .emacs file.... ?

here is the contents of the .emacs. If it's correct (seems to be...) it must be getting ignored? It's damn short, not much to go wrong:


;; -*-Emacs-Lisp-*-

;; This file is designed to be re-evaled; use the variable first-time
;; to avoid any problems with this.

(setq c++-mode-hook
      (function (lambda ()
          (setq indent-tabs-mode nil)
          (setq c-indent-level 3))))

(custom-set-variables
 '(tab-stop-list (quote (3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60 63 66 69 72 75))))

(setq indent-tabs-mode nil)
(setq tab-width 3)
  • Add an intentional syntax error to it and restart emacs. If it doesn't complain, your init file is being ignored. – Kilian Foth Oct 31 '11 at 11:38
  • ok, tried that, it didn't complain. very odd. does emacs use some environment variable to find the .emacs file? it's simply sitting in my home dir, on ubuntu. nothing fancy. `ls -l ~/.emacs` gives me `-rwxrwxrwx 1 ivan ivan 428 2011-10-31 07:29 /home/ivan/.emacs` – user1021810 Oct 31 '11 at 14:31
  • possible duplicate of [Emacs C++-mode incorrect indentation?](http://stackoverflow.com/questions/663588/emacs-c-mode-incorrect-indentation) – Trey Jackson Oct 31 '11 at 14:40

2 Answers2

0

I'd like to reopen this old question. @user1021810 was able to fix her/his problem by adding the homedir to $PATH. I did that too. But it seems that my .emacs is being ignored. Additionally, I also tried

  1. creating a file .emacs.el in my homedir
  2. creating a file init.el in ~/.emacs.d dir

Nothing seems to work. Ideas sought.

Thanks.

Update: The contents of my .emacs file are valid because those effects take place as soon as I load the file manually.

N. CHATURV3DI
  • 253
  • 1
  • 12
0

Try setting the variable c-basic-offset

(setq c-basic-offset 3)

See the cc-manual section Getting Started for more details. There are many many ways to customize the indentation behavior.

Trey Jackson
  • 73,529
  • 11
  • 197
  • 229
  • 2
    you did not read my comments; it does not matter what I put into my .emacs file, it is never sourced by emacs for some reason. – user1021810 Oct 31 '11 at 15:03
  • ok, it seems my homedir was not in $PATH. Now, (setq c-basic-offset 3) has worked and all is good. – user1021810 Oct 31 '11 at 15:25
  • @user1021810 You should be able to edit your question to reflect the clarifications you have (instead of putting them as comments). – Trey Jackson Oct 31 '11 at 16:29