[PATCH 07/13] emacs: Allow tuning of the tag/saved search layout.
authorDavid Edmondson <dme@dme.org>
Wed, 19 May 2010 07:03:34 +0000 (08:03 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:37:04 +0000 (09:37 -0800)
90/5b649c83f75155137fba3dacceb2eee93e1868 [new file with mode: 0644]

diff --git a/90/5b649c83f75155137fba3dacceb2eee93e1868 b/90/5b649c83f75155137fba3dacceb2eee93e1868
new file mode 100644 (file)
index 0000000..85133d0
--- /dev/null
@@ -0,0 +1,159 @@
+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 82D2D40AB25\r
+       for <notmuch@notmuchmail.org>; Wed, 19 May 2010 01:55:14 -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, RCVD_IN_DNSWL_NONE=-0.0001] 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 WmaeLOwLXszv for <notmuch@notmuchmail.org>;\r
+       Wed, 19 May 2010 01:55:00 -0700 (PDT)\r
+Received: from mail-ew0-f213.google.com (mail-ew0-f213.google.com\r
+       [209.85.219.213])\r
+       by olra.theworths.org (Postfix) with ESMTP id 0EABE409DF7\r
+       for <notmuch@notmuchmail.org>; Wed, 19 May 2010 01:53:48 -0700 (PDT)\r
+Received: by mail-ew0-f213.google.com with SMTP id 5so1814158ewy.0\r
+       for <notmuch@notmuchmail.org>; Wed, 19 May 2010 01:53:48 -0700 (PDT)\r
+Received: by 10.213.55.76 with SMTP id t12mr3285630ebg.3.1274259228640;\r
+       Wed, 19 May 2010 01:53:48 -0700 (PDT)\r
+Received: from ut.hh.sledj.net (host83-217-165-81.dsl.vispa.com\r
+       [83.217.165.81])\r
+       by mx.google.com with ESMTPS id 16sm3523089ewy.3.2010.05.19.01.53.44\r
+       (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
+       Wed, 19 May 2010 01:53:45 -0700 (PDT)\r
+Received: by ut.hh.sledj.net (Postfix, from userid 1000)\r
+       id E5EC65940A3; Wed, 19 May 2010 08:03:45 +0100 (BST)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 07/13] emacs: Allow tuning of the tag/saved search layout.\r
+Date: Wed, 19 May 2010 08:03:34 +0100\r
+Message-Id: <1274252620-1249-8-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 1.7.1\r
+In-Reply-To: <1274252620-1249-1-git-send-email-dme@dme.org>\r
+References: <1274252620-1249-1-git-send-email-dme@dme.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: Wed, 19 May 2010 08:55:14 -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
+ 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.1\r
+\r