* Re: [sup-talk] default_attachment_save_dir
2010-03-02 18:06 [sup-talk] default_attachment_save_dir John Bent
@ 2010-03-02 19:27 ` Ben Walton
2010-03-02 22:04 ` Sven Schober
0 siblings, 1 reply; 3+ messages in thread
From: Ben Walton @ 2010-03-02 19:27 UTC (permalink / raw)
To: sup-talk
[-- 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
^ permalink raw reply [flat|nested] 3+ messages in thread