emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Feature proposal: Checking if user-mail-address is in To or CC (to avoid


From: Uwe Brauer
Subject: Feature proposal: Checking if user-mail-address is in To or CC (to avoid an embarrassing social situation) BCC
Date: Sat, 15 Feb 2025 08:19:57 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Hi

Let’s assume I write an email to:  

- Arthur,  
- add John and Richard in CC, and  
- also include Robert in BCC.  

This is done to ensure that Arthur does not know Robert received a
copy of the email.

Now, if John replies and uses the "Reply to all" function, everything
is fine. However, if Robert does the same because he wants to reply to
John and Richard, Arthur will also receive a copy—revealing that
Robert was originally BCC'd.

Robert can only avoid this by using a function (before replying to
all) that checks whether the sender was included in the original
email’s *To* or *CC* fields.

The following code does this, but I am not satisfied:

    1. I need to use add-advice

    2. I have a bizarre (error (progn (message
       at the end of the function, but just with a simple (error
       "Aborted") I sometimes receive and error I cannot reproduce
       always

So maybe such a functionality already exists, but if not, why not
include it (modified/improved)?

Regards

Uwe Brauer 


(defun check-my-to-field (&optional arg)
  "Warn if your email address is not in the To field, unless it's a newsgroup 
post."
  (interactive "P")
  (save-window-excursion
    (gnus-summary-select-article-buffer)
    (let ((to-field (message-fetch-field "To"))
          (newsgroup-field (message-fetch-field "Newsgroups")))
      (unless (or (and to-field (string-match-p (regexp-quote 
user-mail-address) to-field))
                  newsgroup-field)  ; Do not warn if it's a newsgroup
        (if (y-or-n-p "Warning: Followup? But you are not on the TO field, you 
FOOL, proceed?")
            (message "I hope you are sure.")
          (error ; for some bizzarre reason I need a progn and  message here, 
this might be caused by the use of advice-add
       (progn
         (message "Aborted, you are not in the To: field!!!"))))))))



 (advice-add 'gnus-article-followup-with-original :before #'check-my-to-field)
 (advice-add 'gnus-summary-followup-with-original :before #'check-my-to-field)
;; (setq message-reply-to-function #'check-my-to-field)

(defun my-turn-bcc-check-on ()
  (interactive)
  (advice-add 'gnus-article-followup-with-original :before #'check-my-to-field)
  (advice-add 'gnus-summary-followup-with-original :before #'check-my-to-field)
  (message "Now the `To:' field is checked!"))


(defun my-turn-bcc-check-off ()
  (interactive)
  (advice-remove 'gnus-article-followup-with-original  #'check-my-to-field)
  (advice-remove 'gnus-summary-followup-with-original  #'check-my-to-field)
  (message "Now the `To:' field is `NOT' checked!"))

(defun my-toggle-bcc-check ()
  "Function that toggles between checking and not checking the `BBC' field."
  (interactive)
  (make-repeat-command 'my-toggle-bcc-check
                       '(my-turn-bcc-check-on
                         my-turn-bcc-check-off)))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]