emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ebdb 8537076 052/350: Improvements to the gnorb-ebdb-or


From: Eric Abrahamsen
Subject: [elpa] externals/ebdb 8537076 052/350: Improvements to the gnorb-ebdb-org-tags field
Date: Mon, 14 Aug 2017 11:46:01 -0400 (EDT)

branch: externals/ebdb
commit 853707665071c38c61c1be1ea187395d2f36e1f4
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>

    Improvements to the gnorb-ebdb-org-tags field
    
    * ebdb-gnorb.el (gnorb-ebdb-org-tags): New variable holding tags seen
      by EBDB, to be combined with `org-global-tags-completion-table'.
      (ebdb-read): Use `completing-read-multiple' with the tags.
      (ebdb-init-field): Add all field's tags to `gnorb-ebdb-org-tags'.
---
 ebdb-gnorb.el | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/ebdb-gnorb.el b/ebdb-gnorb.el
index dbae6bb..b7873ca 100644
--- a/ebdb-gnorb.el
+++ b/ebdb-gnorb.el
@@ -27,6 +27,15 @@
 (cl-defstruct gnorb-ebdb-link
   subject date group id)
 
+(defvar gnorb-ebdb-org-tags nil
+  "Variable holding tags defined for EBDB records.
+
+This list is added to the result of
+`org-global-tags-completion-table' when producing a list of
+potential tags for completion.")
+
+(push '(gnorb-ebdb-field-tags ";" ";") ebdb-separator-alist)
+
 (defclass gnorb-ebdb-field-messages (ebdb-field-user)
   ((messages
     :type (list-of gnorb-ebdb-link)
@@ -46,6 +55,7 @@
   ((tags
     :type (list-of string)
     :initarg :tags
+    :custom (repeat string)
     :initform nil))
   :human-readable "gnorb tags")
 
@@ -53,8 +63,19 @@
   (ebdb-concat 'gnorb-ebdb-field-tags (slot-value field 'tags)))
 
 (cl-defmethod ebdb-read ((field (subclass gnorb-ebdb-field-tags)) &optional 
slots obj)
-  (let ((val (ebdb-read-string "Tags: " (when obj (ebdb-string obj))
-                              (org-global-tags-completion-table))))
-    (cl-call-next-method field (plist-put slots :tags (split-string val)))))
+  (let* ((crm-separator (cadr (assq 'gnorb-ebdb-field-tags 
ebdb-separator-alist)))
+        (val (completing-read-multiple
+              "Tags: "
+              (append (org-global-tags-completion-table)
+                      (when gnorb-ebdb-org-tags
+                        (mapcar #'list gnorb-ebdb-org-tags)))
+              nil nil
+              (when obj (ebdb-string obj)))))
+    (cl-call-next-method field (plist-put slots :tags val))))
+
+(cl-defmethod ebdb-init-field ((field gnorb-ebdb-field-tags) _record)
+  (let ((tags (slot-value field 'tags)))
+    (dolist (tag tags)
+      (add-to-list 'gnorb-ebdb-org-tags tag))))
 
 (provide 'ebdb-gnorb)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]