Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* Ensuring the subject lines contains a word?
@ 2009-03-31 18:27 Johann 'Myrkraverk' Oskarsson
  2009-04-01 17:40 ` Ted Zlatanov
  0 siblings, 1 reply; 3+ messages in thread
From: Johann 'Myrkraverk' Oskarsson @ 2009-03-31 18:27 UTC (permalink / raw)
  To: info-gnus-english

Hi all,

Is it possible to add a function to some pre-send hook that makes sure
the subject line contains a certain word?  News, not mail, if it
matters.  Of course, the word in question depends on the group, so
some mechanism that ties posting styles (or something similar) to the
mixture would be nice.

For arguments sake, you can assume I want the word GNUS to appear in
the subject lines of all messages to this group, gnu.emacs.gnus.



Johann -- who doesn't even know what hook to use.

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

* Re: Ensuring the subject lines contains a word?
  2009-03-31 18:27 Ensuring the subject lines contains a word? Johann 'Myrkraverk' Oskarsson
@ 2009-04-01 17:40 ` Ted Zlatanov
  2009-04-01 17:46   ` Johann 'Myrkraverk' Oskarsson
  0 siblings, 1 reply; 3+ messages in thread
From: Ted Zlatanov @ 2009-04-01 17:40 UTC (permalink / raw)
  To: info-gnus-english

On Tue, 31 Mar 2009 18:27:50 +0000 Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.com> wrote: 

JO> Hi all,
JO> Is it possible to add a function to some pre-send hook that makes sure
JO> the subject line contains a certain word?  News, not mail, if it
JO> matters.  Of course, the word in question depends on the group, so
JO> some mechanism that ties posting styles (or something similar) to the
JO> mixture would be nice.

JO> For arguments sake, you can assume I want the word GNUS to appear in
JO> the subject lines of all messages to this group, gnu.emacs.gnus.

Here's an example of a hook that aborts under certain conditions:

(defun jidanni-message-confirm ()
 "Confirm that we really want to send the message."
 (interactive)
 (or (y-or-n-p "Send?")
     (keyboard-quit)))

(add-hook 'message-send-hook 'jidanni-message-confirm)
;; you may need message-send--news-hook as well

To get the Subject header, you can do

(save-restriction
  (message-narrow-to-headers)
  (message-fetch-field "Subject"))

I am sure integrating this with posting styles won't be too hard either.

Ted

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

* Re: Ensuring the subject lines contains a word?
  2009-04-01 17:40 ` Ted Zlatanov
@ 2009-04-01 17:46   ` Johann 'Myrkraverk' Oskarsson
  0 siblings, 0 replies; 3+ messages in thread
From: Johann 'Myrkraverk' Oskarsson @ 2009-04-01 17:46 UTC (permalink / raw)
  To: info-gnus-english

Ted Zlatanov <tzz@lifelogs.com> writes:

> I am sure integrating this with posting styles won't be too hard
> either.

I ended up with the following function, and using group parameters, to
have it in message-send-hook.

(defun my-assd-in-subject () (interactive)
  (let ((s (message-field-value "subject")))
    (unless (string-match "{ASSD}" s)
      (save-excursion
	(message-goto-subject)
	(message-delete-line)
	(insert (concat "Subject: {ASSD} " s "\n"))))))

This function will probably fail if the subject line is empty.

I needed this too:

(add-to-list 'gnus-newsgroup-variables 'message-send-hook)

and these are the group parameters:

((message-send-hook 'my-assd-in-subject))

Which will need to be tweaked to allow more than one hook function.


Thank you,

Johann

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

end of thread, other threads:[~2009-04-01 17:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-31 18:27 Ensuring the subject lines contains a word? Johann 'Myrkraverk' Oskarsson
2009-04-01 17:40 ` Ted Zlatanov
2009-04-01 17:46   ` Johann 'Myrkraverk' Oskarsson

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