From: Franz Fellner Date: Fri, 17 Oct 2014 16:14:22 +0000 (+0200) Subject: Re: [PATCH] VIM: Add URI handling X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1e9251802494770d97d73e27fb021ec52fc7993a;p=notmuch-archives.git Re: [PATCH] VIM: Add URI handling --- diff --git a/b3/c15f9a917a906ec7a193d55feb5b09877f75d8 b/b3/c15f9a917a906ec7a193d55feb5b09877f75d8 new file mode 100644 index 000000000..24594a3ae --- /dev/null +++ b/b3/c15f9a917a906ec7a193d55feb5b09877f75d8 @@ -0,0 +1,171 @@ +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 19DCD431FAF + for ; Fri, 17 Oct 2014 09:14:21 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.799 +X-Spam-Level: +X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 GAbmhgcAx-Qy for ; + Fri, 17 Oct 2014 09:14:13 -0700 (PDT) +Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com + [74.125.82.41]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + CF62E431FB6 for ; Fri, 17 Oct 2014 09:14:12 -0700 + (PDT) +Received: by mail-wg0-f41.google.com with SMTP id b13so1263713wgh.12 + for ; Fri, 17 Oct 2014 09:14:11 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=date:message-id:from:to:cc:subject:in-reply-to:references + :mime-version:content-type:content-disposition + :content-transfer-encoding; + bh=erEWxFjw9iu1QcMHVxnSKtQAIZvTaJkx77deUjeygOs=; + b=T4W/80BJxAzMqJCaCXyKKzJMrzmM9FObAzFrGgTq6auggRfVoq7Ys3FhDDOHyRyBW8 + ZDB2ZruySthKTswmVt4t+l2jp0qPcYGb0BLgDO6vx1B48HFCAlgkxTz4Wf+vaqi6awiV + k7ImI8ZgaBW2d/txfe2XjgrbvHNYJWWpKBxxqnBmxYKVBweUdY8DlvLcU35lZMgCJekk + YYQ4CJMGgMBTgVNMl/baerZLitz5XSbuzVPyLveL6qLXD0pHZS5eY5jr9x2TrPKr6u85 + Jqafa4LBE+P6DzQOWzd7pSh3wxREUO+R3lVwRWZGhS/cUKDSbIjzrq4vtrc3+F0kziPh + WGjw== +X-Received: by 10.194.60.230 with SMTP id k6mr4277986wjr.135.1413562451607; + Fri, 17 Oct 2014 09:14:11 -0700 (PDT) +Received: from localhost (p5B00C8AC.dip0.t-ipconnect.de. [91.0.200.172]) + by mx.google.com with ESMTPSA id ei1sm2567181wib.20.2014.10.17.09.14.10 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Fri, 17 Oct 2014 09:14:10 -0700 (PDT) +Date: Fri, 17 Oct 2014 18:14:22 +0200 +Message-ID: <20141017181422.GG20696@TP_L520.localdomain> +From: Franz Fellner +To: Ian Main +Subject: Re: [PATCH] VIM: Add URI handling +In-Reply-To: <543ecc23bb98_2c291569e8c17@ovo.mains.priv.notmuch> +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> +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +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: Fri, 17 Oct 2014 16:14:21 -0000 + +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