diff options
Diffstat (limited to 'emacs/.emacs.d/lisp/my/my-buffer.el')
-rw-r--r-- | emacs/.emacs.d/lisp/my/my-buffer.el | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/emacs/.emacs.d/lisp/my/my-buffer.el b/emacs/.emacs.d/lisp/my/my-buffer.el index 21401b5..f06956f 100644 --- a/emacs/.emacs.d/lisp/my/my-buffer.el +++ b/emacs/.emacs.d/lisp/my/my-buffer.el @@ -239,12 +239,24 @@ that point." (setq buffer temp-buffer)) (set-window-buffer first-window buffer))) -(defun my-focus-write () - "Make the current window the only one centered with width 80." +(defun my-toggle-focus-write () + "Toggle focus write mode. + +Focus write: make the current window the only one centered with +width 80. If in org-mode, also narrow to current subtree." (interactive) - (delete-other-windows) - (let ((margin (/ (- (window-width) 80) 2))) - (set-window-margins nil margin margin))) + ;; Only one window in the current frame indicates we are in focus + ;; write mode. + (if (length= (window-list) 1) + (progn + (winner-undo) + (when (derived-mode-p 'org-mode) + (widen))) + (when (derived-mode-p 'org-mode) + (org-narrow-to-subtree)) + (delete-other-windows) + (let ((margin (/ (- (window-width) 80) 2))) + (set-window-margins nil margin margin)))) (defun my-select-new-window-matching-mode (mode) "Select a new window." |