Emacs: Set fill-column in Change Log Mode
Asked Answered
C

1

5

Very specific question that I hope is not too dumb.

(setq-default fill-column 120) sets the width of the buffer fill to 120 columns. Default for me otherwise is 74.

This command, when put in my .emacs file, works for all major modes I use (C++, Perl, etc). However, it seems not to affect the Change Log major mode (change-log-mode-hook). Do you know how I can set the fill-column for this mode?

Cnut answered 21/3, 2011 at 4:7 Comment(0)
D
7

First, you have to set it (I'm just making sure you got this part right):

(defun my-change-log-mode-hook ()
  (setq fill-column 120))

(add-hook 'change-log-mode-hook 'my-change-log-mode-hook)

Secondly, you have to make sure that there is no directory local variables setting that overrides this. For example, when editing the source code of Emacs itself, fill-column will be set to 74 for change log mode and 70 elsewhere, overriding the value you specified in µour hook. These are defined in files named .dir-locals.el and can be place in or above the directory that contains the edited file.

Detach answered 21/3, 2011 at 7:25 Comment(2)
Great, that works, thank you. In general, why do I need to add-hook when I already set the default value with (setq-default fill-column 120)?Cnut
Because change-log-mode explicitly sets the variable, hiding the global variant of it. I guess that you could have solved this by using kill-local-variable in your hook.Detach

© 2022 - 2024 — McMap. All rights reserved.