Focus in when writing

Sometimes when i am writing something – the spread from east to west is annoying on a widescreen – the modeline also gives redundant information that are annoying – so I created this small mode to focus in on the job. Only creates the padding for org files since when writing elisp code the breadth is actually useful.

(defun focus-mode--backend (&optional left right)
  (when (eq major-mode 'org-mode)
  (set-window-margins (selected-window)
		      (if left
		      (if right

(define-minor-mode focus-mode 
"Toggle focus mode to adjust window margins."
  :global t
  :init-value nil
  :lighter " f🎯"
  (if focus-mode
	(add-hook 'window-state-change-hook #'focus-mode--backend)
	(setq-default mode-line-format '(
					 " "
					 " "
					 " "
					 " f🎯"
					 " "
      (remove-hook 'window-state-change-hook #'focus-mode--backend)
      (focus-mode--backend 0 0)
      (setq-default mode-line-format '("%e" mode-line-front-space
  ("" mode-line-mule-info mode-line-client mode-line-modified mode-line-remote)
 mode-line-frame-identification mode-line-buffer-identification "   " mode-line-position
 (vc-mode vc-mode)
 "  " mode-line-modes mode-line-misc-info mode-line-end-spaces))

Beautiful. I like this kind of snippets of the kind: “My editor does this thing in an annoying fashion, that’s probably in the whole world bothers only me. And here’s how I fixed it…”

In the non-Emacs world, it would sound like “My editor does this thing in such an annoying fashion that everyone complains about it until they get used to it… and there’s no good workaround here…”

1 Like