branch: elpa/fedi
commit 8f2cf86b96d089964570d47dbe299ab3dbf13cef
Author: marty hiatt <[email protected]>
Commit: marty hiatt <[email protected]>
factor out annotation-function for do-completing
---
fedi.el | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/fedi.el b/fedi.el
index 9b14f1ae78b..51c4af849c6 100644
--- a/fedi.el
+++ b/fedi.el
@@ -589,18 +589,24 @@ candidate's car, a string, usually its name or a handle."
(completion-extra-properties
(when list
(list :annotation-function
- (lambda (i)
- (let ((annot (nth 2 (assoc i list #'equal))))
- (concat
- (propertize " " 'display
- '(space :align-to (- right-margin 51)))
- (string-limit (car (string-lines annot)) 50)))))))
+ (lambda (cand)
+ (funcall #'fedi-annot-fun cand list)))))
(choice (when list (completing-read prompt list)))
(id (when list (nth 1 (assoc choice list #'equal)))))
(if (not list)
(user-error "No items returned")
(funcall action-fun id choice))))
+(defun fedi-annot-fun (cand list)
+ "Annotation function for `fedi-do-item-completing'.
+Given CAND, return from LIST its annotation."
+ (let ((annot (nth 2
+ (assoc cand list #'equal))))
+ (concat
+ (propertize " " 'display
+ '(space :align-to (- right-margin 51)))
+ (string-limit (car (string-lines annot)) 50))))
+
(defun fedi-response-msg (response &optional key value format-str)
"Check RESPONSE, JSON from the server, and message on success.
Used to handle server responses after the user