From 334dea822c095aa5c1cf4acfb236803b4c39ad21 Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Sat, 28 May 2016 14:06:04 +0300 Subject: [PATCH] [PATCH 2/2] notmuch-emacs-mua: escape $PWD (and cd always) --- 56/85af5443ee934d427fa1138d336d3f377760af | 89 +++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 56/85af5443ee934d427fa1138d336d3f377760af diff --git a/56/85af5443ee934d427fa1138d336d3f377760af b/56/85af5443ee934d427fa1138d336d3f377760af new file mode 100644 index 000000000..5a4b988da --- /dev/null +++ b/56/85af5443ee934d427fa1138d336d3f377760af @@ -0,0 +1,89 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id CEA5F6DE0261 + for ; Sat, 28 May 2016 04:06:28 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.254 +X-Spam-Level: +X-Spam-Status: No, score=0.254 tagged_above=-999 required=5 tests=[AWL=0.263, + HEADER_FROM_DIFFERENT_DOMAINS=0.001, T_RP_MATCHES_RCVD=-0.01] + autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 5pRRm6me7S4l for ; + Sat, 28 May 2016 04:06:19 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by arlo.cworth.org (Postfix) with ESMTP id B91A66DE0127 + for ; Sat, 28 May 2016 04:06:18 -0700 (PDT) +Received: by guru.guru-group.fi (Postfix, from userid 501) + id 4F3941000C6; Sat, 28 May 2016 14:06:06 +0300 (EEST) +From: Tomi Ollila +To: notmuch@notmuchmail.org +Cc: tomi.ollila@iki.fi +Subject: [PATCH 2/2] notmuch-emacs-mua: escape $PWD (and cd always) +Date: Sat, 28 May 2016 14:06:04 +0300 +Message-Id: <1464433564-13180-2-git-send-email-tomi.ollila@iki.fi> +X-Mailer: git-send-email 2.8.2 +In-Reply-To: <1464433564-13180-1-git-send-email-tomi.ollila@iki.fi> +References: <877fev1mcv.fsf@zancas.localnet> + <1464433564-13180-1-git-send-email-tomi.ollila@iki.fi> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +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: Sat, 28 May 2016 11:06:28 -0000 + +Escaping $PWD makes this work in directories like 'foo"bar'... + +Cd'ing always makes the working directory to be consistent whether +--body option was used or not (when using emacsclient, but cd'ing +when using emacs does not cause any harm). + +Note that documentation of `insert-file` expects programs to +call `insert-file-contents` instead. In our simple case +`insert-file` works better as it does some good checks that we'd +have to implement ourselves. Look lisp/files.el in emacs sources +for more information. +--- + notmuch-emacs-mua | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/notmuch-emacs-mua b/notmuch-emacs-mua +index 1168c6f65a5f..fdb97443102b 100755 +--- a/notmuch-emacs-mua ++++ b/notmuch-emacs-mua +@@ -39,8 +39,10 @@ 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) (notmuch-mua-new-mail)" ++ELISP="(prog1 'done (require 'notmuch) (cd \"$pwd\") (notmuch-mua-new-mail)" + + # Short options compatible with mutt(1). + while getopts :s:c:b:i:h opt; do +@@ -95,7 +97,7 @@ while getopts :s:c:b:i:h opt; do + ELISP="${ELISP} (message-goto-bcc) (insert \"${OPTARG}, \")" + ;; + --body|i) +- ELISP="${ELISP} (message-goto-body) (cd \"${PWD}\") (insert-file \"${OPTARG}\")" ++ ELISP="${ELISP} (message-goto-body) (insert-file \"${OPTARG}\")" + ;; + --print) + PRINT_ONLY=1 +-- +2.8.2 + -- 2.26.2