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 82D2D40AB25 for ; Wed, 19 May 2010 01:55:14 -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, RCVD_IN_DNSWL_NONE=-0.0001] 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 WmaeLOwLXszv for ; Wed, 19 May 2010 01:55:00 -0700 (PDT) Received: from mail-ew0-f213.google.com (mail-ew0-f213.google.com [209.85.219.213]) by olra.theworths.org (Postfix) with ESMTP id 0EABE409DF7 for ; Wed, 19 May 2010 01:53:48 -0700 (PDT) Received: by mail-ew0-f213.google.com with SMTP id 5so1814158ewy.0 for ; Wed, 19 May 2010 01:53:48 -0700 (PDT) Received: by 10.213.55.76 with SMTP id t12mr3285630ebg.3.1274259228640; Wed, 19 May 2010 01:53:48 -0700 (PDT) Received: from ut.hh.sledj.net (host83-217-165-81.dsl.vispa.com [83.217.165.81]) by mx.google.com with ESMTPS id 16sm3523089ewy.3.2010.05.19.01.53.44 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 19 May 2010 01:53:45 -0700 (PDT) Received: by ut.hh.sledj.net (Postfix, from userid 1000) id E5EC65940A3; Wed, 19 May 2010 08:03:45 +0100 (BST) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH 07/13] emacs: Allow tuning of the tag/saved search layout. Date: Wed, 19 May 2010 08:03:34 +0100 Message-Id: <1274252620-1249-8-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1274252620-1249-1-git-send-email-dme@dme.org> References: <1274252620-1249-1-git-send-email-dme@dme.org> 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: Wed, 19 May 2010 08:55:14 -0000 Add `notmuch-column-control', which has three potential sets of values: - t: automatically calculate the number of columns per line 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 column, - a float: a fraction of the window width that is the lower bound on the number of characters that should be used for each column. 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'. --- emacs/notmuch-hello.el | 63 +++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 57 insertions(+), 6 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 1358387..acf40bc 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -65,6 +65,32 @@ "Background colour for the notmuch logo." :group 'notmuch) +(defcustom notmuch-column-control t + "Controls the number of columns for saved searches/tags in notmuch view. + +This variable has three potential sets of values: + +- t: automatically calculate the number of columns 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 column, +- a float: a fraction of the window width that is the lower bound + on the number of characters that should be used for each + column. + +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"))) + (defvar notmuch-hello-url "http://notmuchmail.org" "The `notmuch' web site.") @@ -146,13 +172,38 @@ diagonal." (defun notmuch-saved-search-count (search) (car (process-lines notmuch-command "count" search))) +(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-column-control) + (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-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))) + + (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.1