Alex Schroeder <[EMAIL PROTECTED]> writes:

> Ronan Waide <[EMAIL PROTECTED]> writes:
> 
> > is this: go ahead with the zips-as-strings conversion (does this mean
> > we need BBDB v6 file format? I guess so...), and modify the validation
> > code to work on the strings - i.e. it doesn't try to parse the
> > zipcodes into a list or whatever, but it does try to make sure that
> > the string conforms to something good - and then make the entire
> > validation option switchable. bbdb-validate-zip-codes-p, for
> > example.

I've sent the patch to Ronan, so it will probably appear in CVS soon.

The most important thing is that Zip Codes will be plain strings.  In
order to make this change explicit, I introduced a new file version.
Zip codes will be checked if the new variable bbdb-check-zip-codes-p
is t (the default).  Checking is done by matching the string will all
the regexps in the new variable bbdb-legal-zip-codes.

It looks like this, now:

> (defvar bbdb-legal-zip-codes
>   '(;; Matches 1 to 6 digits.
>     "^[ \t\n]*[0-9][0-9]?[0-9]?[0-9]?[0-9]?[0-9]?[ \t\n]*$"
>     ;; Matches 5 digits and 3 or 4 digits.
>     "^[ \t\n]*\\([0-9][0-9][0-9][0-9][0-9]\\)[ \t\n]*-?[ 
>\t\n]*\\([0-9][0-9][0-9][0-9]?\\)[ \t\n]*$"
>     ;; Match zip codes for Canada, UK, etc. (result is ("LL47" "U4B")).
>     "^[ \t\n]*\\([A-Za-z0-9]+\\)[ \t\n]+\\([A-Za-z0-9]+\\)[ \t\n]*$"
>     ;; Match zip codes for continental Europe.  Examples "CH-8057"
>     ;; or "F - 83320" (result is ("CH" "8057") or ("F" "83320")).
>     ;; Support for "NL-2300RA" added at request from Carsten Dominik
>     ;; <[EMAIL PROTECTED]>
>     "^[ \t\n]*\\([A-Z]+\\)[ \t\n]*-?[ \t\n]*\\([0-9]+ ?[A-Z]*\\)[ \t\n]*$"
>     ;; Match zip codes from Sweden where the five digits are grouped 3+2
>     ;; at the request from Mats Lofdahl <[EMAIL PROTECTED]>.
>     ;; (result is ("SE" (133 36)))
>     "^[ \t\n]*\\([A-Z]+\\)[ \t\n]*-?[ \t\n]*\\([0-9]+\\)[ \t\n]+\\([0-9]+\\)[ 
>\t\n]*$")
>   "List of regexps that match legal zip codes.
> Wether this is used at all depends on the variable `bbdb-check-zip-codes-p'.")

(I just noted that the explanatory comments still refer to the old
datastructure cruft...)

Here's the ChangeLog for all the stuff.

>       * lisp/bbdb-com.el (bbdb-check-zip-codes-p): New variable.
>       (bbdb-legal-zip-codes): New variable.
>       (bbdb-parse-zip-string): Use the two new variables instead of
>       hard-coding valid zip string regepxs.
>       (bbdb-create-internal): Doc change.  Check wether zip code is
>       stringp.
> 
>       * lisp/bbdb-migrate.el (bbdb-migration-features): Added
>       description for version 6.
>       (bbdb-migration-spec): Added version 5->6 stuff.
>       (bbdb-unmigration-spec): Added version 6->5 stuff.
>       (bbdb-migrate-zip-codes-to-strings): New function with code from
>       bbdb-address-zip-string.
>       (bbdb-unmigrate-zip-codes-to-strings): New function with code from
>       bbdb-parse-zip-string.
>       (bbdb-migrate-add-country-field): Doc typo.
>       (bbdb-unmigrate-add-country-field): Doc typo.
> 
>       * lisp/bbdb-print.el (bbdb-print-format-address-continental): Use
>       bbdb-address-zip instead of bbdb-address-zip-string.
>       (bbdb-print-format-address-default): Ditto.
> 
>       * lisp/bbdb.el (bbdb-file-format): Set to 6.
>       (bbdb-address-zip-string): defalised to bbdb-address-zip.
>       (bbdb-continental-zip-regexp): New option.
>       (bbdb-address-is-continental): Use bbdb-continental-zip-regexp.
>       (bbdb-format-address-continental): Use bbdb-address-zip instead of
>       bbdb-address-zip-string.
>       (bbdb-format-address-default): Ditto.

Alex.
-- 
http://www.geocities.com/kensanata/emacs.html
"Emacsen <v21 do not do colors on a tty; use XEmacs or wait for Emacs 21."

_______________________________________________
bbdb-info mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/mailman/listinfo/bbdb-info

Reply via email to