sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit c6a67bdba5e46c1dad850c3aef2dc71c9f55e89e
parent 182827ca5d43b98b46c092bfda9bc79e4dff2cec
Author: Hamish Downer <dmishd@gmail.com>
Date:   Sun,  3 Apr 2011 22:29:04 +0100

Added hook to run in async edit mode.

The hook should not block - so it should use fork() or some such.
For now, you still have to exit the async mode manually.

Diffstat:
M lib/sup/modes/edit-message-async-mode.rb | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+), 0 deletions(-)
diff --git a/lib/sup/modes/edit-message-async-mode.rb b/lib/sup/modes/edit-message-async-mode.rb
@@ -2,7 +2,23 @@ module Redwood
 
 class EditMessageAsyncMode < LineCursorMode
 
+  HookManager.register "async-edit", <<EOS
+Runs when 'H' is pressed in async edit mode. You can run whatever code
+you want here - though the default case would be launching a text
+editor. Your hook is assumed to not block, so you should use exec() or
+fork() to launch the editor.
+
+Once the hook has returned then sup will be responsive as usual. You will
+still need to press 'E' to exit this buffer and send the message.
+
+Variables:
+file_path: The full path to the file containing the message to be edited.
+
+Return value: None
+EOS
+
   register_keymap do |k|
+    k.add :run_async_hook, "Run the async-edit hook", 'H'
     k.add :edit_finished, "Finished editing message", 'E'
     k.add :path_to_clipboard, "Copy file path to the clipboard", :enter
   end
@@ -70,6 +86,10 @@ protected
     end
   end
 
+  def run_async_hook
+    HookManager.run("async-edit", {:file_path => @file_path})
+  end
+
   def file_being_edited?
     # check for common editor lock files
     vim_lock_file = File.join(File.dirname(@file_path), '.'+File.basename(@file_path)+'.swp')