[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb 311c1f2 4/6: Turn ebdb-add-to-list into a macro th
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb 311c1f2 4/6: Turn ebdb-add-to-list into a macro that calls cl-pushnew |
Date: |
Tue, 10 Jul 2018 16:20:18 -0400 (EDT) |
branch: externals/ebdb
commit 311c1f24b7c9e3accdca2dedd9455dc1382caef1
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Turn ebdb-add-to-list into a macro that calls cl-pushnew
* ebdb.el (ebdb-add-to-list): This function only existed to behave
like `add-to-list', except ignoring a nil element argument. It's now
a macro that uses the cl-pushnew macro, so the whole thing can get
compiled away as much as possible -- there might be some minor
speedups at load time.
---
ebdb.el | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/ebdb.el b/ebdb.el
index a0c1975..eeacace 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -1035,7 +1035,7 @@ process."
(cl-defmethod ebdb-init-field ((field ebdb-field-labeled) _record)
"Add FIELD's label to its class label list."
(let ((label-var (slot-value field 'label-list)))
- (ebdb-add-to-list label-var (slot-value field 'object-name))
+ (ebdb-add-to-list (symbol-value label-var) (slot-value field 'object-name))
(cl-call-next-method)))
(cl-defmethod eieio-object-name-string ((field ebdb-field-labeled))
@@ -1579,12 +1579,12 @@ Primary sorts before normal sorts before defunct."
(cl-defmethod ebdb-init-field ((address ebdb-field-address) _record)
(with-slots (object-name streets locality region postcode country) address
(dolist (s streets)
- (ebdb-add-to-list 'ebdb-street-list s))
- (ebdb-add-to-list 'ebdb-locality-list locality)
+ (ebdb-add-to-list ebdb-street-list s))
+ (ebdb-add-to-list ebdb-locality-list locality)
(when (stringp country)
- (ebdb-add-to-list 'ebdb-country-list country))
- (ebdb-add-to-list 'ebdb-region-list region)
- (ebdb-add-to-list 'ebdb-postcode-list postcode)))
+ (ebdb-add-to-list ebdb-country-list country))
+ (ebdb-add-to-list ebdb-region-list region)
+ (ebdb-add-to-list ebdb-postcode-list postcode)))
(cl-defmethod ebdb-read ((class (subclass ebdb-field-address)) &optional slots
obj)
(let ((streets
@@ -4447,17 +4447,10 @@ REQUIRE-MATCH have the same meaning as in
`completing-read'."
(signal 'ebdb-empty (list prompt))
string)))))
-(defun ebdb-add-to-list (list-var element)
+(defmacro ebdb-add-to-list (list-var element)
"Add ELEMENT to the value of LIST-VAR if it isn't there yet and non-nil.
-The test for presence of ELEMENT is done with `equal'.
-The return value is the new value of LIST-VAR."
- ;; Unlike `add-to-list' this ignores ELEMENT if it is nil.
- ;; TO DO: turn this into a faster macro so that we can abandon calls
- ;; of add-to-list.
- (if (or (not element)
- (member element (symbol-value list-var)))
- (symbol-value list-var)
- (set list-var (cons element (symbol-value list-var)))))
+The test for presence of ELEMENT is done with `equal'."
+ `(when ,element (cl-pushnew ,element ,list-var :test #'equal)))
;; FIXME: Get rid of this add-job and eval-spec stuff.
(defsubst ebdb-add-job (spec record string)
- [elpa] externals/ebdb updated (60f8828 -> dbc96c3), Eric Abrahamsen, 2018/07/10
- [elpa] externals/ebdb b8a1e70 2/6: Remove bogus ebdb-mode-hook defcustom, Eric Abrahamsen, 2018/07/10
- [elpa] externals/ebdb 5624e58 1/6: Use apply instead of eval on phone number formatting, Eric Abrahamsen, 2018/07/10
- [elpa] externals/ebdb 1d1d944 3/6: Change write-contents-functions to ebdb-save-ebdb, Eric Abrahamsen, 2018/07/10
- [elpa] externals/ebdb 311c1f2 4/6: Turn ebdb-add-to-list into a macro that calls cl-pushnew,
Eric Abrahamsen <=
- [elpa] externals/ebdb dbc96c3 6/6: Fix to "stop using eieio-named", Eric Abrahamsen, 2018/07/10
- [elpa] externals/ebdb 47e6be2 5/6: Stop using eieio-named as a mixin to provide labelling, Eric Abrahamsen, 2018/07/10