Gnus development mailing list
 help / color / mirror / Atom feed
* Adulterate summary lines
@ 2004-08-16 11:12 Harry Putnam
  2004-08-16 15:40 ` Jonas Steverud
  2004-08-16 15:52 ` Gnus for information storage (Was: Adulterate summary lines) Robert Epprecht
  0 siblings, 2 replies; 7+ messages in thread
From: Harry Putnam @ 2004-08-16 11:12 UTC (permalink / raw)


I sometimes use gnus for certain kinds of information storage that
isn't within its real purpose.  An example might be a group called
nnml:Edited  Where I place articles I've edited with a homeboy
indexing system to be able to lookup certain kinds of info I've found
in posts on usenet.  I record what I think will be usefull lookup
strings in Keyword: header

It would be very handy to be able to make that info appear in the
summary line.  Other examples would want to insert some other info
into the summary line.

So I'm looking for a framework that I can change easily to insert
various parts of the message into the summary line.  Possible even the
matches to stipulated regex.  Or who know what all might be handy.

This needs to happen only to certain groups so must be a group-param
or agent-param induced framework.

Maybe something as simple as setting group summary line there.
I believe there is already provision in summary line formatting to
call a function and display its result.

If so, I'd like to see example code of how this might be done.
The manual describes it in some detail but I was not able to really
understand it or see how to code it:

  `u'
     User defined specifier.  The next character in the format string
     should be a letter.  Gnus will call the function
     `gnus-user-format-function-X', where X is the letter following
     `%u'.  The function will be passed the current header as argument.
     The function should return a string, which will be inserted into
     the summary just like information from any other summary
     specifier.

Where I loose it is where it says the function would be passed the
current header.  Does that mean all headers in rotation or what.
Could it be parts of the body too?

Using this option how would one make the Keywords line appear in
summary buffer or maybe the Date: line?  I see a specifier `o' that
already comes close... with:

  `o'
     The `Date' in YYYYMMDD`T'HHMMSS format.

But I'm finding that format too hard to read quickly.  I'd like to have
my own function that produces MM/DD/YY HH:MM:SS and displays it in
summary buffer.

I'm thinking it would then be possible to close group call `G p'

Change the letter following %u and call a different function.  So one
could close and reopen with a series of homemade functions if need be.

Not sure what these functions need to look like.




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

* Re: Adulterate summary lines
  2004-08-16 11:12 Adulterate summary lines Harry Putnam
@ 2004-08-16 15:40 ` Jonas Steverud
  2004-08-17  0:15   ` Harry Putnam
  2004-08-17  1:14   ` Harry Putnam
  2004-08-16 15:52 ` Gnus for information storage (Was: Adulterate summary lines) Robert Epprecht
  1 sibling, 2 replies; 7+ messages in thread
From: Jonas Steverud @ 2004-08-16 15:40 UTC (permalink / raw)


Harry Putnam <reader@newsguy.com> writes:

> Maybe something as simple as setting group summary line there.

I think that is the way to go, with the %u specifier.

> Where I loose it is where it says the function would be passed the
> current header.  Does that mean all headers in rotation or what.
> Could it be parts of the body too?

I wrote some test code:

(defun gnus-user-format-function-x (STR)
    (message (prin1-to-string STR))
  "test")

(setq gnus-summary-line-format "%U%R%z%I%(%[%4L: %ux%]%) %s\n") ;;
slight modification of my summary-line-format. Observe the %ux part.

The Message buffer:

[1841 "Adulterate summary lines" "Harry Putnam <reader@newsguy.com>"
"Mon, 16 Aug 2004 06:12:31 -0500" "<m3pt5rl4kg.fsf@newsguy.com>" ""
4863 59 "c-ed5372d5.036-4-67626721.cust.bredbandsbolaget.se Ding:1841"
((To . "ding@gnus.org") (User-Agent . "Gnus/5.110003 (No Gnus v0.3)
Emacs/21.3.50 (gnu/linux)"))]

I leave to others to interpret if that makes any sense or not. :-)

> Using this option how would one make the Keywords line appear in
> summary buffer or maybe the Date: line?

Let the gnus-user-format-function-x above return what you want to add
as a string.

> I see a specifier `o' that already comes close... with:
>
>   `o'
>      The `Date' in YYYYMMDD`T'HHMMSS format.
>
> But I'm finding that format too hard to read quickly.  I'd like to have
> my own function that produces MM/DD/YY HH:MM:SS and displays it in
> summary buffer.

Try to find the code for that and see if you wan write a
gnus-user-format-function-x which uses format-time-string to produce
what you want.

I did some search in gnus-sum.el and found
gnus-summary-line-format-alist. The line for 'd' was interesting:
    (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)

In gnus-util.el:
(defun gnus-dd-mmm (messy-date)
  "Return a string like DD-MMM from a big messy string."
  (condition-case ()
      (format-time-string "%d-%b" (safe-date-to-time messy-date))
    (error "  -   ")))

I then did:

(defun gnus-user-format-function-x (STR)
    (condition-case ()
      (format-time-string "%d/%m/%y %H:%M:%S"
                 (safe-date-to-time (mail-header-date STR)))
    (error "  -   ")))


I when I enter the Ding group, your message looks like this:
   [  59: 16/08/04 13:12:31] Adulterate summary lines

How to change to an 12-hour clock with AM/PM is left as an exercise to
the reader but C-h f format-time-string is a big step in the right direction.

> I'm thinking it would then be possible to close group call `G p'
>
> Change the letter following %u and call a different function.  So one
> could close and reopen with a series of homemade functions if need be.

Sorry, but I don't understand those two paragraphs... :-(


This, I think, should get you going. HTH.

-- 
(        http://hem.bredband.net/steverud/        !     Wei Wu Wei     )
(        Meaning of U2 Lyrics, Roleplaying        !  To Do Without Do  )




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

* Gnus for information storage (Was: Adulterate summary lines)
  2004-08-16 11:12 Adulterate summary lines Harry Putnam
  2004-08-16 15:40 ` Jonas Steverud
@ 2004-08-16 15:52 ` Robert Epprecht
  1 sibling, 0 replies; 7+ messages in thread
From: Robert Epprecht @ 2004-08-16 15:52 UTC (permalink / raw)


Harry Putnam <reader@newsguy.com> writes:

> I sometimes use gnus for certain kinds of information storage that
> isn't within its real purpose.

So do I. I guess there are quite a few other users that use gnus for
that in a way or the other.  

It would be interesting to hear what usage patterns or tricks others
have found to use gnus to store informations.

I use a very simple method by sending me messages without a 'To: '
but only a 'Gcc: ' header.  Well since some time gnus bothers me
with a 'No receiver, perform Gcc anyway? (y or n)' question, but
it still works.


I'm quite sure there would be room for some improvements and new
Gnus features regarding information storage if one of the Gnus
developers would donate some of his time to think and work on
this special way of using Gnus... (but probably it is already
there... -- when did I read The Fine Gnus Manual from beginning
to end the last time?  ;-)

Thank you to you all for this wonderful software,
Robert Epprecht



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

* Re: Adulterate summary lines
  2004-08-16 15:40 ` Jonas Steverud
@ 2004-08-17  0:15   ` Harry Putnam
  2004-08-17  1:14   ` Harry Putnam
  1 sibling, 0 replies; 7+ messages in thread
From: Harry Putnam @ 2004-08-17  0:15 UTC (permalink / raw)


Jonas Steverud <tvrud@bredband.net> writes:

Note I haven't tried the stuff you posted yet.  Just saw your post so
just clearing this up...

>> I'm thinking it would then be possible to close group call `G p'
>>
>> Change the letter following %u and call a different function.  So one
>> could close and reopen with a series of homemade functions if need be.
>
> Sorry, but I don't understand those two paragraphs... :-(

My post talked about setting summary format in Group params somehow.
So that the weird behavior could be confined to specific groups.

I further tried to illustrate how one might want to run different
functions with %u.  I'm thinking depending on what messages are in the
instant group.  Perhaps they aren't messages in the normal sense but
records of some kind that one might want to first see the Keywords
header displayed.  Then some other header or even parts of the body.

By closing and reopening the group one could enter G p and change the
letter following %u and thereby change the function that is run.  All
this with never having to restart gnus.




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

* Re: Adulterate summary lines
  2004-08-16 15:40 ` Jonas Steverud
  2004-08-17  0:15   ` Harry Putnam
@ 2004-08-17  1:14   ` Harry Putnam
  2004-08-17  7:41     ` Jonas Steverud
  1 sibling, 1 reply; 7+ messages in thread
From: Harry Putnam @ 2004-08-17  1:14 UTC (permalink / raw)


Jonas Steverud <tvrud@bredband.net> writes:

> I leave to others to interpret if that makes any sense or not. :-)
>
>> Using this option how would one make the Keywords line appear in
>> summary buffer or maybe the Date: line?
>
> Let the gnus-user-format-function-x above return what you want to add
> as a string.

Well, first I can't even begin to see what on earth it does.  Or I
mean how it does this.  How can you tell this function which string to
return for example?

I don't see the stuff you posted as a result of your function.  What I
see is a summary buffer that looks like:

?  [  59: test] Adulterate summary lines
RA     [  90: test] 
R      [  28: test] Gnus for information storage (Was: Adulterate summary lines)

Line one is my post, line 2 is your answer and line 3 is another
message from you about using gnus as info storage tool.

I have not the slightest clue how or what is coding this.

It would be handy if you provided some notes as to what is doing what.
(defun gnus-user-format-function-x (STR)
    (message (prin1-to-string STR))
  "test")

The only part I actuall sort of see is that "test" being a string in
double quotes was returned.  

As I posted to start the manual says "function would be passed the
current header"

What header is being passed?

But before I say  any more I'm going to research the stuff you suggested.




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

* Re: Adulterate summary lines
  2004-08-17  1:14   ` Harry Putnam
@ 2004-08-17  7:41     ` Jonas Steverud
  2004-08-17 11:29       ` Harry Putnam
  0 siblings, 1 reply; 7+ messages in thread
From: Jonas Steverud @ 2004-08-17  7:41 UTC (permalink / raw)


Harry Putnam <reader@newsguy.com> writes:

> Jonas Steverud <tvrud@bredband.net> writes:
[...]
> I don't see the stuff you posted as a result of your function.  What I
> see is a summary buffer that looks like:

I didn't document/comment sufficiently, sorry.

> ?  [  59: test] Adulterate summary lines
> RA     [  90: test] 
> R      [  28: test] Gnus for information storage (Was: Adulterate summary lines)
>
> Line one is my post, line 2 is your answer and line 3 is another
> message from you about using gnus as info storage tool.
>
> I have not the slightest clue how or what is coding this.
>
> It would be handy if you provided some notes as to what is doing what.
> (defun gnus-user-format-function-x (STR)
>     (message (prin1-to-string STR))
>   "test")

What is happening is that when Gnus encounter %u it concatenates
"gnus-user-format-function-" with the letter following %u, in our
example it is %ux, i.e. gnus-user-format-function-x is called. So far
so good.

According to the docs, as you have pointed out, something is sent to
the function - and I wanted to find out what it was. prin1-to-string
takes a lisp symbol/expression and converts it to a string and the
message function takes whatever arguments it gets and puts it in the
*Messages* buffer. This is so I can get a debug printout, similar to a
printf() in a C program.

It turns out that what is sent to the gnus-user-format-function-x
function is a vector of a number of the values of the headers in the
message. I do not know which value is which header except one can
deduce which value is the subject, from and the date. But there are a
number of helper functions, e.g. mail-header-date returns the date field.

Since the result of gnus-user-format-function-x should be a string and
that string is inserted in the *Summary* buffer I added a dummy result
"test" to make sure that it returned a string and that my *Summary*
buffer wasn't bogged down with very long strings - IIRC message
returns its argument and if the message function call was the last in
the function, it might return a very long string indeed depending on
which arguments was passed to gnus-user-format-function-x.

> As I posted to start the manual says "function would be passed the
> current header"
>
> What header is being passed?

The values/fields of the header in the current message. That is not
header as in "the Date header" but as in "the header of the
message". In my example this was passed to gnus-user-format-function-x
as a vector (i.e. what ended up in the *Messages* buffer):

[1841 "Adulterate summary lines" "Harry Putnam <reader@newsguy.com>"
"Mon, 16 Aug 2004 06:12:31 -0500" "<m3pt5rl4kg.fsf@newsguy.com>" ""
4863 59 "c-ed5372d5.036-4-67626721.cust.bredbandsbolaget.se Ding:1841"
((To . "ding@gnus.org") (User-Agent . "Gnus/5.110003 (No Gnus v0.3)
Emacs/21.3.50 (gnu/linux)"))]

My guess is that it is the value of all the header fields that you has
deemed interesting, i.e.  the headers that ends up in the *Article*
buffer when you read the message. In my case I have added a couple of
extra headers (e.g. To) to my gnus-extra-headers, which ends up in the
alist at the end of the vector.



I have assumed that you are an experienced Emacs Lisp/Gnus programmer,
the "homeboy indexing system" made me think this was the case. In case
I'm mistaken I can easily elaborate more on my code. :-)

-- 
(        http://hem.bredband.net/steverud/        !     Wei Wu Wei     )
(        Meaning of U2 Lyrics, Roleplaying        !  To Do Without Do  )




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

* Re: Adulterate summary lines
  2004-08-17  7:41     ` Jonas Steverud
@ 2004-08-17 11:29       ` Harry Putnam
  0 siblings, 0 replies; 7+ messages in thread
From: Harry Putnam @ 2004-08-17 11:29 UTC (permalink / raw)


Jonas Steverud <tvrud@bredband.net> writes:

> I have assumed that you are an experienced Emacs Lisp/Gnus programmer,
> the "homeboy indexing system" made me think this was the case. In case
> I'm mistaken I can easily elaborate more on my code. :-)

A wrong assumption, but that is my fault.  I am a longtime emacs and
gnus user but have never really mastered any of the lisp skills.

Many thanks for your elaboration.  Very helpful.  But before I trouble
you further, I have some work to do with experimenting and looking at
the already written functions as you suggested.

Again, thanks for taking the time.




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

end of thread, other threads:[~2004-08-17 11:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-16 11:12 Adulterate summary lines Harry Putnam
2004-08-16 15:40 ` Jonas Steverud
2004-08-17  0:15   ` Harry Putnam
2004-08-17  1:14   ` Harry Putnam
2004-08-17  7:41     ` Jonas Steverud
2004-08-17 11:29       ` Harry Putnam
2004-08-16 15:52 ` Gnus for information storage (Was: Adulterate summary lines) Robert Epprecht

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