Gnus development mailing list
 help / color / mirror / Atom feed
* Find tick state from gnus-article-prepare-hook?
@ 2004-10-09 15:31 Steinar Bang
  2004-10-09 16:10 ` Steinar Bang
  0 siblings, 1 reply; 4+ messages in thread
From: Steinar Bang @ 2004-10-09 15:31 UTC (permalink / raw)


Is it possible to find the tick state of the current article, from a
function called from gnus-article-prepare-hook?

I need to check whether the article is unread, or not.  I wish to use
u-appt.el to parse messages for Outlook appointment invitations, and I
only want to be prompted for if I wish to save the appointment in the
diary, the first time I read the message.




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

* Re: Find tick state from gnus-article-prepare-hook?
  2004-10-09 15:31 Find tick state from gnus-article-prepare-hook? Steinar Bang
@ 2004-10-09 16:10 ` Steinar Bang
  2004-10-09 16:42   ` Steinar Bang
  2004-10-10 21:13   ` Steinar Bang
  0 siblings, 2 replies; 4+ messages in thread
From: Steinar Bang @ 2004-10-09 16:10 UTC (permalink / raw)


>>>>> Steinar Bang <sb@dod.no>:

> Is it possible to find the tick state of the current article, from a
> function called from gnus-article-prepare-hook?

> I need to check whether the article is unread, or not.  I wish to
> use u-appt.el to parse messages for Outlook appointment invitations,
> and I only want to be prompted for if I wish to save the appointment
> in the diary, the first time I read the message.

I tried using gnus-mark-article-hook instead, since this hook is
called from the summary buffer, in what seems to be the appropriate
moment.

But with the code below, I am asked if I wish to save the diary
entry on an unread article.  But the article is never marked read.
Looks like my-gnus-check-outlook interfers with
gnus-summary-mark-read-and-unread-as-read, which is the other member
of gnus-mark-article-hook.  Hm...

(defun my-gnus-check-outlook ()
  "Run from a hook to check new messages in Gnus for Outlook appointment 
invitations, and offer to save them in the diary."
  (save-excursion
    (let ((mark (gnus-summary-article-mark)))
      (when (gnus-unread-mark-p mark)
	(set-buffer gnus-article-buffer)
	(u-appt-check-outlook)))))

(add-hook 'gnus-mark-article-hook  'my-gnus-check-outlook)




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

* Re: Find tick state from gnus-article-prepare-hook?
  2004-10-09 16:10 ` Steinar Bang
@ 2004-10-09 16:42   ` Steinar Bang
  2004-10-10 21:13   ` Steinar Bang
  1 sibling, 0 replies; 4+ messages in thread
From: Steinar Bang @ 2004-10-09 16:42 UTC (permalink / raw)


>>>>> Steinar Bang <sb@dod.no>:

>>>>> Steinar Bang <sb@dod.no>:
>> Is it possible to find the tick state of the current article, from a
>> function called from gnus-article-prepare-hook?

>> I need to check whether the article is unread, or not.  I wish to
>> use u-appt.el to parse messages for Outlook appointment invitations,
>> and I only want to be prompted for if I wish to save the appointment
>> in the diary, the first time I read the message.

> I tried using gnus-mark-article-hook instead, 
[snip!  Masked setting of mark]

Back to gnus-article-prepare-hook.

I tried skipping back to the summary buffer for a peek, in the hope
that the cursor would be positioned at the correct spot.  But that
doesn't work.  because gnus-summary-article-mark returns `?R' at this
point.  Ie. something that will make gnus-unread-mark-p return nil.

(defun my-gnus-check-outlook ()
  "Run from a hook to check new messages in Gnus for Outlook appointment 
invitations, and offer to save them in the diary."
  (save-excursion
    (set-buffer gnus-summary-buffer)
    (let ((mark (gnus-summary-article-mark)))
      (when (gnus-unread-mark-p mark)
	(set-buffer gnus-article-buffer)
	(u-appt-check-outlook)))))

(add-hook 'gnus-article-prepare-hook 'my-gnus-check-outlook)




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

* Re: Find tick state from gnus-article-prepare-hook?
  2004-10-09 16:10 ` Steinar Bang
  2004-10-09 16:42   ` Steinar Bang
@ 2004-10-10 21:13   ` Steinar Bang
  1 sibling, 0 replies; 4+ messages in thread
From: Steinar Bang @ 2004-10-10 21:13 UTC (permalink / raw)


>>>>> Steinar Bang <sb@dod.no>:

> I tried using gnus-mark-article-hook instead, since this hook is
> called from the summary buffer, in what seems to be the appropriate
> moment.

> But with the code below, I am asked if I wish to save the diary
> entry on an unread article.  But the article is never marked read.

The reason this happens, is that when I do 
 (add-hook 'gnus-mark-article-hook  'my-gnus-check-outlook)
I overwrite the original value of `gnus-mark-article-hook', which is
`(gnus-summary-mark-read-and-unread-as-read)'.  This is not what I
expected when calling add-hook.  I would expect my new function to be
added to the hook.

I think defcustom's handling of hook variables, is wrong.  At least
the way it's done in XEmacs 21.4.

In any case, the below code works for me, for using code in u-appt.el
to scan unread articles in Gnus, for Outlook invitations.

Though I should probably find a less fragile hook, one where the
current mark setting doesn't depend on the position in the hook list.

Here's the code:

(defun my-gnus-check-outlook ()
  "Run from a hook to check new messages in Gnus for Outlook appointment 
invitations, and offer to save them in the diary."
  (save-excursion
    (let ((mark (gnus-summary-article-mark)))
      (when (gnus-unread-mark-p mark)
	(set-buffer gnus-article-buffer)
	(u-appt-check-outlook)))))

; Check for Outlook invitations in unread messages
(add-hook 'gnus-mark-article-hook 'my-gnus-check-outlook)
; Add the original value of gnus-mark-article-hook, since this 
; is overwritten by the above add-hook.
; Add it at the end, since it sets the mark to read.
(add-hook 'gnus-mark-article-hook 'gnus-summary-mark-read-and-unread-as-read t)





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

end of thread, other threads:[~2004-10-10 21:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-09 15:31 Find tick state from gnus-article-prepare-hook? Steinar Bang
2004-10-09 16:10 ` Steinar Bang
2004-10-09 16:42   ` Steinar Bang
2004-10-10 21:13   ` Steinar Bang

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