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 CE36C431FBF for ; Tue, 1 Jul 2014 11:07:03 -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=[none] 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 mBNlAASeYkxe for ; Tue, 1 Jul 2014 11:06:55 -0700 (PDT) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by olra.theworths.org (Postfix) with ESMTP id D70C5431FBC for ; Tue, 1 Jul 2014 11:06:54 -0700 (PDT) Received: by guru.guru-group.fi (Postfix, from userid 501) id 4218C1000CA; Tue, 1 Jul 2014 21:06:46 +0300 (EEST) From: Tomi Ollila To: notmuch@notmuchmail.org Subject: [PATCH] contrib: add notmuch-emacs-mailto.sh Date: Tue, 1 Jul 2014 21:06:32 +0300 Message-Id: <1404237992-9456-1-git-send-email-tomi.ollila@iki.fi> X-Mailer: git-send-email 2.0.0 Cc: tomi.ollila@iki.fi 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: Tue, 01 Jul 2014 18:07:03 -0000 Add a shell handler which sends to/invokes notmuch-emacs mua mailto: urls for further processing. --- I wish notmuch-mua-mailto (not (yet) in notmuch improves as "promised" in id:87vcin2fo6.fsf@servo.finestructure.net ;D (that version seems to do more than implementation of browse-url-mail (in emacs-23.1/lisp/net/browse-url.el) and with that buffer is not marked "modified" when some initial body added). contrib/notmuch-emacs-mailto.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 contrib/notmuch-emacs-mailto.sh diff --git a/contrib/notmuch-emacs-mailto.sh b/contrib/notmuch-emacs-mailto.sh new file mode 100755 index 000000000000..03719f806250 --- /dev/null +++ b/contrib/notmuch-emacs-mailto.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +# use notmuch mua via emacsclient or in emacs to handle mailto: request + +set -eu + +case $# in 0) + echo Usage: $0 mailto-url >&2 + exit 1 +esac + +# concatenate args in $* w/o space (note: empty $IFS is somewhat special case) +IFS= + +case $* in *['"\']*) + url=`printf %s "$*" | sed 's/\\\\/\\\\\\\\/; s/"/\\\\"/'` +;; *) url=$* +esac + +case $url in mailto:*) ;; *) url=mailto:$url ;; esac + +unset ALTERNATE_EDITOR +if "${EMACSCLIENT:=emacsclient}" --eval t >/dev/null 2>&1 +then exec >/dev/null + editor=$EMACSCLIENT +else editor=${EMACS:-emacs} +fi + +exec "$editor" --eval "\ +(let ((url \"$url\")) + (require 'notmuch) + (if (fboundp 'notmuch-mua-mailto) + (notmuch-mua-mailto url) + (browse-url-mail url)))" -- 2.0.0