Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace spacemacs-centered-buffer-mode with olivetti #9488

Closed
mwillsey opened this issue Aug 25, 2017 · 5 comments
Closed

Replace spacemacs-centered-buffer-mode with olivetti #9488

mwillsey opened this issue Aug 25, 2017 · 5 comments

Comments

@mwillsey
Copy link
Contributor

On large monitor, I find it very helpful to have a window center the buffer contents. This is especially useful when only one window is open; otherwise the text is all the way to the left side of the screen.

spacemacs-centered-buffer-mode does the trick, but it has some issues. First of all, it creates a duplicate buffer. This makes SPC-TAB to quickly switch buffers annoying, because you end up switching between the centered and un-centered versions. Second, I've encountered occasional (but pretty major) performance issues with the mode that seem to be linked to the width of Emacs. I won't go into detail here.

I propose replacing spacemacs-centered-buffer-mode with olivetti. I've been using this for a while, and it's fantastic. It simply centeres the buffer contents without creating duplicate buffers or the performance issues I saw with the spacemacs mode.

I've got something like the following in my .spacemacs.d/init.el:

(defun dotspacemacs/layers ()
  (setq-default dotspacemacs-additional-packages '(olivetti)))

(defun dotspacemacs/user-config ()
  ;; I like it a little bit wider
  (setq-default olivetti-body-width 100)
  ;; replace the `spacemacs-centered-buffer-mode` binding
  (spacemacs/set-leader-keys "wc" 'olivetti-mode))

If people think this is a good idea, I'd be happy to submit a PR. It should be a simple fix, mostly adding a small dependency and deleting the old code.

@microamp
Copy link

microamp commented Sep 9, 2017

There is also centered-window-mode, I don't know if it predates Spacemacs' centered-buffer-mode. I think olivetti does everything it does though. And I really like its distraction-free mode (which hides the mode line).

@JAremko
Copy link
Collaborator

JAremko commented Dec 28, 2017

@mwillsey Develop branch has updated centered-buffer-mode if you set spacemacs-centered-buffer-mode-min-content-width and spacemacs-centered-buffer-mode-max-content-width to the same value you will get fixed width centering without a performance penalty (mb we should add min/max to .spacemacs?) Also the updated mode should be more stable and faster overall.
<all configs >

The usage of extra buffers is a trade off for having more features like perfectly centering buffer content without squeezing or stretching it - the process of calculation the content width can be costly for huge buffer but we can add buffer size limitation and if the buffer is too long it will center to some value.

On the other hand, replacing centered-buffer-mode with something that we don't need to maintain might be a good idea even if it doesn't have extra features. (especially since it's pretty hacky)

@microamp If you are using develop try SPC w C (we probably should rename it into "distraction free mode") https://i.imgur.com/eXV6aHd.png

cc @syl20bnr

@jstaursky
Copy link

One feature olivetti has over centered-buffer-mode is that fill-paragraph actually works as expected.

@xoihiox
Copy link

xoihiox commented Dec 2, 2018

Thank you @mwillsey for creating this thread! I am a new spacemacs user who relies on the center-window for almost every application I use, and the default has been crashing my emacs horribly almost every time I invoke it. Olivetti, on the other hand, works without issue.

I second the proposal to replace the default with olivetti, as it works without issue, while centered-buffer-mode still has serious issues more than one year later--or at least missing default parameters that are not mentioned in any easily accessible documentation.

@JAremko
Copy link
Collaborator

JAremko commented Dec 2, 2018

@xoihiox We have already replaced it with writeroom-mode in develop. So it should be in master with the next release.

@JAremko JAremko closed this as completed Dec 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants