Copyright (C) 2000-2012 |
GNU Info (bbdb.info)Predefined HooksPredefined Hooks ---------------- If the variable `bbdb-change-hook' is set to the symbol `bbdb-timestamp-hook' (the default), then every record in the database will have a field named `timestamp', which will always contain the date and time at which this record was created or last modified. If the variable `bbdb-create-hook' is set to the symbol `bbdb-creation-date-hook' (the default), then every record in the database will have a field named `creation-date', which will contain the date and time at which this record was added to the database. If the variable `bbdb/mail-auto-create-p' is set to the symbol `bbdb-ignore-most-messages-hook', then the variable `bbdb-ignore-most-messages-alist' will determine which messages should have records automatically created for them. The format of this alist is (( HEADER-NAME . REGEXP ) ... ) for example, (("From" . "@.*\\.maximegalon\\.edu") ("Subject" . "time travel")) will cause BBDB entries to be made only for messages sent by people at Maximegalon U., or (that's _or_) people posting about time travel. There may be only one entry per header in this alist: that is, (("From" . "addr1\\|addr2") ... ) is legal, but (("From" . "addr1") ("From" . "addr2") ... ) is not. If the variable `bbdb/mail-auto-create-p' is set to the symbol `bbdb-ignore-some-messages-hook', then the variable `bbdb-ignore-some-messages-alist' will determine which messages should have records automatically created for them. This is the exact inverse of the semantics of the `bbdb-ignore-most-messages-alist': the alist specifies which messages should _not_ have records automatically created for them, instead of which should. For example, (("From" . "mailer.daemon") ("To" . "mailing-list-1\\|mailing-list-2") ("CC" . "mailing-list-1\\|mailing-list-2")) will cause BBDB entries to not be made for messages from any mailer daemon, or messages sent to or CCed to either of two mailing lists. The variable `bbdb/news-auto-create-p' may be set to either of the above-mentioned functions as well, to get this behavior for netnews messages instead of mail messages. If the variable `bbdb-notice-hook' is set to the symbol `bbdb-auto-notes-hook', then the variable `bbdb-auto-notes-alist' may be used to automatically add text to the notes fields of the records corresponding to certain messages. The format of this alist is (( HEADER-NAME (REGEXP . STRING) ... ) ... ) for example, (("To" ("-vm@" . "VM mailing list")) ("Subject" ("sprocket" . "mail about sprockets") ("you bonehead" . "called me a bonehead"))) will cause the text `"VM mailing list"' to be added to the notes field of the record corresponding to anyone you get mail from via one of the VM mailing lists. If, that is, `bbdb/mail-auto-create-p' is set such that the record would have been created, or if the record already existed. The format of elements of this list may also be (REGEXP FIELD-NAME STRING) or (REGEXP FIELD-NAME STRING REPLACE-P) meaning add the given string to the named field. The field-name may not be `name', `aka', `address', `phone', or `net' (builtin fields) but must be either `notes', `company', or the name of a user-defined note-field. ("pattern" . "string to add") is equivalent to ("pattern" notes "string to add") STRING can contain `\&' or `\N' escapes like in the function `replace-match'. For example, to automatically add the contents of the organization field of a message to the `company' field of a BBDB record, you can use this: ("Organization" (".*" company "\\&")) (Note you need two \ to get a single \ into a lisp string literal.) If STRING is an integer N, the Nth matching subexpression is used, so the above example could be written more efficiently as ("Organization" (".*" company 0)) If STRING is neither a string or an integer, it should be a function which is called with the contents of the field, and the result of the function call is used. If the REPLACE-P flag is true, then the string replaces the old contents instead of being appended to it. If multiple clauses match the message, all of the corresponding strings will be added. If the string is being appended (REPLACE-P is false or not provided) then the new string is appended to the end of the existing field value, with an intervening newline. So each piece of text automatically added to this field will go on its own line. You can control what the separator is by putting a `field-separator' property on the symbol naming the field. For example, to make text automatically added to a field named `newsgroups' be separated by commas, you could do (put 'newsgroups 'field-separator "; ") This variable works for news as well. You might want to arrange for this to have a different value when in mail as when in news. There may be only one entry per header in this alist: that is, (("Subject" ("\\bfoo\\b" . "Foo!!") ("bar" . "Bar!"))) will work, but (("Subject" ("\\bfoo\\b" . "Foo!!")) ("Subject" ("bar" . "Bar!"))) will not. Here's a more complicated example: some people include bitmaps of themselves in their mail messages in an X-Face: header field. You can capture this field into the `*BBDB*' with the following: (setq bbdb-auto-notes-alist (append bbdb-auto-notes-alist (list "x-face" (list (concat "[ \t\n]*\\([^ \t\n]*\\)" "\\([ \t\n]+\\([^ \t\n]+\\)\\)?" "\\([ \t\n]+\\([^ \t\n]+\\)\\)?" "\\([ \t\n]+\\([^ \t\n]+\\)\\)?" ) 'face "\\1\\3\\5\\7")))) (The calls to `list' and `concat' are just for readability, it could easily be a constant.) The tricky bit here is that it strips out the newlines and whitespace used for header continuation, which are not actually a part of the face data. So though the mail message may have the face data on multiple lines, the entry in the `*BBDB*' will be just one line. `bbdb-auto-notes-ignore' is an alist of headers and regexps to ignore in `bbdb-auto-notes-hook'. Each element looks like (HEADER . REGEXP) for example, ("Organization" . "^Gatewayed from\\|^Source only") would exclude the phony `Organization:' headers in GNU mailing-lists gatewayed to the `gnu.*' newsgroups. Note that this exclusion applies only to a single field, not to the entire message. For that, use the variable `bbdb-auto-notes-ignore-all'. `bbdb-auto-notes-ignore-all' is an alist of headers and regexps which cause the entire message to be ignored in `bbdb-auto-notes-hook'. Each element looks like (HEADER . REGEXP) for example, ("From" . "BLAT\\.COM") would exclude any notes recording for message coming from `BLAT.COM'. Note that this is different from `bbdb-auto-notes-ignore', which applies only to a particular header field, rather than the entire message. automatically generated by info2www version 1.2.2.9 |