Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
From: Max Evans <visitantar@protonmail.com>
To: "info-gnus-english@gnu.org" <info-gnus-english@gnu.org>
Subject: Need help writing predicate function
Date: Mon, 04 Dec 2023 16:44:35 +0000	[thread overview]
Message-ID: <231pPe4tQmLilpsi6Jaf16YkW-PECPaVCl_TdBCz-ZfFfeiqbDkJrVszHjfFJ-VYJJ4Tr3RQjiIodRmv_qkktQzOBYSBkepBOyfZ9E8ovzM=@protonmail.com> (raw)

Help, gnus!

I'm trying to write a simple predicate function to use in my
posting-styles, since from my reading of the manual you can't match
two things at once otherwise, which is what I want to do.

I'm trying to make a rule that kicks in only when a certain company
sends me an email AND when it's sent to a particular address. It's
only relevant when I'm replying back to them, though.

Here's what I've got so far:

(defun max-gnus-predicate ()
  (when (eq major-mode 'gnus-article-mode)
    (and (string-match "foo@bar.org" (with-current-buffer gnus-article-buffer
				       (message-fetch-field "from")))
	 (string-match "visitantar+alias@protonmail.com" (with-current-buffer gnus-article-buffer
							   (message-fetch-field "to"))))))
						 
The problem I'm running into is that the function fails if the
*Article* buffer ever gets killed. When that happens, it corrupts the
mail header. Which makes sense with how I've written it.

I'm sure there's a smarter way of doing what I want to do, so would
someone mind helping me out?

(Please keep me in the thread. I'm not subscribed.)

-Max



             reply	other threads:[~2023-12-04 17:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-04 16:44 Max Evans [this message]
2023-12-04 18:05 ` Eric S Fraga
2023-12-05  0:17 ` Bob Newell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='231pPe4tQmLilpsi6Jaf16YkW-PECPaVCl_TdBCz-ZfFfeiqbDkJrVszHjfFJ-VYJJ4Tr3RQjiIodRmv_qkktQzOBYSBkepBOyfZ9E8ovzM=@protonmail.com' \
    --to=visitantar@protonmail.com \
    --cc=info-gnus-english@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).