19

I would like to set the fill-column in Emacs to 120 for Clojure-mode, but leave it at the default (80) otherwise.

How can I do this in my .emacs file?

Thanks.

Alex Miller
  • 69,183
  • 25
  • 122
  • 167
Ralph
  • 31,584
  • 38
  • 145
  • 282

2 Answers2

29

Add a call to set-fill-column to the clojure-mode-hook.

(add-hook 'clojure-mode-hook
          (lambda ()
            (set-fill-column 120)))

As fill-column is buffer local, it won't affect other buffers. In fact, you can invoke M-x set-fill-column RET 120 to set the fill column in any Emacs buffer interactively.

You can check if a variable is buffer local by invoking the help: C-h v fill-column specifies:

Automatically becomes buffer-local when set in any fashion.

Antoine
  • 5,158
  • 1
  • 24
  • 37
2

fill-column is a buffer-local variable, i.e. it can have unique value in each buffer (if you want). So you can just set it in clojure-mode hook.

Dan Kruchinin
  • 2,945
  • 1
  • 17
  • 21
  • For more information see the Emacs Wiki page on buffer-local variables: https://www.emacswiki.org/emacs/BufferLocalVariable Also see Sect. 11.10 of the Emacs Manual: https://www.gnu.org/software/emacs/manual/html_node/elisp/Buffer_002dLocal-Variables.html#Buffer_002dLocal-Variables – Christian Herenz May 14 '18 at 13:39