diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2019-09-08 10:57:24 +0200 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2019-09-08 10:57:24 +0200 |
commit | d02fa6c2796b81e2069ad7951733750a1d400998 (patch) | |
tree | 82f398849ff5aa806f838132357856496101c0e4 /init.org | |
parent | 4a1c13ce5ce9abf22bd4330327d6ab157508878c (diff) |
Use olivetti-mode.
Diffstat (limited to 'init.org')
-rw-r--r-- | init.org | 29 |
1 files changed, 6 insertions, 23 deletions
@@ -62,6 +62,7 @@ To install all packages via GNU Guix I can either use a manifest file or use the emacs-markdown-mode \ emacs-mmm-mode \ emacs-multiple-cursors \ + emacs-olivetti \ emacs-org \ emacs-org-bullets \ emacs-org-trello \ @@ -881,32 +882,13 @@ I don’t want to have any margins by default. (setq-default left-margin-width 0 right-margin-width 0) #+END_SRC -When writing Org-mode documents or when browsing the web with Eww I prefer to see shorter lines. The following procedure takes the current window width and adjust the buffer margins dynamically such that the buffer contents are restricted in width. I find this much more readable when editing Org documents or browsing with Eww. +When writing Org-mode documents or when browsing the web with Eww I prefer to see shorter lines. =olivetti-mode= adjusts the buffer margins such that the buffer contents are restricted in width and centered. I find this much more readable when editing Org documents or browsing with Eww. #+BEGIN_SRC elisp -(defun my/dynamic-margin-window (window) - "Get current window width and adjust margins such that the buffer contents are centered and no more than 80 characters wide." - (with-current-buffer (window-buffer window) - (when (or (eq major-mode 'org-mode) - (eq major-mode 'eww-mode)) - (let* ((textwidth 80) - (margin (max (- (window-size window t) textwidth) 0))) - (setq left-margin-width 0 right-margin-width margin) - (set-window-buffer window (current-buffer)))))) - -(defun my/dynamic-margin (frame) - "Dynamically adjust margin for all windows of the frame." - (walk-windows 'my/dynamic-margin-window 'no-minibuf frame)) +(require 'olivetti) +(add-hook 'org-mode-hook #'olivetti-mode) #+END_SRC -The procedure is added to the list of functions that are to be evaluated whenever the window size changes. As a result the content width is adjusted dynamically. - -#+BEGIN_SRC elisp -(add-to-list 'window-size-change-functions 'my/dynamic-margin) -#+END_SRC - -TODO: This doesn’t work so well with org tables or genuinely wide content in eww buffers, so I need a way to quickly disable this. Maybe this really should be a minor mode. - * Window management :PROPERTIES: :header-args: :noweb-ref exwm :noweb yes @@ -1695,7 +1677,8 @@ This is even more stuff to be done after initialising packages. I still need to ;; enable variable-pitch-mode in eww (add-hook 'eww-mode-hook (lambda () - (variable-pitch-mode 1))) + (variable-pitch-mode 1) + (olivetti-mode 1))) ;; pretty quotes! (add-hook 'erc-mode-hook |