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

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

[elpa] master a913803 27/66: company-diag: Catch any error in `completio


From: Dmitry Gutov
Subject: [elpa] master a913803 27/66: company-diag: Catch any error in `completions'
Date: Mon, 5 Nov 2018 18:19:16 -0500 (EST)

branch: master
commit a9138030819833c481cea93ddf52442237e4874e
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    company-diag: Catch any error in `completions'
    
    Mentioned in #801.
---
 company.el | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/company.el b/company.el
index 04dcdd9..e465495 100644
--- a/company.el
+++ b/company.el
@@ -2391,11 +2391,13 @@ If SHOW-VERSION is non-nil, show the version in the 
echo area."
          cc annotations)
     (when (or (stringp prefix) (consp prefix))
       (let ((company-backend backend))
-        (setq cc (company-call-backend 'candidates (company--prefix-str 
prefix))
-              annotations
-              (mapcar
-               (lambda (c) (cons c (company-call-backend 'annotation c)))
-               cc))))
+        (condition-case nil
+            (setq cc (company-call-backend 'candidates (company--prefix-str 
prefix))
+                  annotations
+                  (mapcar
+                   (lambda (c) (cons c (company-call-backend 'annotation c)))
+                   cc))
+          (error (setq annotations 'error)))))
     (pop-to-buffer (get-buffer-create "*company-diag*"))
     (setq buffer-read-only nil)
     (erase-buffer)
@@ -2414,11 +2416,13 @@ If SHOW-VERSION is non-nil, show the version in the 
echo area."
     (insert "\n")
     (insert (message  "Completions:"))
     (unless cc (insert " none"))
-    (save-excursion
-      (dolist (c annotations)
-        (insert "\n  " (prin1-to-string (car c)))
-        (when (cdr c)
-          (insert " " (prin1-to-string (cdr c))))))
+    (if (eq annotations 'error)
+        (insert "(error fetching)")
+      (save-excursion
+        (dolist (c annotations)
+          (insert "\n  " (prin1-to-string (car c)))
+          (when (cdr c)
+            (insert " " (prin1-to-string (cdr c)))))))
     (special-mode)))
 
 ;;; pseudo-tooltip 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



reply via email to

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