[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb d7bc0c9 284/350: Drop the whole auto-notes thing
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb d7bc0c9 284/350: Drop the whole auto-notes thing |
Date: |
Mon, 14 Aug 2017 11:46:54 -0400 (EDT) |
branch: externals/ebdb
commit d7bc0c920b97f8dafec00793826a1298821f898a
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Drop the whole auto-notes thing
* ebdb-mua.el (ebdb-annotate-record, ebdb-auto-notes): Remove these
functions, the whole thing was too convoluted. There was no way to
only run the rules once, and why would you want to run them multiple
times?
---
ebdb-mua.el | 233 ------------------------------------------------------------
1 file changed, 233 deletions(-)
diff --git a/ebdb-mua.el b/ebdb-mua.el
index 3fff1ea..9c66e12 100644
--- a/ebdb-mua.el
+++ b/ebdb-mua.el
@@ -411,140 +411,6 @@ are not \"noticed\", nor is the timestamp updated."
(widget-group-match widget
(widget-apply widget :value-to-internal value)))
-(defvar ebdb-auto-notes-rules-expanded nil
- "Expanded `ebdb-auto-notes-rules'.") ; Internal variable
-
-(defcustom ebdb-auto-notes-rules nil
- "List of rules for adding notes to records of mail addresses of messages.
-This automatically annotates the EBDB record of the sender or recipient
-of a message based on the value of a header such as the Subject header.
-This requires that `ebdb-notice-mail-hook' contains `ebdb-auto-notes'
-and that the record already exists or `ebdb-update-records-p' returns such that
-the record will be created. Messages matching
`ebdb-auto-notes-ignore-messages'
-are ignored.
-
-The elements of this list are
-
- (FROM-TO HEADER ANNOTATE ...)
- (HEADER ANNOTATE ...)
-
-FROM-TO is a list of headers and/or header classes as in
`ebdb-message-headers'.
-The record corresponding to a mail address of a message is considered for
-annotation if this mail address was found in a header matching FROM-TO.
-If FROM-TO is missing or t, records for each mail address are considered
-irrespective of where the mail address was found in a message.
-
-HEADER is a message header that is considered for generating the annotation.
-
-ANNOTATE may take the following values:
-
- (REGEXP . STRING) [this is equivalent to (REGEXP notes STRING)]
- (REGEXP FIELD STRING)
- (REGEXP FIELD STRING REPLACE)
-
-REGEXP must match the value of HEADER for generating an annotation.
-However, if the value of HEADER also matches an element of
-`ebdb-auto-notes-ignore-headers' no annotation is generated.
-
-The annotation will be added to FIELD of the respective record.
-FIELD defaults to `ebdb-default-user-field'.
-
-STRING defines a replacement for the match of REGEXP in the value of HEADER.
-It may contain \\& or \\N specials used by `replace-match'.
-The resulting string becomes the annotation.
-If STRING is an integer N, the Nth matching subexpression is used.
-If STRING is a function, it will be called with one arg, the value of HEADER.
-The return value (which must be a string) is then used.
-
-If REPLACE is t, the resulting string replaces the old contents of FIELD.
-If it is nil, the string is appended to the contents of FIELD (unless the
-annotation is already part of the content of field).
-
-For example,
-
- ((\"To\" (\"address@hidden" . \"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 records corresponding to anyone you get mail from via one of the VM
-mailing lists.
-
-If multiple clauses match the message, all of the corresponding strings
-will be added.
-
-See also variables `ebdb-auto-notes-ignore-messages' and
-`ebdb-auto-notes-ignore-headers'.
-
-For speed-up, the function `ebdb-auto-notes' actually use expanded rules
-stored in the internal variable `ebdb-auto-notes-rules-expanded'.
-If you change the value of `ebdb-auto-notes-rules' outside of customize,
-set `ebdb-auto-notes-rules-expanded' to nil, so that the expanded rules
-will be re-evaluated."
- :group 'ebdb-mua
- :set (lambda (symbol value)
- (set-default symbol value)
- (setq ebdb-auto-notes-rules-expanded nil))
- :type '(repeat
- (ebdb-alist-with-header
- (repeat (choice
- (const sender)
- (const recipients)))
- (string :tag "Header name")
- (repeat (choice
- (cons :tag "Value Pair"
- (regexp :tag "Regexp to match on header value")
- (string :tag "String for notes if regexp matches"))
- (list :tag "Replacement list"
- (regexp :tag "Regexp to match on header value")
- (choice :tag "Record field"
- (const notes :tag "Notes")
- (const organization :tag "Organization")
- (symbol :tag "Other field class"))
- (choice :tag "Regexp match"
- (string :tag "Replacement string")
- (integer :tag "Subexpression match")
- (function :tag "Callback Function"))
- (choice :tag "Replace previous contents"
- (const :tag "No" nil)
- (const :tag "Yes" t))))))))
-
-(defcustom ebdb-auto-notes-ignore-messages nil
- "List of rules for ignoring entire messages in `ebdb-auto-notes'.
-The elements may have the following values:
- a function This function is called with one arg, the record
- that would be annotated.
- Ignore this message if the function returns non-nil.
- This function may use `ebdb-update-records-address'.
- (HEADER . REGEXP) Ignore messages where HEADER matches REGEXP.
- For example, (\"From\" . ebdb-user-mail-address-re)
- disables any recording of notes for mail addresses
- found in messages coming from yourself, see
- `ebdb-user-mail-address-re'.
-See also `ebdb-auto-notes-ignore-headers'."
- :group 'ebdb-mua
- :type '(repeat (cons
- (string :tag "Header name")
- (regexp :tag "Regexp to match on header value"))))
-
-(defcustom ebdb-auto-notes-ignore-headers nil
- "Alist of headers and regexps to ignore in `ebdb-auto-notes'.
-Each element is of the form
-
- (HEADER . REGEXP)
-
-For example,
-
- (\"Organization\" . \"^Gatewayed from\\\\\|^Source only\")
-
-will exclude the phony `Organization:' headers in GNU mailing-lists
-gatewayed to gnu.* newsgroups.
-See also `ebdb-auto-notes-ignore-messages'."
- :group 'ebdb-mua
- :type '(repeat (cons
- (string :tag "Header name")
- (regexp :tag "Regexp to match on header value"))))
-
(defcustom ebdb-mua-pop-up t
"If non-nil, display an auto-updated EBDB window while using a MUA."
:group 'ebdb-mua
@@ -1188,20 +1054,6 @@ bind `ebdb-message-all-addresses' to ALL."
;; `ebdb-mua-edit-field' is more explicit: It displays the records
;; as well as the current content of the field that gets edited.
-;; In principle, this function can be used not only with MUAs.
-(defun ebdb-annotate-record (record annotation &optional field _replace)
- "In RECORD add an ANNOTATION to field FIELD.
-FIELD defaults to `ebdb-annotate-field'.
-If REPLACE is non-nil, ANNOTATION replaces the content of FIELD.
-If ANNOTATION is an empty string and REPLACE is non-nil, delete FIELD."
- (if (memq field '(name firstname lastname phone address))
- (error "Field `%s' illegal" field))
- (setq annotation (ebdb-string-trim annotation))
- (cond ((memq field '(affix organization mail aka))
- (setq annotation (list annotation)))
- ((not field) (setq field ebdb-annotate-field)))
- (ebdb-record-change-field record field annotation))
-
(defun ebdb-mua-annotate-field-interactive ()
"Interactive specification for `ebdb-mua-annotate-sender' and friends."
(let ((field (if (eq 'all-fields ebdb-annotate-field)
@@ -1331,91 +1183,6 @@ See `ebdb-mua-display-records' and friends for
interactive commands."
(ebdb-undisplay-records)))
records))
-;;;###autoload
-(defun ebdb-auto-notes (record)
- "Automatically annotate RECORD based on the headers of the current message.
-See the variables `ebdb-auto-notes-rules', `ebdb-auto-notes-ignore-messages'
-and `ebdb-auto-notes-ignore-headers'.
-For use as an element of `ebdb-notice-record-hook'."
- ;; This code re-evaluates the annotations each time a message is viewed.
- ;; It would be faster if we could somehow store (permanently?) that we
- ;; have already annotated a message.
- (let ((case-fold-search t))
- (unless ;; check the ignore-messages pattern
- (let ((ignore-messages ebdb-auto-notes-ignore-messages)
- ignore rule)
- (while (and (not ignore) (setq rule (pop ignore-messages)))
- (if (cond ((functionp rule)
- ;; RULE may use `ebdb-update-records-address'
- (funcall rule record))
- ((symbolp rule)
- (eq rule (nth 4 ebdb-update-records-address)))
- ((eq 1 (safe-length rule))
- (ebdb-message-header-re (car rule) (cdr rule)))
- ((eq 2 (safe-length rule))
- (and (eq (car rule) (nth 4 ebdb-update-records-address))
- (ebdb-message-header-re (nth 1 rule) (nth 2
rule)))))
- (setq ignore t)))
- ignore)
-
- ;; For speed-up expanded rules are stored in
`ebdb-auto-notes-rules-expanded'.
- (when (and ebdb-auto-notes-rules
- (not ebdb-auto-notes-rules-expanded))
- (let (expanded mua from-to header)
- (dolist (rule ebdb-auto-notes-rules)
- ;; Which MUA do we want?
- (if (or (stringp (car rule))
- (stringp (nth 1 rule)))
- (setq mua t)
- (setq mua (if (symbolp (car rule)) (listp (car rule)) (car rule))
- rule (cdr rule)))
- ;; Which FROM-TO headers do we want?
- (if (stringp (car rule))
- (setq from-to t)
- (setq from-to (car rule)
- rule (cdr rule)))
- (setq header (car rule))
- (let (string field replace elt-e)
- (dolist (elt (cdr rule))
- (if (consp (setq string (cdr elt)))
- (setq field (car string) ; (REGEXP FIELD-NAME STRING
REPLACE)
- replace (nth 2 string) ; perhaps nil
- string (nth 1 string))
- ;; else it's simple (REGEXP . STRING)
- (setq field ebdb-default-user-field
- replace nil))
- (push (list (car elt) field string replace) elt-e))
- (push (append (list mua from-to header) (nreverse elt-e))
expanded)))
- (setq ebdb-auto-notes-rules-expanded (nreverse expanded))))
-
- (dolist (rule ebdb-auto-notes-rules-expanded)
- (let ((mua (car rule)) (from-to (nth 1 rule)) (header (nth 2 rule))
- hd-val string annotation)
- (when (and (or (eq mua t)
- (memq (nth 4 ebdb-update-records-address) mua))
- (or (eq from-to t)
- (member-ignore-case
- (nth 2 ebdb-update-records-address) from-to)
- (memq (nth 3 ebdb-update-records-address) from-to))
- (setq hd-val (ebdb-message-header header)))
- (dolist (elt (nthcdr 3 rule))
- (when (and (string-match (car elt) hd-val)
- (let ((ignore (cdr (assoc-string
- header
- ebdb-auto-notes-ignore-headers
t))))
- (not (and ignore (string-match ignore hd-val)))))
- (setq string (nth 2 elt)
- annotation
- (cond ((integerp string)
- (match-string string hd-val))
- ((stringp string)
- (replace-match string nil nil hd-val))
- ((functionp string)
- (funcall string hd-val))
- (t (error "Illegal value: %s" string))))
- (ebdb-annotate-record record annotation
- (nth 1 elt) (nth 3 elt))))))))))
-
;;; Mark EBDB records in the MUA summary buffer
(defun ebdb-mua-summary-unify (address)
- [elpa] externals/ebdb f466e6e 342/350: Add some country name "shorthands", (continued)
- [elpa] externals/ebdb f466e6e 342/350: Add some country name "shorthands", Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 26ee1cb 330/350: Refactor snarfing, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 6cc67a7 315/350: Add instructions for writing i18n libraries to manual, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb c11ef0e 334/350: Rename ebdb-message-header to ebdb-mua-message-header, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 7dd034d 349/350: Fix up record citation, bind a command in EBDB mode, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 615ed9a 326/350: Prefix arg to article snarfing only snarfs signature, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 8776051 341/350: Changes to manual and README, reflecting EBDB's move to ELPA, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 80ce330 340/350: Remove libraries that will live in separate packages, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb bc3c712 332/350: Move "Writing Internationalization Libraries" in manual, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 3210ad7 338/350: Compiler-inspired fixes version 443992, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb d7bc0c9 284/350: Drop the whole auto-notes thing,
Eric Abrahamsen <=
- [elpa] externals/ebdb b25edb9 002/350: Squash "prep" branch, push to Github, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 4bdf47e 263/350: Get notice routine working, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 9ce8e30 310/350: Check db editable before reading new record, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb a4d11f5 293/350: Modify ebdb-mua-yank-cc to yank from any EBDB buffer, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 7caa1b4 308/350: Fix bug in reading mail alias fields, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb f987d46 305/350: Fix buffer modification call, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb c890b24 296/350: Mention mail aliases in the manual, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb be9464d 319/350: When merging organization records, possibly merge role fields, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 969c44c 303/350: Small tweaks to README, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 1df6476 322/350: Remove stray code, Eric Abrahamsen, 2017/08/14