info-gnus-english
[Top][All Lists]
Advanced

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

[a better solution without using advice] (was: [defadvice, advice-add ])


From: Uwe Brauer
Subject: [a better solution without using advice] (was: [defadvice, advice-add ])
Date: Sat, 22 Feb 2025 08:22:40 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

>>> "CG" == Christoph Groth <christoph@grothesque.org> writes:

> Uwe Brauer wrote:
>> BTW I am still wondering that such a functionality is not implemented,
>> yet.

> Could you please post the complete code once you are more or less done
> with it?

After some discussion on the emacs devel list, I came up with a new function 
which you have to bind 

(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)
  (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")))
    (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))
            list-id-field
            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
      (with-output-to-temp-buffer "gnus-bcc-check-buffer"
        (princ "List of functions\n")
        (princ "1: gnus-article-followup-with-original\n")                      
                  
        (princ "2: gnus-article-reply-with-original\n")
        (princ "3: abort\n"))
      (let ((ch (string-to-char (read-string "Warning: Followup? But you are 
not on the TO or CC field, and this is not a mailing list email. A reply may 
reveal that you were Bcc'ed. Which choice: 1: 2: 3: "))))
        (call-interactively
         (cond ((eql ch ?1) #'gnus-article-followup-with-original)
               ((eql ch ?2) #'gnus-article-reply-with-original)
               ((eql ch ?3) #'quit-window)
               (t (error 'args-out-of-range '(1 2 3 ch))))))
      (kill-buffer "gnus-bcc-check-buffer"))))


Enjoy




-- 
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. 

Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

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