From e0ecb6a53e758be24d036bda9da8342349182eb6 Mon Sep 17 00:00:00 2001 From: Franz Fellner Date: Sat, 11 Oct 2014 14:29:43 +0200 Subject: [PATCH] Re: [PATCH] VIM: Add URI handling --- 49/5922e039296fdb099cc7b8a8a9a66a1f5b69bd | 177 ++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 49/5922e039296fdb099cc7b8a8a9a66a1f5b69bd diff --git a/49/5922e039296fdb099cc7b8a8a9a66a1f5b69bd b/49/5922e039296fdb099cc7b8a8a9a66a1f5b69bd new file mode 100644 index 000000000..f0e3eb0a1 --- /dev/null +++ b/49/5922e039296fdb099cc7b8a8a9a66a1f5b69bd @@ -0,0 +1,177 @@ +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 10164431FDB + for ; Sat, 11 Oct 2014 05:29:46 -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 OhMNytjgbZbv for ; + Sat, 11 Oct 2014 05:29:38 -0700 (PDT) +Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com + [209.85.217.173]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id BE808431FD0 + for ; Sat, 11 Oct 2014 05:29:37 -0700 (PDT) +Received: by mail-lb0-f173.google.com with SMTP id 10so4436558lbg.4 + for ; Sat, 11 Oct 2014 05:29:36 -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=vfFTDsXhrWPrj60iFLmwdfCKP/1/OzjlPSV/wRhwjjE=; + b=dVLCDrVtO/CKX2DPms+T7aa9cQsXMRuQxzqPDrgBDypzKmzx6AAYgOrrBmGv6JbfS/ + 7YbRVRrSA7Ovb0a6INPmNoOGTofEfWIrBDJzdtxw4FknWvc1A23unCmquC2l5NMII1/g + HWQDxf8KEpKOwkGOZhIqfbtahGUax9hVMN9wWddvI9N34ggVjjHe+93JVs2DyDoF8nu9 + WbrDwfAT3z1/aWwVjX+itamXxX96ZVR82MdwQqDlmOVadnxlpGp95Q8p5mKEe25RXOQF + YExOY3h/xDaohYU194Dt1e1WPJmTZeXs/zBLn4Gr6Fa7nOsZ3m5/5FH1tZOIW2KcY/HR + hK+w== +X-Received: by 10.152.198.138 with SMTP id jc10mr11401929lac.59.1413030575113; + Sat, 11 Oct 2014 05:29:35 -0700 (PDT) +Received: from localhost (p5B00F017.dip0.t-ipconnect.de. [91.0.240.23]) + by mx.google.com with ESMTPSA id a9sm2657815laa.3.2014.10.11.05.29.33 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sat, 11 Oct 2014 05:29:34 -0700 (PDT) +Date: Sat, 11 Oct 2014 14:29:43 +0200 +Message-ID: <20141011142943.GD23373@TP_L520.localdomain> +From: Franz Fellner +To: Ian Main +Subject: Re: [PATCH] VIM: Add URI handling +In-Reply-To: <543822f73d3fd_46ad163fe88cd@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> +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: Sat, 11 Oct 2014 12:29:46 -0000 + +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. + +Regards +Franz + + +diff --git a/plugin/notmuch.vim b/plugin/notmuch.vim +index 567f75c..ef9fefa 100644 +--- a/plugin/notmuch.vim ++++ b/plugin/notmuch.vim +@@ -269,6 +269,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') +@@ -429,11 +437,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| +@@ -465,6 +474,9 @@ ruby << EOF + end + b << "" + nm_m.end = b.count ++ if msg_id and nm_m.message_id == msg_id ++ VIM::command("normal #{nm_m.start}zt") ++ end + end + b.delete(b.count) + end +@@ -487,7 +499,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 + +@@ -917,6 +929,10 @@ ruby << EOF + q + end + ++ def message(id) ++ @db.find_message(id) ++ end ++ + def close + @queries.delete_if { |q| ! q.destroy! } + @db.close +@@ -937,12 +953,20 @@ 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 ++ attr_reader :message_id, :thread_id, :filename, :mail + + def initialize(msg, mail) + @message_id = msg.message_id ++ @thread_id = msg.thread_id + @filename = msg.filename + @mail = mail + @start = 0 + +On Fri, 10 Oct 2014 11:18:31 -0700, Ian Main wrote: +> Franz Fellner wrote: +> > Works nice. Tested with an https and a mailto URI. +> > But it would be awesome if you could add message id handling, So one +> > could easily navigate to linked messages. I only found emacs client +> > implement this feature. What I read in the docs about ruby URI module +> > it should be fairly easy to add a custom scheme for id. +> +> I'm afraid I'm not sure what you mean by message id handling? It's +> probably something simple but .. :) +> +> Ian -- 2.26.2