Re: What's the best way to auto-sign some emails but not all?

Björn Bidar <[email protected]> Tue, 03 Dec 2024 22:38:04 +0200
Newsgroups gmane.emacs.gnus.general
Message-ID <[email protected]>
Bjørn Mork <[email protected]> writes:

> Björn Bidar <[email protected]> writes:
>> Bjørn Mork <[email protected]> writes:
>>
>>> 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.
>>
>> That is not true. gnus-alias has rules which make it possible to
>> automatically apply an identity. Check C-h v gnus-alias-identity-rules RET. 
>
> Yes, I know, and I didn't mean to say anything else.
>
> But AFAICS, the result of the gnus-alias automatic identity mapping is
> limited by what is possible in a message-setup-hook.  That's what I tried
> to express.
>
>> Message-signature manual or automatically should also take into account
>> a yanked article AFAIU.
>
> Sorry if I've misunderstood something, but I really don't understand how
> that could work.  Not sure where the authoritative source of gnus-alias
> is.  Doesn't look like it is part of emacs.  Google gave me a github
> repo, but I don't know if that's correct?

I was talking of the builtin message-signature function which can be
called automatically or manually using C-c C-w. From what I read it did
look like that these look to not insert into the yanked article but at
the signature marker at the end of the article where the don't conflict
with the yanked article/message.

> Anyway, that version seems to do automatic identity mapping by adding a
> hook to message-setup-hook - which makes sense:
>
> https://github.com/altruizine/gnus-alias/blob/master/gnus-alias.el#L666
>
> I understand that you can insert anything into the message buffer here.
> But Gnus has not yet inserted the yanked text, so you cannot position
> your inserts relative to that text.  Anything you place at the beginning
> of the body will be moved around later.
>
> There's a lot of code spread over many functions, but I believe
> gnus-summary-reply() is the best place to start looking at the problem:
>
> https://github.com/emacs-mirror/emacs/blob/master/lisp/gnus/gnus-msg.el#L1061
>
> It ends with:
>
> 	(message-reply nil wide)
> 	(when yank
> 	  (gnus-inews-yank-articles yank))
> 	(gnus-summary-handle-replysign)))))
>
> Where message-reply() will call message-setup() as its final step, which
> in turn will run all the message-setup-hook hooks.  See
>
> https://github.com/emacs-mirror/emacs/blob/master/lisp/gnus/message.el#L7314
> https://github.com/emacs-mirror/emacs/blob/master/lisp/gnus/message.el#L6823
>
> This means that gnus-inews-yank-articles() runs after any automatic
> message setup by gnus-posting-styles, gnus-alias or my own personal
> setup hook.

> gnus-inews-yank-articles() can be configured to insert the quoted text
> above or below the message, but I can't see any obvious way to allow it
> to insert the text between any existing mml tag and the rest of the
> message body.  Which is where I'd like it to end up.

From what I read the message-mode yank functions took account of not
interfering with the signature. To me it does sound like a bug if
gnus-inews-yank-articles would break the signature.

Looking at comment in message.el:4037
at (message--yank-original-internal (arg)):
;; Add a `message-setup-very-last-hook' here?

It does appear like this a known possible issue.

I assume gnus-message-setup-hook doesn't work either.

Maybe it's worth to look for an existing bug report for possible context
or open a new one.

Anway good that you found a solution.