[PATCH] contrib: add notmuch-emacs-mailto.sh

Tomi Ollila tomi.ollila at iki.fi
Tue Jul 1 11:06:32 PDT 2014


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 at 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



More information about the notmuch mailing list