--- /dev/null
+Return-Path: <too@guru-group.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id CE36C431FBF\r
+ for <notmuch@notmuchmail.org>; Tue, 1 Jul 2014 11:07:03 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id mBNlAASeYkxe for <notmuch@notmuchmail.org>;\r
+ Tue, 1 Jul 2014 11:06:55 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id D70C5431FBC\r
+ for <notmuch@notmuchmail.org>; Tue, 1 Jul 2014 11:06:54 -0700 (PDT)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+ id 4218C1000CA; Tue, 1 Jul 2014 21:06:46 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] contrib: add notmuch-emacs-mailto.sh\r
+Date: Tue, 1 Jul 2014 21:06:32 +0300\r
+Message-Id: <1404237992-9456-1-git-send-email-tomi.ollila@iki.fi>\r
+X-Mailer: git-send-email 2.0.0\r
+Cc: tomi.ollila@iki.fi\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 01 Jul 2014 18:07:03 -0000\r
+\r
+Add a shell handler which sends to/invokes notmuch-emacs mua\r
+mailto: urls for further processing.\r
+---\r
+\r
+I wish notmuch-mua-mailto (not (yet) in notmuch improves as\r
+"promised" in id:87vcin2fo6.fsf@servo.finestructure.net ;D\r
+(that version seems to do more than implementation of\r
+browse-url-mail (in emacs-23.1/lisp/net/browse-url.el) and\r
+with that buffer is not marked "modified" when some initial\r
+body added).\r
+\r
+ contrib/notmuch-emacs-mailto.sh | 34 ++++++++++++++++++++++++++++++++++\r
+ 1 file changed, 34 insertions(+)\r
+ create mode 100755 contrib/notmuch-emacs-mailto.sh\r
+\r
+diff --git a/contrib/notmuch-emacs-mailto.sh b/contrib/notmuch-emacs-mailto.sh\r
+new file mode 100755\r
+index 000000000000..03719f806250\r
+--- /dev/null\r
++++ b/contrib/notmuch-emacs-mailto.sh\r
+@@ -0,0 +1,34 @@\r
++#!/bin/sh\r
++\r
++# use notmuch mua via emacsclient or in emacs to handle mailto: request\r
++\r
++set -eu\r
++\r
++case $# in 0)\r
++ echo Usage: $0 mailto-url >&2\r
++ exit 1\r
++esac\r
++\r
++# concatenate args in $* w/o space (note: empty $IFS is somewhat special case)\r
++IFS=\r
++\r
++case $* in *['"\']*)\r
++ url=`printf %s "$*" | sed 's/\\\\/\\\\\\\\/; s/"/\\\\"/'`\r
++;; *) url=$*\r
++esac\r
++\r
++case $url in mailto:*) ;; *) url=mailto:$url ;; esac\r
++\r
++unset ALTERNATE_EDITOR\r
++if "${EMACSCLIENT:=emacsclient}" --eval t >/dev/null 2>&1\r
++then exec >/dev/null\r
++ editor=$EMACSCLIENT\r
++else editor=${EMACS:-emacs}\r
++fi\r
++\r
++exec "$editor" --eval "\\r
++(let ((url \"$url\"))\r
++ (require 'notmuch)\r
++ (if (fboundp 'notmuch-mua-mailto)\r
++ (notmuch-mua-mailto url)\r
++ (browse-url-mail url)))"\r
+-- \r
+2.0.0\r
+\r