From 34cc6d0faf7c9288b54ede1010572a2b9c23aed6 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Mon, 23 Dec 2024 14:38:39 +0100 Subject: Overthink Gnus window configurations The status-quo looks like [ SUMMARY ] [ ][ ][ ] [PADDING][ ARTICLE ][PADDING] [ ][ ][ ] which wastes a lot of horizontal space, and sometimes fails to display anything interesting about the article without scrolling, depending on the quantity of headers and introductory cruft. Since Gnus allows dynamically-evaluated forms, consult the frame width to choose between [ ][ ] or [ SUMMARY ] [ SUMMARY ][ARTICLE] [ ] [ ][ ] [ ARTICLE ] [ ] --- .gnus | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/.gnus b/.gnus index 2c9c122..ab5b7f3 100644 --- a/.gnus +++ b/.gnus @@ -86,6 +86,34 @@ gnus-treat-fill-long-lines nil gnus-treat-fold-headers nil) +;;; Window configurations. + +(defvar my/gnus-side-by-side-threshold 160) + +(gnus-add-configuration + '(article + (if (>= (frame-width) my/gnus-side-by-side-threshold) + '(horizontal 1.0 + (summary 1.0 point) + (article 80)) + '(vertical 1.0 + (summary 0.25 point) + (article 1.0))))) + +(dolist (buf-name '(forward reply reply-yank)) + (gnus-add-configuration + `(,buf-name + (if (>= (frame-width) my/gnus-side-by-side-threshold) + '(vertical 1.0 + (summary 0.25) + (horizontal 1.0 + (article 0.5) + (message 1.0 point))) + '(vertical 1.0 + (summary 0.2) + (article 0.2) + (message 1.0 point)))))) + ;;; Summary tweaks. (defun my/gnus-toggle-article-wrap () @@ -93,14 +121,9 @@ (with-current-buffer gnus-article-buffer (visual-line-mode 'toggle))) -(defun my/gnus-summary-center () - (setq fill-column 160) - (my/centered-mode)) - (defun my/gnus-summary-tweak-keys () (keymap-local-set "C-c d v" 'my/gnus-toggle-article-wrap)) -(add-hook 'gnus-summary-mode-hook 'my/gnus-summary-center) (add-hook 'gnus-summary-mode-hook 'my/gnus-summary-tweak-keys) ;; message-subject-re-regexp is used both in Gnus summary buffers to @@ -142,11 +165,6 @@ ;;; Article tweaks. -(defun my/gnus-article-center () - (setq fill-column 80 - my/centered-set-right-margin t) - (my/centered-mode)) - (defun my/gnus-article-eschew-tables () ;; I set shr-fill-text to nil because I prefer letting ;; visual-line-mode manage wrapping. Unfortunately, many HTML @@ -186,7 +204,8 @@ (setq should-wrap (and ;; The line is bigger than the target width. - (> (length current-line) fill-column) + (> (length current-line) + (window-width (get-buffer-window gnus-article-buffer))) ;; The line is not boring (citation, diff addition/removal). (not (string-match-p "\\`[>+-]" current-line)) ;; Lines that start with spaces are boring, except in @@ -228,7 +247,6 @@ ;; (Ⅱ) call `visual-line-mode' (if needed) in prepare-hook, after ;; truncate-lines has been set. -(add-hook 'gnus-article-mode-hook 'my/gnus-article-center) (add-hook 'gnus-article-mode-hook 'my/gnus-article-eschew-tables) (add-hook 'gnus-article-prepare-hook 'my/gnus-article-wrap-maybe) -- cgit v1.2.3