[PATCH] notmuch-emacs-mua: escape $PWD (and cd always). use message-add-actions.
authorTomi Ollila <tomi.ollila@iki.fi>
Thu, 14 Apr 2016 17:44:44 +0000 (20:44 +0300)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:21:38 +0000 (16:21 -0700)
20/222c37da956368de42170a94929e32b299a1e2 [new file with mode: 0644]

diff --git a/20/222c37da956368de42170a94929e32b299a1e2 b/20/222c37da956368de42170a94929e32b299a1e2
new file mode 100644 (file)
index 0000000..d46c7ac
--- /dev/null
@@ -0,0 +1,100 @@
+Return-Path: <too@guru-group.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id BF3ED6DE0222\r
+ for <notmuch@notmuchmail.org>; Thu, 14 Apr 2016 10:45:04 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.284\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.284 tagged_above=-999 required=5 tests=[AWL=0.293, \r
+ HEADER_FROM_DIFFERENT_DOMAINS=0.001, T_RP_MATCHES_RCVD=-0.01]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id v-V-WdqIvS7x for <notmuch@notmuchmail.org>;\r
+ Thu, 14 Apr 2016 10:44:56 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by arlo.cworth.org (Postfix) with ESMTP id AA76D6DE00F5\r
+ for <notmuch@notmuchmail.org>; Thu, 14 Apr 2016 10:44:55 -0700 (PDT)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+ id 9678D1001A3; Thu, 14 Apr 2016 20:44:45 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: notmuch@notmuchmail.org\r
+Cc: tomi.ollila@iki.fi\r
+Subject: [PATCH] notmuch-emacs-mua: escape $PWD (and cd always). use\r
+ message-add-actions.\r
+Date: Thu, 14 Apr 2016 20:44:44 +0300\r
+Message-Id: <1460655884-18148-1-git-send-email-tomi.ollila@iki.fi>\r
+X-Mailer: git-send-email 2.6.4\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 14 Apr 2016 17:45:04 -0000\r
+\r
+Escaping $PWD makes this work in directories like 'foo"bar'...\r
+\r
+Cd'ing always makes the working directory to be consistent whether\r
+--body option was used or not (when using emacsclient, but cd'ing\r
+when using emacs does not cause any harm).\r
+\r
+Finally, use message.el -provided function message-add-actions to\r
+set(/add) #'save-buffers-kill-terminal to the message-exit-actions\r
+list.\r
+---\r
+\r
+Now that there is new potential interest to this tool I got motivation\r
+to prepare this for sending (i.e. commit message & message-add-action\r
+usage done today).\r
+\r
+\r
+ notmuch-emacs-mua | 8 +++++---\r
+ 1 file changed, 5 insertions(+), 3 deletions(-)\r
+\r
+diff --git a/notmuch-emacs-mua b/notmuch-emacs-mua\r
+index 4404cd7..fdb9744 100755\r
+--- a/notmuch-emacs-mua\r
++++ b/notmuch-emacs-mua\r
+@@ -39,8 +39,10 @@ USE_EMACSCLIENT=\r
+ AUTO_DAEMON=\r
+ CREATE_FRAME=\r
\r
++escape -v pwd "$PWD"\r
++\r
+ # The crux of it all: construct an elisp progn and eval it.\r
+-ELISP="(prog1 'done (require 'notmuch) (notmuch-mua-new-mail)"\r
++ELISP="(prog1 'done (require 'notmuch) (cd \"$pwd\") (notmuch-mua-new-mail)"\r
\r
+ # Short options compatible with mutt(1).\r
+ while getopts :s:c:b:i:h opt; do\r
+@@ -95,7 +97,7 @@ while getopts :s:c:b:i:h opt; do\r
+           ELISP="${ELISP} (message-goto-bcc) (insert \"${OPTARG}, \")"\r
+           ;;\r
+       --body|i)\r
+-          ELISP="${ELISP} (message-goto-body) (cd \"${PWD}\") (insert-file \"${OPTARG}\")"\r
++          ELISP="${ELISP} (message-goto-body) (insert-file \"${OPTARG}\")"\r
+           ;;\r
+       --print)\r
+           PRINT_ONLY=1\r
+@@ -132,7 +134,7 @@ done\r
\r
+ # Kill the terminal/frame if we're creating one.\r
+ if [ -z "$USE_EMACSCLIENT" -o -n "$CREATE_FRAME" -o -n "$NO_WINDOW" ]; then\r
+-    ELISP="${ELISP} (setq message-exit-actions (list #'save-buffers-kill-terminal))"\r
++    ELISP="${ELISP} (message-add-action #'save-buffers-kill-terminal 'exit)"\r
+ fi\r
\r
+ # End progn.\r
+-- \r
+1.9.3\r
+\r