From 1d8fec29abdc8a1945047d78dd9fd83cd340fd39 Mon Sep 17 00:00:00 2001 From: Ian Main Date: Tue, 21 Oct 2014 10:45:29 +1700 Subject: [PATCH] Re: [PATCH] VIM: Add URI handling --- 11/3bbba952cc311f6b9b373c23ccf0f78e35a24c | 172 ++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 11/3bbba952cc311f6b9b373c23ccf0f78e35a24c diff --git a/11/3bbba952cc311f6b9b373c23ccf0f78e35a24c b/11/3bbba952cc311f6b9b373c23ccf0f78e35a24c new file mode 100644 index 000000000..14f985bf9 --- /dev/null +++ b/11/3bbba952cc311f6b9b373c23ccf0f78e35a24c @@ -0,0 +1,172 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 13C5B431FAF + for ; Mon, 20 Oct 2014 10:45:43 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id YdviNLbsQ6f4 for ; + Mon, 20 Oct 2014 10:45:35 -0700 (PDT) +Received: from cmta11.telus.net (cmta11.telus.net [209.171.16.84]) + by olra.theworths.org (Postfix) with ESMTP id 67664431FAE + for ; Mon, 20 Oct 2014 10:45:35 -0700 (PDT) +Received: from ovo.mains.priv ([207.102.88.62]) by cmta11.telus.net with TELUS + id 5VlZ1p00C1LiWEf01VlZkM; Mon, 20 Oct 2014 11:45:34 -0600 +X-Authority-Analysis: v=2.0 cv=daReKwre c=1 sm=2 + a=EcQDfIwDZEqJA1f7rVUV8Q==:17 a=S-IsBHyFrF4A:10 a=IkcTkHD0fZMA:10 + a=tsa3CZZnAAAA:8 a=NEAV23lmAAAA:8 a=pGLkceISAAAA:8 + a=sbtZFu4L9O4t544OEacA:9 + a=QEXdDO2ut3YA:10 a=P87eogJZi2UA:10 a=MSl-tDqOz04A:10 + a=EcQDfIwDZEqJA1f7rVUV8Q==:117 +X-Telus-Outbound-IP: 207.102.88.62 +Received: from ovo.mains.priv (localhost.localdomain [127.0.0.1]) + by ovo.mains.priv (8.14.8/8.14.8) with ESMTP id s9KHjT2q002072; + Mon, 20 Oct 2014 10:45:32 -0700 +Received: (from imain@localhost) + by ovo.mains.priv (8.14.8/8.14.8/Submit) id s9KHjTkv002071; + Mon, 20 Oct 2014 10:45:29 -0700 +X-Authentication-Warning: ovo.mains.priv: imain set sender to imain@redhat.com + using -f +Date: Mon, 20 Oct 2014 10:45:29 -0700 +From: Ian Main +To: Franz Fellner +Message-ID: <54454a39e0a1_6dc1435e9496@ovo.mains.priv.notmuch> +In-Reply-To: <20141017181422.GG20696@TP_L520.localdomain> +References: <1412281423-22441-1-git-send-email-imain@stemwinder.org> + <20141010114457.GG28601@TP_L520.localdomain> + <543822f73d3fd_46ad163fe88cd@ovo.mains.priv.notmuch> + <20141011142943.GD23373@TP_L520.localdomain> + <543ecc23bb98_2c291569e8c17@ovo.mains.priv.notmuch> + <20141017181422.GG20696@TP_L520.localdomain> +Subject: Re: [PATCH] VIM: Add URI handling +Mime-Version: 1.0 +Content-Type: text/plain; + charset=utf-8 +Content-Transfer-Encoding: 7bit +Cc: notmuch@notmuchmail.org +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Mon, 20 Oct 2014 17:45:43 -0000 + +Franz Fellner wrote: +> On Wed, 15 Oct 2014 12:33:55 -0700, Ian Main wrote: +> > Franz Fellner wrote: +> > > Here is a working implementation. +> > > Please review carefully as I only can simulate ruby and vimscript +> > > knowledge from what I see in notmuch.vim sourcefile and quick +> > > googling. +> > +> > Yes, this works nicely. Thanks! +> > +> > I do notice however that this is against the github plugin repo (I think)? +> Yes, that's right. +> I forked the notmuch repo on github and incorporated your patches. +> Already made a mistake while applying one of your patches... +> https://github.com/ff2000/notmuch +> (Hope everythin is fine now) +> +> commit cb757e9e438341a7bc6d2cfec4de7bdcc85946ea +> Author: Franz Fellner +> Date: Fri Oct 17 11:19:41 2014 +0200 +> +> VIM: Add MsgID to supported URIs +> +> diff --git a/vim/notmuch.vim b/vim/notmuch.vim +> index 6287cf6..30e1876 100644 +> --- a/vim/notmuch.vim +> +++ b/vim/notmuch.vim +> @@ -268,6 +268,14 @@ ruby << EOF +> if uri.class == URI::MailTo +> vim_puts("Composing new email to #{uri.to}.") +> VIM::command("call s:compose('#{uri.to}')") +> + elsif uri.class == URI::MsgID +> + msg = $curbuf.message(uri.opaque) +> + if !msg +> + vim_puts("Message not found in NotMuch database: #{uri.to_s}") +> + else +> + vim_puts("Opening message #{msg.message_id} in thread #{msg.thread_id}.") +> + VIM::command("call s:show('thread:#{msg.thread_id}', '#{msg.message_id}')") +> + end +> else +> vim_puts("Opening #{uri.to_s}.") +> cmd = VIM::evaluate('g:notmuch_open_uri') +> @@ -428,11 +436,12 @@ endfunction +> +> "" main +> +> -function! s:show(thread_id) +> +function! s:show(thread_id, msg_id) +> call s:new_buffer('show') +> setlocal modifiable +> ruby << EOF +> thread_id = VIM::evaluate('a:thread_id') +> + msg_id = VIM::evaluate('a:msg_id') +> $cur_thread = thread_id +> $messages.clear +> $curbuf.render do |b| +> @@ -464,6 +473,9 @@ ruby << EOF +> end +> b << "" +> nm_m.end = b.count +> + if !msg_id.empty? and nm_m.message_id == msg_id +> + VIM::command("normal #{nm_m.start}zt") +> + end +> end +> b.delete(b.count) +> end +> @@ -486,7 +498,7 @@ ruby << EOF +> when 1; $cur_filter = nil +> when 2; $cur_filter = $cur_search +> end +> - VIM::command("call s:show('#{id}')") +> + VIM::command("call s:show('#{id}', '')") +> EOF +> endfunction +> +> @@ -910,6 +922,10 @@ ruby << EOF +> q +> end +> +> + def message(id) +> + @db.find_message(id) +> + end +> + +> def close +> @queries.delete_if { |q| ! q.destroy! } +> @db.close +> @@ -930,6 +946,13 @@ ruby << EOF +> end +> end +> +> + module URI +> + class MsgID < Generic +> + end +> + +> + @@schemes['ID'] = MsgID +> + end +> + +> class Message +> attr_accessor :start, :body_start, :end +> attr_reader :message_id, :filename, :mail + +LGTM! Nice addition. + + Ian + -- 2.26.2