[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb bbe407e 257/350: Code tweaks and re-arrangments
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb bbe407e 257/350: Code tweaks and re-arrangments |
Date: |
Mon, 14 Aug 2017 11:46:49 -0400 (EDT) |
branch: externals/ebdb
commit bbe407eaafaff072e6833b1fc5bc5a0175265ffe
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Code tweaks and re-arrangments
Inspired by the compiler, and tumashu's bug report. Make sure all
functions and variables are required, autoloaded, defvar'd, or
otherwise available.
Fixes #41.
* ebdb.el (ebdb-canonicalize-mail-function,
ebdb-message-clean-name-function): Biggest change is that these two
customization options have been moved here from ebdb-mua.el, and
switched to the 'ebdb-utilities defgroup. They aren't MUA
specific (we should use them in snarfing, for one thing), and the
functions they point to by default are already in ebdb.el.
---
ebdb-com.el | 5 ++---
ebdb-mua.el | 66 ++++++++++++++++++++++-------------------------------------
ebdb-snarf.el | 2 +-
ebdb.el | 23 ++++++++++++++++++++-
4 files changed, 50 insertions(+), 46 deletions(-)
diff --git a/ebdb-com.el b/ebdb-com.el
index 10f1d4c..ad341e2 100644
--- a/ebdb-com.el
+++ b/ebdb-com.el
@@ -27,7 +27,6 @@
(require 'ebdb)
(require 'ebdb-format)
-(require 'ebdb-snarf)
(require 'mailabbrev)
(eval-and-compile
@@ -2575,7 +2574,7 @@ of all of these people."
(ebdb-dwim-mail (if (stringp (car e))
(ebdb-gethash e 'uuid)
(car e))
- (second e)))
+ (cl-second e)))
(cdr entry) ", "))
f-alias)
@@ -2633,7 +2632,7 @@ actions."
(cdar actions))
(let ((alst (mapcar
(lambda (a)
- (cons (first a) (cdr a)))
+ (cons (cl-first a) (cdr a)))
actions)))
(cdr
(assoc (completing-read "Action: " alst)
diff --git a/ebdb-mua.el b/ebdb-mua.el
index 5ad668f..f859411 100644
--- a/ebdb-mua.el
+++ b/ebdb-mua.el
@@ -45,9 +45,13 @@
(require 'ebdb)
(require 'ebdb-com)
+(autoload 'ebdb-snarf "ebdb-snarf")
+
(eval-and-compile
(autoload 'mail-decode-encoded-word-string "mail-parse"))
+(defvar message-alternative-emails)
+
;;; MUA interface
(defvar ebdb-offer-to-create nil
@@ -244,7 +248,8 @@ accordingly."
(regexp-opt (slot-value
(ebdb-record-cache self-rec)
'mail-canon)))))
- ((eq ebdb-user-mail-address-re 'message)
+ ((and (eq ebdb-user-mail-address-re 'message)
+ (boundp 'message-alternative-emails))
(setq ebdb-user-mail-address-re
message-alternative-emails))
(t ebdb-user-mail-address-re)))
@@ -315,18 +320,6 @@ See also `ebdb-ignore-redundant-mails'."
(function :tag "Function for analyzing name handling")
(regexp :tag "If the new address matches this regexp ignore
it.")))
-(defcustom ebdb-canonicalize-mail-function nil
- "If non-nil, it should be a function of one arg: a mail address string.
-When EBDB \"notices\" a message, the corresponding mail addresses are passed
-to this function first. It acts as a kind of \"filter\" to transform
-the mail addresses before they are compared against or added to the database.
-See `ebdb-canonicalize-mail-1' for a more complete example.
-If this function returns nil, EBDB assumes that there is no mail address.
-
-See also `ebdb-ignore-redundant-mails'."
- :group 'ebdb-mua
- :type 'function)
-
(defcustom ebdb-ignore-redundant-mails 'query
"How to handle redundant mail addresses for existing EBDB records.
For example, \"address@hidden" is redundant w.r.t. \"address@hidden".
@@ -352,15 +345,6 @@ See also `ebdb-add-mails' and
`ebdb-canonicalize-mail-function'."
(number :tag "Number of seconds to display redundant
addresses")
(function :tag "Function for handling redundant mail
addresses")
(regexp :tag "If the new address matches this regexp never
ignore it.")))
-(define-obsolete-variable-alias 'ebdb-canonicalize-redundant-mails
- 'ebdb-ignore-redundant-mails)
-
-(defcustom ebdb-message-clean-name-function 'ebdb-message-clean-name-default
- "Function to clean up the name in the header of a message.
-It takes one argument, the name as extracted by
-`mail-extract-address-components'."
- :group 'ebdb-mua
- :type 'function)
(defcustom ebdb-message-mail-as-name t
"If non-nil use mail address of message as fallback for name of new records."
@@ -627,6 +611,25 @@ Currently no other MUAs support this EBDB feature."
(when (and val (string-match regexp val))
(throw 'done t))))
+(defsubst ebdb-mua-check-header (header-type address-parts &optional invert)
+ (let ((rest (if invert
+ ebdb-ignore-header-alist
+ ebdb-accept-header-alist))
+ h-type)
+ (catch 'done
+ (dolist (elt rest)
+ (setq h-type (car elt))
+ (cond ((and (eq h-type 'subject)
+ (eq header-type 'subject))
+ (when (ebdb-message-header-re "Subject" (cdr elt))
+ (throw 'done (if invert nil t))))
+ ((or (eq h-type header-type)
+ (and (eq h-type 'any)
+ (memq header-type '(sender recipients))))
+ (when (string-match-p (cdr elt) (cl-second address-parts))
+ (throw 'done (if invert nil t))))))
+ (throw 'done t))))
+
(defun ebdb-mua-test-headers (header-type address-parts &optional
ignore-address)
"Decide if the address in ADDRESS-PARTS should be ignored or
acted upon. Return t if the header \"passes\".
@@ -656,25 +659,6 @@ variables `ebdb-user-mail-address-re',
(and (ebdb-mua-check-header header-type address-parts)
(ebdb-mua-check-header header-type address-parts t)))))))
-(defsubst ebdb-mua-check-header (header-type address-parts &optional invert)
- (let ((rest (if invert
- ebdb-ignore-header-alist
- ebdb-accept-header-alist))
- h-type)
- (catch 'done
- (dolist (elt rest)
- (setq h-type (car elt))
- (cond ((and (eq h-type 'subject)
- (eq header-type 'subject))
- (when (ebdb-message-header-re "Subject" (cdr elt))
- (throw 'done (if invert nil t))))
- ((or (eq h-type header-type)
- (and (eq h-type 'any)
- (memq header-type '(sender recipients))))
- (when (string-match-p (cdr elt) (second address-parts))
- (throw 'done (if invert nil t))))))
- (throw 'done t))))
-
;; How are you supposed to do the &context arglist for a defgeneric?
(cl-defgeneric ebdb-message-header (header)
"Get value of HEADER for the mua keyed to major-mode.")
diff --git a/ebdb-snarf.el b/ebdb-snarf.el
index b05c735..6b238f1 100644
--- a/ebdb-snarf.el
+++ b/ebdb-snarf.el
@@ -39,7 +39,7 @@
;;; Code:
-(require 'ebdb)
+(require 'ebdb-com)
(defcustom ebdb-snarf-routines
'((ebdb-field-mail
"[[:blank:]([<\"]*\\([^[:space:]\":\n<address@hidden:[:space:])>\"\n]+\\)"))
diff --git a/ebdb.el b/ebdb.el
index dbf07a7..9c89fdc 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -4221,9 +4221,30 @@ If the domain part of a mail address matches this
regexp, the domain
is replaced by the substring that actually matched this address.
Used by `ebdb-canonicalize-mail-1'. See also `ebdb-ignore-redundant-mails'."
- :group 'ebdb-mua
+ :group 'ebdb-utilities
:type '(regexp :tag "Regexp matching sites"))
+
+(defcustom ebdb-canonicalize-mail-function nil
+ "If non-nil, it should be a function of one arg: a mail address string.
+When EBDB is parsing mail addresses, the corresponding mail
+addresses are passed to this function first. It acts as a kind
+of \"filter\" to transform the mail addresses before they are
+compared against or added to the database. See
+`ebdb-canonicalize-mail-1' for a more complete example. If this
+function returns nil, EBDB assumes that there is no mail address.
+
+See also `ebdb-ignore-redundant-mails'."
+ :group 'ebdb-utilities
+ :type 'function)
+
+(defcustom ebdb-message-clean-name-function 'ebdb-message-clean-name-default
+ "Function to clean up the name in the header of a message.
+It takes one argument, the name as extracted by
+`mail-extract-address-components'."
+ :group 'ebdb-utilities
+ :type 'function)
+
(defun ebdb-canonicalize-mail-1 (address)
"Example of `ebdb-canonicalize-mail-function'.
However, this function is too specific to be useful for the general user.
- [elpa] externals/ebdb 01262e3 277/350: Mark EBDB buffers as modified after edits, (continued)
- [elpa] externals/ebdb 01262e3 277/350: Mark EBDB buffers as modified after edits, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb cc83f62 197/350: Add protection around ebdb-record-uuid, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 4f3db7f 195/350: Save match data around ebdb-parse-i18n, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb fcf0702 275/350: Mark EBDB buffers as unmodified after save, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 88f5e12 261/350: Fill out functionality of gnorb messages field, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb a81769c 272/350: Allow custom hash predicates, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb e80753a 264/350: Change ebdb-record-change-name to accept strings, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb d3e1485 283/350: Reinstate the notice record hook, and move notice-record method, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb d8bc159 290/350: Fairly embarrassing oversight in setting ebdb buffers modified, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb afe5495 279/350: Adjust indentation of multi-line field values, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb bbe407e 257/350: Code tweaks and re-arrangments,
Eric Abrahamsen <=
- [elpa] externals/ebdb 727eddb 262/350: Change databases' buffer-char slot into actual character, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 5362b12 291/350: require pyim, for chinese-pyim has been renamed to pyim (#45), Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb f62f15f 282/350: Pop up empty *EBDB* buffer for users with no records, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb f3f9f37 292/350: Move, rename and bind ebdb-mail-yank, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 89467fc 258/350: Don't wrap cl-print-object in eval-when-compile, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 5e7a0d6 266/350: Change arg order of record-insert|delete-field, refactor, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 75de073 314/350: Let ebdb-complete can grab string which similar "guix-devel" (#46), Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb dbf980e 288/350: Create specific keymap for using EBDB in MUAs, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 4a35635 297/350: Mention vCard export support in manual, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 13f32ef 304/350: Fix propertize call when formatting field values, Eric Abrahamsen, 2017/08/14