[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb 1c4fadd 080/350: Make ebdb-record-name a get-or-ge
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb 1c4fadd 080/350: Make ebdb-record-name a get-or-get-and-set operation |
Date: |
Mon, 14 Aug 2017 11:46:07 -0400 (EDT) |
branch: externals/ebdb
commit 1c4fadd92199f18ed5503e4e1c20aedd7ceeb964
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Make ebdb-record-name a get-or-get-and-set operation
* ebdb.el (ebdb-record-name): If the cached string isn't there,
generate it.
(ebdb-init-record): Don't do the caching here.
(ebdb-string): This method for records should make use of
`ebdb-record-name'.
This ought to work okay. It might shift a tiny bit of user wait time
from load/initialize, to the first search. Probably negligible.
---
ebdb-com.el | 2 +-
ebdb.el | 18 ++++++++++--------
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/ebdb-com.el b/ebdb-com.el
index 5572f62..4a805a1 100644
--- a/ebdb-com.el
+++ b/ebdb-com.el
@@ -589,7 +589,7 @@ This happens in addition to any pre-defined indentation of
STRING."
;; We don't actually ask the name field to format itself, just use
;; the cached canonical name string. We do add the field to the
;; string as a text property, however.
- (insert (slot-value (ebdb-record-cache record) 'name-string))
+ (insert (ebdb-record-name record))
(add-text-properties (line-beginning-position) (point)
(list 'ebdb-record record-class))
(add-text-properties step (point)
diff --git a/ebdb.el b/ebdb.el
index cceccb7..117f3e6 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -1988,7 +1988,13 @@ only return fields that are suitable for user editing.")
;; TODO: rename this to `ebdb-record-name-string', it's confusing.
(cl-defmethod ebdb-record-name ((record ebdb-record))
- (slot-value (ebdb-record-cache record) 'name-string))
+ "Get or set-and-get the cached name string of RECORD."
+ (let ((cached (slot-value (ebdb-record-cache record) 'name-string))
+ str)
+ (or cached
+ (and (slot-value record 'name)
+ (setf (slot-value (ebdb-record-cache record) 'name-string)
+ (ebdb-string (slot-value record 'name)))))))
(cl-defmethod ebdb-record-alt-names ((record ebdb-record))
(slot-value (ebdb-record-cache record) 'alt-names))
@@ -2244,7 +2250,7 @@ priority."
(cl-defmethod ebdb-string ((record ebdb-record-person))
"Return a readable string label for RECORD."
- (slot-value (ebdb-record-cache record) 'name-string))
+ (ebdb-record-name record))
(cl-defmethod ebdb-read ((class (subclass ebdb-record-person)) &optional slots)
"Read the name slot for a \"person\" record."
@@ -2253,9 +2259,7 @@ priority."
class (plist-put slots :name name))))
(cl-defmethod ebdb-init-record ((record ebdb-record-person))
- (let ((name (slot-value record 'name)))
- (ebdb-init-field name record)
- (setf (slot-value (ebdb-record-cache record) 'name-string) (ebdb-string
name)))
+ (ebdb-init-field (slot-value record 'name) record)
(dolist (aka (slot-value record 'aka))
(ebdb-init-field aka record))
(dolist (relation (slot-value record 'relations))
@@ -2470,8 +2474,6 @@ Currently only works for mail fields."
(cl-defmethod ebdb-init-record ((record ebdb-record-organization))
(let ((name (slot-value record 'name)))
(ebdb-init-field name record)
- (setf (slot-value (ebdb-record-cache record) 'name-string)
- (ebdb-string name))
(cl-call-next-method)))
(cl-defmethod ebdb-delete-record ((org ebdb-record-organization) &optional _db
unload)
@@ -2490,7 +2492,7 @@ Currently only works for mail fields."
(cl-defmethod ebdb-string ((record ebdb-record-organization))
"Return a string representation of RECORD."
- (slot-value (ebdb-record-cache record) 'name-string))
+ (ebdb-record-name record))
(cl-defmethod ebdb-read ((class (subclass ebdb-record-organization)) &optional
slots)
(let ((name (ebdb-read 'ebdb-field-name-simple slots
- [elpa] externals/ebdb e159e3a 070/350: Yet another method definition in the wrong place, (continued)
- [elpa] externals/ebdb e159e3a 070/350: Yet another method definition in the wrong place, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 38db90d 063/350: Improve ebdb-copy-mail-as-kill, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb f397e3d 092/350: Add missing require statement, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb ae23a9b 095/350: Fix to ebdb-parse with field-name-simple, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 6197578 107/350: Change default separator of org tags, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb f1edaed 075/350: Prevent eieio-persistent-save from changing db file slot, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb c7d378b 071/350: Autoload eieio-customize-object, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 31bf2cf 117/350: No, that's not the proper way to create a &context catchall, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb a2de313 110/350: Install ebdb-save as a kill-emacs-hook, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb ab1480b 078/350: Remove ebdb-this-buffer-name, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 1c4fadd 080/350: Make ebdb-record-name a get-or-get-and-set operation,
Eric Abrahamsen <=
- [elpa] externals/ebdb 9aab682 088/350: Add a generic for ebdb-db-editable, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 4263d5b 090/350: Fix the reload process, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb dd4f251 098/350: Split off ebdb-record-field for field classes, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 8c20202 103/350: Update company-ebdb to work with new search style, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 5ec40d5 102/350: Add sections on searching and record marking to manual, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 7da77f4 089/350: Expand ebdb-with-record-edits, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 8312ea4 109/350: Allow company-ebdb to work in notmuch-message-mode as well, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb dcb7dbc 104/350: Change default keybindings in Gnus, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb 9ac0f0f 111/350: Searching on empty strings should happen in field-search method, Eric Abrahamsen, 2017/08/14
- [elpa] externals/ebdb c43e39b 097/350: Another round of compiler-inspired fixes, Eric Abrahamsen, 2017/08/14