I am thinking about ways to make the formatting of snail mail
addresses more flexible. In my BBDB I have addresses from a few
countries in the world, and each goes with slightly different
formatting styles, in particular for city, zip code and state.

Yet currently BBDB has only two hard-coded functions
bbdb-format-address-default and bbdb-format-address-continental.
I am thinking about replacing this scheme by a generic function
bbdb-format-address that uses some kind of format strings for
addresses from different countries.

One could have the format specifiers

%s  streets (used repeatedly for each street part)
%c  city
%z  zip code
%S  state
%C  country

A problem is that not every element is always present in an address.
So if there is no country, we want to omit the delimiting newline,
too. This would require some kind of generalized format
specification.

So I thought one could have a delimiter such as `@' in the format
string. If the element referred to by a format specifier was missing,
everything between two `@' was skipped (e.g., "@\n%C@" would omit
the newline, too, if there was no country).  But we do not need "@"
at the very beginning / very end of a format string.

So we could have for example the following format strings

"%s\n@%c@, %S@ %z@\n%C"     USA
"%s\n@%s @%c@ (%S)@\n%C"    most European countries
"%s\n@%c@ %S@ %z@\n%C"      Australia
"%s\n@%c@ %z@ (%S)@\n%C"    India
...                         ...

(I guess that state names are used neither in Europe nor in
India, but if you insist you can get them...)

Also, I want to make the scheme for selecting the above address
formatting schemes more flexible. Old BBDB used the format of zip
code, where the approach was rather euro-centric. I guess this works
fine for some people. But for a more international database, it's
more reliable to use the country -- if (and only if) an address
includes the country field. If I remember correctly, Europe
introduced zip codes like CH-8052, NL-2300RA, and SE-132 54 so that
one need not spell out country names anymore. I do not know whether
people ever followed this rule. Yet it seems that this was the idea
underlying Babb-continental-zip-regexp. -- I am not yet sure what is
the best way how to combine a look-up table based on country names
with a zip-based scheme.

Comments and suggestions welcome!

Roland

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/

Reply via email to