How to intercept recipient before reply, and before sending?
Jean Louis
bugs at gnu.support
Wed Jun 30 15:52:55 UTC 2021
* P. Mazart <pmazart at web.de> [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 "<enter-command>set editor=\"edit-id-then-reply.py\"<enter><reply><enter-command>set editor=\"vim\"<enter>"
> 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/
More information about the Mutt-users
mailing list