Domanda

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.

È stato utile?

Soluzione 2

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.

Altri suggerimenti

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")
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top