* [Patch 2/3] Respect window margins in notmuch-hello.el
@ 2011-10-29 16:30 Ivy Foster
2011-12-23 23:53 ` Dmitry Kurochkin
0 siblings, 1 reply; 2+ messages in thread
From: Ivy Foster @ 2011-10-29 16:30 UTC (permalink / raw)
To: notmuch
Hello again, folks,
The following patch makes notmuch take window margins into
account when calculating the width of the notmuch-hello
window in Emacs. As a side benefit (so that I only had to
write the code once), I've added a named function to return
said width.
Folks using linum-mode should still probably get a copy of
linum-off.el and disable linum for notmuch-hello, though,
since it doesn't set the margin until after the buffer is
done being created, causing text to overflow across the
edge. Alternately, take a look at my next message, with yet
another patch.
Enjoy!
iff
Signed-off-by: Ivy Foster <joyfulgirl@archlinux.us>
From 0c1a0fa0858e3c22b416ce6bd9ad623198217d34 Mon Sep 17 00:00:00 2001
From: Ivy Foster <joyfulgirl@archlinux.us>
Date: Fri, 28 Oct 2011 23:18:14 -0400
Subject: [PATCH 2/3] Respect margins in new named window-width function
This patch removes a function which is duplicated
several times in notmuch-hello.el, improving
readability. Also, factors in window margins
when calculating width.
---
emacs/notmuch-hello.el | 28 ++++++++++++++++++----------
1 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 65fde75..1a213f0 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -213,25 +213,27 @@ should be. Returns a cons cell `(tags-per-line width)'."
(cond
((integerp notmuch-column-control)
(max 1
- (/ (- (window-width) notmuch-hello-indent)
+ (/ (notmuch-hello-available-width)
;; 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))
- (proposed-width (max (* available-width notmuch-column-control) widest)))
- (floor available-width proposed-width)))
+ (let ((proposed-width (max
+ (* (notmuch-hello-available-width)
+ notmuch-column-control)
+ widest)))
+ (floor (notmuch-hello-available-width) proposed-width)))
(t
(max 1
- (/ (- (window-width) notmuch-hello-indent)
+ (/ (notmuch-hello-available-width)
;; 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
+ (- (notmuch-hello-available-width)
;; Count is 9 wide (8 digits plus
;; space), 1 for the space after the
;; name.
@@ -458,7 +460,7 @@ 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 (- (notmuch-hello-available-width)
(length "Search: ")))
:action (lambda (widget &rest ignore)
(notmuch-hello-search (widget-value widget))))
@@ -481,12 +483,13 @@ Complete list of currently available key bindings:
;; Don't let the search boxes be
;; less than 8 characters wide.
:size (max 8
- (- (window-width)
+ (-
+ (notmuch-hello-available-width)
;; Leave some space
;; at the start and
;; end of the
;; boxes.
- (* 2 notmuch-hello-indent)
+ notmuch-hello-indent
;; 1 for the space
;; before the
;; `[save]' button. 6
@@ -540,7 +543,7 @@ Complete list of currently available key bindings:
(widget-insert "Edit saved searches with the `edit' button.\n"))
(widget-insert "Hit RET or click on a saved search or tag name to view matching threads.\n")
(widget-insert "`=' refreshes this screen. `s' jumps to the search box. `q' to quit.\n")
- (let ((fill-column (- (window-width) notmuch-hello-indent)))
+ (let ((fill-column (notmuch-hello-available-width)))
(center-region start (point))))
(widget-setup)
@@ -558,6 +561,11 @@ Complete list of currently available key bindings:
(interactive)
(notmuch-hello))
+(defun notmuch-hello-available-width ()
+ (let ((left-margin (or (car (window-margins)) 0))
+ (right-margin (or (cadr (window-margins)) 0)))
+ (- (window-width) left-margin right-margin notmuch-hello-indent)))
+
;;
(provide 'notmuch-hello)
--
1.7.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Patch 2/3] Respect window margins in notmuch-hello.el
2011-10-29 16:30 [Patch 2/3] Respect window margins in notmuch-hello.el Ivy Foster
@ 2011-12-23 23:53 ` Dmitry Kurochkin
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Kurochkin @ 2011-12-23 23:53 UTC (permalink / raw)
To: Ivy Foster, notmuch
Hi Ivy.
The patch looks good to me. But I think it would be very nice to have a
test for it, which would be broken at first and fixed by this patch.
Can you add it please?
Regards,
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-12-23 23:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-29 16:30 [Patch 2/3] Respect window margins in notmuch-hello.el Ivy Foster
2011-12-23 23:53 ` Dmitry Kurochkin
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).