I have configured evolution to use Emacs for me to edit my replies to emails I receive. However, I need to limit my line length to around 72 characters to avoid the odd-ball line wrapping by the mailer (MicroSoft EWS).

I currently have the following line in my .emacs:

(add-to-list 'auto-mode-alist (quote("/tmp/evo*\\'" . text-mode))

So that the files are put in text-mode. However, I would also like to invoke ruler-mode automatically instead of having to do it manually.

But I cannot seem to figure this one out. Is there a text hook I can add a custom function on to deal with this?

(GNU Emacs 24.5.1 on Ubuntu 16.04 and GNU Emacs 24.3.1 on private red-hat like distro)


There is a hook for text-mode, and it's called text-mode-hook. You can use it like so:

(add-hook 'text-mode-hook 'ruler-mode)

You might also be interested in auto-fill-mode, which you can set to hard-wrap your lines at 72 automatically. See the manual for details. The short version is you set the fill column to 72, turn on auto-fill-mode, and then whenever you add text beyond column 72 Emacs will insert a new line at the appropriate place for you. You can also refill a paragraph if the line lengths got disrupted when you made changes somewhere in the middle with M-q.

  • Okay, I really only need to invoke this when the buffer is /tmp/evo* name, so I see a new private defun in my future. Thanks this is helpful. – FoggyKernel Apr 18 '18 at 18:06

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.