Re: How to intercept recipient before reply, and before sending?

2021-06-30 Thread P. Mazart
Hi Jean,

we missed each other in IRC, so here’s my reply.

Jean Louis schrieb am 24.06.2021 15:36:10:
> Thus I would like to inject the ID number into the text before the
> reply. 

I think you could always create a {python,bash,ruby} script or c-program
and let it “mimic” an editor when you reply:

:macro index r "set 
editor=\"edit-id-then-reply.py\"set 
editor=\"vim\""

Once you hit your reply button »r« the editor is changed, started and
set back again. It could also start your favourite text editor.

e.g. you could use this as »edit-id-then-reply.py«:

#!/usr/bin/env python3

import sys
import subprocess

with open(sys.argv[1], 'a') as email_file:
email_file.write('Hello, I am your ID\n');

subprocess.run(['vim', sys.argv[1]]);

This would open the filename of the reply-email, then read it and change
some of its content (e.g. insert user id), then start your text editor so
you can type your reply.

> Is there a way to intercept the recipient's address, like making a
> macro for the `y' key binding?

Similar to the above, you could create a sendmail-compatible wrapper,
that does the interception and later actually runs sendmail or msmtp or
else.

Best Regards,
PM



Re: How to intercept recipient before reply, and before sending?

2021-06-30 Thread Jean Louis
* P. Mazart  [2021-06-30 10:01]:
> Hi Jean,
> 
> we missed each other in IRC, so here’s my reply.

Thanks.

> I think you could always create a {python,bash,ruby} script or c-program
> and let it “mimic” an editor when you reply:
> 
> :macro index r "set 
> editor=\"edit-id-then-reply.py\"set 
> editor=\"vim\""

> Once you hit your reply button »r« the editor is changed, started and
> set back again. It could also start your favourite text editor.
> 
> e.g. you could use this as »edit-id-then-reply.py«:
> 
> #!/usr/bin/env python3
> 
> import sys
> import subprocess
> 
> with open(sys.argv[1], 'a') as email_file:
> email_file.write('Hello, I am your ID\n');
> 
> subprocess.run(['vim', sys.argv[1]]);
> 
> This would open the filename of the reply-email, then read it and change
> some of its content (e.g. insert user id), then start your text editor so
> you can type your reply.

That is good idea. It is nice hack. Intercept the file, change it a
bit if necessary and delegate to editor.

I think in this version I will not get the To: field, I will get the
reply message.

What I need is recipient's email to associate it with the ID from the
database. I could maybe pipe it, get the Email, associate with ID,
store it somewhere, then launch editor that is anyway Emacs that could
by the file name recognize that it has to insert ID if not inserted. 

Maybe first piping, getting email address, recording ID, then reply as
usual. The ID actually need not be in the text, it can be outside of
Mutt, important is that I can access the "current ID" from editor. 

This is all good as brainstorming.

> > Is there a way to intercept the recipient's address, like making a
> > macro for the `y' key binding?
> 
> Similar to the above, you could create a sendmail-compatible wrapper,
> that does the interception and later actually runs sendmail or msmtp or
> else.

Also good idea. That is what I have to do.

Thanks.


Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/


Re: How to intercept recipient before reply, and before sending?

2021-06-30 Thread P. Mazart
Hi Jean,

Jean Louis schrieb am 30.06.2021 17:52:55:
> That is good idea. It is nice hack. Intercept the file, change it a
> bit if necessary and delegate to editor.
> 
> I think in this version I will not get the To: field, I will get the
> reply message.

My fault: I was implying that you have edit_headers on:
:set edit_headers="yes"

Now run that “hack” again and your good to go. 🙂

> Maybe first piping, getting email address, recording ID, then reply as
> usual. The ID actually need not be in the text, it can be outside of
> Mutt, important is that I can access the "current ID" from editor. 

True, you could maybe even put it into the postponed location and then try to 
send
that message. I guess that could work as one nice macro, too.
If the above does not work, let’s elaborate on this idea later.

Anyhow I guess, edit_headers="yes" opens up some new capabilities; maybe
even doing everything inside emacs without the “hack” above.
 
> This is all good as brainstorming.

Nice, any chance that this system will be talked about in a blog or
something like that? This CRM of yours sounds like an interesting read.

> Also good idea. That is what I have to do.

Great!

Best Regards,
PM