[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ebdb 9102219 7/9: Re-work ebdb-records-cite
From: |
Eric Abrahamsen |
Subject: |
[elpa] externals/ebdb 9102219 7/9: Re-work ebdb-records-cite |
Date: |
Sun, 18 Feb 2018 22:56:26 -0500 (EST) |
branch: externals/ebdb
commit 9102219eb28c1b02af4aa93dc4f72ae1706fbb3c
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>
Re-work ebdb-records-cite
* ebdb.el (ebdb-records-cite): I was trying to be too clever combining
:around methods with &context specializers, and generally tripping
over my own feet. This version has more duplicate code, but behaves
correctly.
---
ebdb.el | 121 +++++++++++++++++++++++++++++-----------------------------------
1 file changed, 54 insertions(+), 67 deletions(-)
diff --git a/ebdb.el b/ebdb.el
index b3cf84c..356b90c 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -4980,79 +4980,66 @@ inserting it."
(cl-defgeneric ebdb-records-cite (style records)
"Return mode-appropriate mail strings for RECORDS.
STYLE is a symbol, one of 'inline or 'list. This is interpreted
-differently by different major modes.
+differently by different major modes; the default looks like
+\"Firstname Lastname <address@hidden>\".
This is a generic function that dispatches on the value of
`major-mode'. It only inserts names and mail addresses.")
+(cl-defmethod ebdb-records-cite ((_style (eql list))
+ (records list))
+ (mapconcat (lambda (pair)
+ (format "%s <%s>"
+ ;; TODO: Wrap non-ASCII record names in double
+ ;; quotes?
+ (ebdb-string (car pair))
+ (ebdb-string (cdr pair))))
+ records "\n"))
+
(cl-defmethod ebdb-records-cite ((_style (eql inline))
+ (records list))
+ (mapconcat (lambda (pair)
+ (format "%s <%s>"
+ (ebdb-string (car pair))
+ (ebdb-string (cdr pair))))
+ records ", "))
+
+(cl-defmethod ebdb-records-cite ((_style (eql list))
+ (records list)
+ &context (major-mode org-mode))
+ (mapconcat (lambda (pair)
+ (format "- [[mailto:%s][%s]]"
+ (slot-value (cdr pair) 'mail)
+ (ebdb-string (car pair))))
+ records "\n"))
+
+(cl-defmethod ebdb-records-cite ((_style (eql inline))
+ (records list)
+ &context (major-mode org-mode))
+ (mapconcat (lambda (pair)
+ (format "[[mailto:%s][%s]]"
+ (slot-value (cdr pair) 'mail)
+ (ebdb-string (car pair))))
+ records ", "))
+
+(cl-defmethod ebdb-records-cite ((_style (eql list))
(records list)
- &context (major-mode message-mode))
- (when records
- (mapcar (lambda (pair)
- (format "%s <%s>"
- (ebdb-string (car pair))
- (ebdb-string (cdr pair))))
- records)))
-
-(cl-defmethod ebdb-records-cite :around ((_style (eql inline))
- (_records list)
- &context (major-mode message-mode))
- (let ((lst (cl-call-next-method)))
- (mapconcat #'identity lst ", ")))
-
-
-(cl-defmethod ebdb-records-cite :around ((_style (eql list))
- (_records list)
- &context (major-mode message-mode))
- (let ((lst (cl-call-next-method)))
- (mapconcat #'identity lst "\n")))
-
-(cl-defmethod ebdb-records-cite :around ((_style (eql list))
- (_records list)
- &context (major-mode org-mode))
- (let ((list (cl-call-next-method)))
- (mapconcat (lambda (elt)
- (format "- %s" elt))
- list "\n")))
-
-(cl-defmethod ebdb-records-cite :around ((_style (eql inline))
- (_records list)
- &context (major-mode org-mode))
- (let ((lst (cl-call-next-method)))
- (mapconcat #'identity lst " ")))
-
-(cl-defmethod ebdb-records-cite
- (_style (records list) &context (major-mode org-mode))
- "Insert RECORDS as a list of org links."
- (mapcar (lambda (pair)
- (format "[[mailto:%s][%s]]"
- (slot-value (cdr pair) 'mail)
- (ebdb-string (car pair))))
- records))
-
-(cl-defmethod ebdb-records-cite :around ((_style (eql list))
- (_records list)
- &context (major-mode html-mode))
- (let ((list (cl-call-next-method)))
- (mapconcat (lambda (l)
- (format "<li>%s</li>" l))
- list "\n")))
-
-(cl-defmethod ebdb-records-cite :around ((_style (eql inline))
- (_records list)
- &context (major-mode html-mode))
- (let ((list (cl-call-next-method)))
- (mapconcat #'identity list " ")))
-
-(cl-defmethod ebdb-records-cite
- (_style (records list) &context (major-mode html-mode))
- (mapcar
- (lambda (pair)
- (format "<a href=\"mailto:%s>%s</a>"
- (slot-value (cdr pair) 'mail)
- (ebdb-string (car pair))))
- records))
+ &context (major-mode html-mode))
+ (mapconcat (lambda (pair)
+ (format "<li><a href=\"mailto:%s>%s</a></li>"
+ (slot-value (cdr pair) 'mail)
+ (ebdb-string (car pair))))
+ records "\n"))
+
+(cl-defmethod ebdb-records-cite ((_style (eql inline))
+ (records list)
+ &context (major-mode html-mode))
+ (mapconcat (lambda (pair)
+ (format "<a href=\"mailto:%s>%s</a>"
+ (slot-value (cdr pair) 'mail)
+ (ebdb-string (car pair))))
+ records ", "))
+
;;; Loading and saving EBDB
- [elpa] externals/ebdb updated (5735686 -> 2c71ef9), Eric Abrahamsen, 2018/02/18
- [elpa] externals/ebdb c07f50b 2/9: Get rid of ebdb-version, Eric Abrahamsen, 2018/02/18
- [elpa] externals/ebdb 6395a75 1/9: Manipulation of ebdb-db-list *still* in the wrong place, Eric Abrahamsen, 2018/02/18
- [elpa] externals/ebdb 4796722 3/9: Fix mail sorting, Eric Abrahamsen, 2018/02/18
- [elpa] externals/ebdb 7f51a4e 5/9: Make explicit "full" formatter, Eric Abrahamsen, 2018/02/18
- [elpa] externals/ebdb 2c71ef9 9/9: Bump EBDB version to 0.4.3, Eric Abrahamsen, 2018/02/18
- [elpa] externals/ebdb 2a25117 6/9: New option ebdb-print-object-name, Eric Abrahamsen, 2018/02/18
- [elpa] externals/ebdb 9102219 7/9: Re-work ebdb-records-cite,
Eric Abrahamsen <=
- [elpa] externals/ebdb 44cce48 8/9: Absorb helm-ebdb package, rename to ebdb-helm, Eric Abrahamsen, 2018/02/18
- [elpa] externals/ebdb 639694c 4/9: Docstring changes, Eric Abrahamsen, 2018/02/18