unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] notmuch-emacs-mua: escape $PWD (and cd always). use message-add-actions.
@ 2016-04-14 17:44 Tomi Ollila
  2016-05-15 13:28 ` David Bremner
  0 siblings, 1 reply; 5+ messages in thread
From: Tomi Ollila @ 2016-04-14 17:44 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] notmuch-emacs-mua: escape $PWD (and cd always). use message-add-actions.
  2016-04-14 17:44 [PATCH] notmuch-emacs-mua: escape $PWD (and cd always). use message-add-actions Tomi Ollila
@ 2016-05-15 13:28 ` David Bremner
  2016-05-28 11:06   ` [PATCH 1/2] notmuch-emacs-mua: " Tomi Ollila
  0 siblings, 1 reply; 5+ messages in thread
From: David Bremner @ 2016-05-15 13:28 UTC (permalink / raw)
  To: Tomi Ollila, notmuch

Tomi Ollila <tomi.ollila@iki.fi> writes:

>  # 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
>  

This seems to work fine, but afaict it is two completely distinct
patches squashed into one.

d

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] notmuch-emacs-mua: use message-add-actions
  2016-05-15 13:28 ` David Bremner
@ 2016-05-28 11:06   ` Tomi Ollila
  2016-05-28 11:06     ` [PATCH 2/2] notmuch-emacs-mua: escape $PWD (and cd always) Tomi Ollila
  2016-06-11 16:25     ` [PATCH 1/2] notmuch-emacs-mua: use message-add-actions David Bremner
  0 siblings, 2 replies; 5+ messages in thread
From: Tomi Ollila @ 2016-05-28 11:06 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

Use message.el -provided function message-add-actions to
set(/add) #'save-buffers-kill-terminal into the message-exit-actions
list.
---
 notmuch-emacs-mua | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/notmuch-emacs-mua b/notmuch-emacs-mua
index 4404cd7c33b8..1168c6f65a5f 100755
--- a/notmuch-emacs-mua
+++ b/notmuch-emacs-mua
@@ -132,7 +132,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.
-- 
2.8.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] notmuch-emacs-mua: escape $PWD (and cd always)
  2016-05-28 11:06   ` [PATCH 1/2] notmuch-emacs-mua: " Tomi Ollila
@ 2016-05-28 11:06     ` Tomi Ollila
  2016-06-11 16:25     ` [PATCH 1/2] notmuch-emacs-mua: use message-add-actions David Bremner
  1 sibling, 0 replies; 5+ messages in thread
From: Tomi Ollila @ 2016-05-28 11:06 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] notmuch-emacs-mua: use message-add-actions
  2016-05-28 11:06   ` [PATCH 1/2] notmuch-emacs-mua: " Tomi Ollila
  2016-05-28 11:06     ` [PATCH 2/2] notmuch-emacs-mua: escape $PWD (and cd always) Tomi Ollila
@ 2016-06-11 16:25     ` David Bremner
  1 sibling, 0 replies; 5+ messages in thread
From: David Bremner @ 2016-06-11 16:25 UTC (permalink / raw)
  To: Tomi Ollila, notmuch; +Cc: tomi.ollila

Tomi Ollila <tomi.ollila@iki.fi> writes:

> Use message.el -provided function message-add-actions to
> set(/add) #'save-buffers-kill-terminal into the message-exit-actions
> list.

Pushed the series.

d

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-06-11 16:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-14 17:44 [PATCH] notmuch-emacs-mua: escape $PWD (and cd always). use message-add-actions Tomi Ollila
2016-05-15 13:28 ` David Bremner
2016-05-28 11:06   ` [PATCH 1/2] notmuch-emacs-mua: " Tomi Ollila
2016-05-28 11:06     ` [PATCH 2/2] notmuch-emacs-mua: escape $PWD (and cd always) Tomi Ollila
2016-06-11 16:25     ` [PATCH 1/2] notmuch-emacs-mua: use message-add-actions David Bremner

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).