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.
The fill-column indicator is a useful functionality especially in prog-mode and its descendants (see Major Modes) to indicate the position of a specific column that has some special meaning for formatting the source code of a program.
The command M-q ( fill-paragraph ) fills the current paragraph. It redistributes the line breaks within the paragraph, and deletes any excess space and tab characters occurring within the paragraph, in such a way that the lines end up fitting within a certain maximum width.
If you prefer menu-based customization, select Options > Show/Hide > Column Numbers, then Options > Save Options. (This might vary depending on Emacs version.) I'm not into the menu-bar, if you are't either you can do M-x customize-variable then put in column-number-mode then you can toggle the mode on or off.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With