Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id B537D429E25 for ; Sat, 29 Oct 2011 09:33:37 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yA-kNWk-QIWV for ; Sat, 29 Oct 2011 09:33:37 -0700 (PDT) Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com [209.85.216.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id DC102431FB6 for ; Sat, 29 Oct 2011 09:33:36 -0700 (PDT) Received: by qyk27 with SMTP id 27so5838408qyk.5 for ; Sat, 29 Oct 2011 09:33:36 -0700 (PDT) Received: by 10.229.190.9 with SMTP id dg9mr179805qcb.246.1319906016094; Sat, 29 Oct 2011 09:33:36 -0700 (PDT) Received: from localhost (209-6-79-248.c3-0.abr-ubr1.sbo-abr.ma.cable.rcn.com. [209.6.79.248]) by mx.google.com with ESMTPS id du5sm20729174qab.14.2011.10.29.09.33.34 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 29 Oct 2011 09:33:35 -0700 (PDT) From: Ivy Foster To: notmuch@notmuchmail.org Subject: [Patch 2/3] Respect window margins in notmuch-hello.el Date: Sat, 29 Oct 2011 12:30:48 -0400 Message-ID: <87k47nlpzb.fsf@nausicaa.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Oct 2011 16:33:37 -0000 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 >From 0c1a0fa0858e3c22b416ce6bd9ad623198217d34 Mon Sep 17 00:00:00 2001 From: Ivy Foster 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