Re: [PATCH v4 08/16] reorganize indexing of multipart/signed and multipart/encrypted
[notmuch-archives.git] / 49 / 5922e039296fdb099cc7b8a8a9a66a1f5b69bd
1 Return-Path: <alpine.art.de@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 10164431FDB\r
6         for <notmuch@notmuchmail.org>; Sat, 11 Oct 2014 05:29:46 -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.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id OhMNytjgbZbv for <notmuch@notmuchmail.org>;\r
17         Sat, 11 Oct 2014 05:29:38 -0700 (PDT)\r
18 Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com\r
19         [209.85.217.173]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id BE808431FD0\r
22         for <notmuch@notmuchmail.org>; Sat, 11 Oct 2014 05:29:37 -0700 (PDT)\r
23 Received: by mail-lb0-f173.google.com with SMTP id 10so4436558lbg.4\r
24         for <notmuch@notmuchmail.org>; Sat, 11 Oct 2014 05:29:36 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26         h=date:message-id:from:to:cc:subject:in-reply-to:references\r
27         :mime-version:content-type:content-disposition\r
28         :content-transfer-encoding;\r
29         bh=vfFTDsXhrWPrj60iFLmwdfCKP/1/OzjlPSV/wRhwjjE=;\r
30         b=dVLCDrVtO/CKX2DPms+T7aa9cQsXMRuQxzqPDrgBDypzKmzx6AAYgOrrBmGv6JbfS/\r
31         7YbRVRrSA7Ovb0a6INPmNoOGTofEfWIrBDJzdtxw4FknWvc1A23unCmquC2l5NMII1/g\r
32         HWQDxf8KEpKOwkGOZhIqfbtahGUax9hVMN9wWddvI9N34ggVjjHe+93JVs2DyDoF8nu9\r
33         WbrDwfAT3z1/aWwVjX+itamXxX96ZVR82MdwQqDlmOVadnxlpGp95Q8p5mKEe25RXOQF\r
34         YExOY3h/xDaohYU194Dt1e1WPJmTZeXs/zBLn4Gr6Fa7nOsZ3m5/5FH1tZOIW2KcY/HR\r
35         hK+w==\r
36 X-Received: by 10.152.198.138 with SMTP id jc10mr11401929lac.59.1413030575113;\r
37         Sat, 11 Oct 2014 05:29:35 -0700 (PDT)\r
38 Received: from localhost (p5B00F017.dip0.t-ipconnect.de. [91.0.240.23])\r
39         by mx.google.com with ESMTPSA id a9sm2657815laa.3.2014.10.11.05.29.33\r
40         for <multiple recipients>\r
41         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
42         Sat, 11 Oct 2014 05:29:34 -0700 (PDT)\r
43 Date: Sat, 11 Oct 2014 14:29:43 +0200\r
44 Message-ID: <20141011142943.GD23373@TP_L520.localdomain>\r
45 From: Franz Fellner <alpine.art.de@gmail.com>\r
46 To: Ian Main <imain@stemwinder.org>\r
47 Subject: Re: [PATCH] VIM: Add URI handling\r
48 In-Reply-To: <543822f73d3fd_46ad163fe88cd@ovo.mains.priv.notmuch>\r
49 References: <1412281423-22441-1-git-send-email-imain@stemwinder.org>\r
50         <20141010114457.GG28601@TP_L520.localdomain>\r
51         <543822f73d3fd_46ad163fe88cd@ovo.mains.priv.notmuch>\r
52 MIME-Version: 1.0\r
53 Content-Type: text/plain; charset=utf-8\r
54 Content-Disposition: inline\r
55 Content-Transfer-Encoding: 8bit\r
56 Cc: notmuch@notmuchmail.org\r
57 X-BeenThere: notmuch@notmuchmail.org\r
58 X-Mailman-Version: 2.1.13\r
59 Precedence: list\r
60 List-Id: "Use and development of the notmuch mail system."\r
61         <notmuch.notmuchmail.org>\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
63         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
65 List-Post: <mailto:notmuch@notmuchmail.org>\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
68         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
69 X-List-Received-Date: Sat, 11 Oct 2014 12:29:46 -0000\r
70 \r
71 Here is a working implementation.\r
72 Please review carefully as I only can simulate ruby and vimscript\r
73 knowledge from what I see in notmuch.vim sourcefile and quick\r
74 googling.\r
75 \r
76 Regards\r
77 Franz\r
78 \r
79 \r
80 diff --git a/plugin/notmuch.vim b/plugin/notmuch.vim\r
81 index 567f75c..ef9fefa 100644\r
82 --- a/plugin/notmuch.vim\r
83 +++ b/plugin/notmuch.vim\r
84 @@ -269,6 +269,14 @@ ruby << EOF\r
85                 if uri.class == URI::MailTo\r
86                         vim_puts("Composing new email to #{uri.to}.")\r
87                         VIM::command("call s:compose('#{uri.to}')")\r
88 +               elsif uri.class == URI::MsgID\r
89 +                       msg = $curbuf.message(uri.opaque)\r
90 +                       if !msg\r
91 +                               vim_puts("Message not found in NotMuch database: #{uri.to_s}")\r
92 +                       else\r
93 +                               vim_puts("Opening message #{msg.message_id} in thread #{msg.thread_id}.")\r
94 +                               VIM::command("call s:show('thread:#{msg.thread_id}', '#{msg.message_id}')")\r
95 +                       end\r
96                 else\r
97                         vim_puts("Opening #{uri.to_s}.")\r
98                         cmd = VIM::evaluate('g:notmuch_open_uri')\r
99 @@ -429,11 +437,12 @@ endfunction\r
100  \r
101  "" main\r
102  \r
103 -function! s:show(thread_id)\r
104 +function! s:show(thread_id, msg_id)\r
105         call s:new_buffer('show')\r
106         setlocal modifiable\r
107  ruby << EOF\r
108         thread_id = VIM::evaluate('a:thread_id')\r
109 +       msg_id = VIM::evaluate('a:msg_id')\r
110         $cur_thread = thread_id\r
111         $messages.clear\r
112         $curbuf.render do |b|\r
113 @@ -465,6 +474,9 @@ ruby << EOF\r
114                         end\r
115                         b << ""\r
116                         nm_m.end = b.count\r
117 +                       if msg_id and nm_m.message_id == msg_id\r
118 +                               VIM::command("normal #{nm_m.start}zt")\r
119 +                       end\r
120                 end\r
121                 b.delete(b.count)\r
122         end\r
123 @@ -487,7 +499,7 @@ ruby << EOF\r
124         when 1; $cur_filter = nil\r
125         when 2; $cur_filter = $cur_search\r
126         end\r
127 -       VIM::command("call s:show('#{id}')")\r
128 +       VIM::command("call s:show('#{id}', '')")\r
129  EOF\r
130  endfunction\r
131  \r
132 @@ -917,6 +929,10 @@ ruby << EOF\r
133                         q\r
134                 end\r
135  \r
136 +               def message(id)\r
137 +                       @db.find_message(id)\r
138 +               end\r
139 +\r
140                 def close\r
141                         @queries.delete_if { |q| ! q.destroy! }\r
142                         @db.close\r
143 @@ -937,12 +953,20 @@ ruby << EOF\r
144                 end\r
145         end\r
146  \r
147 +       module URI\r
148 +               class MsgID < Generic\r
149 +               end\r
150 +\r
151 +               @@schemes['ID'] = MsgID\r
152 +       end\r
153 +\r
154         class Message\r
155                 attr_accessor :start, :body_start, :end\r
156 -               attr_reader :message_id, :filename, :mail\r
157 +               attr_reader :message_id, :thread_id, :filename, :mail\r
158  \r
159                 def initialize(msg, mail)\r
160                         @message_id = msg.message_id\r
161 +                       @thread_id = msg.thread_id\r
162                         @filename = msg.filename\r
163                         @mail = mail\r
164                         @start = 0\r
165 \r
166 On Fri, 10 Oct 2014 11:18:31 -0700, Ian Main <imain@stemwinder.org> wrote:\r
167 > Franz Fellner wrote:\r
168 > > Works nice. Tested with an https and a mailto URI.\r
169 > > But it would be awesome if you could add message id handling, So one\r
170 > > could easily navigate to linked messages. I only found emacs client\r
171 > > implement this feature. What I read in the docs about ruby URI module\r
172 > > it should be fairly easy to add a custom scheme for id.\r
173\r
174 > I'm afraid I'm not sure what you mean by message id handling?  It's\r
175 > probably something simple but .. :)\r
176\r
177 >     Ian\r