From: Tomi Ollila Date: Wed, 29 Oct 2014 17:09:36 +0000 (+0200) Subject: Re: [DRAFT PATCH] modified notmuch-emacs-mua X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c43c0f62338958839675714d378f71006f92ad15;p=notmuch-archives.git Re: [DRAFT PATCH] modified notmuch-emacs-mua --- diff --git a/ca/1f388db31e0c799fe0b6eccdb9b6d1c12e165d b/ca/1f388db31e0c799fe0b6eccdb9b6d1c12e165d new file mode 100644 index 000000000..f0afd742a --- /dev/null +++ b/ca/1f388db31e0c799fe0b6eccdb9b6d1c12e165d @@ -0,0 +1,160 @@ +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 D2342431FCB + for ; Wed, 29 Oct 2014 10:09:58 -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 ok0dBvzcs0f2 for ; + Wed, 29 Oct 2014 10:09:54 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id 9C837431FB6 + for ; Wed, 29 Oct 2014 10:09:53 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id 51C9F100051 + for ; Wed, 29 Oct 2014 19:09:36 +0200 (EET) +From: Tomi Ollila +To: notmuch@notmuchmail.org +Subject: Re: [DRAFT PATCH] modified notmuch-emacs-mua +In-Reply-To: <1405026779-29966-1-git-send-email-tomi.ollila@iki.fi> +References: <1405026779-29966-1-git-send-email-tomi.ollila@iki.fi> +User-Agent: Notmuch/0.18.1+130~ga61922f (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +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: Wed, 29 Oct 2014 17:09:59 -0000 + + +This mail id:1405026779-29966-1-git-send-email-tomi.ollila@iki.fi +has not got much attention, probably due it is marked as 'draft' +and as it was not marked 'needs-review' in nmbug (this is now changed). + +As the script is IMO in good condition (is IMO feature-complete and robust) +the draftness comes from the commit message being blunt and the namual .rst +not (yet updated). + +I've been using this version like 3-10 times per week for quite a long time +now. I normaly use the -nw, --to, --subject and --body options to send +work-related mail. Just yesterday I was planning to also use the --from +option to send email on (mutually agreed) behalf of a colleaque... + +This is somewhat more complex than the older alternative at +id:1404244957-3671-1-git-send-email-david@tethera.net, but addresses +the comments I sent in id:m2k37thvq1.fsf@guru.guru-group.fi . + +I think the script is straightforward enough for anyone who knows +shell scripts a bit more than just the shiny surface ;) + +This script also handles mailto: urls -- I just set firefox to run +this script on mailto: links and (in my case) emacs in my X desktop +appears with Message buffer filled with initial contents as expected. +If mailto: link had body content, then Message buffer was in modified +state (otherwise not!), which is a bit PITA to exit in case of accidental +clicks. I have a potential "fix" for that in a diff that otherwise contains +comment changes below -- whether the fix should be applied is a bit +controversial -- is there a chance that some other buffer is set to +non-modified state; I tried with emacsclient(1) interface (too) and +right buffer was set to non-modified state in this case too... + +If users are interested to have this version of notmuch-emacs-mua +available in future notmuch versions I'll update the manual .rst, +pick David's manual building change and write suitable commit message to +the forthcoming patch email. + +Tomi + +First the "commit message" from previous mail and then diff of further +changes after that: + +> Highlights: +> +> * notmuch-emacs-mua without arguments runs (notmuch-hello) +> +> * runs emacs(1) in case emacsclient(1) fails to connect to running emacs +> +> * takes -nw option +> +> * handles mailto: +> +> * --from option when sending non-mailto: way +> +> * -i includes file --body[= ]string inserts string +> --- + +diff --git a/notmuch-emacs-mua b/notmuch-emacs-mua +index b1696f7..2dfd160 100755 +--- a/notmuch-emacs-mua ++++ b/notmuch-emacs-mua +@@ -24,14 +24,14 @@ + + set -eu + +-# "expand" '\' to '\\' & '"' to '\"' ++# "expand" '\' to '\\' and '"' to '\"' + escape_optarg () + { + OPTARG=${OPTARG//\\/\\\\}; OPTARG=${OPTARG//\"/\\\"} + } + +-# ditto, in case there is '\n' sequence in the source, otherwise +-# "expand" only trailing '\'s to '\\'s ++# ditto, in case there is '\"' sequence in the source, ++# otherwise "expand" only trailing '\'s to '\\'s + escape_body_optarg () + { + case ${OPTARG} in +@@ -54,6 +54,7 @@ exec_mua () + fi + ${X:-exec} "$emacs" $W --eval "$*" + exit ++ # unused alternative to the above + ${X:-exec "$emacs" $W --eval} "$*" + } + +@@ -71,9 +72,11 @@ while + continue + ;; + mailto:*) ++ # concatenate all args to one string, using ';' as a separator + oIFS=$IFS; IFS=; OPTARG="$*" IFS=$oIFS + escape_optarg +- exec_mua "(progn (require 'notmuch) (browse-url-mail \"$OPTARG\"))" ++ exec_mua "(progn (require 'notmuch) (browse-url-mail \"$OPTARG\") ++ (set-buffer (window-buffer)) (set-buffer-modified-p nil))" + exit + esac + +@@ -176,6 +179,7 @@ done + + # Positional parameters. + for arg; do ++ # like escape_optarg, but for 'arg' variable + arg=${arg//\\/\\\\}; arg=${arg//\"/\\\"} + TO=${TO:+$TO, }${arg} + done + +