3

I thought I had this set fine, however now occasionally emacs will go and insert an 8 character tab, or a 6 or 5 character tab....

Maybe this is caused by the document (this has occurred in a large text file which contains many different tab spacings, though mostly 4 character space increments or regular tab characters).

(setq-default indent-tabs-mode 0)
(setq-default tab-width 4)
(setq indent-line-function 'insert-tab)

The above is the code from my init.el, which leads me to wonder why it is occasionally failing and inserting 6 character tabs.

tobeannounced
  • 1,999
  • 1
  • 20
  • 30
  • You could use `customize-group indent`. – jfs Dec 18 '10 at 10:02
  • Does nil instead of 0 have any effect? – cristobalito Dec 18 '10 at 10:47
  • There could be a mode-specific setting overriding the global default, or a [directory-specific setting](http://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html), or a [file-specific setting](http://www.gnu.org/software/emacs/manual/html_node/emacs/File-Variables.html). What mode is the buffer in? Is there a `.dir-locals.el` file in the current directory or one of its parents? Is there a `Local Variables` section in the file? – Gilles 'SO- stop being evil' Dec 18 '10 at 17:17
  • I just tried by removing the emacs-starter-kit, and only having my init.el, with only those 3 lines listed in the original question, and still no luck. Any suggestions? I think the file must be overwriting it? And when I edit my init.el file, tab doesn't even do anything. – tobeannounced Dec 18 '10 at 23:42

1 Answers1

1

The major mode in question might have its own rules for indentation, but if we're talking about text-mode then indent-line-function should indeed be called (eventually). You might want to double-check that this isn't buffer-local with a different value to the one you thought you'd set, but I would say the more likely culprit is the tab-stop-list variable.

You can read about that and other related things here:
http://www.emacswiki.org/emacs/CategoryIndentation

It's tucked away near the bottom of that list of links, but it's critical to understanding the behaviour of tabs in the absence of automated-indentation rules.

If you enable ruler-mode and the ruler-mode-show-tab-stops variable, it may shed some light on things.

Community
  • 1
  • 1
phils
  • 71,335
  • 11
  • 153
  • 198