Re: can I set user-mail-address differently for each group?

Uwe Brauer <[email protected]> Sat, 08 Mar 2025 08:21:49 +0100
Newsgroups gmane.emacs.gnus.general
Message-ID <[email protected]>
>>> "ESF" == Eric S Fraga <[email protected]> writes:

> Response below/inline for email Uwe Brauer wrote:
>> (original email sent  6 Mar 2025 at 17:14)
>> 
>> But this seems to be independent of the user-mail-address as I just checked.

> I'm not sure what this means.  In any case, I set both "address" and
> "from".

What I tried to say is this:

I have

(setq gnus-posting-styles
      '(("nnimap\\+UCMgmail.*"
         (address "[email protected]"))
        ("nnimap\\+WorkMail.*"
         (address "[email protected]"))))

I enter on of the WorkMail groups and run describe-variable
user-mail-address and see
[email protected]
but *not* [email protected]


Why is this important?



Well as I wrote in the other gnus mailing list and on email dev, I now
use a function that checks if your address (as controlled by
user-mail-address, is in the To or CC field in order to check that you
have not be on the BCC and can run in potentially  embarrassing
situation.


(defun check-bcc-gnus-article-followup-with-original ()
  "This function warns you if your email address is not in the To or
Cc field, unless it's a newsgroup post or the email is from a
mailing list (List-Id or List-Post fields). If any of these conditions
apply, it directly calls `gnus-article-followup-with-original`."
  (interactive)
  (gnus-summary-select-article-buffer)
  (gnus-summary-toggle-header 1)
  (let* ((to-field (message-fetch-field "To"))
         (cc-field (message-fetch-field "Cc"))
         (newsgroup-field (message-fetch-field "Newsgroups"))
         (list-id-field (message-fetch-field "List-Id"))
         (list-post-field (message-fetch-field "List-Post")))
    (message "To: %s, Cc: %s, Newsgroups: %s, List-Id: %s, List-Post: %s"
             to-field cc-field newsgroup-field list-id-field list-post-field)
    (if (or (and to-field (string-match-p (regexp-quote user-mail-address) to-field))
            (and cc-field (string-match-p (regexp-quote user-mail-address) cc-field))
            (and list-id-field (not (string= list-id-field "")))  ;; Ensure non-empty value
            (and list-post-field (not (string= list-post-field "")))
            newsgroup-field)
        ;; Case 1-4: If To, Cc, List-Id, List-Post, or Newsgroups field applies, directly follow up
        (gnus-article-followup-with-original)
      ;; Case 5: If none of the conditions are met, warn the user using `read-multiple-choice`
      (let* ((choices
              `((?1 "followup" "Use gnus-article-followup-with-original")
                (?2 "reply" "Use gnus-article-reply-with-original")
                (?3 "abort" "Abort operation")))
             (choice (read-multiple-choice
                      "Warning: Followup? But you are not on the TO or CC field, and this is not a mailing list email.\n A reply may reveal that you were Bcc'ed. \n Which choice?"
                      choices)))
        (pcase (car choice)
          (?1 (gnus-article-followup-with-original))
          (?2 (gnus-article-reply-with-original))
          (?3 (quit-window))
          (_ (error "Unexpected choice"))))))
  (gnus-summary-toggle-header))

But this does not work if I enter a group that is connected to a
different mail server via the nnimap server

Did I explain my problem now better?

Regards

Uwe 

-- 
I strongly condemn Hamas heinous despicable pogroms/atrocities on Israel
I strongly condemn Putin's war of aggression against Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the EU and NATO membership of Ukraine.
smime.p7s (application/pkcs7-signature, 5.6 KB) - not displayed