From 1eb7535511add8a828290e0353ac6c9719b7af7c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Mon, 14 Jan 2019 14:15:20 +0000 Subject: [PATCH] Protect against null messages from eldoc * eglot.el (eglot--eldoc-message): Protect against nil FORMAT. GitHub-reference: fix https://github.com/joaotavora/eglot/issues/209 --- lisp/progmodes/eglot.el | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index d251bcb7c09..799ab10fa29 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -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. -- 2.39.2