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

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

[elpa] externals/ebdb ab1a2ff 1/3: Fix field sorting, partway


From: Eric Abrahamsen
Subject: [elpa] externals/ebdb ab1a2ff 1/3: Fix field sorting, partway
Date: Sun, 19 Apr 2020 17:46:24 -0400 (EDT)

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

    Fix field sorting, partway
    
    * ebdb.el (ebdb-field-compare): By default, sort by class name. This
    will at least group fields of like classes together.
---
 ebdb-format.el |  2 ++
 ebdb.el        | 16 +++++++++++-----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/ebdb-format.el b/ebdb-format.el
index b57ccfa..ac6954d 100644
--- a/ebdb-format.el
+++ b/ebdb-format.el
@@ -354,6 +354,8 @@ slot of FMT."
   (let* ((sort-order (slot-value fmt 'sort))
         (catchall (or (seq-position sort-order "_")
                       (length sort-order)))
+        ;; This sorts by class type, what we also want is, if the
+        ;; "plumbing" fields are present, to put them first.
         (sorted (seq-sort #'ebdb-field-compare field-list)))
 
     (when sort-order
diff --git a/ebdb.el b/ebdb.el
index a1c7a95..e12b7e5 100644
--- a/ebdb.el
+++ b/ebdb.el
@@ -1008,12 +1008,12 @@ chance to react somehow.  TYPE is one of the symbols 
'sender or
 in."
   nil)
 
+;; See actual implementation down below `ebdb-field-user' definition.
 (cl-defgeneric ebdb-field-compare (field1 field2)
-  "Return non-nil if FIELD1 should be sorted before FIELD2.")
+  "Return non-nil if FIELD1 should be sorted before FIELD2."
+  (:method (_field1 _field2)
+          nil))
 
-(cl-defmethod ebdb-field-compare (_field1 _field2)
-  "By default, leave order unchanged."
-  nil)
 
 ;;; The UUID field.
 
@@ -1153,6 +1153,12 @@ process."
   class that subclasses this will be offered as a choice to the
   user when inserting new fields.")
 
+(cl-defmethod ebdb-field-compare ((field1 ebdb-field-user)
+                                 (field2 ebdb-field-user))
+  "By default, order by field class."
+  (string< (symbol-name (eieio-object-class-name field1))
+          (symbol-name (eieio-object-class-name field2))))
+
 (defvar ebdb-user-label-list nil
   "List of existing labels of user fields.")
 
@@ -2107,7 +2113,7 @@ Adds relation information to the 
`ebdb-relation-hashtable'."
        (gethash (slot-value rel 'rel-uuid) ebdb-relation-hashtable)))
 
 (cl-defmethod ebdb-delete-field ((rel ebdb-field-relation) record
-                                &optional unload)
+                                &optional _unload)
   "Delete REL related field on RECORD.
 Removes relation information from the
 `ebdb-relation-hashtable'."



reply via email to

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