Discussions of development and use of the Sup email client
 help / color / mirror / Atom feed
From: Gaute Hope <eg@gaute.vetsj.com>
To: supmua@googlegroups.com
Subject: Re: [sup] Re: how to write interactive hook
Date: Sun, 21 Sep 2014 17:20:06 +0000	[thread overview]
Message-ID: <1411319662-astroid-1-fmtkb2haww-21321@strange> (raw)
In-Reply-To: <1411151595-sup-2926@ruthard-lappi>

Excerpts from Ruthard Baudach's message of September 19, 2014 20:41:
>>== Auszüge aus der Nachricht von  Gaute Hope vom 2014-09-18 23:10:
>> Excerpts from Ruthard Baudach's message of September 18, 2014 22:15:
>> > Works, but the hook seems to be called – or at least
>> > ask_many_with_completions asks when
>> > 
>> > 1) sup enters compose mode
>> > 2) sup calls the external editor
>> > 3)4) two times when sup regains control – only the second answer is
>> >    attached to compose-mode text
>> > 5) after initializing sendmail by hitting y
>> 
>> It is probably called every time the message needs to be generated. If
>> you could figure out a way to save the state for the message then you
>> could just return the previously selected one on the subsequent calls.
> 
> For sure.
> 
> At the moment my drafted solution is:
> 
> ----------->%--------------------
> # signature.rb -- generate signature
> 
> unless $signature
>     $signature = BufferManager.ask_many_with_completions :sign, "Choose signature: ", ["One","Two","Three"]
> end
> 'Signature: ' + $signature
> ----------->%--------------------
> # sendemail.rb – send mail
> 
> $signature = nil
> 
> IO.popen(account.sendmail, "w:UTF-8") { |p| p.puts message }
> if $?
>        	return true
> else
> 	return false
> end
> ----------->%--------------------
> 
> Now I just needed a discard-message and a safe-draft hook to set the
> signature to nil in these cases, and everything was fine!
> 
> I'm afraid I have to tackle sup core code to get this working. I'll
> report back if I get it to work,

Setting up new hooks is not too complicated, have a look at some
of the existing.

Another option is to pass the message id (if it is persistent) to the
signature hook, then when the message id changes you reset the hook
state.

I'm a bit reluctant to add new hooks for very seldomly used purposes,
but the ones you describe above might be worth it.

Cheers, Gaute



  reply	other threads:[~2014-09-21 17:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-14 18:07 Ruthard Baudach
2014-09-17 18:46 ` [sup] " Matthieu Rakotojaona
2014-09-18  5:51   ` Gaute Hope
2014-09-18 17:46   ` Ruthard Baudach
2014-09-18 18:58     ` Gaute Hope
2014-09-18  9:34 ` Eric Weikl
2014-09-18 20:06 ` Ruthard Baudach
2014-09-18 20:15 ` Ruthard Baudach
2014-09-18 21:10   ` [sup] " Gaute Hope
2014-09-19 18:41     ` Ruthard Baudach
2014-09-21 17:20       ` Gaute Hope [this message]
2014-10-01 20:46         ` Ruthard Baudach
2014-10-06 12:05           ` Gaute Hope

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=1411319662-astroid-1-fmtkb2haww-21321@strange \
    --to=eg@gaute.vetsj.com \
    --cc=supmua@googlegroups.com \
    /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