Gnus development mailing list
 help / color / mirror / Atom feed
From: Harry Putnam <reader@newsguy.com>
Subject: Re: Summary format - the `u' spec
Date: 04 Mar 2001 13:52:46 -0800	[thread overview]
Message-ID: <m3k865jmf8.fsf@gnus.cvs.983032537> (raw)
In-Reply-To: <vafd7bxh12e.fsf@lucy.cs.uni-dortmund.de> (Kai.Grossjohann@CS.Uni-Dortmund.DE's message of "04 Mar 2001 18:54:33 +0100")

Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Großjohann) writes:

> On 04 Mar 2001, Harry Putnam wrote:
> 
> > Hopefully I'm, correct in thinking the line that says:
> > "...The function will be passed the current header as argument."
> > Means that all header lines get scanned.
> 
> Hm, no, not really.  `Mail header' in this context (oh, how I love the
> inconsistent terminology in Gnus!) is a structure which contains the
> information from the NOV (or overview) file/data in a Lisp-predigested
> form.  For example, if X is such a header, then (mail-header-subject
> X) returns a string, the subject of the message.

Well, still close enough to get what I want here.  I do understand the
NOV file a bit and as luck would have it I've had code in .gnus for a
long time to insert a `Keywords' header into the .overiew file. And
have them displayed in the article view buffer.

[...]

> > I want to use this option to cause gnus to scan the headers for this
> > pattern `^Keywords: \\[A\\] '.  And if found, to insert the capital
> > letter found inside the [] into th summary display.

[...]

> And then you can do:
> 
>     (defun gnus-user-format-function-H (header)
>       (let* ((xtra (mail-header-extra header))
>              (kw (cdr (assq 'Keywords xtra))))
>         (if (and kw (stringp kw))
>             (substring kw 0 5)
>           "    ")))
> 
> This is untested.  Not sure if it works.  It tries to print the first
> 5 or 6 characters of the Keywords header, or spaces (if there is no
> Keywords header).
> 
> Does this work, and can you take it from here?

Yes it works, and I see how it works and how to adjust what gets
printed, at least somewhat.  I don't really follow all the ins and
outs of even this simple  code.  But I see that this:

    (defun gnus-user-format-function-H (header)
      (let* ((xtra (mail-header-extra header))
             (kw (cdr (assq 'Keywords xtra))))
        (if (and kw (stringp kw))
            (substring kw 4 5)
          "N")))

Given a keywords header like:
        Keywords: [ed]A something

And a format string like:
        "%2t%U%R%7d%z%I%(%[%uH%4L: %-20,20f%]%) %s\n" 
              (inserted =>)^^^

will give a summary buffer line like:
  (Printing an `N' if no keyword line)

1R  07-Oct [A 161: me                  ] [ed]V [comp.editors] Vim - append to file
inserted => ^^

I guess what I really want to know is if it can be made to match a
regexp instead of a a static number of characters in a string.  And to
return that portion that matches or even better to edit the portion
that matches in some predictable way.

I see the first stringmatch thing is to match the keyword line itself
and I need that, and even bettter your trial code does do that
admirably.

Once we have a match, then the code looks as if it grabs a
predetermined number of characters from the Keyword header begining
with the first character after `:' (0 5).

And I do see how one would adjust that number, if need be.

I guess what I want is, once the keyword is matched, to take the
string after `:' and pluck a pattern from it leaving the rest behind.

Something like what one would do with sed (in bash) in this fashion.

        echo "Keywords: [A] blabbity blah blick"\
        |sed 's/^\(Keywords: \[\)\(A\)\(\]\).*/\2/'
        A
Plucking out only the `A' 

Or with awk
        echo "Keywords: [A] blabbity blah blick"\
        |awk -vRS="\\\[A\\\]" '{gsub (/\[|\]/,"",RT);print RT;ORS=FS}'          
        A

So once the keywords line is matched does elisp offer a pattern
matching command that returns the matched portion?



  reply	other threads:[~2001-03-04 21:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-04 16:21 Harry Putnam
2001-03-04 17:54 ` Kai Großjohann
2001-03-04 21:52   ` Harry Putnam [this message]
2001-03-05  0:39     ` Alex Schroeder
2001-03-05  1:07       ` Harry Putnam
2001-03-05 20:52         ` Alex Schroeder
2001-03-05 23:59           ` Harry Putnam
2001-03-05  9:29       ` Kai Großjohann
2001-03-04 21:21 ` Pavel Janík ml.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3k865jmf8.fsf@gnus.cvs.983032537 \
    --to=reader@newsguy.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).