unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] contrib: add notmuch-emacs-mailto.sh
@ 2014-07-01 18:06 Tomi Ollila
  0 siblings, 0 replies; only message in thread
From: Tomi Ollila @ 2014-07-01 18:06 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-07-01 18:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-01 18:06 [PATCH] contrib: add notmuch-emacs-mailto.sh Tomi Ollila

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).