From b12df73cc123f2b514f0c5d360ea729a1e1b1c7d Mon Sep 17 00:00:00 2001 From: Nikita Bloshchanevich Date: Sat, 2 Jan 2021 12:24:31 +0100 Subject: [PATCH] Emacs-lisp eldoc: fix error if symbol unbound `+emacs-lisp-append-value-to-eldoc-a' `error's if the symbol isn't bound, because `symbol-value' errors in that case. Fix that bug by only modifying the result of `elisp-get-var-docstring' if the symbol is bound. --- modules/lang/emacs-lisp/config.el | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/modules/lang/emacs-lisp/config.el b/modules/lang/emacs-lisp/config.el index 1286a7588..bf8c5553d 100644 --- a/modules/lang/emacs-lisp/config.el +++ b/modules/lang/emacs-lisp/config.el @@ -99,15 +99,17 @@ employed so that flycheck still does *some* helpful linting.") "Display variable value next to documentation in eldoc." :around #'elisp-get-var-docstring (when-let (ret (funcall orig-fn sym)) - (concat ret " " - (let* ((truncated " [...]") - (print-escape-newlines t) - (str (symbol-value sym)) - (str (prin1-to-string str)) - (limit (- (frame-width) (length ret) (length truncated) 1))) - (format (format "%%0.%ds%%s" (max limit 0)) - (propertize str 'face 'warning) - (if (< (length str) limit) "" truncated)))))) + (if (fboundp sym) + (concat ret " " + (let* ((truncated " [...]") + (print-escape-newlines t) + (str (symbol-value sym)) + (str (prin1-to-string str)) + (limit (- (frame-width) (length ret) (length truncated) 1))) + (format (format "%%0.%ds%%s" (max limit 0)) + (propertize str 'face 'warning) + (if (< (length str) limit) "" truncated)))) + ret))) (map! :localleader :map emacs-lisp-mode-map