(via #killable?) before killing. inbox-mode always returns false.
also improved ask_yes_or_no. three outputs: yes, no, and nil (cancel).
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@68
5c8cc53c-5e98-4d25-b20a-
d8db53a31250
when :roll_buffers_backwards
bm.roll_buffers_backwards
when :kill_buffer
- bm.kill_buffer bm.focus_buf unless bm.focus_buf.mode.is_a? InboxMode
+ bm.kill_buffer bm.focus_buf if bm.focus_buf.mode.killable?
when :list_buffers
bm.spawn_unless_exists("Buffer List") { BufferListMode.new }
when :list_contacts
case $exception
when IndexError
$stderr.puts <<EOS
-An error occurred while parsing a message from source "#{$exception.source}".
+An error occurred while parsing a message from source:
+ #{$exception.source}.
Typically, this means that the source has been modified in some
-way which has rendered the messages invalid. For example, if it's an mbox
-file, you may have read or deleted messages using another client.
+way which has rendered the messages invalid. For example, if it's
+an mbox file, you may have read or deleted messages using another
+mail client.
You must rebuild the index for this source. Please run:
sup-import --rebuild #{$exception.source}
end
def ask_yes_or_no question
- [?y, ?Y].member? ask_getch(question, "ynYN")
+ r = ask_getch(question, "ynYN")
+ case r
+ when ?y, ?Y
+ true
+ when nil
+ nil
+ else
+ false
+ end
end
def draw_minibuf
end
end
+ def killable?; true; end
def draw; end
def focus; end
def blur; end
end
def send_message
- return false unless @edited || BufferManager.ask_yes_or_no("message unedited---really send?")
+ return false unless @edited || BufferManager.ask_yes_or_no("Message unedited. Really send?")
raise "no message id!" unless header["Message-Id"]
date = Time.now
DraftManager.write_draft { |f| write_message f, false }
BufferManager.kill_buffer buffer
BufferManager.flash "Saved for later editing."
+ true
end
def sig_lines
super [:inbox], [:inbox]
end
+ def killable?; false; end
+
def archive
remove_label_and_hide_thread cursor_thread, :inbox
regen_text
@header.delete "Date"
@header["Message-Id"] = gen_message_id # generate a new'n
regen_text
- @sent = false
+ @safe = false
+ end
+
+ def killable?
+ unless @safe
+ case BufferManager.ask_yes_or_no "Discard draft?"
+ when true
+ DraftManager.discard @id
+ BufferManager.flash "Draft discarded."
+ true
+ when false
+ BufferManager.flash "Draft saved."
+ true
+ else
+ false
+ end
+ end
end
def send_message
if super
DraftManager.discard @id
- @sent = true
+ @safe = true
end
end
- def cleanup
- unless @sent
- if BufferManager.ask_yes_or_no "discard draft?"
- DraftManager.discard @id
- BufferManager.flash "Draft discarded."
- else
- BufferManager.flash "Draft saved."
- end
- super
- end
+ def save_as_draft
+ @safe = true
+ DraftManager.discard @id if super
end
end