[PATCH] emacs: Allow tuning of the tag/saved search layout.
authorDavid Edmondson <dme@dme.org>
Thu, 29 Apr 2010 08:28:23 +0000 (09:28 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:37:00 +0000 (09:37 -0800)
0d/db55b021427986d974ec4841f3b44aa5d51186 [new file with mode: 0644]

diff --git a/0d/db55b021427986d974ec4841f3b44aa5d51186 b/0d/db55b021427986d974ec4841f3b44aa5d51186
new file mode 100644 (file)
index 0000000..dab86bc
--- /dev/null
@@ -0,0 +1,162 @@
+Return-Path: <dme@dme.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 79C744196F0\r
+       for <notmuch@notmuchmail.org>; Thu, 29 Apr 2010 01:28:07 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.9\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5\r
+       tests=[BAYES_00=-1.9] autolearn=ham\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id YdOaJIMXqSgO for <notmuch@notmuchmail.org>;\r
+       Thu, 29 Apr 2010 01:28:06 -0700 (PDT)\r
+Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com\r
+       [74.125.82.181])\r
+       by olra.theworths.org (Postfix) with ESMTP id 62700431FC1\r
+       for <notmuch@notmuchmail.org>; Thu, 29 Apr 2010 01:28:06 -0700 (PDT)\r
+Received: by wyj26 with SMTP id 26so2874369wyj.26\r
+       for <notmuch@notmuchmail.org>; Thu, 29 Apr 2010 01:28:05 -0700 (PDT)\r
+Received: by 10.216.154.206 with SMTP id h56mr5087860wek.94.1272529685406;\r
+       Thu, 29 Apr 2010 01:28:05 -0700 (PDT)\r
+Received: from ut.hh.sledj.net (gmp-ea-fw-1b.sun.com [192.18.8.1])\r
+       by mx.google.com with ESMTPS id z3sm5366595wbs.22.2010.04.29.01.28.03\r
+       (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
+       Thu, 29 Apr 2010 01:28:04 -0700 (PDT)\r
+Received: by ut.hh.sledj.net (Postfix, from userid 1000)\r
+       id 0420459411F; Thu, 29 Apr 2010 09:28:24 +0100 (BST)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs: Allow tuning of the tag/saved search layout.\r
+Date: Thu, 29 Apr 2010 09:28:23 +0100\r
+Message-Id: <1272529703-29092-1-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 1.7.0\r
+In-Reply-To: <87d3xknc1w.fsf@yoom.home.cworth.org>\r
+References: <87d3xknc1w.fsf@yoom.home.cworth.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 29 Apr 2010 08:28:07 -0000\r
+\r
+Add `notmuch-column-control', which has three potential sets of\r
+values:\r
+\r
+- t: automatically calculate the number of columns per line based on\r
+  the tags to be shown and the window width,\r
+- an integer: a lower bound on the number of characters that will be\r
+  used to display each column,\r
+- a float: a fraction of the window width that is the lower bound on\r
+  the number of characters that should be used for each column.\r
+\r
+So:\r
+- if you would like two columns of tags, set this to 0.5.\r
+- if you would like a single column of tags, set this to 1.0.\r
+- if you would like tags to be 30 characters wide, set this to\r
+  30.\r
+- if you don't want to worry about all of this nonsense, leave\r
+  this set to `t'.\r
+---\r
+\r
+`notmuch-hello-tag-width' is now `notmuch-column-control', given that\r
+your proposed first sentence is a better explanation of the purpose.\r
+\r
+ emacs/notmuch-hello.el |   63 +++++++++++++++++++++++++++++++++++++++++++----\r
+ 1 files changed, 57 insertions(+), 6 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
+index 1358387..acf40bc 100644\r
+--- a/emacs/notmuch-hello.el\r
++++ b/emacs/notmuch-hello.el\r
+@@ -65,6 +65,32 @@\r
+   "Background colour for the notmuch logo."\r
+   :group 'notmuch)\r
\r
++(defcustom notmuch-column-control t\r
++  "Controls the number of columns for saved searches/tags in notmuch view.\r
++\r
++This variable has three potential sets of values:\r
++\r
++- t: automatically calculate the number of columns possible based\r
++  on the tags to be shown and the window width,\r
++- an integer: a lower bound on the number of characters that will\r
++  be used to display each column,\r
++- a float: a fraction of the window width that is the lower bound\r
++  on the number of characters that should be used for each\r
++  column.\r
++\r
++So:\r
++- if you would like two columns of tags, set this to 0.5.\r
++- if you would like a single column of tags, set this to 1.0.\r
++- if you would like tags to be 30 characters wide, set this to\r
++  30.\r
++- if you don't want to worry about all of this nonsense, leave\r
++  this set to `t'."\r
++  :group 'notmuch\r
++  :type '(choice\r
++        (const :tag "Automatically calculated" t)\r
++        (integer :tag "Number of characters")\r
++        (float :tag "Fraction of window")))\r
++\r
+ (defvar notmuch-hello-url "http://notmuchmail.org"\r
+   "The `notmuch' web site.")\r
\r
+@@ -146,13 +172,38 @@ diagonal."\r
+ (defun notmuch-saved-search-count (search)\r
+   (car (process-lines notmuch-command "count" search)))\r
\r
++(defun notmuch-hello-tags-per-line (widest)\r
++  "Determine how many tags to show per line and how wide they\r
++should be. Returns a cons cell `(tags-per-line width)'."\r
++  (let ((tags-per-line\r
++       (cond\r
++        ((integerp notmuch-column-control)\r
++         (max 1\r
++              (/ (- (window-width) notmuch-hello-indent)\r
++                 ;; Count is 7 wide (6 digits plus space), 1 for the space\r
++                 ;; after the name.\r
++                 (+ 7 1 (max notmuch-column-control widest)))))\r
++\r
++        ((floatp notmuch-column-control)\r
++         (let* ((available-width (- (window-width) notmuch-hello-indent))\r
++                (proposed-width (max (* available-width notmuch-column-control) widest)))\r
++           (floor available-width proposed-width)))\r
++\r
++        (t\r
++         (max 1\r
++              (/ (- (window-width) notmuch-hello-indent)\r
++                 ;; Count is 7 wide (6 digits plus space), 1 for the space\r
++                 ;; after the name.\r
++                 (+ 7 1 widest)))))))\r
++\r
++    (cons tags-per-line (/ (- (window-width) notmuch-hello-indent\r
++                            (* tags-per-line (+ 7 1)))\r
++                         tags-per-line))))\r
++\r
+ (defun notmuch-hello-insert-tags (tag-alist widest target)\r
+-  (let* ((tags-per-line (max 1\r
+-                           (/ (- (window-width) notmuch-hello-indent)\r
+-                              ;; Count is 7 wide (6 digits plus\r
+-                              ;; space), 1 for the space after the\r
+-                              ;; name.\r
+-                              (+ 7 1 widest))))\r
++  (let* ((tags-and-width (notmuch-hello-tags-per-line widest))\r
++       (tags-per-line (car tags-and-width))\r
++       (widest (cdr tags-and-width))\r
+        (count 0)\r
+        (reordered-list (notmuch-hello-reflect tag-alist tags-per-line))\r
+        ;; Hack the display of the buttons used.\r
+-- \r
+1.7.0\r
+\r