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 BF3ED6DE0222 for ; Thu, 14 Apr 2016 10:45:04 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.284 X-Spam-Level: X-Spam-Status: No, score=0.284 tagged_above=-999 required=5 tests=[AWL=0.293, 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 v-V-WdqIvS7x for ; Thu, 14 Apr 2016 10:44:56 -0700 (PDT) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by arlo.cworth.org (Postfix) with ESMTP id AA76D6DE00F5 for ; Thu, 14 Apr 2016 10:44:55 -0700 (PDT) Received: by guru.guru-group.fi (Postfix, from userid 501) id 9678D1001A3; Thu, 14 Apr 2016 20:44:45 +0300 (EEST) From: Tomi Ollila To: notmuch@notmuchmail.org Cc: tomi.ollila@iki.fi Subject: [PATCH] notmuch-emacs-mua: escape $PWD (and cd always). use message-add-actions. Date: Thu, 14 Apr 2016 20:44:44 +0300 Message-Id: <1460655884-18148-1-git-send-email-tomi.ollila@iki.fi> X-Mailer: git-send-email 2.6.4 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: Thu, 14 Apr 2016 17:45:04 -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). Finally, use message.el -provided function message-add-actions to set(/add) #'save-buffers-kill-terminal to the message-exit-actions list. --- Now that there is new potential interest to this tool I got motivation to prepare this for sending (i.e. commit message & message-add-action usage done today). notmuch-emacs-mua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/notmuch-emacs-mua b/notmuch-emacs-mua index 4404cd7..fdb9744 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 @@ -132,7 +134,7 @@ done # Kill the terminal/frame if we're creating one. if [ -z "$USE_EMACSCLIENT" -o -n "$CREATE_FRAME" -o -n "$NO_WINDOW" ]; then - ELISP="${ELISP} (setq message-exit-actions (list #'save-buffers-kill-terminal))" + ELISP="${ELISP} (message-add-action #'save-buffers-kill-terminal 'exit)" fi # End progn. -- 1.9.3