Re: What's the best way to auto-sign some emails but not all?
Bjørn Mork <[email protected]> Mon, 02 Dec 2024 16:11:40 +0100
| Newsgroups | gmane.emacs.gnus.general |
|---|---|
| Organization | m |
| Message-ID | <[email protected]> |
Thanks for all the great ideas. I have realized that there are probably
more ways to do this than there are Gnus users :-)
The discussion made me look closer at the code in question, which I
should have done in the first place. And I believe my problem is that
there are no hooks in the appropriate places. Yanking the original
message happens very late, long after message-setup is finished.
Most of the suggestions depend on message-setup-hook in some way, making
them work and fail similar to my existing gnus-posting-styles setup. One
exception is gnus-alias which AFAIU can apply a new identity to an
existing message buffer. But that's an interactive choice, which is
what I'm trying to avoid. After all, I could just run
mml-secure-message-sign if I wanted to.
So what I have ended up with is this ugly hack:
#+BEGIN_SRC emacs-lisp
(defun bjorn/message--yank-original-advice (arg)
"Leave sign/encrypt mml tags untouched when yanking original"
(when (looking-at "<#secure")
(forward-line 1)))
(advice-add 'message--yank-original-internal :before #'bjorn/message--yank-original-advice)
#+END_SRC
which does the job for me when combined
(body "<#secure method=pgpmime mode=sign>")
in the appropriate posting style(s).
Bjørn