0

I am running Emacs 24.2-18 on Fedora 19 64-bit. I have set in my .emacs file for the C default style to be "linux", the default tab width to be 4, the indentation to use tabs, the default C offset to be the tab width, and the Perl offset to be the tab width. But whenever I start Emacs, the tab width and C offset are 2. The style is listed as "linux", but when I set style in Emacs to "linux" it changes the tab width and C offset. So the initial default style is not being loaded correctly, and I have no idea what is going on. Here are some files of mine. The .emacs is http://paste.fedoraproject.org/23068/13729669/, the contents of the ~/.emacs.d directory are http://paste.fedoraproject.org/23070/67043137 (smartparens and archive are directories), and my installed software relating to Emacs via the Fedora software manager are:

  • emacs.x86_64 1:24.2-18.fc19 @fedora
  • emacs-auto-complete.noarch 1.3.1-5.fc19 @fedora
  • emacs-auto-complete-el.noarch 1.3.1-5.fc19 @fedora
  • emacs-common.x86_64 1:24.2-18.fc19 @fedora
  • emacs-filesystem.noarch 1:24.2-19.fc18 @updates/18
  • emacs-vala.noarch 0.20.1-1.fc19 @fedora
  • emacs-vala-el.noarch 0.20.1-1.fc19 @fedora

Something to note is that emacs-filesystem.noarch is a Fedora 18 package, not a Fedora 19 package. Is there any reason for why my tab width and C offset are getting overridden like this? I have no idea what is going on.

Sammidysam
  • 43
  • 1
  • 7

2 Answers2

1

Try defining you own style, based on "linux" and overriding the offset:

(setq-default tab-width 4
              indent-tabs-mode t)

(c-add-style "my-style"
             `("linux"
               (c-basic-offset . ,tab-width)))

(setq c-default-style "my-style")
François Févotte
  • 19,520
  • 4
  • 51
  • 74
  • I changed my `.emacs` to http://paste.fedoraproject.org/23118/72977155/ (note lines 49-57) and now tab width is correctly 4 but c-basic-offset is still 2 when I go to a C file as shown [here](http://s11.postimg.org/tr5nfibz7/emacs.png). I changed `.emacs` to http://paste.fedoraproject.org/23119/72977435 and then the c-basic-offset is off until I manually set the style to my-style, then it works fine. Could this be a bug in the program? – Sammidysam Jul 04 '13 at 22:34
  • Using a hook, I've gotten it to with with C files. It does not work, however, with in Vala files with vala-mode unless I set the variable from inside of Emacs. – Sammidysam Jul 05 '13 at 19:14
1

The culprit is auto-indent-mode which is used in the .emacs file. Auto-indent-mode will force an offset on the major mode, and the default value is 2, which you did not customize. Because of that, it forced an offset of 2 on all your files.

Sammidysam
  • 43
  • 1
  • 7