diff --git a/ha-config.org b/ha-config.org index fdaf206..614773e 100644 --- a/ha-config.org +++ b/ha-config.org @@ -574,12 +574,11 @@ The goal here is toggle switches and other miscellaneous settings. "t d" '("debug" . toggle-debug-on-error) "t f" '("auto-fill" . auto-fill-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 v" '("visual" . visual-line-mode) "t w" '("whitespace" . whitespace-mode)) #+END_SRC - +**** Line Numbers Really? We can't automatically toggle between relative and absolute line numbers? #+BEGIN_SRC emacs-lisp (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 'relative))) #+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 While it comes with Emacs, I use [[https://www.emacswiki.org/emacs/WinnerMode][winner-mode]] to undo window-related changes: #+BEGIN_SRC emacs-lisp diff --git a/ha-org.org b/ha-org.org index e3dfb48..7bc3b85 100644 --- a/ha-org.org +++ b/ha-org.org @@ -605,7 +605,8 @@ And tell [[https://www.flycheck.org/][flycheck]] to use this: (use-package flycheck :config (add-to-list 'flycheck-checkers 'proselint)) #+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]]: #+BEGIN_SRC emacs-lisp @@ -617,12 +618,50 @@ For a complete focused, /distraction-free/ environment, for writing or concentra "=" '("adjust width" . writeroom-adjust-width) "<" '("decrease width" . writeroom-decrease-width) ">" '("increase width" . writeroom-increase-width)) - :bind (:map writeroom-mode-map ("C-M-<" . writeroom-decrease-width) ("C-M->" . writeroom-increase-width) ("C-M-=" . writeroom-adjust-width))) #+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: Let's provide a name, to allow =require= to work: #+BEGIN_SRC emacs-lisp :exports none