* [PATCH] notmuch-emacs-mua: add support for mailto: URL handling
@ 2016-09-30 17:59 Jani Nikula
2016-09-30 18:24 ` Tomi Ollila
0 siblings, 1 reply; 2+ messages in thread
From: Jani Nikula @ 2016-09-30 17:59 UTC (permalink / raw)
To: notmuch
Add support for composing an email in the Notmuch Emacs UI using a
mailto: URL. The mailto: URL mode is mutually exclusive with
specifying other message modifying parameters and positional
arguments.
---
doc/man1/notmuch-emacs-mua.rst | 8 +++++---
notmuch-emacs-mua | 35 +++++++++++++++++++++++++++++------
2 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/doc/man1/notmuch-emacs-mua.rst b/doc/man1/notmuch-emacs-mua.rst
index 7c5729047173..651d00fa4eb8 100644
--- a/doc/man1/notmuch-emacs-mua.rst
+++ b/doc/man1/notmuch-emacs-mua.rst
@@ -5,13 +5,13 @@ notmuch-emacs-mua
SYNOPSIS
========
-**notmuch-emacs-mua** [options ...] [<to-address> ...]
+**notmuch-emacs-mua** [options ...] [<to-address> ... | <mailto-url>]
DESCRIPTION
===========
Start composing an email in the Notmuch Emacs UI with the specified
-subject, recipients, and message body.
+subject, recipients, and message body, or mailto: URL.
Supported options for **notmuch-emacs-mua** include
@@ -56,7 +56,9 @@ Supported options for **notmuch-emacs-mua** include
Output the resulting elisp to stdout instead of evaluating it.
The supported positional parameters and short options are a compatible
-subset of the **mutt** MUA command-line options.
+subset of the **mutt** MUA command-line options. The options and
+positional parameters modifying the message can't be combined with the
+mailto: URL.
Options may be specified multiple times.
diff --git a/notmuch-emacs-mua b/notmuch-emacs-mua
index f9d83713b789..89d7956b3e2e 100755
--- a/notmuch-emacs-mua
+++ b/notmuch-emacs-mua
@@ -38,11 +38,8 @@ NO_WINDOW=
USE_EMACSCLIENT=
AUTO_DAEMON=
CREATE_FRAME=
-
-escape -v pwd "$PWD"
-
-# The crux of it all: construct an elisp progn and eval it.
-ELISP="(prog1 'done (require 'notmuch) (cd \"$pwd\") (notmuch-mua-new-mail)"
+ELISP=
+MAILTO=
# Short options compatible with mutt(1).
while getopts :s:c:b:i:h opt; do
@@ -129,9 +126,35 @@ done
# Positional parameters.
for arg; do
escape -v arg "${arg}"
- ELISP="${ELISP} (message-goto-to) (insert \"${arg}, \")"
+ case $arg in
+ mailto:*)
+ if [ -n "${MAILTO}" ]; then
+ echo "$0: more than one mailto: argument." >&2
+ exit 1
+ fi
+ MAILTO="${arg}"
+ ;;
+ *)
+ ELISP="${ELISP} (message-goto-to) (insert \"${arg}, \")"
+ ;;
+ esac
done
+if [ -n "${MAILTO}" ]; then
+ if [ -n "${ELISP}" ]; then
+ echo "$0: mailto: is not compatible with other message parameters." >&2
+ exit 1
+ fi
+ ELISP="(browse-url-mail \"${MAILTO}\")"
+else
+ ELISP="(notmuch-mua-new-mail) ${ELISP}"
+fi
+
+escape -v pwd "$PWD"
+
+# The crux of it all: construct an elisp progn and eval it.
+ELISP="(prog1 'done (require 'notmuch) (cd \"$pwd\") ${ELISP}"
+
# Kill the terminal/frame if we're creating one.
if [ -z "$USE_EMACSCLIENT" -o -n "$CREATE_FRAME" -o -n "$NO_WINDOW" ]; then
ELISP="${ELISP} (message-add-action #'save-buffers-kill-terminal 'exit)"
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] notmuch-emacs-mua: add support for mailto: URL handling
2016-09-30 17:59 [PATCH] notmuch-emacs-mua: add support for mailto: URL handling Jani Nikula
@ 2016-09-30 18:24 ` Tomi Ollila
0 siblings, 0 replies; 2+ messages in thread
From: Tomi Ollila @ 2016-09-30 18:24 UTC (permalink / raw)
To: Jani Nikula, notmuch
On Fri, Sep 30 2016, Jani Nikula <jani@nikula.org> wrote:
> Add support for composing an email in the Notmuch Emacs UI using a
> mailto: URL. The mailto: URL mode is mutually exclusive with
> specifying other message modifying parameters and positional
> arguments.
> ---
> doc/man1/notmuch-emacs-mua.rst | 8 +++++---
> notmuch-emacs-mua | 35 +++++++++++++++++++++++++++++------
> 2 files changed, 34 insertions(+), 9 deletions(-)
>
> diff --git a/doc/man1/notmuch-emacs-mua.rst b/doc/man1/notmuch-emacs-mua.rst
> index 7c5729047173..651d00fa4eb8 100644
> --- a/doc/man1/notmuch-emacs-mua.rst
> +++ b/doc/man1/notmuch-emacs-mua.rst
> @@ -5,13 +5,13 @@ notmuch-emacs-mua
> SYNOPSIS
> ========
>
> -**notmuch-emacs-mua** [options ...] [<to-address> ...]
> +**notmuch-emacs-mua** [options ...] [<to-address> ... | <mailto-url>]
>
> DESCRIPTION
> ===========
>
> Start composing an email in the Notmuch Emacs UI with the specified
> -subject, recipients, and message body.
> +subject, recipients, and message body, or mailto: URL.
>
> Supported options for **notmuch-emacs-mua** include
>
> @@ -56,7 +56,9 @@ Supported options for **notmuch-emacs-mua** include
> Output the resulting elisp to stdout instead of evaluating it.
>
> The supported positional parameters and short options are a compatible
> -subset of the **mutt** MUA command-line options.
> +subset of the **mutt** MUA command-line options. The options and
> +positional parameters modifying the message can't be combined with the
> +mailto: URL.
>
> Options may be specified multiple times.
>
> diff --git a/notmuch-emacs-mua b/notmuch-emacs-mua
> index f9d83713b789..89d7956b3e2e 100755
> --- a/notmuch-emacs-mua
> +++ b/notmuch-emacs-mua
> @@ -38,11 +38,8 @@ NO_WINDOW=
> USE_EMACSCLIENT=
> AUTO_DAEMON=
> CREATE_FRAME=
> -
> -escape -v pwd "$PWD"
> -
> -# The crux of it all: construct an elisp progn and eval it.
> -ELISP="(prog1 'done (require 'notmuch) (cd \"$pwd\") (notmuch-mua-new-mail)"
> +ELISP=
> +MAILTO=
>
> # Short options compatible with mutt(1).
> while getopts :s:c:b:i:h opt; do
> @@ -129,9 +126,35 @@ done
> # Positional parameters.
> for arg; do
> escape -v arg "${arg}"
> - ELISP="${ELISP} (message-goto-to) (insert \"${arg}, \")"
> + case $arg in
> + mailto:*)
> + if [ -n "${MAILTO}" ]; then
> + echo "$0: more than one mailto: argument." >&2
> + exit 1
> + fi
> + MAILTO="${arg}"
> + ;;
> + *)
> + ELISP="${ELISP} (message-goto-to) (insert \"${arg}, \")"
> + ;;
> + esac
> done
>
> +if [ -n "${MAILTO}" ]; then
> + if [ -n "${ELISP}" ]; then
> + echo "$0: mailto: is not compatible with other message parameters." >&2
> + exit 1
> + fi
> + ELISP="(browse-url-mail \"${MAILTO}\")"
> +else
> + ELISP="(notmuch-mua-new-mail) ${ELISP}"
> +fi
> +
> +escape -v pwd "$PWD"
> +
> +# The crux of it all: construct an elisp progn and eval it.
> +ELISP="(prog1 'done (require 'notmuch) (cd \"$pwd\") ${ELISP}"
Looks fine by me.
IMO it would look better if the above part would be combined with #End progn.
line below (the patch context here). In there the parentheses could
be balanced. e.g.
-# End progn.
-ELISP="${ELISP})"
+escape -v pwd "$PWD"
+
+# Complete the elisp progn and eval it.
+ELISP="(prog1 'done (require 'notmuch) (cd \"$pwd\") ${ELISP})"
> +
> # Kill the terminal/frame if we're creating one.
> if [ -z "$USE_EMACSCLIENT" -o -n "$CREATE_FRAME" -o -n "$NO_WINDOW" ]; then
> ELISP="${ELISP} (message-add-action #'save-buffers-kill-terminal 'exit)"
> --
> 2.1.4
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-09-30 18:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-30 17:59 [PATCH] notmuch-emacs-mua: add support for mailto: URL handling Jani Nikula
2016-09-30 18:24 ` 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).