Trying out Protesilaos' distraction-free focus package
This brought back Olivetti as well as creating a DWIM function for narrowing a buffer the way I would expect.
This commit is contained in:
parent
2aa2886535
commit
ccebc03e7f
2 changed files with 66 additions and 4 deletions
|
@ -574,12 +574,11 @@ The goal here is toggle switches and other miscellaneous settings.
|
||||||
"t d" '("debug" . toggle-debug-on-error)
|
"t d" '("debug" . toggle-debug-on-error)
|
||||||
"t f" '("auto-fill" . auto-fill-mode)
|
"t f" '("auto-fill" . auto-fill-mode)
|
||||||
"t l" '("line numbers" . display-line-numbers-mode)
|
"t l" '("line numbers" . display-line-numbers-mode)
|
||||||
"t r" '("relative lines" . ha-toggle-relative-line-numbers)
|
|
||||||
"t t" '("truncate" . toggle-truncate-lines)
|
"t t" '("truncate" . toggle-truncate-lines)
|
||||||
"t v" '("visual" . visual-line-mode)
|
"t v" '("visual" . visual-line-mode)
|
||||||
"t w" '("whitespace" . whitespace-mode))
|
"t w" '("whitespace" . whitespace-mode))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
**** Line Numbers
|
||||||
Really? We can't automatically toggle between relative and absolute line numbers?
|
Really? We can't automatically toggle between relative and absolute line numbers?
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(defun ha-toggle-relative-line-numbers ()
|
(defun ha-toggle-relative-line-numbers ()
|
||||||
|
@ -588,6 +587,30 @@ Really? We can't automatically toggle between relative and absolute line numbers
|
||||||
(setq display-line-numbers t)
|
(setq display-line-numbers t)
|
||||||
(setq display-line-numbers 'relative)))
|
(setq display-line-numbers 'relative)))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
Add it to the toggle menu:
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(ha-leader
|
||||||
|
"t r" '("relative lines" . ha-toggle-relative-line-numbers))
|
||||||
|
#+END_SRC
|
||||||
|
**** Narrowing
|
||||||
|
I like the focus the [[info:emacs#Narrowing][Narrowing features]] offer, but what a /dwim/ aspect:
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(defun ha-narrow-dwim ()
|
||||||
|
"Narrow to region or org-tree or widen if already narrowed."
|
||||||
|
(interactive)
|
||||||
|
(cond
|
||||||
|
((buffer-narrowed-p) (widen))
|
||||||
|
((region-active-p) (narrow-to-region (region-beginning) (region-end)))
|
||||||
|
((and (fboundp 'logos-focus-mode)
|
||||||
|
(seq-contains local-minor-modes 'logos-focus-mode 'eq))
|
||||||
|
(logos-narrow-dwim))
|
||||||
|
((eq major-mode 'org-mode) (org-narrow-to-subtree))
|
||||||
|
(t (narrow-to-defun))))
|
||||||
|
#+END_SRC
|
||||||
|
And put it on the toggle menu:
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(ha-leader "t n" '("narrow" . ha-narrow-dwim))
|
||||||
|
#+END_SRC
|
||||||
*** Window Operations
|
*** Window Operations
|
||||||
While it comes with Emacs, I use [[https://www.emacswiki.org/emacs/WinnerMode][winner-mode]] to undo window-related changes:
|
While it comes with Emacs, I use [[https://www.emacswiki.org/emacs/WinnerMode][winner-mode]] to undo window-related changes:
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
|
43
ha-org.org
43
ha-org.org
|
@ -605,7 +605,8 @@ And tell [[https://www.flycheck.org/][flycheck]] to use this:
|
||||||
(use-package flycheck
|
(use-package flycheck
|
||||||
:config (add-to-list 'flycheck-checkers 'proselint))
|
:config (add-to-list 'flycheck-checkers 'proselint))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** Write-room
|
** Distraction-Free Writing
|
||||||
|
*** Write-room
|
||||||
For a complete focused, /distraction-free/ environment, for writing or concentrating, I'm using [[https://github.com/joostkremers/writeroom-mode][Writeroom-mode]]:
|
For a complete focused, /distraction-free/ environment, for writing or concentrating, I'm using [[https://github.com/joostkremers/writeroom-mode][Writeroom-mode]]:
|
||||||
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
@ -617,12 +618,50 @@ For a complete focused, /distraction-free/ environment, for writing or concentra
|
||||||
"=" '("adjust width" . writeroom-adjust-width)
|
"=" '("adjust width" . writeroom-adjust-width)
|
||||||
"<" '("decrease width" . writeroom-decrease-width)
|
"<" '("decrease width" . writeroom-decrease-width)
|
||||||
">" '("increase width" . writeroom-increase-width))
|
">" '("increase width" . writeroom-increase-width))
|
||||||
|
|
||||||
:bind (:map writeroom-mode-map
|
:bind (:map writeroom-mode-map
|
||||||
("C-M-<" . writeroom-decrease-width)
|
("C-M-<" . writeroom-decrease-width)
|
||||||
("C-M->" . writeroom-increase-width)
|
("C-M->" . writeroom-increase-width)
|
||||||
("C-M-=" . writeroom-adjust-width)))
|
("C-M-=" . writeroom-adjust-width)))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
*** Olivetti
|
||||||
|
The [[https://github.com/rnkn/olivetti][olivetti project]] sets wide margins and centers the text. It isn’t better than Writeroom, however, it works well with Logos (below).
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(use-package olivetti
|
||||||
|
:init
|
||||||
|
(setq-default olivetti-body-width 100)
|
||||||
|
:config
|
||||||
|
(ha-leader "t O" '("olivetti" . olivetti-mode))
|
||||||
|
:bind (:map olivetti-mode-map
|
||||||
|
("C-M-<" . olivetti-shrink)
|
||||||
|
("C-M->" . olivetti-expand)
|
||||||
|
("C-M-=" . olivetti-set-width)))
|
||||||
|
#+END_SRC
|
||||||
|
*** Logos
|
||||||
|
Trying out [[https://protesilaos.com/][Protesilaos Stavrou]]’s [[https://protesilaos.com/emacs/logos][logos project]] as a replacement for [[https://github.com/joostkremers/writeroom-mode][Writeroom-mode]]:
|
||||||
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(use-package logos
|
||||||
|
:straight (:type git :protocol ssh :host gitlab :repo "protesilaos/logos")
|
||||||
|
:init
|
||||||
|
(setq logos-outlines-are-pages t
|
||||||
|
logos-outline-regexp-alist
|
||||||
|
`((emacs-lisp-mode . "^;;;+ ")
|
||||||
|
(org-mode . "^\\*+ +")
|
||||||
|
(t . ,(or outline-regexp logos--page-delimiter))))
|
||||||
|
|
||||||
|
;; These apply when `logos-focus-mode' is enabled. Their value is
|
||||||
|
;; buffer-local.
|
||||||
|
(setq-default logos-hide-mode-line t
|
||||||
|
logos-scroll-lock nil
|
||||||
|
logos-indicate-buffer-boundaries nil
|
||||||
|
logos-buffer-read-only nil
|
||||||
|
logos-olivetti t)
|
||||||
|
:config
|
||||||
|
(ha-leader "t L" '("logos" . logos-focus-mode))
|
||||||
|
(let ((map global-map))
|
||||||
|
(define-key global-map [remap narrow-to-region] #'logos-narrow-dwim)
|
||||||
|
(evil-define-key 'normal map (kbd "g [") 'logos-backward-page-dwim)
|
||||||
|
(evil-define-key 'normal map (kbd "g ]") 'logos-forward-page-dwim)))
|
||||||
|
#+END_SRC
|
||||||
* Technical Artifacts :noexport:
|
* Technical Artifacts :noexport:
|
||||||
Let's provide a name, to allow =require= to work:
|
Let's provide a name, to allow =require= to work:
|
||||||
#+BEGIN_SRC emacs-lisp :exports none
|
#+BEGIN_SRC emacs-lisp :exports none
|
||||||
|
|
Loading…
Reference in a new issue