[notmuch] [PATCH 2/2] Save all attachments to a directory

2009-12-13 Thread Carl Worth
On Fri, 11 Dec 2009 17:32:51 -0800, Keith Amidon  
wrote:
> {-- Thu, 10 Dec 2009 16:57:01 -0800: Carl  wrote: --}
> What do you see as the "write one" behavior for a message with multiple
> attachments?

I was imagining a direct-manipulation approach by clicking on (or
pressing a key while point is on) a button representing the attachment.

And then it would probably be reasonable to make that same keypress save
the next attachment if point is positioned between attachment buttons.

> Yes, you're right the current approach should have had a proper prompt.
> I've been thinking about this though and I wonder if we should skip
> separately prompting for the directory and instead do the following:
> 
> 1) Have customizable "default save directory" both types of attachment
>saving default to.  Use this as the path part of the prompt for the
>filename to which the attachment will be written.
> 2) After the user has adjusted the path as required, verify that the
>full directory path exists and if not create it.
> 3) Use the same directory path as the default for any subsequent
>attachments that are being saved.

Yes, the above sounds good to me. If the directory doesn't exist it
should probably give a y-or-n prompt before creating it, (and drop back
to prompting for the full filename path again if the users says no to
creating the directory).

> This seems like it would lesson the number of keystrokes required for
> at least some common cases.

Spoken as a man after my own heart.

> I'm not sure it is the most usable solution, but I believe selecting the
> text to save in the rendered message in the thread view and using "M-x
> write-region" should handle this use case.

Funny---I don't think I've ever used that command before. But it should
be handy---thanks!

-Carl
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 



Re: [notmuch] [PATCH 2/2] Save all attachments to a directory

2009-12-13 Thread Carl Worth
On Fri, 11 Dec 2009 17:32:51 -0800, Keith Amidon cama...@picnicpark.org wrote:
 {-- Thu, 10 Dec 2009 16:57:01 -0800: Carl cwo...@cworth.org wrote: --}
 What do you see as the write one behavior for a message with multiple
 attachments?

I was imagining a direct-manipulation approach by clicking on (or
pressing a key while point is on) a button representing the attachment.

And then it would probably be reasonable to make that same keypress save
the next attachment if point is positioned between attachment buttons.

 Yes, you're right the current approach should have had a proper prompt.
 I've been thinking about this though and I wonder if we should skip
 separately prompting for the directory and instead do the following:
 
 1) Have customizable default save directory both types of attachment
saving default to.  Use this as the path part of the prompt for the
filename to which the attachment will be written.
 2) After the user has adjusted the path as required, verify that the
full directory path exists and if not create it.
 3) Use the same directory path as the default for any subsequent
attachments that are being saved.

Yes, the above sounds good to me. If the directory doesn't exist it
should probably give a y-or-n prompt before creating it, (and drop back
to prompting for the full filename path again if the users says no to
creating the directory).

 This seems like it would lesson the number of keystrokes required for
 at least some common cases.

Spoken as a man after my own heart.

 I'm not sure it is the most usable solution, but I believe selecting the
 text to save in the rendered message in the thread view and using M-x
 write-region should handle this use case.

Funny---I don't think I've ever used that command before. But it should
be handy---thanks!

-Carl


pgpyZYIx18fug.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH 2/2] Save all attachments to a directory

2009-12-11 Thread Keith Amidon
{-- Thu, 10 Dec 2009 16:57:01 -0800: Carl  wrote: --}

  Carl> First, I'm not sure whether we need two different variations of
  Carl> what's effectively the same operation here ("save all
  Carl> attachments").

Yes, I agree it is an ugly solution.  Thanks for not letting me get away
with it.  :-)

  Carl> What I would like is one command to save a single attachment,
  Carl> and then one command to save all attachments. So if we assume
  Carl> that the current 'w' keybinding is really for "write one
  Carl> attachment" (with a lame implementation currently), and 'W' is
  Carl> for "write all attachments", then I think I'd be OK with that.

What do you see as the "write one" behavior for a message with multiple
attachments?  I think there needs to be some way to select the
attachment to be written.  Maybe we use the prefix-argument for this so
that 'M-2 w' would write the second attachment, 'M-3 w' would write the
third attachment, etc.  Since the default is 1, a plain 'w' would write
the first attachment which is the correct default for the single message
case.  It's not the most discoverable approach, but it wouldn't be too
bad.  

  Carl> As for the changes we need here, the prompting for the directory
  Carl> needs a string telling the user what's being prompted
  Carl> for. Something like "Save all attachments to: ", which should
  Carl> just be another argument to the interactive call, right?

Yes, you're right the current approach should have had a proper prompt.
I've been thinking about this though and I wonder if we should skip
separately prompting for the directory and instead do the following:

1) Have customizable "default save directory" both types of attachment
   saving default to.  Use this as the path part of the prompt for the
   filename to which the attachment will be written.
2) After the user has adjusted the path as required, verify that the
   full directory path exists and if not create it.
3) Use the same directory path as the default for any subsequent
   attachments that are being saved.

This seems like it would lesson the number of keystrokes required for
at least some common cases.

  Carl> Second, the command needs to provide a little bit of feedback as
  Carl> to what was saved. I ended up running this command a couple of
  Carl> times before I realized it was never going to save the inline
  Carl> patch with no filename that I was looking at[*].

  Carl> So it at least needs to message something like "N files written
  Carl> to DIR" or so.

Sure, that's easy to add and makes a lot of sense.  We should add
similar error reporting for other common error cases like selecting a
non-existing single attachment to save if we implement the
keystroke-based approach suggested above.

  Carl> [*] So there's something else I think we need here. I was seeing
  Carl> a patch in a message, but wanted to get it into a file before
  Carl> piping it off to something, (so '|' didn't work). The patch
  Carl> wasn't an attachment so 'w' didn't work as described above. I
  Carl> tried using 'V' to view the raw message, but then found that the
  Carl> MIME part I wanted was actually encoded as quoted-printable, so
  Carl> just saving the raw message wasn't useful either.

I'm not sure it is the most usable solution, but I believe selecting the
text to save in the rendered message in the thread view and using "M-x
write-region" should handle this use case.



Re: [notmuch] [PATCH 2/2] Save all attachments to a directory

2009-12-11 Thread Keith Amidon
{-- Thu, 10 Dec 2009 16:57:01 -0800: Carl cwo...@cworth.org wrote: --}

  Carl First, I'm not sure whether we need two different variations of
  Carl what's effectively the same operation here (save all
  Carl attachments).

Yes, I agree it is an ugly solution.  Thanks for not letting me get away
with it.  :-)

  Carl What I would like is one command to save a single attachment,
  Carl and then one command to save all attachments. So if we assume
  Carl that the current 'w' keybinding is really for write one
  Carl attachment (with a lame implementation currently), and 'W' is
  Carl for write all attachments, then I think I'd be OK with that.

What do you see as the write one behavior for a message with multiple
attachments?  I think there needs to be some way to select the
attachment to be written.  Maybe we use the prefix-argument for this so
that 'M-2 w' would write the second attachment, 'M-3 w' would write the
third attachment, etc.  Since the default is 1, a plain 'w' would write
the first attachment which is the correct default for the single message
case.  It's not the most discoverable approach, but it wouldn't be too
bad.  

  Carl As for the changes we need here, the prompting for the directory
  Carl needs a string telling the user what's being prompted
  Carl for. Something like Save all attachments to: , which should
  Carl just be another argument to the interactive call, right?

Yes, you're right the current approach should have had a proper prompt.
I've been thinking about this though and I wonder if we should skip
separately prompting for the directory and instead do the following:

1) Have customizable default save directory both types of attachment
   saving default to.  Use this as the path part of the prompt for the
   filename to which the attachment will be written.
2) After the user has adjusted the path as required, verify that the
   full directory path exists and if not create it.
3) Use the same directory path as the default for any subsequent
   attachments that are being saved.

This seems like it would lesson the number of keystrokes required for
at least some common cases.

  Carl Second, the command needs to provide a little bit of feedback as
  Carl to what was saved. I ended up running this command a couple of
  Carl times before I realized it was never going to save the inline
  Carl patch with no filename that I was looking at[*].

  Carl So it at least needs to message something like N files written
  Carl to DIR or so.

Sure, that's easy to add and makes a lot of sense.  We should add
similar error reporting for other common error cases like selecting a
non-existing single attachment to save if we implement the
keystroke-based approach suggested above.

  Carl [*] So there's something else I think we need here. I was seeing
  Carl a patch in a message, but wanted to get it into a file before
  Carl piping it off to something, (so '|' didn't work). The patch
  Carl wasn't an attachment so 'w' didn't work as described above. I
  Carl tried using 'V' to view the raw message, but then found that the
  Carl MIME part I wanted was actually encoded as quoted-printable, so
  Carl just saving the raw message wasn't useful either.

I'm not sure it is the most usable solution, but I believe selecting the
text to save in the rendered message in the thread view and using M-x
write-region should handle this use case.

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH 2/2] Save all attachments to a directory

2009-12-10 Thread Carl Worth
On Sat,  5 Dec 2009 14:54:00 -0800, Keith Amidon  wrote:
> Prompt for a directory and write all attachments of the current
> message to that directory, prompting for a filename for each with a
> default value of the filename specified in the attachment.

I really like the idea of this function. I'd just like to see a few,
little improvements.

> The behavior of this function differs in two ways from the existing
> notmuch-show-save-attachments function:

First, I'm not sure whether we need two different variations of what's
effectively the same operation here ("save all attachments").

What I would like is one command to save a single attachment, and then
one command to save all attachments. So if we assume that the current
'w' keybinding is really for "write one attachment" (with a lame
implementation currently), and 'W' is for "write all attachments", then
I think I'd be OK with that.

As for the changes we need here, the prompting for the directory needs
a string telling the user what's being prompted for. Something like
"Save all attachments to: ", which should just be another argument to
the interactive call, right?

Second, the command needs to provide a little bit of feedback as to what
was saved. I ended up running this command a couple of times before I
realized it was never going to save the inline patch with no filename
that I was looking at[*].

So it at least needs to message something like "N files written to DIR"
or so.

Should be fairly trivial improvements to the current patch I think.

-Carl

[*] So there's something else I think we need here. I was seeing a patch
in a message, but wanted to get it into a file before piping it off to
something, (so '|' didn't work). The patch wasn't an attachment so 'w'
didn't work as described above. I tried using 'V' to view the raw
message, but then found that the MIME part I wanted was actually encoded
as quoted-printable, so just saving the raw message wasn't useful
either.

So do we need a command to write the current "cooked" message to a file?
I suppose I could have just used:

| cat > /some/filename

but that feels a little bit like cat abuse.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 



Re: [notmuch] [PATCH 2/2] Save all attachments to a directory

2009-12-10 Thread Carl Worth
On Sat,  5 Dec 2009 14:54:00 -0800, Keith Amidon ke...@nicira.com wrote:
 Prompt for a directory and write all attachments of the current
 message to that directory, prompting for a filename for each with a
 default value of the filename specified in the attachment.

I really like the idea of this function. I'd just like to see a few,
little improvements.

 The behavior of this function differs in two ways from the existing
 notmuch-show-save-attachments function:

First, I'm not sure whether we need two different variations of what's
effectively the same operation here (save all attachments).

What I would like is one command to save a single attachment, and then
one command to save all attachments. So if we assume that the current
'w' keybinding is really for write one attachment (with a lame
implementation currently), and 'W' is for write all attachments, then
I think I'd be OK with that.

As for the changes we need here, the prompting for the directory needs
a string telling the user what's being prompted for. Something like
Save all attachments to: , which should just be another argument to
the interactive call, right?

Second, the command needs to provide a little bit of feedback as to what
was saved. I ended up running this command a couple of times before I
realized it was never going to save the inline patch with no filename
that I was looking at[*].

So it at least needs to message something like N files written to DIR
or so.

Should be fairly trivial improvements to the current patch I think.

-Carl

[*] So there's something else I think we need here. I was seeing a patch
in a message, but wanted to get it into a file before piping it off to
something, (so '|' didn't work). The patch wasn't an attachment so 'w'
didn't work as described above. I tried using 'V' to view the raw
message, but then found that the MIME part I wanted was actually encoded
as quoted-printable, so just saving the raw message wasn't useful
either.

So do we need a command to write the current cooked message to a file?
I suppose I could have just used:

| cat  /some/filename

but that feels a little bit like cat abuse.


pgpxVGiEYtZ5t.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH 2/2] Save all attachments to a directory

2009-12-07 Thread Keith Amidon
Prompt for a directory and write all attachments of the current
message to that directory, prompting for a filename for each with a
default value of the filename specified in the attachment.

The behavior of this function differs in two ways from the existing
notmuch-show-save-attachments function:

1) It first prompts for the directory in which to save attachments
   instead of assuming the current default directory.

2) If there is more than one attachment in the message, it assumes all
   should be saved and only prompts for filenames instead of asking
   first whether each attachment should be saved.
---
 notmuch.el |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 8d51709..08bd114 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -65,6 +65,7 @@
 (define-key map r 'notmuch-show-reply)
 (define-key map | 'notmuch-show-pipe-message)
 (define-key map w 'notmuch-show-save-attachments)
+(define-key map W 'notmuch-show-save-all-attachments)
 (define-key map V 'notmuch-show-view-raw-message)
 (define-key map v 'notmuch-show-view-all-mime-parts)
 (define-key map - 'notmuch-show-remove-tag)
@@ -352,6 +353,17 @@ buffer.
   mm-handle ( (notmuch-count-attachments mm-handle) 1
   (message Done))
 
+(defun notmuch-show-save-all-attachments (directory)
+  Save all attachments of a message to a directory.
+  (interactive G)
+  (let ((dirname (file-name-as-directory directory)))
+(make-directory dirname t)
+(with-current-notmuch-show-message
+ (let ((mm-handle (mm-dissect-buffer))
+   (mm-default-directory dirname))
+   (notmuch-save-attachments mm-handle nil
+  (message Done))
+
 (defun notmuch-reply (query-string)
   (switch-to-buffer (generate-new-buffer notmuch-draft))
   (call-process notmuch-command nil t nil reply query-string)
-- 
1.6.5.4

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH 2/2] Save all attachments to a directory

2009-12-05 Thread Keith Amidon
Prompt for a directory and write all attachments of the current
message to that directory, prompting for a filename for each with a
default value of the filename specified in the attachment.

The behavior of this function differs in two ways from the existing
notmuch-show-save-attachments function:

1) It first prompts for the directory in which to save attachments
   instead of assuming the current default directory.

2) If there is more than one attachment in the message, it assumes all
   should be saved and only prompts for filenames instead of asking
   first whether each attachment should be saved.
---
 notmuch.el |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 8d51709..08bd114 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -65,6 +65,7 @@
 (define-key map "r" 'notmuch-show-reply)
 (define-key map "|" 'notmuch-show-pipe-message)
 (define-key map "w" 'notmuch-show-save-attachments)
+(define-key map "W" 'notmuch-show-save-all-attachments)
 (define-key map "V" 'notmuch-show-view-raw-message)
 (define-key map "v" 'notmuch-show-view-all-mime-parts)
 (define-key map "-" 'notmuch-show-remove-tag)
@@ -352,6 +353,17 @@ buffer."
   mm-handle (> (notmuch-count-attachments mm-handle) 1
   (message "Done"))

+(defun notmuch-show-save-all-attachments (directory)
+  "Save all attachments of a message to a directory."
+  (interactive "G")
+  (let ((dirname (file-name-as-directory directory)))
+(make-directory dirname t)
+(with-current-notmuch-show-message
+ (let ((mm-handle (mm-dissect-buffer))
+   (mm-default-directory dirname))
+   (notmuch-save-attachments mm-handle nil
+  (message "Done"))
+
 (defun notmuch-reply (query-string)
   (switch-to-buffer (generate-new-buffer "notmuch-draft"))
   (call-process notmuch-command nil t nil "reply" query-string)
-- 
1.6.5.4