>>> "AadfGtGEUn(E" == Announcements and discussions for GNUS, the GNU Emacs >>> Usenet newsreader (in English) <Michael> writes: Moin Michael > Moin Uwe, > Nice idea, thx for sharing. Some comments below:
I modified the function but I have problems to generalise my defadvice
call. This works
--8<---------------cut here---------------start------------->8---
(defadvice gnus-article-followup-with-original (before mychecktofield activate)
"This function will be run before you execute followup. It warns you if your
email address is not in the To field. That
warning is a safty message if you had been only on the BCC field!!"
(check-my-to-field))
(defadvice gnus-summary-followup-with-original (before mychecktofield activate)
"This function will be run before you execute followup. It warns you if your
email address is not in the To field. That
warning is a safty message if you had been only on the BCC field!!"
(check-my-to-field))
--8<---------------cut here---------------end--------------->8---
But this
--8<---------------cut here---------------start------------->8---
(advice-add 'gnus-article-followup-with-original :before
#'check-my-to-field)
(advice-add 'gnus-summary-followup-with-original :before
#'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)))
--8<---------------cut here---------------end--------------->8---
Does not. Any ideas?
>> Adding (gnus-summary-select-article-buffer)
>>
>> Solves the problem somehow:
>> (defun check-my-to-field ()
>> "This function will be run before you execute followup. And it
>> warns you if your email address is not in the To field. That
>> warning is a safty message if you had been only on the BCC
>> field!!"
>> (interactive)
>> (gnus-summary-select-article-buffer)
> Hmm, but you don't want to select that buffer, right? I would at least
> wrap the whole thing in an appropriate excursion
> (`save-window-excursion'?) But maybe we find a better suited function.
> Doesn't (with-current-buffer gnus-article-buffer ...) suffice?
>> (unless
>> (string-match user-mail-address (message-fetch-field "To"))
> Slightly better:
> (string-match-p (regexp-quote user-mail-address)
> (message-fetch-field "To"))
>> (error
>> (progn
>> (message "Aborted, you are not in the To: field!!!"))))))
> Either `error', then with string + arg, or a message. We don't have a
> condition-case handler here, right? I'd use `user-error'.
>> (defadvice gnus-article-followup-with-original (before mychecktofield
>> activate)
>> "This function will be run before you execute followup. It warns you if your
>> email address is not in the To field. That
>> warning is a safty message if you had been only on the BCC field!!"
>> (check-my-to-field))
>>
>> (defadvice gnus-summary-followup-with-original (before mychecktofield
>> activate)
>> "This function will be run before you execute followup. It warns you if your
>> email address is not in the To field. That
>> warning is a safty message if you had been only on the BCC field!!"
>> (check-my-to-field))
> Is there some hook one could alternatively use for this functionality?
> We could check `this-command' to include only commands we want to
> influence.
> Michael.
--
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
Description: S/MIME cryptographic signature
