Git Product home page Git Product logo

writeroom-mode's Introduction

Writeroom-mode

writeroom-mode is a minor mode for Emacs that implements a distraction-free writing mode similar to the famous Writeroom editor for OS X. writeroom-mode is meant for GNU Emacs 24, lower versions are not actively supported.

Installation

writeroom-mode can be installed through the package manager from Melpa. If installing manually, make sure to also install its dependency visual-fill-column.

Usage

writeroom-mode can be activated in a buffer by calling M-x writeroom-mode RET. A screen shot can probably explain best what writeroom-mode does. In the default configuration, after activating writeroom-mode, your screen looks like this (modulo the colour theme, of course):

screenshot

By default, writeroom-mode does the following things:

  • activate fullscreen
  • disable transparency
  • disable the menu bar
  • disable the tool bar
  • disable the scroll bar
  • enable a bottom window divider of 1 pixel
  • maximise the current window (i.e., delete all other windows in the frame)
  • place the fringes outside the margins
  • disable the mode line
  • add window margins to the current buffer so that the text is 80 characters wide

The last three effects are buffer-local. The other effects apply to the current frame. Because writeroom-mode is a minor mode, this isn't entirely on the up and up, since minor modes aren't supposed to have such global effects. But writeroom-mode is meant for distraction-free writing, so these effects do make sense.

All these effects can be disabled or customised. In addition, there are several more options that are disabled by default but can be enabled in the customisation buffer.

Multiple writeroom-mode buffers

It is possible to activate writeroom-mode in more than one buffer. The global effects are of course activated only once and they remain active until writeroom-mode is deactivated in all buffers. Alternatively, if you wish to use writeroom-mode in all buffers that have a particular major mode (e.g., text-mode, markdown-mode), you can use the global minor mode global-writeroom-mode. This function enables the global effects and activates the buffer-local effects in all (current and future) buffers that have a major mode listed in the user option writeroom-major-modes (by default only text-mode).

When global-writeroom-mode is active, the function writeroom-mode can still be called to enable or disable writeroom-mode in individual buffers (regardless of their major mode, of course). Calling global-writeroom-mode again disables writeroom-mode in all buffers in which it is active, also those in which it was activated manually.

Frame effects

Most of the global effects that writeroom-mode enables are handled by setting specific frame parameters. This means that they apply to the current frame. If you switch to another frame and display a writeroom-mode buffer, only the buffer-local effects will be visible.

writeroom-mode tries to make sure that it only affects one frame, and that it restores that particular frame when it is deactivated in the last buffer. This means it should be safe to activate writeroom-mode in one frame and deactivate it in another. Killing the writeroom-mode frame should also be safe.

The affected frame is always restored to its original state, before writeroom-mode was activated, even if you change any of the frame parameters manually while writeroom-mode is active.

Customisation

The customisation buffer for writeroom-mode can be opened with M-x customize-group RET writeroom RET. It provides the options listed below.

Added Width Left

Extra columns added to the left side of the text area. These columns are added after the text area is centred, so that the text area is essentially off-set to the left by the amount provided. This can be an integer or a function of no arguments that should return an integer. By default, this is used to accommodate line numbers if display-line-numbers-mode is active, so that the actual text is still centred.

Border Width

Width of the border around the text area. Disabled by default, see writeroom-global-effects to enable the border.

Bottom Divider Width

Width in pixels of the bottom window divider. Default value is 1. The bottom window divider helps in distinguishing the minibuffer from the text area, and also in distinguishing two windows split top-to-bottom.

Extra Line Spacing

Increase the line spacing. Can be an absolute value (the number of pixels to add to the line) or a number relative to the default line height. Disabled by default.

Fringes Outside Margins

If set, place the fringes outside the margins. writeroom-mode expands the window margins, causing the fringes to be pushed inside, which may be visually distracting. This option keeps the fringes at the window’s edges. Unset it if you prefer to have the fringes close to the text.

Fullscreen Effect

Effect to apply when writeroom-mode activates fullscreen. Can be fullboth, which uses the entire screen (i.e., window decorations are disabled and the window manager’s panel or task bar is covered by the Emacs frame) or maximized, in which case the Emacs frame is maximised but keeps its window decorations and does not cover the panel.

Global Effects

List of global effects:

  • fullscreen
  • transparency
  • scroll bar
  • menu bar
  • tool bar
  • bottom window divider
  • border (add a border around the text area; disabled by default)
  • sticky (display the window on all virtual workspaces; disabled by default)

Each option can be enabled or disabled individually.

Header Line

The header line format to use. This option can be nil (the default), which disables the header line entirely, it can be t, which retains the header line, or it can be set to a customised format. Note that Emacs does not use the header line by default, so changing this option from the default only makes sense if you have a customised header line that you do not want to be displayed in writeroom-mode buffers.

As an additional possibility, this option can be set to the symbol mode-line, in which case the standard mode line is shown in the header line.

Maximize Window

Maximise the current window in its frame, i.e., delete all other windows.

Writeroom-mode Disable Hook

Hook run when writeroom-mode is disabled. This hook can be used to disable effects that are enabled in writeroom-mode-enable-hook (see below).

Writeroom-mode Enable Hook

Hook run when writeroom-mode is enabled. This hook is run just before writeroom-mode-hook is run. Unlike writeroom-mode-hook, it is not run when writeroom-mode is disabled.

Note, however, that if you have a minor mode that you want activated and deactivated along with writeroom-mode (e.g., variable-pitch-mode), it is usually more convenient to simply add it to the option writeroom-local-effects (see below).

Left Shift

The number of columns by which the text area is shifted to the left (if positive) or right (if negative). This can be a number or a list of functions that each return a number, which are then summed. By default, the text area is shifted by the width of the line number column.

Local Effects

A list of functions that enable buffer-local effects. These functions are called with the argument 1 when writeroom-mode is enabled and with the argument -1 when it is disabled.

You can add minor modes to this option that you want activated together with writeroom-mode but also deactivated again when you deactivate writeroom-mode. You can, of course also add your own functions to this option, provided they take the arguments 1 and -1.

Mode Line

The mode line format to use. This option can be nil (the default), which disables the mode line altogether, it can be t, which retains the mode line, or it can be set to a customised format to only show some information. If the latter option is chosen, the mode line shows only the file name and the file modification status, but the format can be customised. See the documentation for the variable mode-line-format for details. If you set this option, it may be more visually pleasing to set the option Bottom Divider Width to 0.

Mode Line Toggle Position

If you disable or customise the mode line, you may sometimes want to see the entire mode line. writeroom-mode provides the function writeroom-toggle-mode-line (see below) to do this. You can specify where you want to make the mode line visible when using this function: in the mode line itself, or in the header line.

Note that the default value of this option is to display the mode line in the header line, because for some reason that is more reliable. (Toggling the mode line multiple times in a row does not always work very well.)

Restore Window Config

Restore the window configuration that existed before writeroom-mode was activated. This is primarily useful if you use writeroom-mode in only a single buffer, since the window configuration that is restored is the one that existed at the moment when writeroom-mode is called for the first time. Disabled by default.

Width

Width of the text area. Can be specified as an absolute value (number of characters) or as a fraction of the total window width (in which case it should be a number between 0 and 1).

Changing the width interactively

The width of the text area in the current buffer can be changed interactively with the commands writeroom-increase-width and writeroom-decrease-width, which increase and decrease the text width by 2 characters. There is also a more general command writeroom-adjust-width, which adjusts the width of the text area by the amount passed as prefix argument. That is, calling it with M-5 M-x writeroom-adjust-width increases the text width by 5 characters. Calling writeroom-adjust-width without prefix argument resets the width to the default value.

These commands are not bound to any keys, but you can bind them in the following manner (the actual keys are just examples, of course; choose any keys you like):

(with-eval-after-load 'writeroom-mode
  (define-key writeroom-mode-map (kbd "C-M-<") #'writeroom-decrease-width)
  (define-key writeroom-mode-map (kbd "C-M->") #'writeroom-increase-width)
  (define-key writeroom-mode-map (kbd "C-M-=") #'writeroom-adjust-width))

Text size adjustments

Text size adjustments are taken into account in calculating the margins, which means that if the text size is increased, the margins are decreased, so that the number of characters on the line remains more or less the same. Since it is not possible to detect interactive text size adjustments (e.g., with text-size-adjust), the adjustments of the margins cannot be made automatically. You need to force a redisplay, e.g., with the command redraw-display.

Alternatively, you can advise the command you use for adjusting the text size (most likely text-size-adjust):

(advice-add 'text-scale-adjust :after
  #'visual-fill-column-adjust)

Displaying the mode line

By default, writeroom-mode disables the mode line. If you occasionally need to see the full mode line, you can use the command writeroom-toggle-mode-line, which makes the mode line visible. Calling it again hides the mode line. This command is bound to s-? (s is the super key, i.e., the Windows key on PCs, the ⌘ key on Macs), but it can be rebound by putting something like the following in your init.el:

(with-eval-after-load 'writeroom-mode
  (define-key writeroom-mode-map (kbd "s-?") nil)
  (define-key writeroom-mode-map (kbd "<some-key>") #’writeroom-toggle-mode-line))

The first define-key disables the binding for s-?. Substitute your preferred key binding in the second line to bind writeroom-toggle-mode-line to it.

Adding global effects

It is possible to add your own global effects to writeroom-mode. If there is a global minor mode that you want turned on when writeroom-mode is activated for the first time, you can simply add it to the user option writeroom-global-effects by checking the box "Custom effects", clicking the [INS] button and adding the function to the list.

Alternatively, you can also write your own function. This function should take one argument and enable the effect if the argument is 1 and disable it if the argument is -1. To give an example, if you want to activate a minimalist colour theme in writeroom-mode, you can write the following function:

(defun my-writeroom-theme (arg)
  (cond
   ((= arg 1)
    (enable-theme 'minimalist-dark))
   ((= arg -1)
    (disable-theme 'minimalist-dark))))

If your function affects the frame, you should make sure that it only affects the writeroom-mode frame by passing the variable writeroom--frame to all frame-changing functions. If your frame effect involves changing the value of a frame parameter, you may be able to use the macro define-writeroom-global-effect; see its doc string for details.

In principle, it is not a good idea to define a custom global effect function as a toggle, but if you are sure you'll only ever use a single frame, it should be safe enough. For example, sometimes setting the fullscreen frame parameter does not work. In this case, if you're on Linux, you could send an X client message directly:

(defun my-toggle-fullscreen (_)
  (x-send-client-message nil 0 nil "_NET_WM_STATE" 32
                         '(2 "_NET_WM_STATE_FULLSCREEN" 0)))

Other similar modes

There are two other modes that I know of that also implement a distraction-free writing environment: Darkroom and Olivetti. Both are narrower in scope than writeroom-mode.

In particular, both Darkroom and Olivetti only affect the buffer (or more precisely, its window), not the frame. They centre the text by adding window margins, and optionally resize the text and hide the mode line. They do not make Emacs fullscreen and do not remove the menu and tool bars, the scroll bar or the window decorations. This is a conscious choice (see, e.g., this pull request and this issue), motivated by the fact that affecting the frame in this way may lead to problems when using multiple Emacs frames.

It is true that changing the appearance of the current frame (the global effects, as writeroom-mode calls them) is risky if you use multiple frames. writeroom-mode applies its global effects to the frame that is current when it is first activated and tries to make sure that only this frame is ever affected. Therefore, it should be safe to use writeroom-mode, even if you use multiple frames. (If you do run into issues, however, I would welcome a bug report.) Alternatively, you can turn off all global effects and use writeroom-mode in much the same way as Darkroom or Olivetti.

Another difference with Darkroom and Olivetti is that writeroom-mode tries to be as customisable as possible. It has a larger number of customisation options than either of the other modes and also provides a way to add custom global effects. This may or may not be what you need, of course.

writeroom-mode's People

Contributors

joostkremers avatar purcell avatar sixshotx avatar wbolster-eiq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

writeroom-mode's Issues

Size of the font and other things

Very useful minor mode for me. Thank you.
It would be very helpful to be abble to:

  • define the size of the fonts
  • define the size of width relatively to the size of the window
  • adjust the size of the window to the size of the screen (to avoid to have to click the green maximize/zoom twice on my mac)
    (but I'm not able to programm anything)

Margins disappear after save

Hi, I'm on emacs GNU Emacs 25.2.1, after saving the buffer the text jumps from the center to the left. Edits and changes are keeping them to the left, until I press M-x; as soon as pressed, everything goes back to the center until the next save.

I don't know how to debug it,
Thanks, Nicolò

how to add custom global effects

Hi!

Here, it looks like the fullscreen mode doesn't work. It may be because of my exotic window manager (xmonad), but i was able to make emacs go to fullscreen mode using:

(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
                       '(2 "_NET_WM_STATE_FULLSCREEN" 0))

as documented here. now I am trying to figure out how to send this in a custom function but i can't figure out how to add functions to the list of global effects through "customize": i can check the "custom effect" checkbox, but then i can't enter the function name there and the setting is lost after reloading the page.

i have looked through the writeroom.el source code and i also can't figure out where exactly the fullscreen mode is toggled (or where writeroom-toggle-fullscreen is used or how).

Changing default font dimension mess up the writing area width

Please, check the following procedure:

  1. open a file with a certain font dimension (i.e. 10)
  2. type M-x writeroom-mode
  3. type it again, in order to deactivate it
  4. change the default font dimension (Options -> Set Default Font)
  5. activate again writeroom-mode
    You should see the text shrinking in a very narrow area.

P.S. do you want me to provide a screen capture?

Window size remains fixed when starting writeroom-mode

Here is what is happening.

  • Start Emacs
  • type M-x writeroom-mode without manually maximizing the window
  • Emacs goes fullscreen but the actual buffer has the original window's dimension, as shown here

Emacs version:
GNU Emacs 24.3.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.8.6) of 2014-01-02 on alphard, modified by Debian
Ubuntu 13.10

info-document-missing-dir-entry

Hi,

First, thank you for your wonderful mode, I've been using it for years, and thank you for writing solid documentation :-) I'm packaging writeroom-mode for Debian and I ran into an issue with the provided info file. As I'm not familiar with info docs I think lintian is expecting this syntax:
@dircategory Package short info
@direntry
* menu item 1: (infofile). Description.
* menu item 2: (infofile2). Description.
@EnD direntry

Rather than the existing:
INFO-DIR-SECTION Emacs START-INFO-DIR-ENTRY * Writeroom mode:
(writeroom-mode). Distraction-free writing. END-INFO-DIR-ENTRY
^_
File: writeroom-mode.info, Node: Top, Next: Writeroom-mode, Up: (dir)

Top


  • Menu:

Downstream repo can be browsed here:
https://anonscm.debian.org/cgit/pkg-emacsen/pkg/writeroom-mode.git/
And here is the remote:
https://anonscm.debian.org/git/pkg-emacsen/pkg/writeroom-mode.git

Cheers,
Nicholas

Large images and margins

If some images which are larger with respect to the margins they will be cut. Is it possiblle to avoid this issue? I would like to see the full image with the text respecting the margins.

OSX XQuartz malloc error

writeroom-mode version: 20140326.2059
emacs version: 24.3.91
XQuartz version: 2.7.6
OSX: 10.9.3

Not sure if anyone else has experienced this issue, but whenever I open emacs in X11 and try to enter writeroom-mode XQuartz will crash with this error. This may be due to the new XQuartz update a few days ago. There doesn't seem to be issues with other users of of writeroom on OSX.

emacs(59989,0x7fff7528e310) malloc: *** error for object 0x7fff5fbfd6b0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Fatal error 6: Abort trap
Backtrace:
0   emacs                               0x000000010010a83a emacs_backtrace + 90
1   emacs                               0x00000001000ebaa1 terminate_due_to_signal + 97
2   emacs                               0x000000010010a6d6 deliver_fatal_thread_signal + 134
3   libsystem_platform.dylib            0x00007fff8af225aa _sigtramp + 26
4   ???                                 0x0000000000000000 0x0 + 0
5   libsystem_c.dylib                   0x00007fff8c046b1a abort + 125
6   libsystem_malloc.dylib              0x00007fff8842c07f malloc_get_zone_name + 0
7   libX11.6.dylib                      0x0000000100ff7d65 XFree + 9
8   emacs                               0x00000001000b7835 x_set_frame_alpha + 485
9   emacs                               0x00000001000c207a x_frame_rehighlight + 314
10  emacs                               0x00000001000c5237 x_focus_changed + 279
11  emacs                               0x00000001000c287d handle_one_xevent + 381
12  emacs                               0x00000001000baf48 event_handler_gdk + 264
13  libgdk-x11-2.0.0.dylib              0x0000000100b1d357 gdk_event_translate + 83
14  libgdk-x11-2.0.0.dylib              0x0000000100b1ec85 _gdk_events_queue + 173
15  libgdk-x11-2.0.0.dylib              0x0000000100b1fee5 gdk_event_dispatch + 35
16  libglib-2.0.0.dylib                 0x0000000100ef8168 g_main_context_dispatch + 456
17  libglib-2.0.0.dylib                 0x0000000100ef880f g_main_context_iterate + 997
18  libglib-2.0.0.dylib                 0x0000000100ef88de g_main_context_iteration + 115
19  libgtk-x11-2.0.0.dylib              0x00000001007e8b75 gtk_main_iteration + 40
20  emacs                               0x00000001000bbc7b XTread_socket + 75
21  emacs                               0x00000001000f267f gobble_input + 287
22  emacs                               0x00000001000f8fb5 unblock_input + 69
23  emacs                               0x0000000100010393 x_set_frame_parameters + 1027
24  emacs                               0x000000010000cd33 Fmodify_frame_parameters + 163
25  emacs                               0x000000010016bd5b Ffuncall + 779
26  emacs                               0x00000001001a4902 exec_byte_code + 2338
27  emacs                               0x000000010016ca3f funcall_lambda + 847
28  emacs                               0x000000010016bcd2 Ffuncall + 642
29  emacs                               0x00000001001a4902 exec_byte_code + 2338
30  emacs                               0x000000010016bcd2 Ffuncall + 642
31  emacs                               0x00000001001a4902 exec_byte_code + 2338
32  emacs                               0x000000010016bcd2 Ffuncall + 642
33  emacs                               0x000000010016c3cd call1 + 45
34  emacs                               0x0000000100173ee4 mapcar1 + 644
35  emacs                               0x00000001001740c3 Fmapc + 83
36  emacs                               0x000000010016bd5b Ffuncall + 779
37  emacs                               0x00000001001a4902 exec_byte_code + 2338
38  emacs                               0x000000010016bcd2 Ffuncall + 642
39  emacs                               0x00000001001a4902 exec_byte_code + 2338
40  emacs                               0x000000010016bcd2 Ffuncall + 642

Can writeroom-fullscreen-effect set to nil?

I don't want writeroom to alter my frame state, my frame is usually in fullscreen or maximised state when I invoke writeroom.

The document for writeroom-fullscreen-effect says it supports two values, 'fullboth or 'maximized. I tried to set it to nil, and when I enable writeroom, it cancels the fullscreen effect for my frame and restores it to a normal frame.

Can I stop writeroom from changing my frame state?

Top margin

Just a (minor) enhancement. When opening buffer in writeroom-mode it would be nice to have a three lines top margin.

Start screen remaining in the writeroom buffer

  1. type on your shell emacs mydoc.txt
  2. Emacs opens up with the frame horizontally split, with the mydoc.txt content in the upper buffer and the start screen content in the lower one. The cursor is in the upper buffer.
  3. type M-x writeroom-mode without maximizing the window manually before.
    before
    The lower buffer content goes into the new frame but in (almost) the same position it was before, with the unmaximized window.
    after

Option to hide fringes

It would be cool to hide fringes as an option in writeroom-mode, such that it is restored after exiting writeroom-mode. I can take a stab at it, mainly writing this issue in case I missed something :)

Unable to scroll in the margins

Sometimes I use the mouse wheel to quickly scroll through a document, but in writeroom mode it's much more likely for the cursor to be positioned in the large margin areas.
This leads to warnings like <left-margin> <wheel-down> is undefined instead of scrolling.

The following bit of code solves it:

(dolist (k '(wheel-up
             double-wheel-up
             triple-wheel-up
             wheel-down
             double-wheel-down
             triple-wheel-down))
  (global-set-key (vector 'left-margin k) 'mwheel-scroll)
  (global-set-key (vector 'right-margin k) 'mwheel-scroll))

For some reason, defining the keys in writeroom-mode-map doesn't take effect at all, whereas setting them with global-set-key works. I could open a PR with the above, but not sure if it's acceptable to produce global key binding effects in a minor mode.

Last line of screen not left padded in terminal Emacs

Emacs for Mac OS X 24.3
OS X 10.9.3
Most recent writeroom-mode.el

Everything works fine when I run Emacs in GUI mode but when I start it with -nw, the last line of each screenful is shifted all the way to the left rather than being centered like the rest of the lines.

I've attached an example of the incorrect behavior in terminal mode and the correct behavior in GUI mode so you can see it is not an issue with the file. I have an extremely trimmed down .emacs so nothing should be conflicting.

Thank you for any help you can provide.

screen shot 2014-06-29 at 7 57 34 pm
screen shot 2014-06-29 at 7 52 54 pm

Weird wrong calculated width

I only have writeroom-mode installed using use-package

(use-package writeroom-mode
  :init
  (setq writeroom-width 0.5)
  (global-set-key (kbd "C-c w") 'writeroom-mode))

Steps:

  1. open emacs (no frame-parameter whatsoever), press C-c w
  2. Weird width, so I change the code to this:
(defun writeroom--calculate-width ()
  "Calculate the width of the writing area."
  (if (floatp writeroom-width)
      (progn
	(message "%s" (window-total-width))
	(truncate (* (window-total-width) writeroom-width)))
    writeroom-width))
  1. goto step 1, and It prints out 96(the old width before fullscreen), which should be 192 when in fullscreen.
  2. but when I edebug this function and go step by step, it prints out 192 and show things correctly...
  3. if I fullscreen first then call writeroom-mode, it also works correctly.
  4. that's weird, you can see the screen capture below:

bug

Displaying line numbers in writeroom-mode kills left margin.

When inside writeroom-mode, enabling the line numbers (linum-mode) kills the left margin completely, so that the text is not centered anymore. Re-enabling writeroom-mode fixes the margin, but hides the line numbers again.

Disclaimer: New to emacs. Using spacemacs. Havn't tried with vanilla emacs.

First call doesn't set margins correctly

I'm using a recent pull of the the development branch with homebrew. (version: GNU Emacs 24.3.50.1 (i386-apple-darwin11.4.2, NS apple-appkit-1138.51) of 2013-07-12 on xxx). I also got the same result on the release 24.3. I pulled writeroom-mode from melpa. I have customized writeroom-width to 100, but leaving this at default seem to make a difference for my problem.

For the first buffer where I call writeroom-mode, the full screen opens correctly, but the margins are not set correctly. It appears that window-body-width returns the pre-fullscreen size instead of the post-fullscreen size. Calling writeroom-mode on another buffer sets the margins correctly.

add "fullscreen" for emacs-mac port?

https://bitbucket.org/mituharu/emacs-mac is an alternate Cocoa front-end to Emacs. Its window-system is 'mac as opposed to the official 'ns.

Its handling of fullscreen is slightly different than that of the official mac version as well. Whereas normal emacs has 2 behaviors, fullboth and maximized, where fullboth means "native fullscreen" and maximized means "resized as big as the screen", emacs-mac has three behaviors: fullboth, fullscreen, and maximized. fullboth means "old-style fullscreen, just covering the entire normal desktop", and fullscreen means "use native fullscreen support", similar to what fullboth means in the GNU ns frontend.

It would be appreciated if you could add fullscreen to the list of options - or, better yet, detect this, so that my configuration would do fullboth on linux and fullscreen on emacs-mac.

Thank you!

Grey borders on left & right?

When I turn on writeroom-mode (with default settings), I seem to still have (fairly thin, fairly dark) grey borders on left & right edges. I assume this is not intended behaviour? If so, what could be the source of these?

writeroom-major-modes detects derived modes?

This an awesome package 😄

I try to turn global-writeroom-mode on, but I have to manually specify so many major modes. IMHO, it would be convenient if writeroom-mode is enabled whenever the buffer's major mode is

  1. in the list of writeroom-major-modes, or
  2. derived from one of the modes listed inwriteroom-major-modes.

In this case, you could just specify the major mode specifically or you could specify, say text-mode, then writeroom-mode will be enabled in all buffers in text-mode, makrdown-mode, org-mode, etc,

conflict with persp-mode

If I enable writeroom-mode, persp-mode cannot switch perspective correctly.
It worked fine in the previous version of writeroom-mode, but I didn't notice which update introduced the issue. If you need more info, please tell me.

Debugger entered--Lisp error: (wrong-type-argument window-valid-p nil)
  set-window-combination-limit(nil t)
  window--state-put-2(t 718)
  window-state-put((((min-height . 4) (min-width . 20) (min-height-ignore . 3) (min-width-ignore . 8) (min-height-safe . 1) (min-width-safe . 4) (min-pixel-height . 72) (min-pixel-width . 160) (min-pixel-height-ignore . 54) (min-pixel-width-ignore . 64) (min-pixel-height-safe . 18) (min-pixel-width-safe . 32)) hc (pixel-width . 1268) (pixel-height . 718) (total-width . 158) (total-height . 39) (normal-height . 1.0) (normal-width . 1.0) (combination-limit . t) (leaf (pixel-width . 636) (pixel-height . 718) (total-width . 79) (total-height . 39) (normal-height . 1.0) (normal-width . 0.501577287066246) (buffer "gtd.org" (selected . t) (hscroll . 0) (fringes 8 8 nil) (margins nil) (scroll-bars nil 0 t nil 0 t) (vscroll . 0) (dedicated) (point . 23760) (start . 1))) (leaf (last . t) (pixel-width . 632) (pixel-height . 718) (total-width . 79) (total-height . 39) (normal-height . 1.0) (normal-width . 0.49842271293375395) (buffer "gtd.org" (selected) (hscroll . 0) (fringes 8 8 nil) (margins nil) (scroll-bars nil 0 t nil 0 t) (vscroll . 0) (dedicated) (point . 23760) (start . 1)))) #<window 3 on gtd.org> t)
  (progn (window-state-put pwc rwin t))
  (if (fboundp (quote window-state-put)) (progn (window-state-put pwc rwin t)))
  (when (fboundp (quote window-state-put)) (window-state-put pwc rwin t))
  (progn (when (fboundp (quote window-state-put)) (window-state-put pwc rwin t)))
  (if (or rwin (setq rwin (frame-root-window (or frame (selected-frame))))) (progn (when (fboundp (quote window-state-put)) (window-state-put pwc rwin t))))
  (when (or rwin (setq rwin (frame-root-window (or frame (selected-frame))))) (when (fboundp (quote window-state-put)) (window-state-put pwc rwin t)))
  (lambda (pwc &optional frame rwin) (when (or rwin (setq rwin (frame-root-window (or frame (selected-frame))))) (when (fboundp (quote window-state-put)) (window-state-put pwc rwin t))))((((min-height . 4) (min-width . 20) (min-height-ignore . 3) (min-width-ignore . 8) (min-height-safe . 1) (min-width-safe . 4) (min-pixel-height . 72) (min-pixel-width . 160) (min-pixel-height-ignore . 54) (min-pixel-width-ignore . 64) (min-pixel-height-safe . 18) (min-pixel-width-safe . 32)) hc (pixel-width . 1268) (pixel-height . 718) (total-width . 158) (total-height . 39) (normal-height . 1.0) (normal-width . 1.0) (combination-limit . t) (leaf (pixel-width . 636) (pixel-height . 718) (total-width . 79) (total-height . 39) (normal-height . 1.0) (normal-width . 0.501577287066246) (buffer "gtd.org" (selected . t) (hscroll . 0) (fringes 8 8 nil) (margins nil) (scroll-bars nil 0 t nil 0 t) (vscroll . 0) (dedicated) (point . 23760) (start . 1))) (leaf (last . t) (pixel-width . 632) (pixel-height . 718) (total-width . 79) (total-height . 39) (normal-height . 1.0) (normal-width . 0.49842271293375395) (buffer "gtd.org" (selected) (hscroll . 0) (fringes 8 8 nil) (margins nil) (scroll-bars nil 0 t nil 0 t) (vscroll . 0) (dedicated) (point . 23760) (start . 1)))) #<frame [email protected] 0x102a2f438>)
  persp-restore-window-conf(#<frame [email protected] 0x102a2f438> nil nil)
  #f(compiled-function (persp &rest --cl-rest--) #<bytecode 0x43f624fd>)(nil #<frame [email protected] 0x102a2f438>)
  apply(#f(compiled-function (persp &rest --cl-rest--) #<bytecode 0x43f624fd>) (nil #<frame [email protected] 0x102a2f438>))
  persp-activate(nil #<frame [email protected] 0x102a2f438>)
  persp-frame-switch("Default" #<frame [email protected] 0x102a2f438>)
  #f(compiled-function (name &optional frame &rest --cl-rest--) "Switch to the perspective with name `NAME'.\nIf there is no perspective with that name it will be created.\nReturn `NAME'." (interactive "i") #<bytecode 0x43f6167d>)("Default")
  apply(#f(compiled-function (name &optional frame &rest --cl-rest--) "Switch to the perspective with name `NAME'.\nIf there is no perspective with that name it will be created.\nReturn `NAME'." (interactive "i") #<bytecode 0x43f6167d>) "Default")
  persp-switch("Default")
  (if persp-to-switch (persp-switch persp-to-switch) (persp-switch nil))
  (let ((persp-to-switch (nth pos (persp-names-current-frame-fast-ordered)))) (if persp-to-switch (persp-switch persp-to-switch) (persp-switch nil)))
  switch-persp-by-pos(0)
  switch-to-persp-1()
  funcall-interactively(switch-to-persp-1)
  call-interactively(switch-to-persp-1 nil nil)
  command-execute(switch-to-persp-1)

optional buffer-face-mode call

I've been using darkroom-mode but it has a few bugs that I'm hoping writeroom-mode can address. Specifically, darkroom-mode uses font scaling, which is incompatible with pretty much everything (e.g. company-mode).

As a workaround, I use buffer-face-mode like this:

    (set (make-local-variable 'buffer-face-mode-face) '(:height 200))
    (buffer-face-mode 1)

but without a writeroom-mode-hook I have no way of attaching this. Can you please consider adding a hook (that gets called both on load and unload) or adding a new writeroom-face-height variable that (if non-nil) will trigger a load of buffer-face-mode.

Disabling effect

Each option can be enabled or disabled individually.

Great but how do I disable it ? This is what I tryed this in my config

(setq writeroom--disable "transparency")
(writeroom--disable "transparency")

Writeroom-mode breaks Helm

When I enable writeroom-mode and then helm-M-x, I get the following error message:

 split-window: Window #<window 3 on manuscript.Rnw> too small for splitting (2)

Using a recent development Emacs and up-to-date helm and writeroom-mode from MELPA.

Internal width affects also other buffers

  1. run Emacs and open a couple of bufffers
  2. go into one of them and M-x writeroom-mode
  3. M-: (writeroom-toggle-internal-border-width 1)
  4. also the other buffer has internal borders

Zoom breaks decrease-width character-limit in org-mode (Spacemacs macOS 10.11)

Reproduce:

  • Open org-file in org-mode
  • M-x writeroom-mode
  • M-x writeroom-decrease-width until it's at 66 characters per line
  • Zoom in with C-x +
  • Fill a line with characters. 70 this time
  • Esc :w to save (in EVIL-mode)
  • Text jumps to the left a bit.

Spacemacs on macOS 10.11 - GNU Emacs 25.3.1 - (x86_64-apple-darwin15.6.0, NS appkit-1404.47 Version 10.11.6 (Build 15G20015)) of 2018-05-16 - Org mode version 9.1.13 (9.1.13-elpaplus @ /Users/jonta/.emacs.d/elpa/org-plus-contrib-20180514)

Related: Size of the font and other things #1. Over 6 years old, and supporting zoom seems like something that should work outside the box

Also: Conflict with Org Mode #30. I'm not using linum-mode.

Custom frame size

The maximized frame doesn't always fill the entire screen. It would be nice if I could set writeroom-fullscreen-effect to a custom size instead. Something like this would work:

(defun my/maximized ()
  (interactive)
  (let ((frame (selected-frame)))
    (set-frame-size frame 1256 747 t)))

(setq writeroom-fullscreen-effect 'my/maximized)

What would you recommend?

conflict with persp-mode

When enabling writeroom-mode, persp cannot switch to perspective correctly. It worked in the previous version of writeroom-mode, but I didn't notice that which update introduced the issue. If you need more info, please tell me.

Debugger entered--Lisp error: (wrong-type-argument window-valid-p nil)
  set-window-combination-limit(nil t)
  window--state-put-2(t 718)
  window-state-put((((min-height . 4) (min-width . 20) (min-height-ignore . 3) (min-width-ignore . 8) (min-height-safe . 1) (min-width-safe . 4) (min-pixel-height . 72) (min-pixel-width . 160) (min-pixel-height-ignore . 54) (min-pixel-width-ignore . 64) (min-pixel-height-safe . 18) (min-pixel-width-safe . 32)) hc (pixel-width . 1268) (pixel-height . 718) (total-width . 158) (total-height . 39) (normal-height . 1.0) (normal-width . 1.0) (combination-limit . t) (leaf (pixel-width . 636) (pixel-height . 718) (total-width . 79) (total-height . 39) (normal-height . 1.0) (normal-width . 0.501577287066246) (buffer "gtd.org" (selected . t) (hscroll . 0) (fringes 8 8 nil) (margins nil) (scroll-bars nil 0 t nil 0 t) (vscroll . 0) (dedicated) (point . 23760) (start . 1))) (leaf (last . t) (pixel-width . 632) (pixel-height . 718) (total-width . 79) (total-height . 39) (normal-height . 1.0) (normal-width . 0.49842271293375395) (buffer "gtd.org" (selected) (hscroll . 0) (fringes 8 8 nil) (margins nil) (scroll-bars nil 0 t nil 0 t) (vscroll . 0) (dedicated) (point . 23760) (start . 1)))) #<window 3 on gtd.org> t)
  (progn (window-state-put pwc rwin t))
  (if (fboundp (quote window-state-put)) (progn (window-state-put pwc rwin t)))
  (when (fboundp (quote window-state-put)) (window-state-put pwc rwin t))
  (progn (when (fboundp (quote window-state-put)) (window-state-put pwc rwin t)))
  (if (or rwin (setq rwin (frame-root-window (or frame (selected-frame))))) (progn (when (fboundp (quote window-state-put)) (window-state-put pwc rwin t))))
  (when (or rwin (setq rwin (frame-root-window (or frame (selected-frame))))) (when (fboundp (quote window-state-put)) (window-state-put pwc rwin t)))
  (lambda (pwc &optional frame rwin) (when (or rwin (setq rwin (frame-root-window (or frame (selected-frame))))) (when (fboundp (quote window-state-put)) (window-state-put pwc rwin t))))((((min-height . 4) (min-width . 20) (min-height-ignore . 3) (min-width-ignore . 8) (min-height-safe . 1) (min-width-safe . 4) (min-pixel-height . 72) (min-pixel-width . 160) (min-pixel-height-ignore . 54) (min-pixel-width-ignore . 64) (min-pixel-height-safe . 18) (min-pixel-width-safe . 32)) hc (pixel-width . 1268) (pixel-height . 718) (total-width . 158) (total-height . 39) (normal-height . 1.0) (normal-width . 1.0) (combination-limit . t) (leaf (pixel-width . 636) (pixel-height . 718) (total-width . 79) (total-height . 39) (normal-height . 1.0) (normal-width . 0.501577287066246) (buffer "gtd.org" (selected . t) (hscroll . 0) (fringes 8 8 nil) (margins nil) (scroll-bars nil 0 t nil 0 t) (vscroll . 0) (dedicated) (point . 23760) (start . 1))) (leaf (last . t) (pixel-width . 632) (pixel-height . 718) (total-width . 79) (total-height . 39) (normal-height . 1.0) (normal-width . 0.49842271293375395) (buffer "gtd.org" (selected) (hscroll . 0) (fringes 8 8 nil) (margins nil) (scroll-bars nil 0 t nil 0 t) (vscroll . 0) (dedicated) (point . 23760) (start . 1)))) #<frame [email protected] 0x102a2f438>)
  persp-restore-window-conf(#<frame [email protected] 0x102a2f438> nil nil)
  #f(compiled-function (persp &rest --cl-rest--) #<bytecode 0x40c913fd>)(nil #<frame [email protected] 0x102a2f438>)
  apply(#f(compiled-function (persp &rest --cl-rest--) #<bytecode 0x40c913fd>) (nil #<frame [email protected] 0x102a2f438>))
  persp-activate(nil #<frame [email protected] 0x102a2f438>)
  persp-frame-switch("Default" #<frame [email protected] 0x102a2f438>)
  #f(compiled-function (name &optional frame &rest --cl-rest--) "Switch to the perspective with name `NAME'.\nIf there is no perspective with that name it will be created.\nReturn `NAME'." (interactive "i") #<bytecode 0x40c9057d>)("Default")
  apply(#f(compiled-function (name &optional frame &rest --cl-rest--) "Switch to the perspective with name `NAME'.\nIf there is no perspective with that name it will be created.\nReturn `NAME'." (interactive "i") #<bytecode 0x40c9057d>) "Default")
  persp-switch("Default")
  (if persp-to-switch (persp-switch persp-to-switch) (persp-switch nil))
  (let ((persp-to-switch (nth pos (persp-names-current-frame-fast-ordered)))) (if persp-to-switch (persp-switch persp-to-switch) (persp-switch nil)))
  switch-persp-by-pos(0)
  switch-to-persp-1()
  funcall-interactively(switch-to-persp-1)
  call-interactively(switch-to-persp-1 nil nil)
  command-execute(switch-to-persp-1)

error in xemacs

writeroom-mode.el:176:1:Error: Wrong number of arguments: #[(old new) "\302\303�    E\304�\305  FE\207" [old new progn defalias put (quote byte-obsolete-variable)] 6], 3

My emacs version:
GNU Emacs 24.5.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.16.2) of 2015-04-20 on bitzer.hoetzel.info

It looks like xemacs 's define-obsolete-variable-alias macro only take two parameters, I found some code in /usr/share/emacs/24.5/lisp/mh-e/mh-compat.el:

(defmacro mh-define-obsolete-variable-alias
  (obsolete-name current-name &optional when docstring)
  "Make OBSOLETE-NAME a variable alias for CURRENT-NAME and mark it obsolete.
See documentation for `define-obsolete-variable-alias' for a description
of the arguments OBSOLETE-NAME, CURRENT-NAME, and perhaps WHEN
and DOCSTRING. This macro is used by XEmacs that lacks WHEN and
DOCSTRING arguments."
  (if (featurep 'xemacs)
      `(define-obsolete-variable-alias ,obsolete-name ,current-name)
    `(define-obsolete-variable-alias ,obsolete-name ,current-name ,when ,docstring)))

Hoops this will help somebody:)

How are global effects disabled?

This is coming from rnkn/olivetti#6 and joaotavora/darkroom#2, and is just a question.

You say that affecting global frame settings in a minor mode isn't exactly "up and up" but you say that these effects are justified because of distraction free writing. Fair enough, but how and when are these effects undone in your implementation? If/when you undo them, how to you restore them to their previous values?

I'd gladly abandon darkroom-mode in favor of writeroom-mode (you seems to be much more actively maintaining it) if you can answer this and also provide some writeroom-tentative-mode like darkroom-tentative-mode.

Wrapping at 81 characters rather than at 80 characters

I may be misunderstanding something, but upon trying whiteroom-mode out, I noticed that lines were not wrapped at 80 characters; rather, writeroom-mode allowed for 81 characters before wrapping the line:

screenshot

I would have expected the "x" characters at the end of the two longest lines to be on the next line.

This behaviour can be reproduced by starting from an Emacs configuration consisting of only...

(package-initialize)
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/") t)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)

... and executing package-refresh-contents, package-install writeroom-mode and writeroom-mode in the *scratch* buffer.

I'm using Emacs 26.1 on Arch Linux.

Add screenshot to intro page

Maybe a bit silly, but could you please add a screenshot to the intro page? It would make it easier to evaluate this package at a glance. Thanks in advance.

writeroom-global-effects could support standard minor mode argument interpretation

In my writeroom I use the standard modeline but hide my panel (fullboth) and thus want to show time and battery status in the modeline. This is easily done with display-time-mode and display-battery-mode. I thought I would be able to just add these to writeroom-global-effects but I had to write a short wrapper function and add that to writeroom-global-effects for it to work:

(defun aj/wr-time-and-battery (arg)
  (if arg
      (progn (display-time-mode 1) (display-battery-mode 1))
    (display-time-mode -1) (display-battery-mode -1)))

This was no problem of course, but what I propose is that the interpretation of the argument in writeroom--activate-global-effects should be the same as the interpretation of arguments for minor modes, i.e. "If called from Lisp, enable the mode if ARG is omitted or nil" (or non-negative really) and disable for negative arguments.
This would enable anyone to just throw in any (global) minor mode into writeroom-global-effects, but changing it would of course possibly break current configurations.

Thanks for a great package!

[Question] How to show buffer borders?

Hey, thanks for writing this excellent package.

I like using your extension when using org-mode to do research, and often I open plots that I generate in a separate buffer. What I'd like to do is enable showing borders between two buffers as often it gets quite confusing which buffer has focus in current setup.

I couldn't figure out how to enable displaying buffer borders from reading source code (I get writeroom-border-width is not quite what I want).

`global-linum-mode` and intended margin space

writeroom-mode functions finely without activating global-linum-mode
emacs-writeroom

but if we activate line numbers in the left margin using global-linum-mode, lines will not have intended margin space in writeroom-mode.
emacs-writeroom-global-linum-mode

more info.:
GNE Emacs 24.3
GNU/Linux

Disabling writeroom-mode doesn't work

I suppose I should be able to disable writeroom-mode using M-x writeroom-mode but this doesn't appear to do anything apart from showing t in the mini buffer. When I (writeroom--disable), the original configuration is restored except that the mode line is missing. No error messages.

Tested with a recent development version of Emacs, an up-to-date writeroom-mode from MELPA, and emacs -Q. The only thing that I did after starting Emacs was (package-initialize).

Let some parts of the buffer (eg, tables) use full width [Feature request]

This is a bit of a crazy request, but it would be great to allow some parts of the buffer to use the full width of the window, even if most of the contents is in a centered column. It would allow, eg, to have org or latex tables appear without random line breaks in writeroom-mode.

I'm thinking of something like this:

        Text appears with
        large margins
  
        Lorem ipsum dolor
        sit amet,
        consectetur
        adipiscing
        elit. Etiam at
        aliquam ex.
        Ut iaculis turpis
        nisl, vehicula
        lobortis libero
        
        Then, a table:

| Header | First field | Second field |
|--------+-------------+--------------|
| This   |          12 | 32           |
| That   |        48.5 | N/A          |

        Then, text goes
        on.

Not sure if I'm clear...

Thanks,
Th

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.