;ELC   
;;; Compiled by nelhage@localhost.localdomain on Tue Dec 13 12:19:28 2005
;;; from file /home/nelhage/Desktop/bbdb-2.34/lisp/bbdb-snarf.el
;;; in Emacs version 22.0.50.7
;;; with all optimizations.

;;; This file uses dynamic docstrings, first added in Emacs 19.29.
(if (and (boundp 'emacs-version)
	 (< (aref emacs-version (1- (length emacs-version))) ?A)
	 (or (and (boundp 'epoch::version) epoch::version)
	     (string-lessp emacs-version "19.29")))
    (error "`bbdb-snarf.el' was compiled for Emacs 19.29 or later"))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(byte-code "\301\302!\210\301\303!\210\301\304!\210\301\305!\210\306B\307\310!\207" [current-load-list require bbdb bbdb-com rfc822 mail-extr digit (lambda (#1=#:defconst-tmp-var) (defconst digit #1#)) "[0-9]"] 2)
#@25 regexp to match phones.
(defvar bbdb-snarf-phone-regexp "\\(([2-9][0-9][0-9])[-\\. ]?\\|[2-9][0-9][0-9][-\\. ]\\)?[0-9][0-9][0-9][-\\. ][0-9][0-9][0-9][0-9]\\( *\\(x\\|ext\\.?\\) *[0-9]+\\)?" (#$ . 817))
#@22 regexp matching zip.
(defvar bbdb-snarf-zip-regexp (byte-code "\301\211\211\211\211\302\211\211\211\303\304\260\207" [digit "\\<" "\\(-" "\\)?" "\\>$"] 13) (#$ . 1027))
#@75 What property bbdb should use for the web, or nil to not detect web URLs.
(custom-declare-variable 'bbdb-snarf-web-prop ''www '(#$ . 1205) :group 'bbdb :type 'symbol)
(defalias 'bbdb-snarf-address-lines #[nil "\302\303 \304\"	\305Y\204( G\306W\203 \307\310C\"\211\202 G\306V\203( \311\312!\210ed|\210)\207" [lines bbdb-file-format bbdb-split buffer-string "\n" 5 3 append nil error "bbdb-snarf-address-lines: too many lines in address."] 4])
(defalias 'bbdb-snarf-make-address #[(label address-lines city state zip country) "\306Y\203 \307	\n\f\n&\207\310Y\203 \307	\n\f%\207\307	\n@\nA@\311\n8\f&\207" [bbdb-file-format label address-lines city state zip 4 vector 3 2 country] 8])
(defalias 'bbdb-snarf-prune-empty-lines #[nil "eb\210\300\301d\302#\205 \303\304!\210\202 \207" [re-search-forward "^[ 	]*\n" t replace-match ""] 4])
(defalias 'delete-and-return-region #[(begin end) "	{	|\210\207" [begin end] 3])
#@116 Extract the label before the point, or return DEFAULT if no label.
If CONSUME-P is set, delete the text, if found.
(defalias 'bbdb-snarf-extract-label #[(default consume-p) "\304 \305\306x\210\307u\210\310\311!\203$ `\312\313\306x\210`	\"`|\210\n*\202% )\207" [end label-end label default point-marker " 	" nil -1 looking-at ":" delete-and-return-region "^\n,;"] 3 (#$ . 2150) "sDefault label: "])
#@163 Fix the bogosity that is `bbdb-snarf-parse-phone-number'.
It doesn't always return a normalized phone number.
For (800) 555-1212 it returns a three element list.
(defalias 'bbdb-snarf-parse-phone-number #[(phone) "\302!\211G\303U\203 	\304\244\210	)\207" [phone try bbdb-parse-phone-number 3 (0)] 3 (#$ . 2560)])
#@628 snarf up a bbdb record WHERE the point is.
We assume things are line-broken and paragraph-bounded.
The name comes first and other fields (address,
phone, email, web pages) are recognized by context.

Required context:
    addresses end with "City, State ZIP" or "City, State"
    phones match bbdb-snarf-phone-regexp
        (currently US-style phones)
    e-mail addresses have @'s in them
    web sites are recognized by http:// or www.

Address and phone context are currently US-specific;
patches to internationalize these assumptions are welcome.

\[bbdb-snarf] is similar to \[bbdb-whois-sentinel], but less specialized.
(defalias 'bbdb-snarf #[(where) "\301b\210\302\303!\210`\302\304!\210`\"\207" [where bbdb-snarf-region forward-paragraph -1 1] 4 (#$ . 2883) "d"])
#@83 snarf up a bbdb record in the current region.  See `bbdb-snarf' for
more details.
(defalias 'bbdb-snarf-region #[(begin end) "\212\306\307!	{\310\211\211\211\211\211\211\211\211\2116789:;<\211=q\210\311 \210<c\210\312ed\310#\210eb\210\313\314d\315#\203G \316\317!\210\2028 eb\210\313\320d\315#\203Y \316\321!\210\202J eb\210\313>d\315#\203\234 \310\322\224\322\225?b\210\323u\210\324\325!\203\200 	b\210\202\230 \326\327	\"!?\330;\331\332\333\315\"C?\"C\";+\202\\ eb\210@\203\277 \313\334d\315#\203\277 \335\322!9\330\n@9BC\"\316\336!\210eb\210\313\337d\315#\203\333 \330:\335\322!C\":\316\340!\210\202\302 \341 \210eb\210`fz\342U\204\357 \343y\210\202\341 \313\344\310\315#\210\335\322!\322\224\322\225|\210eb\210\313Ad\315#\203f\212\214\310Be\322\225}\210db\210\345Ae\315#\210\346\335\322!!6\347\310x\210`B\350\310x\210`B{7\351\310x\210`B\352 \210`B{8\323u\210`d|\210eb\210\353 \354\355\f876\356&C+\202\232\313\357d\315#\203\226\212\214\335\343!8\335\360!7e\322\225}\210eb\210\353 \354\361\f87\322\362&C*\202\232\363\310\341 \210edU\204\254\330\n\302\364 BC\"\365\310:;\n&.\207" [begin end notes address-vector address-lines name get-buffer-create " *BBDB snarf*" nil erase-buffer set-text-properties re-search-forward "^[ 	]+" t replace-match "" "\\s +$" "" 0 -1 looking-at "[0-9A-Za-z]" bbdb-snarf-parse-phone-number delete-and-return-region append vconcat bbdb-snarf-extract-label "phone" "\\(http://\\|www.\\)[^ 	\n]+" match-string "" "[^ 	\n<]+@[^ 	\n>]+" "" bbdb-snarf-prune-empty-lines 119 1 "\\(\\sw\\|[ -.,]\\)*\\sw" re-search-backward bbdb-parse-zip-string " 	" "^ 	," " 	," beginning-of-line bbdb-snarf-address-lines bbdb-snarf-make-address "address" "" "^\\(.*\\), \\([A-Z][A-Za-z]\\)$" 2 "address" "" (nil nil nil) buffer-string bbdb-merge-interactively zip state city web nets phones text buf bbdb-snarf-phone-regexp phone bbdb-snarf-web-prop bbdb-snarf-zip-regexp mk] 13 (#$ . 3664) "r"])
#@76 Interactively add a new record; arguments same as \[bbdb-create-internal].
(defalias 'bbdb-merge-interactively #[(name company nets addrs phones notes) "\306!\211@	A@\307\310\n\f !\"#\311$\307\"&	%\"&\211G\312=\2032 \307&G\312=\203= \307&\313\314!\210\205\221 \315\227r\316 q\210\313\307\314\"\210')\"J\307())\203\216 )@*\227\317*!\206w *\320H\206w \321\227\230\203\205 \322)*C\"()A))\202\\ (*&;\203\255 \315&\227r\316 q\210\313\307\314\"\210')\"J\202\334 \307(&\203\331 (\204\331 \315&@\227r\316 q\210\313\307\314\"\210')\"J(&A\211&\204\265 ()\307+,\211-\203\354 ,\204-\203\367 -@\206J,\205J,@\202J-\203H-@,\".\"\2034\"@.=\203+\307\211\"-.+\202\"A\211\"\204-\203A-A-\202D.\210*\202+-\211/\203^\323/%\"%\324/!\210\325\326%\"\210\327%\314\"\210%\2110\2110\330H\3120\312H0\331H1\2112G\312V\203\2361G\312V\203\2312\3321Q\202\2402\202\2401*I)0\320H0\333H0\334H&\211G\312V\203\324\335\227'\"\21130\3363!\205\3203JBL\210)G\312V\203\364\335\227'\"\21130\3363!\205\3603JBL\210)\f\203\335\f@\227'\"\21130\3363!\2053JBL\210)\fA\211\204\370&\205C\335&@\227'\"\21130\3363!\20553JBL\210)&A\211&\204\307,\210)\337%C!.\207" [name f-l-name firstname lastname aka company bbdb-divide-name nil vector make-vector 0 bbdb-records t intern-soft bbdb-buffer bbdb-record-name 3 "" append bbdb-merge-internally bbdb-delete-record-internal bbdb-invoke-hook bbdb-create-hook bbdb-change-record 8 1 " " 2 6 intern boundp bbdb-display-records phones addrs nets notes bbdb-cache-length new-record net bbdb-hashtable answer recs n-rec ret net-recs name-recs name-rec old-record record lname fname sym] 13 (#$ . 5645)])
#@65 Merge two records.  NEW-RECORDS wins over OLD in cases of ties.
(defalias 'bbdb-merge-internally #[(old-record new-record) "\306H\204 	\306H\203 \306	\306HI\210\307H\204& 	\307H\203& \307	\307HI\210\310H\2049 	\310H\2039 \310	\310HI\210	\311H\311H\211\203Z @\n\235\204S \312\n@C\"A\211\204E \311\nI\210*	\313H\313H\211\203\201 @\f\235\204z \312\f@C\"A\211\204l \313\fI\210*	\314H\314H\211\203\261 @\235\204\250 \312@C\"A\211\204\225 \314I\210*	\315H\315H\211\203\342 @\235\204\331 \312@C\"A\211\204\306 \315I\210*\207" [new-record old-record new-nets old-nets new-addresses old-addresses 0 1 3 6 append 5 4 7 new-phones old-phones new-notes old-notes] 5 (#$ . 7406)])
(byte-code "\300\301!\203 \302\301M\210\202$ \300\303!\203 \304\303M\210\202 \305\304\306\"\210\305\302\307\"\210\300\207" [fboundp replace-in-string bbdb-replace-in-string replace-regexp-in-string bbdb-replace-regexp-in-string defalias #[(regexp newtext string &optional fixedcase literal) "\306\307\310\211\311\f\n#\203$ \307\224\307\225\n	O\nQ\202 \n\310OP,\207" [me mb start result regexp string "" 0 nil string-match newtext] 4] #[(string regexp newtext &optional literal) "\304	\n\305%\207" [regexp newtext string literal bbdb-replace-regexp-in-string nil] 6]] 3)
#@107 Function called to parse one or more email addresses.
See bbdb-extract-address-components for an example.
(custom-declare-variable 'bbdb-extract-address-components-func ''bbdb-rfc822-addresses '(#$ . 8743) :group 'bbdb-noticing-records :type 'function)
#@564 *List of regexps matching headers.
Each list element should have the form (REGEXP FULLNAME ADDRESS), where
REGEXP matches the address while the actual address components should
be a parenthesized expression.

FULLNAME is a default string for addresses without full name or a
number denoting parenthesized expression.
ADDRESS is a number denoting the parenthesized expression matching the
address.

If FULLNAME or ADDRESS is a list it will be evaluated to return a
string or nil.  If its a function it will be called with the remaining
address-string as argument.
(custom-declare-variable 'bbdb-extract-address-component-regexps ''(("\"\\([^\"]*\\)\"\\s-*<\\([^>]+\\)>" (car (mail-extract-address-components (concat "\"" (match-string 1 adstring) "\""))) 2) ("\\([^<>,	][^<>,]+[^<>, 	]\\)\\s-*<\\([^>]+\\)>" 1 2) ("<\\([^>]+\\)>" nil 2) ("\\(\\b[^<\",()]+\\b\\)\\s-*(\\([^)]+\\))" (car (mail-extract-address-components (concat "\"" (match-string 2 adstring) "\""))) 1) ("\\b\\(\\([^@ 	\n.]+\\.[^@ 	\n.]+\\)@[^@ 	\n]+\\)\\b" (car (mail-extract-address-components (concat "\"" (match-string 2 adstring) "\""))) 1) ("\\b\\(\\([^@ 	\n]+\\)@[^@ 	\n]+\\)\\b" nil 1) ("\\b\\([^@ 	\n]+\\)\\b" nil 1)) '(#$ . -9003) :group 'bbdb-noticing-records :type 'list)
#@55 *A regexp matching addresses which should be ignored.
(custom-declare-variable 'bbdb-extract-address-component-ignore-regexp '"\\(\\(undisclosed\\|unlisted\\)[^,]*recipients\\)\\|no To-header on input" '(#$ . -10258) :group 'bbdb-noticing-records :type 'string)
#@609 *Specifies how `bbdb-extract-address-components' reports errors.

A value of nil means ignore unparsable stuff and 'warn will report
a warning, 'message will report a message in the minibuffer and all
other value will fire a error.

When set to a function it will be called with the remaining string in
order to extract the address components and return the rest and the
components as list or to do what ever it wants, e.g. send a complain
to the author ...

To skip known unparseable stuff you rather should set the variable
`bbdb-extract-address-component-ignore-regexp' instead of disabling
this handler.
(custom-declare-variable 'bbdb-extract-address-component-handler ''message '(#$ . -10527) :group 'bbdb-noticing-records :type '(choice (const :tag "Ignore problems." nil) (const :tag "Warn about parsing problems." 'warn) (const :tag "Show a message about parsing problems." 'message) (function :tag "A user defined handler")))
#@158 Return a list of address components found in ADSTRING.
If extracting fails one probably has to adjust the variable
`bbdb-extract-address-component-regexps'.
(defalias 'bbdb-extract-address-components #[(adstring &optional ignore-errors) "\306\307\211\211\310\f\311\312#\310\f\313\314#\310\f\315\316#\f\317\230\204\202\306	\203		\211-@@)	\211-@A)@	\211-@A)A@./0\320\3211\322Q\f\"\203^ \f\323\225\307O\307\211\202\320\3240\325Q\f\"\203\326\302/\247\203y \327/\f\"\202\244 /<\203\215 \330 2\331\216\332/!*\202\244 \333/!\203\242 \330 2\334\216/\f!*\202\244 /\2113\335\230?\205\257 3).\247\203\276 \327.\f\"\202\351 .<\203\322 \330 2\336\216\332.!*\202\351 \333.!\203\347 \330 2\337\216.\f!*\202\351 .\2114\340\230?\205\364 4)D\"\210\f\323\225\307O\307\211	A+\202$ \203g5\204g6\307\232\204g6\341\232\203(\342\343\f\"\210\202g6\344\232\2037\344\345\f\"\210\202g\3336!\203b6\f!\2117<\203^7G\346U\203^\326\3027A\"\2107@\307)\202g\347\350\f\"\210\203 \320\351\f\"\203|\f\323\225\307O\211\202 \352\211\202 \353\354\n\237\",\207" [nomatch adcom-regexp fnadlist case-fold-search adstring bbdb-extract-address-component-regexps t nil bbdb-replace-in-string "[\n	]" " " "  " " " "^ +" "" "" string-match "^[^,]*\\(" "\\)[^,]*\\(,\\|$\\)" 0 "^\\s-*" "\\s-*\\(,\\|$\\)" add-to-list match-string match-data ((byte-code "\301\302\"\207" [save-match-data-internal set-match-data evaporate] 3)) eval functionp ((byte-code "\301\302\"\207" [save-match-data-internal set-match-data evaporate] 3)) "" ((byte-code "\301\302\"\207" [save-match-data-internal set-match-data evaporate] 3)) ((byte-code "\301\302\"\207" [save-match-data-internal set-match-data evaporate] 3)) "" warn bbdb-warn "Cannot extract an address component at \"%s\".\nSee `bbdb-extract-address-component-handler' for more information." message "Cannot extract an address component at \"%s\"." 3 error "Cannot extract an address component at \"%30s\"" "^[^,]*," "" delete (nil nil) x ad fn regexp bbdb-extract-address-component-ignore-regexp save-match-data-internal n a ignore-errors bbdb-extract-address-component-handler result] 7 (#$ . 11469)])
#@324 Split ADDRLINE into a list of parsed addresses.

You can't do this with rfc822.el in any sort of useful way because it discards
the comments. You can't do this with mail-extr.el because the multiple address
parsing in GNU Emacs appears to be broken beyond belief, and the XEmacs
version doesn't support multiple addresses.
(defalias 'bbdb-rfc822-addresses #[(addrline &optional ignore-errors) "\306\307\n\310P\311\312\n#\203A \n\307\313\225O\307\225\314!\311\315@\206% \316\"\203. \f\202= \317	\320!C\"\n\f\306O\307+\202 	*\207" [start addrs addrline thisaddr comma parsed nil 0 "," string-match "\\([^,]+\\)," 1 rfc822-addresses "(" "" append mail-extract-address-components] 4 (#$ . 13660)])
(provide 'bbdb-snarf)
