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

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

[elpa] externals/ebdb 886cfd0 054/350: Change gnorb tags field to plain


From: Eric Abrahamsen
Subject: [elpa] externals/ebdb 886cfd0 054/350: Change gnorb tags field to plain org tags field
Date: Mon, 14 Aug 2017 11:46:02 -0400 (EDT)

branch: externals/ebdb
commit 886cfd08b53afeb90a0d75eee7a749ba76b5ea25
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>

    Change gnorb tags field to plain org tags field
    
    There was no reason to keep this under the gnorb package.
    
    * ebdb-org.el (ebdb-org-tags): Tags collection variable moves here.
      (ebdb-org-field-tags): As does the class, plus its various methods.
    * ebdb-gnorb.el: Remove stuff from here.
    * ebdb-migrate.el (gnorb-ebdb-org-tag-field): Keep this in the
      migration file, it's not good for anything else.
      (ebdb-migrate-vector-to-class): Adjust the name of the class we're
      creating.
---
 ebdb-gnorb.el   | 45 ++-------------------------------------------
 ebdb-migrate.el | 10 ++++++++--
 ebdb-org.el     | 40 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 45 deletions(-)

diff --git a/ebdb-gnorb.el b/ebdb-gnorb.el
index b7873ca..485326d 100644
--- a/ebdb-gnorb.el
+++ b/ebdb-gnorb.el
@@ -19,23 +19,14 @@
 
 ;;; Commentary:
 
-;; Bits and pieces useful for tying EBDB in with Gnorb.  This file
-;; will eventually be moved to the Gnorb package.
+;; Bits and pieces useful for tying EBDB in with Gnorb.  Everything in
+;; this file can be moved elsewhere.
 
 ;;; Code:
 
 (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,36 +37,4 @@ potential tags for completion.")
 (cl-defmethod ebdb-string ((_field gnorb-ebdb-field-messages))
   "Some messages")
 
-(defcustom gnorb-ebdb-org-tag-field 'org-tags
-  "The name (as a symbol) of the field to use for org tags."
-  :group 'gnorb-ebdb
-  :type 'symbol)
-
-(defclass gnorb-ebdb-field-tags (ebdb-field-user)
-  ((tags
-    :type (list-of string)
-    :initarg :tags
-    :custom (repeat string)
-    :initform nil))
-  :human-readable "gnorb tags")
-
-(cl-defmethod ebdb-string ((field gnorb-ebdb-field-tags))
-  (ebdb-concat 'gnorb-ebdb-field-tags (slot-value field 'tags)))
-
-(cl-defmethod ebdb-read ((field (subclass gnorb-ebdb-field-tags)) &optional 
slots obj)
-  (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)
diff --git a/ebdb-migrate.el b/ebdb-migrate.el
index 430095c..751d70f 100644
--- a/ebdb-migrate.el
+++ b/ebdb-migrate.el
@@ -354,6 +354,11 @@ checked for a score to add to the mail addresses in the 
same record."
   :group 'ebdb-mua-gnus-scoring
   :type 'symbol)
 
+(defcustom gnorb-ebdb-org-tag-field 'org-tags
+  "The name (as a symbol) of the field to use for org tags."
+  :group 'gnorb-ebdb
+  :type 'symbol)
+
 ;;;###autoload
 (defun ebdb-migrate-from-bbdb ()
   "Migrate from BBDB to EBDB.
@@ -366,6 +371,7 @@ Assume that the variable `bbdb-file' points to an existing 
file
 holding valid contacts in a previous BBDB format."
   (require 'url-handlers)
   (require 'ebdb-gnorb)
+  (require 'ebdb-org)
   (require 'ebdb-gnus)
   (with-current-buffer (find-file-noselect bbdb-file)
     (when (and (/= (point-min) (point-max))
@@ -542,10 +548,10 @@ holding valid contacts in a previous BBDB format."
                                 :messages val)
                  fields)))
         ((eq lab gnorb-ebdb-org-tag-field)
-         (push (make-instance 'gnorb-ebdb-field-tags
+         (push (make-instance 'ebdb-org-field-tags
                               :tags (if (listp val)
                                         val
-                                      (ebdb-split gnorb-ebdb-org-tag-field 
val)))
+                                      (split-string val ";" t t)))
                fields))
         ((memq lab (list bbdb/gnus-score-field
                          bbdb/gnus-split-private-field
diff --git a/ebdb-org.el b/ebdb-org.el
index e1aa151..ab1f6ee 100644
--- a/ebdb-org.el
+++ b/ebdb-org.el
@@ -44,6 +44,9 @@
 ;; When calling `org-store-link' on a contact, a "ebdb:uuid/" style
 ;; link is created by default.
 
+;; This file also defines a "tags" field class, for tagging EBDB
+;; contacts with Org tags.
+
 ;;; Code:
 
 (if (fboundp 'org-link-set-parameters)
@@ -105,5 +108,42 @@ italicized, in all other cases it is left unchanged."
     (format "<text:span text:style-name=\"Emphasis\">%s</text:span>" desc))
    (t desc)))
 
+(defvar 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 '(ebdb-org-field-tags ";" ";") ebdb-separator-alist)
+
+
+(defclass ebdb-org-field-tags (ebdb-field-user)
+  ((tags
+    :type (list-of string)
+    :initarg :tags
+    :custom (repeat string)
+    :initform nil))
+  :human-readable "org tags")
+
+(cl-defmethod ebdb-string ((field ebdb-org-field-tags))
+  (ebdb-concat 'ebdb-org-field-tags (slot-value field 'tags)))
+
+(cl-defmethod ebdb-read ((field (subclass ebdb-org-field-tags)) &optional 
slots obj)
+  (let* ((crm-separator (cadr (assq 'ebdb-org-field-tags 
ebdb-separator-alist)))
+        (val (completing-read-multiple
+              "Tags: "
+              (append (org-global-tags-completion-table)
+                      (when ebdb-org-tags
+                        (mapcar #'list 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 ebdb-org-field-tags) _record)
+  (let ((tags (slot-value field 'tags)))
+    (dolist (tag tags)
+      (add-to-list 'ebdb-org-tags tag))))
+
 (provide 'ebdb-org)
 ;;; ebdb-org.el ends here



reply via email to

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