Gnus development mailing list
 help / color / mirror / Atom feed
From: "Bjørn Mork" <bjorn@mork.no>
To: Trevor Arjeski <tmarjeski@gmail.com>
Cc: ding@gnus.org
Subject: Re: What's the best way to auto-sign some emails but not all?
Date: Sat, 30 Nov 2024 20:28:41 +0100	[thread overview]
Message-ID: <87o71wikra.fsf@miraculix.mork.no> (raw)
In-Reply-To: <87jzckmv6k.fsf@gmail.com> (Trevor Arjeski's message of "Sat, 30 Nov 2024 21:29:55 +0300")

Trevor Arjeski <tmarjeski@gmail.com> writes:
> Bjørn Mork <bjorn@mork.no> writes:
>
>> Is there a nice way to always sign emails based on e.g. the current From
>> address?  I don't want to sign everything, but I would like to sign all
>> emails I send from one specific address.
>
> Hi Bjørn,
>
> For me, I am signing all messages and just removing the "secure" tag
> when I am writing on a mailing list or something.

Yes, that's a possibilty.  But do hate manual procedures for anything
that can be automated.  And knowing myself, I am going to forget this
47% of the time.  I'll remember it if the passphrase box shows up.  But
I don't want to disable caching, and I am sure that will result in some
emails going out with an unwanted gpg signature. Not a big problem,
maybe.  But we're looking for the perfect solution here :-)

> I do this by adding a hook on `message-setup-hook' that calls
> `mml-secure-message-encrypt'.
>
> Therefore, you can add a similar hook with the help of a function (or
> just lambda), for example:
>
> #+BEGIN_SRC emacs-lisp
> (defun my/mml-secure-message-encrypt ()
>   "Encrypt all messages when we are sending as bjorn@mork.no. Do nothing
> for all other From addresses."
>   (when (string= message-sendmail-envelope-from
>                  "bjorn@mork.no")
>     (mml-secure-message-encrypt)))
>
> (add-hook 'message-setup-hook #'my/mml-secure-message-encrypt)
> #+END_SRC
>
> Let me know if that is what you want or helps at all.

Thanks a lot!  It does not work any better, but at least it shows me how
easy adding a hook would be.

And it also made me look at how the gnus posting styles are implemented.

I tried your suggestion with message-sendmail-envelope-from replaced by
user-mail-address, since SPF prevents me from changing the envelope
along with the from address.

Unfortunately, this works exacly like using "body" or "eval" in a
posting style.  It's fine with an empty buffer, but not when replying
with quoted text.  Which isn't surprising after having looked at
gnus-configure-posting-styles in gnus-msg.el.

What gnus-configure-posting-styles does under the hood is

        (add-hook 'message-setup-hook
                  (cond
                   ((eq 'eval (car result))
                    #'ignore)
                   ((eq 'body (car result))
                    (let ((txt (cdr result)))
                      (lambda ()
                        (save-excursion
                          (message-goto-body)
                          (insert txt)))))

etc.

Not exactly sure how all this works, but it looks like the yanked text
must be inserted into the buffer at a later stage.


Bjørn


  reply	other threads:[~2024-11-30 19:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-29 14:49 Bjørn Mork
2024-11-30 18:29 ` Trevor Arjeski
2024-11-30 19:28   ` Bjørn Mork [this message]
2024-11-30 20:17     ` Trevor Arjeski
2024-12-02 15:11     ` Bjørn Mork
2024-12-03 10:35       ` Björn Bidar
2024-12-03 11:36         ` Bjørn Mork
2024-12-03 20:38           ` Björn Bidar
2024-12-01  3:58 ` Sean Whitton
2024-12-01 23:04 ` Björn Bidar
2024-12-01 23:43   ` Bob Newell
2024-12-08  5:05 ` James Thomas
2024-12-08 13:22   ` Bjørn Mork
2024-12-08 21:03     ` James Thomas

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=87o71wikra.fsf@miraculix.mork.no \
    --to=bjorn@mork.no \
    --cc=ding@gnus.org \
    --cc=tmarjeski@gmail.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;
as well as URLs for NNTP newsgroup(s).