Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
From: Ben Walton <bwalton@artsci.utoronto.ca>
To: sup-talk <sup-talk@rubyforge.org>
Subject: Re: [sup-talk] default_attachment_save_dir
Date: Tue, 02 Mar 2010 14:27:27 -0500	[thread overview]
Message-ID: <1267557911-sup-352@pinkfloyd.chass.utoronto.ca> (raw)
In-Reply-To: <1267553166-sup-2030@tangerine.lanl.gov>


[-- Attachment #1.1.1: Type: text/plain, Size: 291 bytes --]

Excerpts from John Bent's message of Tue Mar 02 13:06:35 -0500 2010:

> Is there a patch so that the default_attachment_save_dir is not
> static but uses the last used location?

Not that I'm aware of, but the attached seems to do the trick.  I like
this feature?  Anyone else?

Thanks
-Ben

[-- Attachment #1.1.2: 0001-remember-save-dir.patch --]
[-- Type: application/octet-stream, Size: 1718 bytes --]

From 5998fa6f683af85f0ae90b2beec04d780f871b14 Mon Sep 17 00:00:00 2001
From: Ben Walton <bwalton@artsci.utoronto.ca>
Date: Tue, 2 Mar 2010 14:22:03 -0500
Subject: [PATCH] Remember the previous directory used to save attachments

This patch teaches the thread view mode to remember the last directory
that an attachment was saved in, making it the default for the next
save operation.

Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca>
---
 lib/sup/modes/thread-view-mode.rb |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb
index 63fe211..ca34458 100644
--- a/lib/sup/modes/thread-view-mode.rb
+++ b/lib/sup/modes/thread-view-mode.rb
@@ -357,11 +357,15 @@ EOS
     chunk = @chunk_lines[curpos] or return
     case chunk
     when Chunk::Attachment
-      default_dir = $config[:default_attachment_save_dir]
-      default_dir = ENV["HOME"] if default_dir.nil? || default_dir.empty?
-      default_fn = File.expand_path File.join(default_dir, chunk.filename)
+      cd = $config[:default_attachment_save_dir]
+      default_dir = ((cd.nil? || cd.empty?) ? ENV["HOME"] : cd)
+      @last_save_dir ||= default_dir
+      default_fn = File.expand_path File.join(@last_save_dir, chunk.filename)
       fn = BufferManager.ask_for_filename :filename, "Save attachment to file: ", default_fn
-      save_to_file(fn) { |f| f.print chunk.raw_content } if fn
+      if fn
+        save_to_file(fn) { |f| f.print chunk.raw_content }
+        @last_save_dir = File.dirname(fn)
+      end
     else
       m = @message_lines[curpos]
       fn = BufferManager.ask_for_filename :filename, "Save message to file: "
-- 
1.7.0


[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 140 bytes --]

_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk

  reply	other threads:[~2010-03-02 19:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-02 18:06 John Bent
2010-03-02 19:27 ` Ben Walton [this message]
2010-03-02 22:04   ` Sven Schober

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1267557911-sup-352@pinkfloyd.chass.utoronto.ca \
    --to=bwalton@artsci.utoronto.ca \
    --cc=sup-talk@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox