]> git.eshelyaron.com Git - emacs.git/commitdiff
Protect against null messages from eldoc
authorJoão Távora <joaotavora@gmail.com>
Mon, 14 Jan 2019 14:15:20 +0000 (14:15 +0000)
committerJoão Távora <joaotavora@gmail.com>
Mon, 14 Jan 2019 14:15:20 +0000 (14:15 +0000)
* eglot.el (eglot--eldoc-message): Protect against nil FORMAT.

GitHub-reference: fix https://github.com/joaotavora/eglot/issues/209

lisp/progmodes/eglot.el

index d251bcb7c091651660c72448ace3cb13ccf12552..799ab10fa295a4364822e10ed8055e125d930a51 100644 (file)
@@ -2070,26 +2070,27 @@ Buffer is displayed with `display-buffer', which obeys
   :type 'boolean)
 
 (defun eglot--eldoc-message (format &rest args)
-  (let ((string (apply #'format format args))) ;; FIXME: overworking?
-    (when (or (eq t eglot-put-doc-in-help-buffer)
-              (funcall eglot-put-doc-in-help-buffer string))
-      (with-current-buffer (eglot--help-buffer)
-        (rename-buffer (format "*eglot-help for %s*" eglot--eldoc-hint))
-        (let ((inhibit-read-only t))
-          (erase-buffer)
-          (insert string)
-          (goto-char (point-min))
-          (if eglot-auto-display-help-buffer
-              (display-buffer (current-buffer))
-            (unless (get-buffer-window (current-buffer))
-              (eglot--message
-               "%s\n(...truncated. Full help is in `%s')"
-               (truncate-string-to-width
-                (replace-regexp-in-string "\\(.*\\)\n.*" "\\1" string)
-                (frame-width) nil nil "...")
-               (buffer-name eglot--help-buffer))))
-          (help-mode)
-          t)))))
+  (when format
+    (let ((string (apply #'format format args))) ;; FIXME: overworking?
+      (when (or (eq t eglot-put-doc-in-help-buffer)
+                (funcall eglot-put-doc-in-help-buffer string))
+        (with-current-buffer (eglot--help-buffer)
+          (rename-buffer (format "*eglot-help for %s*" eglot--eldoc-hint))
+          (let ((inhibit-read-only t))
+            (erase-buffer)
+            (insert string)
+            (goto-char (point-min))
+            (if eglot-auto-display-help-buffer
+                (display-buffer (current-buffer))
+              (unless (get-buffer-window (current-buffer))
+                (eglot--message
+                 "%s\n(...truncated. Full help is in `%s')"
+                 (truncate-string-to-width
+                  (replace-regexp-in-string "\\(.*\\)\n.*" "\\1" string)
+                  (frame-width) nil nil "...")
+                 (buffer-name eglot--help-buffer))))
+            (help-mode)
+            t))))))
 
 (defun eglot-eldoc-function ()
   "EGLOT's `eldoc-documentation-function' function.