2

I am new to emacs and I am wondering if I can set the writeroom-mode to always be on. I want it to be on as I start up emacs and as I open new buffers or switch between them.

All help is highly appreciated!

  • 1
    You could instead separately enable each of the things writeroom does, given that it seems to be designed to be turned on and off, and does not support all major modes. – Squidly Nov 10 '14 at 15:27
  • 1
    you might get a faster response if you explained what whiteroom is. – sds Nov 10 '14 at 18:45
  • If anyone just wants to put writeroom-mode on *just* when you're using org-mode then see here for an answer: https://emacs.stackexchange.com/a/52667/24053 – nmu Sep 15 '19 at 15:06

2 Answers2

2

So now that you've provided a link (albeit in your other question), I can see that the library provides a global minor mode which only turns itself on for a specific configurable set of major modes.

The following will redefine the function which makes that decision, so that if the writeroom-major-modes is nil (empty list), it will turn on for any major mode.

I also changed the existing test to check for a derived mode match, rather than simply an exact match. That way the default value of '(text-mode) would match not only text-mode, but every mode derived from text-mode. Not strictly relevant to your question, but perhaps useful if you find the "all modes" approach overkill.

(eval-after-load 'writeroom-mode
  '(defun turn-on-writeroom-mode ()
     "Turn on `writeroom-mode'.
This function activates `writeroom-mode' in a buffer if that
buffer's major mode is a member of `writeroom-major-modes',
or derived from one of those modes.

If `writeroom-major-modes' is nil, activate `writeroom-mode'
in ALL buffers."
     (when (or (not writeroom-major-modes)
               (apply 'derived-mode-p writeroom-major-modes))
       (writeroom-mode 1))))

Whether you need to explicitly load/require the library depends on how you've installed it; but as you're using the library already, that's presumably been taken care of, meaning it's then just a case of:

(global-writeroom-mode 1)

Alternatively (to all of the above), you could ignore the global mode provided, and create your own alternative global minor mode, as described in How to enable a non-global minor mode by default, on emacs startup?

Edit: Well I've had a bit of a play with writeroom-mode, and it would seem there are very good reasons why its global mode was a bit conservative. You might still find the "derived mode" improvement useful, but I suspect trying to make this particular mode 100% global is not going to work very well at all.

Community
  • 1
  • 1
phils
  • 71,335
  • 11
  • 153
  • 198
1
  • If write-room mode is a globalized minor mode, then just turn it on in your init file.

  • If write-room mode is a minor mode and there is no globalized version of it, you can use define-globalized-minor-mode to define such a globalized mode. Then turn that on in your init file.

  • If write-room is a major mode then you can customize option auto-mode-alist to turn it on for any number of file-name extensions.

  • If write-room is an ordinary function (not a major-mode function) then you can automatically turn it on by using add-hook to add it to the major modes you use.

And yes, if you specified what write-room is (in Lisp terms) then answering your question would be easier.

Drew
  • 29,895
  • 7
  • 74
  • 104