How do I set the Emacs fill-column for a specific mode?

风格不统一 提交于 2019-12-03 16:56:03

问题


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.


回答1:


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.




回答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.



来源:https://stackoverflow.com/questions/8080495/how-do-i-set-the-emacs-fill-column-for-a-specific-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!