;ELC ;;; Compiled by proclus@darwintel on Tue Jan 1 13:53:25 2008 ;;; from file /mnt/gmirror/ports/databases/bbdb/work/bbdb-2.34/lisp/bbdb-snarf.el ;;; in Emacs version 21.2.1 ;;; with bytecomp version 1.1.1.4 ;;; 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 "\302\303!\210\302\304!\210\302\305!\210\302\306!\210\301B\307\302\207" [current-load-list digit require bbdb bbdb-com rfc822 mail-extr "[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]+\\)?" (#$ . 799)) #@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) (#$ . 1009)) #@75 What property bbdb should use for the web, or nil to not detect web URLs. (custom-declare-variable 'bbdb-snarf-web-prop ''www '(#$ . 1187) :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 (#$ . 2132) "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!\211G\303U\203 \304\244\210 )\207" [phone try bbdb-parse-phone-number 3 (0)] 3 (#$ . 2542)]) #@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) "\301b\210\302\303!\210`\302\304!\210`\"\207" [where bbdb-snarf-region forward-paragraph -1 1] 4 (#$ . 2865) "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\2110123456\2117q\210\311 \2106c\210\312ed\310#\210eb\210\313\314d\315#\203G\316\317!\210\2028eb\210\313\320d\315#\203Y\316\317!\210\202Jeb\210\3138d\315#\203\234\310\321\224\321\2259b\210\322u\210\323\324!\203\200 b\210\202\230\325\326 \"!9\3275\330\331\332\315\"C9\"C\"5+\202\\eb\210:\203\277\313\333d\315#\203\277\334\321!3\327\n:3BC\"\316\317!\210eb\210\313\335d\315#\203\333\3274\334\321!C\"4\316\317!\210\202\302\336 \210eb\210`fz\337U\204\357\340y\210\202\341\313\341\310\315#\210\334\321!\321\224\321\225|\210eb\210\313;d\315#\203f\212\214\310]+" 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 (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 (#$ . 3646) "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\"& %\"&\211G\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-@\206D,\205D,@\202D-\203B-@,\".\"\2034\"@.=\203+\307\"\307-.+\202\"A\211\"\204-\203>-A-*\202+-\211/\203X\323/%\"%\324/!\210\325\326%\"\210\327%\314\"\210%\2110\2110\330H\3120\312H0\331H1\2112G\312V\203\2301G\312V\203\2232\3321Q\202\2322\202\2321*I)0\320H0\333H0\334H&\211G\312V\203\316\335\227'\"\21130\3363!\205\3123JBL\210) G\312V\203\356\335 \227'\"\21130\3363!\205\3523JBL\210)\f\203\335\f@\227'\"\21130\3363!\2053JBL\210)\fA\211\204\362&\205=\335&@\227'\"\21130\3363!\205/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 (#$ . 5602)]) #@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\314I\210* \315H\315H\211\203\342@\235\204\331\312@C\"A\211\204\306\315I\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 (#$ . 7351)]) (byte-code "\300\301!\203 \302\301M\210\202\"\300\303!\203\304\303M\210\202\304\305M\210\302\306M\210\300\207" [fboundp replace-in-string bbdb-replace-in-string replace-regexp-in-string bbdb-replace-regexp-in-string #[(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]] 2) #@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 '(#$ . 8670) :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)) '(#$ . -8930) :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" '(#$ . -10185) :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 '(#$ . -10454) :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\312#\310\f\314\315#\f\315\230\204\202 \306 \203  \211(@@) \211(@A)@ \211(@A)A@)*+\316\317,\320Q\f\"\203^\f\321\225\307O\307\307\202\316\322+\323Q\f\"\203\324\302*\247\203y\325*\f\"\202\244*<\203\215\326 -\327\216\330*!*\202\244\331*!\203\242\326 -\332\216*\f!*\202\244*\211.\315\230?\205\257.))\247\203\276\325)\f\"\202\351)<\203\322\326 -\333\216\330)!*\202\351\331)!\203\347\326 -\334\216)\f!*\202\351)\211/\315\230?\205\364/)D\"\210\f\321\225\307O\307\307 A+\202$\203g0\204g1\307\232\204g1\335\232\203(\336\337\f\"\210\202g1\340\232\2037\340\341\f\"\210\202g\3311!\203b1\f!\2112<\203^2G\342U\203^\324\3022A\"\2102@\307)\202g\343\344\f\"\210\203\316\345\f\"\203|\f\321\225\307O\211\202\315\211\202\346\347\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 ((set-match-data save-match-data-internal)) eval functionp ((set-match-data save-match-data-internal)) ((set-match-data save-match-data-internal)) ((set-match-data save-match-data-internal)) 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 (#$ . 11396)]) #@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 (#$ . 13403)]) (provide 'bbdb-snarf)