Gnus development mailing list
 help / color / mirror / Atom feed
* Name washing
@ 1999-12-14 20:51 Paul Stevenson
  1999-12-14 21:48 ` Paul Stevenson
  1999-12-15 11:04 ` Toby Speight
  0 siblings, 2 replies; 6+ messages in thread
From: Paul Stevenson @ 1999-12-14 20:51 UTC (permalink / raw)


Has anyone written, or does gnus already have some function to wash
names?

I have in mind turning things like
Lars Magne Ingebrigtsen <larsi@gnus.org>
which one gets as %n in gnus-summary-line-format into a shorter form
such as
L M Ingebrigtsen
so that people's full names can appear without making the field too
wide.

Obviously I would be after some clever function which could turn
wmperry@aventail.com (William M. Perry)
into W M Perry
or similar.

I just thought I'd see if any bits of code existed before I
re-implement it...

Paul


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

* Re: Name washing
  1999-12-14 20:51 Name washing Paul Stevenson
@ 1999-12-14 21:48 ` Paul Stevenson
  1999-12-14 22:04   ` Paul Stevenson
       [not found]   ` <wtniu20lgtz.fsf@licia.dtek.chalmers.se>
  1999-12-15 11:04 ` Toby Speight
  1 sibling, 2 replies; 6+ messages in thread
From: Paul Stevenson @ 1999-12-14 21:48 UTC (permalink / raw)


Paul Stevenson <spaul@mail.phy.ornl.gov> writes:

> Has anyone written, or does gnus already have some function to wash
> names?
>
> [snip]

okay, it was easier than I thought for just a very simple heuristic
algorithm:


(defun ps-wash-name (name)
  (if (stringp name)
      (if (string= name (car (split-string name "(")))
	  (progn
	    (if (string= name (car (split-string name "<")))
		(car (split-string name "@"))
	      (car (split-string name " <"))))
	(car (cdr (split-string name "(\\|)"))))
    "Fudged name"))

then with 

(defun gnus-user-format-function-a (headers)
  (let ((name (aref headers 2)))
    (ps-wash-name name)))

I can have 

(setq gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20ua%]%) %s\n")

and it does most of what I want. woo-hoo. Hooray for
gnus-user-format-function


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

* Re: Name washing
  1999-12-14 21:48 ` Paul Stevenson
@ 1999-12-14 22:04   ` Paul Stevenson
       [not found]   ` <wtniu20lgtz.fsf@licia.dtek.chalmers.se>
  1 sibling, 0 replies; 6+ messages in thread
From: Paul Stevenson @ 1999-12-14 22:04 UTC (permalink / raw)


doh!

I had my format line previously set to something weird, so I had
thought that the default was not to remove the email address. All I've
done is reproduced the default behaviour.
Sorry 'bout the wasted bandwidth.

Paul


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

* Re: Name washing
  1999-12-14 20:51 Name washing Paul Stevenson
  1999-12-14 21:48 ` Paul Stevenson
@ 1999-12-15 11:04 ` Toby Speight
  1 sibling, 0 replies; 6+ messages in thread
From: Toby Speight @ 1999-12-15 11:04 UTC (permalink / raw)


Paul> Paul Stevenson <URL:mailto:spaul@mail.phy.ornl.gov>

0> In article <m2puw9i6uk.lavish@bethe.phy.ornl.gov>, Paul wrote:

Paul> I have in mind turning things like "Lars Magne Ingebrigtsen
Paul> <larsi@gnus.org>" which one gets as %n in
Paul> gnus-summary-line-format into a shorter form such as "L M
Paul> Ingebrigtsen" so that people's full names can appear without
Paul> making the field too wide.

I have the following, to use the full names out of the BBDB, prefixed
with '*' (or a marker char from their notes).  It works with the "To:"
hack if you get nnmail to re-write NOV entries for your own sent mail.

(defun bbdb-extract-address-components (from)
  "Get the real name of FROM from the BBDB.\n
Meant for use as the value of gnus-extract-address-components."
  (if (string-match "^=> " from)
      (let ((components (bbdb-extract-address-components (substring from 3))))
        (cons (concat "=>" (car components))
              (cdr components)))
    (let* ((mail-extr-ignore-single-names t)
           (data (condition-case ()
                     (mail-extract-address-components from)
                   (error nil)))
           (name (car data))
           (net (car (cdr data)))
           (net-canon (if (and net bbdb-canonicalize-net-hook)
                          (bbdb-canonicalize-address net)
                        net))
           (record (and data (bbdb-search-simple name net-canon)))
           string L)

      (if (and record name (member (downcase name) (bbdb-record-net record)))
          ;; bogon!
          (setq record nil))

      (setq name (or (and bbdb/gnus-header-prefer-real-names
                          (or (and bbdb/gnus-header-show-bbdb-names record
                                   (bbdb-record-name record))
                              name
                              (car (gnus-extract-address-components from))))
                     net))
      (list (format "%s%s"
                    (if (and record bbdb/gnus-mark-known-posters)
                        (or (bbdb-record-getprop record bbdb-message-marker-field) "*")
                      " ")
                    (or name from))
            net))))

(setq gnus-extract-address-components 'bbdb-extract-address-components)





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

* Re: Name washing
       [not found]   ` <wtniu20lgtz.fsf@licia.dtek.chalmers.se>
@ 1999-12-17 13:47     ` Paul Stevenson
  1999-12-21 20:52       ` Kai Großjohann
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Stevenson @ 1999-12-17 13:47 UTC (permalink / raw)


Jonas Steverud <d4jonas@dtek.chalmers.se> writes:

> Paul Stevenson <spaul@mail.phy.ornl.gov> writes:
> 
> [...]
> > (defun gnus-user-format-function-a (headers)
> >   (let ((name (aref headers 2)))
> >     (ps-wash-name name)))
> 
> How does that work with the documentation? "The function will be
> passed a single dummy parameter as argument." (node: Group Line
> Specification)  ^^^^^
> 
> Bug in the documentation?

>From the 5.8.2 docs which I just printed, section 3.1.1 [Summary
Buffer Lines]  I got "the function[1] will be passed the current
header as argument". It didn't say in what form it would be, but I saw
that it was a vector, with the From: line as its second element.  I'm
a bit worried that this is not the right way to do it.  

It probably wasn't a waste of time, after all, since getting the plain
name sans email address as a string means that I can do the extra
length reduction (turning first names into initials) as I had outlined
in the first mail.

[1] The gnus-user-format-function-X




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

* Re: Name washing
  1999-12-17 13:47     ` Paul Stevenson
@ 1999-12-21 20:52       ` Kai Großjohann
  0 siblings, 0 replies; 6+ messages in thread
From: Kai Großjohann @ 1999-12-21 20:52 UTC (permalink / raw)
  Cc: ding

Paul Stevenson <spaul@mail.phy.ornl.gov> writes:

> >From the 5.8.2 docs which I just printed, section 3.1.1 [Summary
> Buffer Lines]  I got "the function[1] will be passed the current
> header as argument". It didn't say in what form it would be, but I saw
> that it was a vector, with the From: line as its second element.  I'm
> a bit worried that this is not the right way to do it.  

This vector is a data structure used internally by Gnus, and there are
a number of accessor functions for it.  mail-header-from might be what
you are looking for.

kai
-- 
A preposition is not a good thing to end a sentence with.



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

end of thread, other threads:[~1999-12-21 20:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-14 20:51 Name washing Paul Stevenson
1999-12-14 21:48 ` Paul Stevenson
1999-12-14 22:04   ` Paul Stevenson
     [not found]   ` <wtniu20lgtz.fsf@licia.dtek.chalmers.se>
1999-12-17 13:47     ` Paul Stevenson
1999-12-21 20:52       ` Kai Großjohann
1999-12-15 11:04 ` Toby Speight

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