Re: Filesystem functionality used by notmuch
[notmuch-archives.git] / e9 / 9c4547a02d9b70e5addb726f66dcec7fc4ce65
1 Return-Path: <markwalters1009@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 8EE83431FAF\r
6         for <notmuch@notmuchmail.org>; Wed,  5 Jun 2013 00:48:49 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id 0n2f46Jq49C7 for <notmuch@notmuchmail.org>;\r
18         Wed,  5 Jun 2013 00:48:41 -0700 (PDT)\r
19 Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com\r
20         [209.85.212.171]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id AB6F6431FAE\r
23         for <notmuch@notmuchmail.org>; Wed,  5 Jun 2013 00:48:41 -0700 (PDT)\r
24 Received: by mail-wi0-f171.google.com with SMTP id hm9so1529668wib.4\r
25         for <notmuch@notmuchmail.org>; Wed, 05 Jun 2013 00:48:39 -0700 (PDT)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id:x-mailer;\r
28         bh=6Opny4hGdBbTAkssxN5thYSmIpZms6znsDWWw4rd258=;\r
29         b=cvdTjL7ZISU2exEPrNKkfGuOnFHwCDnWJNeYLFF+QIWGk+6hQ9AXGNbFlwR656MQGr\r
30         +pJLMJGVeOTUr42Smsf9ZVYfTy7yHl6acVg9qhu4Q/jck1YGNr0vO9FiPJuxmIwo8nv2\r
31         hLGyRIXX7Li6i+5Oxcmv1AmXWdWPI9yeoKLlAraLUQi/QmSGNHzAA58dLhOCv3ITfmj7\r
32         trnS5nhPE7eT+4kPJbs35S0XXU4H1I4hoFZ3jxOTRk7A/yssHSzPrMPC8ghRtMGQokPF\r
33         oO11wYPqUdsYtShwN+MvQMgEvOBqX2Zm/St+IzNk7mtn+6Vg+Gp5y0o8PXHSDbozlw6M\r
34         etOg==\r
35 X-Received: by 10.180.210.225 with SMTP id mx1mr5286095wic.15.1370418519312;\r
36         Wed, 05 Jun 2013 00:48:39 -0700 (PDT)\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
38         by mx.google.com with ESMTPSA id h8sm8463137wiz.9.2013.06.05.00.48.37\r
39         for <multiple recipients>\r
40         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
41         Wed, 05 Jun 2013 00:48:38 -0700 (PDT)\r
42 From: Mark Walters <markwalters1009@gmail.com>\r
43 To: notmuch@notmuchmail.org,\r
44         Jani Nikula <jani@nikula.org>\r
45 Subject: [WIP PATCH] emacs: search: toggle multiline\r
46 Date: Wed,  5 Jun 2013 08:48:35 +0100\r
47 Message-Id: <1370418515-9845-1-git-send-email-markwalters1009@gmail.com>\r
48 X-Mailer: git-send-email 1.7.9.1\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.13\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53         <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Wed, 05 Jun 2013 07:48:50 -0000\r
62 \r
63 ---\r
64 Jani and I were chatting on irc and he mentioned it was annoying not\r
65 to be able to see the whole subject in the eamcs search view (if the\r
66 window is not very wide). Since Austin's search changes sometime ago\r
67 allow multiline results and updating results in place we can use this\r
68 to give an expanded view. In this preliminary version "e" toggles\r
69 between the expanded view and normal view.\r
70 \r
71 It's definitely work in progress but seems to work. There are some\r
72 oddities in multiline results which probably need fixin and,\r
73 personally, I would like the option of a full date as well as the\r
74 brief relative date.\r
75 \r
76 Best wishes\r
77 \r
78 Mark\r
79 \r
80 \r
81  emacs/notmuch.el |   30 +++++++++++++++++++++++++-----\r
82  1 files changed, 25 insertions(+), 5 deletions(-)\r
83 \r
84 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
85 index 6a4052e..3f5ae4a 100644\r
86 --- a/emacs/notmuch.el\r
87 +++ b/emacs/notmuch.el\r
88 @@ -80,6 +80,16 @@ To enter a line break in customize, press \\[quoted-insert] C-j."\r
89    :type '(alist :key-type (string) :value-type (string))\r
90    :group 'notmuch-search)\r
91  \r
92 +(defcustom notmuch-search-expanded-result-format\r
93 +  `(("date" . "%12s ")\r
94 +    ("count" . "%-7s\n")\r
95 +    ("authors" . "  Authors: %-70s")\r
96 +    ("subject" . "\n  Subject: %s\n")\r
97 +    ("tags" . "  Tags: (%s)\n"))\r
98 +  "format for expanded results"\r
99 +  :type '(alist :key-type (string) :value-type (string))\r
100 +  :group 'notmuch-search)\r
101 +\r
102  (defvar notmuch-query-history nil\r
103    "Variable to store minibuffer history for notmuch queries")\r
104  \r
105 @@ -230,6 +240,7 @@ For a mouse binding, return nil."\r
106      (define-key map "c" 'notmuch-search-stash-map)\r
107      (define-key map "=" 'notmuch-search-refresh-view)\r
108      (define-key map "G" 'notmuch-search-poll-and-refresh-view)\r
109 +    (define-key map "e" 'notmuch-search-toggle-expand-result)\r
110      (define-key map "t" 'notmuch-search-filter-by-tag)\r
111      (define-key map "f" 'notmuch-search-filter)\r
112      (define-key map [mouse-1] 'notmuch-search-show-thread)\r
113 @@ -611,7 +622,7 @@ This function advances the next thread when finished."\r
114       (notmuch-tag-change-list notmuch-archive-tags unarchive)))\r
115    (notmuch-search-next-thread))\r
116  \r
117 -(defun notmuch-search-update-result (result &optional pos)\r
118 +(defun notmuch-search-update-result (result &optional pos format)\r
119    "Replace the result object of the thread at POS (or point) by\r
120  RESULT and redraw it.\r
121  \r
122 @@ -626,7 +637,7 @@ of the result."\r
123      ;; Delete the current thread\r
124      (delete-region start end)\r
125      ;; Insert the updated thread\r
126 -    (notmuch-search-show-result result start)\r
127 +    (notmuch-search-show-result result start format)\r
128      ;; If point was inside the old result, make an educated guess\r
129      ;; about where to place it now.  Unfortunately, this won't work\r
130      ;; with save-excursion (or any other markers that would be nice to\r
131 @@ -639,6 +650,14 @@ of the result."\r
132                           (min init-point (- new-end 1)))))\r
133         (goto-char new-point)))))\r
134  \r
135 +(defun notmuch-search-toggle-expand-result (&optional pos)\r
136 +  (interactive)\r
137 +  (let* ((result (notmuch-search-get-result pos))\r
138 +        (expanded (not (plist-get result :expanded)))\r
139 +        (new-result (plist-put result :expanded expanded))\r
140 +        (format (and expanded notmuch-search-expanded-result-format)))\r
141 +    (notmuch-search-update-result new-result pos format)))\r
142 +\r
143  (defun notmuch-search-process-sentinel (proc msg)\r
144    "Add a message to let user know when \"notmuch search\" exits"\r
145    (let ((buffer (process-buffer proc))\r
146 @@ -801,14 +820,15 @@ non-authors is found, assume that all of the authors match."\r
147      (let ((tags (plist-get result :tags)))\r
148        (insert (format format-string (notmuch-tag-format-tags tags)))))))\r
149  \r
150 -(defun notmuch-search-show-result (result &optional pos)\r
151 +(defun notmuch-search-show-result (result &optional pos format)\r
152    "Insert RESULT at POS or the end of the buffer if POS is null."\r
153    ;; Ignore excluded matches\r
154    (unless (= (plist-get result :matched) 0)\r
155 -    (let ((beg (or pos (point-max))))\r
156 +    (let ((beg (or pos (point-max)))\r
157 +         (format (or format notmuch-search-result-format)))\r
158        (save-excursion\r
159         (goto-char beg)\r
160 -       (dolist (spec notmuch-search-result-format)\r
161 +       (dolist (spec format)\r
162           (notmuch-search-insert-field (car spec) (cdr spec) result))\r
163         (insert "\n")\r
164         (notmuch-search-color-line beg (point) (plist-get result :tags))\r
165 -- \r
166 1.7.9.1\r
167 \r