Gnus development mailing list
 help / color / mirror / Atom feed
* Getting message details from message-sent-hook
@ 2003-05-28 17:51 Burton Samograd
  2003-05-28 19:25 ` Burton Samograd
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Burton Samograd @ 2003-05-28 17:51 UTC (permalink / raw)


Hi,

I'm trying to write a function that inserts some information about
emails I send into my diary.  I'm hoping to be able to get it to write
lines like:

Mar 28, 2003 To: someone@pobox.com Subject: Hi There

So far I've got the following:

(defun message-to-diary ()
  (make-diary-entry (concat 
		   (calendar-julian-date-string) 
		   " To: "  " From: ")))
(add-hook 'message-sent-hook 'message-to-diary)

What I need is functions that get the To and Subject from the mail or
post that was sent.  Is any of that information available or am I
going to have to write something that parses the current *mail*
buffer?

Thanks for any help. 

-- 
burton samograd
kruhft@kruhft.dyndns.org
http://kruhftwerk.dyndns.org




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

* Re: Getting message details from message-sent-hook
  2003-05-28 17:51 Getting message details from message-sent-hook Burton Samograd
@ 2003-05-28 19:25 ` Burton Samograd
  2003-05-29  3:22   ` Bill White
  2003-05-28 19:57 ` Johan Bockgård
  2003-05-28 20:14 ` Benjamin Rutt
  2 siblings, 1 reply; 7+ messages in thread
From: Burton Samograd @ 2003-05-28 19:25 UTC (permalink / raw)


Burton Samograd <kruhft@hotmail.com> writes:
> What I need is functions that get the To and Subject from the mail or
> post that was sent.  Is any of that information available or am I
> going to have to write something that parses the current *mail*
> buffer?

Some stroke of luck caused me to find the solution in a posting to
gnu.emacs.sources.  Here's the working code if anybody wants it:

(defun message-to-diary ()
  (make-diary-entry (concat 
		     (calendar-date-string (calendar-current-date) t)
		     (if (message-fetch-field "newsgroups")
			 (concat " Sent news To: " (message-fetch-field "newsgroups"))
		       (concat " Sent mail To: " (message-fetch-field "to")))
		     " Subject: \"" (message-fetch-field "subject") "\""
		     " Message-ID: " (message-fetch-field "message-id"))))
(add-hook 'message-sent-hook 'message-to-diary)


This adds:

<today's date> Sent [mail|news] To: <to> Subject: "<subject>" Message-ID: <message-id>

to the current diary file whenever you send a mail or news message.
Hope someone finds it useful.

-- 
burton samograd
kruhft@kruhft.dyndns.org
http://kruhftwerk.dyndns.org




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

* Re: Getting message details from message-sent-hook
  2003-05-28 17:51 Getting message details from message-sent-hook Burton Samograd
  2003-05-28 19:25 ` Burton Samograd
@ 2003-05-28 19:57 ` Johan Bockgård
  2003-05-28 20:14 ` Benjamin Rutt
  2 siblings, 0 replies; 7+ messages in thread
From: Johan Bockgård @ 2003-05-28 19:57 UTC (permalink / raw)


Burton Samograd <kruhft@hotmail.com> writes:

> What I need is functions that get the To and Subject from the mail
> or post that was sent. Is any of that information available or am I
> going to have to write something that parses the current *mail*
> buffer?

message-fetch-field  or mail-fetch-field

-- 
The day Microsoft makes something that doesn't suck is probably the
day they start making vacuum cleaners. -- Ernst Jan Plugge



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

* Re: Getting message details from message-sent-hook
  2003-05-28 17:51 Getting message details from message-sent-hook Burton Samograd
  2003-05-28 19:25 ` Burton Samograd
  2003-05-28 19:57 ` Johan Bockgård
@ 2003-05-28 20:14 ` Benjamin Rutt
  2 siblings, 0 replies; 7+ messages in thread
From: Benjamin Rutt @ 2003-05-28 20:14 UTC (permalink / raw)
  Cc: ding

Burton Samograd <kruhft@hotmail.com> writes:

> Hi,
>
> I'm trying to write a function that inserts some information about
> emails I send into my diary.  I'm hoping to be able to get it to write
> lines like:
>
> Mar 28, 2003 To: someone@pobox.com Subject: Hi There
>
> So far I've got the following:
>
> (defun message-to-diary ()
>   (make-diary-entry (concat 
> 		   (calendar-julian-date-string) 
> 		   " To: "  " From: ")))
> (add-hook 'message-sent-hook 'message-to-diary)
>
> What I need is functions that get the To and Subject from the mail or
> post that was sent.  Is any of that information available or am I
> going to have to write something that parses the current *mail*
> buffer?

Something like:

(defun message-to-diary ()
  (save-restriction
    (save-excursion
      (make-diary-entry
        (concat 
          (calendar-julian-date-string) 
          " To: " (message-fetch-field "To")
          " Subject: " (message-fetch-field "Subject"))))))

should work.
-- 
Benjamin



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

* Re: Getting message details from message-sent-hook
  2003-05-28 19:25 ` Burton Samograd
@ 2003-05-29  3:22   ` Bill White
  2003-05-29 15:08     ` Burton Samograd
  0 siblings, 1 reply; 7+ messages in thread
From: Bill White @ 2003-05-29  3:22 UTC (permalink / raw)
  Cc: ding

On Wed May 28 2003 at 14:25, Burton Samograd <kruhft@hotmail.com> said:

> Some stroke of luck caused me to find the solution in a posting to
> gnu.emacs.sources.  Here's the working code if anybody wants it:
>
> (defun message-to-diary ()
>   (make-diary-entry (concat 
> 		     (calendar-date-string (calendar-current-date) t)
> 		     (if (message-fetch-field "newsgroups")
> 			 (concat " Sent news To: " (message-fetch-field "newsgroups"))
> 		       (concat " Sent mail To: " (message-fetch-field "to")))
> 		     " Subject: \"" (message-fetch-field "subject") "\""
> 		     " Message-ID: " (message-fetch-field "message-id"))))
> (add-hook 'message-sent-hook 'message-to-diary)

This is a neat idea.  Here's my version:

   ,----
   | (defun message-to-diary ()
   |   (make-diary-entry (concat 
=> | 		     (format-time-string "%B %d, %Y %H:%M" (gnus-date-get-time (message-fetch-field "date")))
   | 		     (if (message-fetch-field "newsgroups")
   | 			 (concat " Sent news To: " (message-fetch-field "newsgroups"))
   | 		       (concat " Sent mail To: " (message-fetch-field "to")))
   | 		     " Subject: \"" (message-fetch-field "subject") "\""
   | 		     " Message-ID: " (message-fetch-field "message-id")))
=> |   (save-buffer "diary"))
   `----

This results in this line in `diary-file':
   May 28, 2003 22:19 Sent mail To: billw Subject: "test" Message-ID: <ruo65nua18e.fsf@billw2lx.wolfram.com> 
which gives me this in the Fancy Diary Entries buffer:
   22:19 Sent mail To: billw Subject: "test" Message-ID: <ruo65nua18e.fsf@billw2lx.wolfram.com> 

Now, can some function grab the message id and jump to that article?
Perhaps using Ted's registry stuff?

Cheers -

bw
-- 
Bill White . billw@wolfram.com . http://members.wri.com/billw
"No ma'am, we're musicians."




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

* Re: Getting message details from message-sent-hook
  2003-05-29  3:22   ` Bill White
@ 2003-05-29 15:08     ` Burton Samograd
  2003-05-29 17:30       ` Ted Zlatanov
  0 siblings, 1 reply; 7+ messages in thread
From: Burton Samograd @ 2003-05-29 15:08 UTC (permalink / raw)


Bill White <billw@wolfram.com> writes:

> On Wed May 28 2003 at 14:25, Burton Samograd <kruhft@hotmail.com> said:
> This results in this line in `diary-file':
>    May 28, 2003 22:19 Sent mail To: billw Subject: "test" Message-ID: <ruo65nua18e.fsf@billw2lx.wolfram.com> 
> which gives me this in the Fancy Diary Entries buffer:
>    22:19 Sent mail To: billw Subject: "test" Message-ID: <ruo65nua18e.fsf@billw2lx.wolfram.com> 
> 
> Now, can some function grab the message id and jump to that article?
> Perhaps using Ted's registry stuff?

I was thinking that there would be something available to select a
message-id but I haven't gotten around to looking for it.  It just
seemed like a good thing to have in there because I'm sure someone
will write that functionality someday (maybe even me if I get inspired
:)

-- 
burton samograd
kruhft@kruhft.dyndns.org
http://kruhftwerk.dyndns.org




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

* Re: Getting message details from message-sent-hook
  2003-05-29 15:08     ` Burton Samograd
@ 2003-05-29 17:30       ` Ted Zlatanov
  0 siblings, 0 replies; 7+ messages in thread
From: Ted Zlatanov @ 2003-05-29 17:30 UTC (permalink / raw)
  Cc: ding

On 29 May 2003, kruhft@hotmail.com wrote:
> Bill White <billw@wolfram.com> writes:
> 
>> Now, can some function grab the message id and jump to that
>> article?  Perhaps using Ted's registry stuff?
> 
> I was thinking that there would be something available to select a
> message-id but I haven't gotten around to looking for it.  It just
> seemed like a good thing to have in there because I'm sure someone
> will write that functionality someday (maybe even me if I get
> inspired :)

The registry can help:

gnus-registry-fetch-group is a compiled Lisp function in `gnus-registry'.
(gnus-registry-fetch-group ID)

Get the group of a message, based on the message ID.
Returns the first place where the trail finds a group name.

Three issues:

- the group name is currently not prefixed, so you don't know the
  server.  I'll work on that, but time has been short lately.

- the registry may be inaccurate, e.g. someone deletes a IMAP message
  outside this instance of Gnus

- there may be more than one copy of the message (and thus, multiple
  groups in the registry trail)

If anyone is interested in using the registry as a generic message-ID
locator, patches or ideas are welcome.

Ted



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

end of thread, other threads:[~2003-05-29 17:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-28 17:51 Getting message details from message-sent-hook Burton Samograd
2003-05-28 19:25 ` Burton Samograd
2003-05-29  3:22   ` Bill White
2003-05-29 15:08     ` Burton Samograd
2003-05-29 17:30       ` Ted Zlatanov
2003-05-28 19:57 ` Johan Bockgård
2003-05-28 20:14 ` Benjamin Rutt

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