Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* Need help writing predicate function
@ 2023-12-04 16:44 Max Evans
  2023-12-04 18:05 ` Eric S Fraga
  2023-12-05  0:17 ` Bob Newell
  0 siblings, 2 replies; 3+ messages in thread
From: Max Evans @ 2023-12-04 16:44 UTC (permalink / raw)
  To: info-gnus-english

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-05  0:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-04 16:44 Need help writing predicate function Max Evans
2023-12-04 18:05 ` Eric S Fraga
2023-12-05  0:17 ` Bob Newell

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