When writing text (Fundamental) in auto-fill-mode, the second line after an automatic line break is indented.

This is to be expected, since the doc says:

Otherwise the new line is indented, as though you had typed < TAB > on it

This is not practical for me, for example when I write commit messages. They tend to look like this:

Make the world a better place

This is an explanation of the reason for a change I made, for example
    a bug fix or a new feature which will save the world from all evil
    and nastiness.

How can I make auto-fill-mode skip the "new line is indented" part?

EDIT Starting emacs with no init file, it works fine.

Luckily I version control my init files, and I could find when this behavior started to happen. The commit introducing the issue does not seem like touching anything related, though:

Commented out offending lines in init.el.

----------------------------------- init.el -----------------------------------
index 368319c..e1b06e8 100644
@@ -59,11 +59,11 @@
      (delete-region (point) (progn (skip-chars-forward " \t") (point)))))

-(set-default-font "-outline-Lucida Console-normal-normal-normal-mono-11-*-*-*-c-*-iso8859-1")
+;(set-default-font "-outline-Lucida Console-normal-normal-normal-mono-11-*-*-*-c-*-iso8859-1")
 ; Default font 9 pt
 ;(set-face-attribute 'default nil :height 90)
 ;(set-default-font "-outline-Lucida Console-normal-normal-normal-mono-11-*-*-*-c-*-iso8859-1")
-(set-default-font "Lucida Console-9")
+;(set-default-font "Lucida Console-9")
 ;(set-face-attribute 'default nil :height 90)

@@ -83,13 +83,13 @@
  '(egg-enable-tooltip t)
  '(egg-git-command "c:\\Program\\git\\bin\\git")
  '(tab-stop-list (quote (4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120))))
   ;; custom-set-faces was added by Custom.
   ;; If you edit it by hand, you could mess it up, so be careful.
   ;; Your init file should contain only one such instance.
   ;; If there is more than one, they won't work right.
- '(font-lock-comment-face ((t (:foreground "limegreen" :slant oblique))))
- '(font-lock-preprocessor-face ((t (:inherit font-lock-builtin-face :foreground "orange" :weight bold)))))
+; '(font-lock-comment-face ((t (:foreground "limegreen" :slant oblique))))
+; '(font-lock-preprocessor-face ((t (:inherit font-lock-builtin-face :foreground "orange" :weight bold)))))

 (global-set-key [C-tab] 'other-window)
@@ -148,11 +148,12 @@ kernel."
 (setq-default buffer-file-coding-system 'dos)

+; This is not working in emacs 24. Use M-x load-theme instead, suggestedly with
+; the theme tango-dark (not too long from zenbrun).
 ; Color theme
-(require 'color-theme)
-(require 'color-theme-zenburn)
+;(require 'color-theme)
+;(require 'color-theme-zenburn)
 ;;Emacs.pane.menubar.* does not seem to work?
 ;(setq Emacs.pane.menubar.background 'darkGrey)

But more than that, I am in the dark.

  • 1
    You could use describe-key function which is bound to C-h k to learn which function RET is bound to. It might help you to investigate the problem. – Mustafa Simav Sep 5 '13 at 12:17

Check indent-line-function.

I inadvertently had this:

(setq indent-line-function 'insert-tab)

in my init file. The reason the old commit was working is only that errors while running through the init file made it stop and never reach the indent-line-function line. It was meant only for C code but was used by other modes as well.


I don't see this. Do you see it starting from emacs -Q (no init file)?

When I do that in fundamental mode, the second line starts in column 1, just like the first line.

See also (emacs)Adaptive Fill --- perhaps that will clarify some things.

  • You are correct that it seems to work with -Q, my configuration must be wrong somewhere. The thing is I only see that in fundamental mode, not in e.g. text mode, but I haven't voluntarily touched fundamental explicitly. How can I check what I might have done to fundamental? – Gauthier Sep 5 '13 at 6:42
  • And I could pinpoint when things started to go wrong, see my edit. – Gauthier Sep 5 '13 at 7:02
  • Pinpoint it further. Uncomment some of the stuff you commented out until you narrow it down to the minimal change that breaks things. If that makes use of other code (e.g. another library) then check whether that library code changed. And so on. If in the end you can come up with a minimal recipe that shows that something in Emacs itself changed and broke things, then use M-x report-emacs-bug. In sum, you need to track down just what breaks the behavior. – Drew Sep 5 '13 at 14:22
  • Problem solved. I had set indent-line-function to 'insert-tab long ago. I thought only for C, but I was wrong. In the old commits, reading the init file caused errors (since running with a newer emacs than a the time of the commit). No code after the first error was run, omitting the setting of the indent-line-function. In hindsight, a good answer to my question would have been to ask if I was setting indent-line-function anywhere (do write this answer if you want the rep :) ). – Gauthier Sep 5 '13 at 20:12
  • I think you can answer your own question and get credit for it. ;-) – Drew Sep 5 '13 at 21:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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