New "notmuch address" command
[notmuch-archives.git] / 12 / ddd2c098282ab28a6eb9e4551bdf9a24e2aa15
1 Return-Path: <imain@redhat.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 4E0A7431FB6\r
6         for <notmuch@notmuchmail.org>; Wed, 15 Oct 2014 12:34:03 -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\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id d3AYF5s1z9U1 for <notmuch@notmuchmail.org>;\r
16         Wed, 15 Oct 2014 12:33:59 -0700 (PDT)\r
17 Received: from cmta10.telus.net (cmta10.telus.net [209.171.16.83])\r
18         by olra.theworths.org (Postfix) with ESMTP id 5B1B6431FAF\r
19         for <notmuch@notmuchmail.org>; Wed, 15 Oct 2014 12:33:59 -0700 (PDT)\r
20 Received: from ovo.mains.priv ([207.102.88.62]) by cmta10.telus.net with TELUS\r
21         id 3XZy1p00D1LiWEf01XZyoQ; Wed, 15 Oct 2014 13:33:58 -0600\r
22 X-Authority-Analysis: v=2.0 cv=PP7RD4WC c=1 sm=2\r
23         a=EcQDfIwDZEqJA1f7rVUV8Q==:17 a=S-IsBHyFrF4A:10 a=IkcTkHD0fZMA:10\r
24         a=tsa3CZZnAAAA:8 a=XWforfwaZwZkm9eP2S4A:9 a=QEXdDO2ut3YA:10\r
25         a=P87eogJZi2UA:10 a=EcQDfIwDZEqJA1f7rVUV8Q==:117\r
26 X-Telus-Outbound-IP: 207.102.88.62\r
27 Received: from ovo.mains.priv (localhost.localdomain [127.0.0.1])\r
28         by ovo.mains.priv (8.14.8/8.14.8) with ESMTP id s9FJXu0b011335;\r
29         Wed, 15 Oct 2014 12:33:56 -0700\r
30 Received: (from imain@localhost)\r
31         by ovo.mains.priv (8.14.8/8.14.8/Submit) id s9FJXtMY011334;\r
32         Wed, 15 Oct 2014 12:33:55 -0700\r
33 X-Authentication-Warning: ovo.mains.priv: imain set sender to imain@redhat.com\r
34         using -f\r
35 Date: Wed, 15 Oct 2014 12:33:55 -0700\r
36 From: Ian Main <imain@stemwinder.org>\r
37 To: Franz Fellner <alpine.art.de@gmail.com>\r
38 Message-ID: <543ecc23bb98_2c291569e8c17@ovo.mains.priv.notmuch>\r
39 In-Reply-To: <20141011142943.GD23373@TP_L520.localdomain>\r
40 References: <1412281423-22441-1-git-send-email-imain@stemwinder.org>\r
41         <20141010114457.GG28601@TP_L520.localdomain>\r
42         <543822f73d3fd_46ad163fe88cd@ovo.mains.priv.notmuch>\r
43         <20141011142943.GD23373@TP_L520.localdomain>\r
44 Subject: Re: [PATCH] VIM: Add URI handling\r
45 Mime-Version: 1.0\r
46 Content-Type: text/plain;\r
47  charset=utf-8\r
48 Content-Transfer-Encoding: 7bit\r
49 Cc: notmuch@notmuchmail.org\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.13\r
52 Precedence: list\r
53 List-Id: "Use and development of the notmuch mail system."\r
54         <notmuch.notmuchmail.org>\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
58 List-Post: <mailto:notmuch@notmuchmail.org>\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
62 X-List-Received-Date: Wed, 15 Oct 2014 19:34:03 -0000\r
63 \r
64 Franz Fellner wrote:\r
65 > Here is a working implementation.\r
66 > Please review carefully as I only can simulate ruby and vimscript\r
67 > knowledge from what I see in notmuch.vim sourcefile and quick\r
68 > googling.\r
69 \r
70 Yes, this works nicely.  Thanks!\r
71 \r
72 I do notice however that this is against the github plugin repo (I think)?\r
73 \r
74 I think It'd be nice to have this against the main repo and in its own\r
75 thread.  I can repost it for you if you like as I added it to mine, or you\r
76 can do it if you prefer.\r
77 \r
78     Ian\r
79  \r
80 > Regards\r
81 > Franz\r
82\r
83\r
84 > diff --git a/plugin/notmuch.vim b/plugin/notmuch.vim\r
85 > index 567f75c..ef9fefa 100644\r
86 > --- a/plugin/notmuch.vim\r
87 > +++ b/plugin/notmuch.vim\r
88 > @@ -269,6 +269,14 @@ ruby << EOF\r
89 >               if uri.class == URI::MailTo\r
90 >                       vim_puts("Composing new email to #{uri.to}.")\r
91 >                       VIM::command("call s:compose('#{uri.to}')")\r
92 > +             elsif uri.class == URI::MsgID\r
93 > +                     msg = $curbuf.message(uri.opaque)\r
94 > +                     if !msg\r
95 > +                             vim_puts("Message not found in NotMuch database: #{uri.to_s}")\r
96 > +                     else\r
97 > +                             vim_puts("Opening message #{msg.message_id} in thread #{msg.thread_id}.")\r
98 > +                             VIM::command("call s:show('thread:#{msg.thread_id}', '#{msg.message_id}')")\r
99 > +                     end\r
100 >               else\r
101 >                       vim_puts("Opening #{uri.to_s}.")\r
102 >                       cmd = VIM::evaluate('g:notmuch_open_uri')\r
103 > @@ -429,11 +437,12 @@ endfunction\r
104 >  \r
105 >  "" main\r
106 >  \r
107 > -function! s:show(thread_id)\r
108 > +function! s:show(thread_id, msg_id)\r
109 >       call s:new_buffer('show')\r
110 >       setlocal modifiable\r
111 >  ruby << EOF\r
112 >       thread_id = VIM::evaluate('a:thread_id')\r
113 > +     msg_id = VIM::evaluate('a:msg_id')\r
114 >       $cur_thread = thread_id\r
115 >       $messages.clear\r
116 >       $curbuf.render do |b|\r
117 > @@ -465,6 +474,9 @@ ruby << EOF\r
118 >                       end\r
119 >                       b << ""\r
120 >                       nm_m.end = b.count\r
121 > +                     if msg_id and nm_m.message_id == msg_id\r
122 > +                             VIM::command("normal #{nm_m.start}zt")\r
123 > +                     end\r
124 >               end\r
125 >               b.delete(b.count)\r
126 >       end\r
127 > @@ -487,7 +499,7 @@ ruby << EOF\r
128 >       when 1; $cur_filter = nil\r
129 >       when 2; $cur_filter = $cur_search\r
130 >       end\r
131 > -     VIM::command("call s:show('#{id}')")\r
132 > +     VIM::command("call s:show('#{id}', '')")\r
133 >  EOF\r
134 >  endfunction\r
135 >  \r
136 > @@ -917,6 +929,10 @@ ruby << EOF\r
137 >                       q\r
138 >               end\r
139 >  \r
140 > +             def message(id)\r
141 > +                     @db.find_message(id)\r
142 > +             end\r
143 > +\r
144 >               def close\r
145 >                       @queries.delete_if { |q| ! q.destroy! }\r
146 >                       @db.close\r
147 > @@ -937,12 +953,20 @@ ruby << EOF\r
148 >               end\r
149 >       end\r
150 >  \r
151 > +     module URI\r
152 > +             class MsgID < Generic\r
153 > +             end\r
154 > +\r
155 > +             @@schemes['ID'] = MsgID\r
156 > +     end\r
157 > +\r
158 >       class Message\r
159 >               attr_accessor :start, :body_start, :end\r
160 > -             attr_reader :message_id, :filename, :mail\r
161 > +             attr_reader :message_id, :thread_id, :filename, :mail\r
162 >  \r
163 >               def initialize(msg, mail)\r
164 >                       @message_id = msg.message_id\r
165 > +                     @thread_id = msg.thread_id\r
166 >                       @filename = msg.filename\r
167 >                       @mail = mail\r
168 >                       @start = 0\r
169\r
170 > On Fri, 10 Oct 2014 11:18:31 -0700, Ian Main <imain@stemwinder.org> wrote:\r
171 > > Franz Fellner wrote:\r
172 > > > Works nice. Tested with an https and a mailto URI.\r
173 > > > But it would be awesome if you could add message id handling, So one\r
174 > > > could easily navigate to linked messages. I only found emacs client\r
175 > > > implement this feature. What I read in the docs about ruby URI module\r
176 > > > it should be fairly easy to add a custom scheme for id.\r
177 > > \r
178 > > I'm afraid I'm not sure what you mean by message id handling?  It's\r
179 > > probably something simple but .. :)\r
180 > > \r
181 > >     Ian\r
182 \r
183 \r