Howdy, howdy fellow e-mail hackers. :)
The attached patches are my first-cut attempt to:
(1) Make notmuch-hello play nicely with display-line-numbers-mode.
(2) Make notmuch-hello re-layout when window width changes.
WDYT?
Rudy
>From 278017d06bb986f4ec99118bfcfdec8dab970f2b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?=
Date: Thu, 25 May 2023 16:22:08 +0200
Subject: [PATCH 1/2] emacs: fix notmuch-hello layout when
display-line-numbers-mode is on
---
emacs/notmuch-hello.el | 25 +++--
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 4662e704..3235f555 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -412,6 +412,7 @@ supported for \"Customized queries section\" items."
(defun notmuch-search-item-field-width ()
(max 8 ; Don't let the search boxes be less than 8 characters wide.
(- (window-width)
+ (line-number-display-width)
notmuch-hello-indent ; space at bol
notmuch-hello-indent ; space at eol
1; for the space before the [save] button
@@ -508,23 +509,31 @@ should be. Returns a cons cell `(tags-per-line width)'."
(cond
((integerp notmuch-column-control)
(max 1
- (/ (- (window-width) notmuch-hello-indent)
+ (/ (- (window-width)
+ (line-number-display-width)
+ notmuch-hello-indent)
;; Count is 9 wide (8 digits plus space), 1 for the space
;; after the name.
(+ 9 1 (max notmuch-column-control widest)
((floatp notmuch-column-control)
- (let* ((available-width (- (window-width) notmuch-hello-indent))
+ (let* ((available-width (- (window-width)
+ (line-number-display-width)
+ notmuch-hello-indent))
(proposed-width (max (* available-width notmuch-column-control)
widest)))
(floor available-width proposed-width)))
(t
(max 1
- (/ (- (window-width) notmuch-hello-indent)
+ (/ (- (window-width)
+ (line-number-display-width)
+ notmuch-hello-indent)
;; Count is 9 wide (8 digits plus space), 1 for the space
;; after the name.
(+ 9 1 widest)))
(cons tags-per-line (/ (max 1
-(- (window-width) notmuch-hello-indent
+(- (window-width)
+ (line-number-display-width)
+ notmuch-hello-indent
;; Count is 9 wide (8 digits plus
;; space), 1 for the space after the
;; name.
@@ -824,7 +833,9 @@ Complete list of currently available key bindings:
(widget-create 'editable-field
;; Leave some space at the start and end of the
;; search boxes.
- :size (max 8 (- (window-width) notmuch-hello-indent
+ :size (max 8 (- (window-width)
+ (line-number-display-width)
+ notmuch-hello-indent
(length "Search: ")))
:action #'notmuch-hello-search)
;; Add an invisible dot to make `widget-end-of-line' ignore
@@ -947,7 +958,9 @@ following:
(customize-variable 'notmuch-hello-sections))
:button-prefix "" :button-suffix ""
"this page.")
-(let ((fill-column (- (window-width) notmuch-hello-indent)))
+(let ((fill-column (- (window-width)
+ (line-number-display-width)
+ notmuch-hello-indent)))
(center-region start (point)
;;; Hello!
--
2.37.1 (Apple Git-137.1)
>From 4964ac4a656521a0e84615ea718c81fb4e95bedf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?=
Date: Thu, 25 May 2023 17:21:38 +0200
Subject: [PATCH 2/2] emacs: re-layout notmuch-hello when window width changes
---
emacs/notmuch-hello.el | 22 +++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 3235f555..f245a7dd 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -383,6 +383,10 @@ supported for \"Customized queries section\" items."
(defvar notmuch-hello-first-run t
"True if `notmuch-hello' is run for the first time, set to nil afterwards.")
+(defvar notmuch-hello-scheduled-to-run nil
+ "True if `notmuch-hello' is scheduled to run during the next
+re-display, and set to nil afterwards.")
+
;;; Widgets for inserters
(define-widget 'notmuch-search-item 'item
@@ -701,12 +705,23 @@ with `notmuch-hello-query-counts'."
;; The user just switched to hello in this window (hello
;; is currently visible, was not visible on the last
;; configuration change, and this is not a new window)
- (setq do-refresh t)
-(when (and do-refresh notmuch-hello-auto-refresh)
+ (setq do-refresh t)))
+ (when (eq cur-buf hello-buf)
+ ;; This is the hello buffer, so check its last and current width.
+ (let ((last-width (window-parameter window 'notmuch-hello-last-width))
+ (cur-width (window-width window)))
+ (unless (equal last-width cur-width)
+ ;; The with of the window has changed, so do refresh.
+ (set-window-parameter window 'notmuch-hello-last-width cur-width)
+ (setq do-refresh t))
+(when