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 6E2A54196F0 for ; Tue, 27 Apr 2010 07:58:34 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.9 X-Spam-Level: X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9] autolearn=ham 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 UqFcgQP5OIGZ for ; Tue, 27 Apr 2010 07:58:32 -0700 (PDT) Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com [74.125.82.181]) by olra.theworths.org (Postfix) with ESMTP id DEAEB431FC1 for ; Tue, 27 Apr 2010 07:58:31 -0700 (PDT) Received: by wyj26 with SMTP id 26so1549892wyj.26 for ; Tue, 27 Apr 2010 07:58:31 -0700 (PDT) Received: by 10.216.90.17 with SMTP id d17mr271194wef.117.1272380310844; Tue, 27 Apr 2010 07:58:30 -0700 (PDT) Received: from ut.hh.sledj.net (gmp-ea-fw-1b.sun.com [192.18.8.1]) by mx.google.com with ESMTPS id z3sm5974884wbs.10.2010.04.27.07.58.29 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 27 Apr 2010 07:58:29 -0700 (PDT) Received: by ut.hh.sledj.net (Postfix, from userid 1000) id 9B2E259413B; Tue, 27 Apr 2010 15:58:43 +0100 (BST) From: dme@dme.org To: notmuch@notmuchmail.org Subject: [PATCH] emacs: Allow tuning of the tag/saved search layout. Date: Tue, 27 Apr 2010 15:58:39 +0100 Message-Id: <1272380319-2387-1-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.0 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: Tue, 27 Apr 2010 14:58:34 -0000 From: David Edmondson Add `notmuch-hello-tag-width', which has three potential sets of values: - t: automatically calculate the number of tags per line possible based on the tags to be shown and the window width, - an integer: a lower bound on the number of characters that will be used to display each tag, - a float: a fraction of the window width that is the lower bound on the number of characters that should be used for each tag. So: - if you would like two columns of tags, set this to 0.5. - if you would like a single column of tags, set this to 1.0. - if you would like tags to be 30 characters wide, set this to 30. - if you don't want to worry about all of this nonsense, leave this set to `t'. --- Carl, for 0.4. You mentioned that you might like to have a single column of tags/saved searches, but others appear to like multiple columns. So, make it configurable. emacs/notmuch-hello.el | 62 +++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 56 insertions(+), 6 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 378d41c..f7703d9 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -141,13 +141,63 @@ diagonal." (defun notmuch-saved-search-count (search) (car (process-lines notmuch-command "count" search))) +(defcustom notmuch-hello-tag-width t + "How wide should a tag be? + +This variable has three potential sets of values: + +- t: automatically calculate the number of tags per line possible + based on the tags to be shown and the window width, +- an integer: a lower bound on the number of characters that will + be used to display each tag, +- a float: a fraction of the window width that is the lower bound + on the number of characters that should be used for each tag. + +So: +- if you would like two columns of tags, set this to 0.5. +- if you would like a single column of tags, set this to 1.0. +- if you would like tags to be 30 characters wide, set this to + 30. +- if you don't want to worry about all of this nonsense, leave + this set to `t'." + :group 'notmuch + :type '(choice + (const :tag "Automatically calculated" t) + (integer :tag "Number of characters") + (float :tag "Fraction of window"))) + +(defun notmuch-hello-tags-per-line (widest) + "Determine how many tags to show per line and how wide they +should be. Returns a cons cell `(tags-per-line width)'." + (let ((tags-per-line + (cond + ((integerp notmuch-hello-tag-width) + (max 1 + (/ (- (window-width) notmuch-hello-indent) + ;; Count is 7 wide (6 digits plus space), 1 for the space + ;; after the name. + (+ 7 1 (max notmuch-hello-tag-width widest))))) + + ((floatp notmuch-hello-tag-width) + (let* ((available-width (- (window-width) notmuch-hello-indent)) + (proposed-width (max (* available-width notmuch-hello-tag-width) widest))) + (floor available-width proposed-width))) + + (t + (max 1 + (/ (- (window-width) notmuch-hello-indent) + ;; Count is 7 wide (6 digits plus space), 1 for the space + ;; after the name. + (+ 7 1 widest))))))) + + (cons tags-per-line (/ (- (window-width) notmuch-hello-indent + (* tags-per-line (+ 7 1))) + tags-per-line)))) + (defun notmuch-hello-insert-tags (tag-alist widest target) - (let* ((tags-per-line (max 1 - (/ (- (window-width) notmuch-hello-indent) - ;; Count is 7 wide (6 digits plus - ;; space), 1 for the space after the - ;; name. - (+ 7 1 widest)))) + (let* ((tags-and-width (notmuch-hello-tags-per-line widest)) + (tags-per-line (car tags-and-width)) + (widest (cdr tags-and-width)) (count 0) (reordered-list (notmuch-hello-reflect tag-alist tags-per-line)) ;; Hack the display of the buttons used. -- 1.7.0