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

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

[elpa] master c41f462 1/6: Added check for empty dictionary during print


From: Ian Dunn
Subject: [elpa] master c41f462 1/6: Added check for empty dictionary during printing
Date: Mon, 19 Feb 2018 14:20:19 -0500 (EST)

branch: master
commit c41f46288b0afcdd362defd7d9b1a21cd73e42f7
Author: Ian Dunn <address@hidden>
Commit: Ian Dunn <address@hidden>

    Added check for empty dictionary during printing
    
    * paced.el (paced-dictionary-empty-p): New defmethod.
      (paced-dictionary-length-of-longest-word): Use it.
---
 paced.el | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/paced.el b/paced.el
index 73d9488..984c9be 100644
--- a/paced.el
+++ b/paced.el
@@ -331,6 +331,10 @@ customization interface."
   "Return the name of dictionary OBJ."
   (oref obj object-name))
 
+(cl-defmethod paced-dictionary-empty-p ((dict paced-dictionary))
+  "Return non-nil if DICT is empty."
+  (map-empty-p (oref dict usage-hash)))
+
 ;;; Current Dictionary
 
 (defcustom paced-global-dictionary-enable-alist nil
@@ -1271,11 +1275,15 @@ For how the current dictionary is determined, see
 
 (cl-defmethod paced-dictionary-length-of-longest-word ((dict paced-dictionary))
   "Return the length of the longest word in DICT."
-  (seq-max
-   (map-apply
-    (lambda (key _value)
-      (length key))
-    (oref dict usage-hash))))
+  (cond
+   ;; If DICT is empty, seq-max throws an error.
+   ((paced-dictionary-empty-p dict) 0)
+   (t
+    (seq-max
+     (map-apply
+      (lambda (key _value)
+        (length key))
+      (oref dict usage-hash))))))
 
 (cl-defmethod paced-dictionary-tabulated-list-entries ((dict paced-dictionary))
   "Create a value for `tabulated-list-entries' from DICT."



reply via email to

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