Subject: bug#77628: [PATCH] ; Fix `elisp-eldoc-funcall-with-docstring' when fn has no docstring.

From: Elijah Gabe Pérez <[email-masked]>
Date: Mon, 07 Apr 2025 23:08:18 -0600

>From 0aefc44cd151725cceb755776c497b62746465cb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?El=C3=ADas=20Gabriel=20P=C3=A9rez?= <[email-masked]>
Date: Mon, 7 Apr 2025 23:00:20 -0600
Subject: [PATCH] ; Fix `elisp-eldoc-funcall-with-docstring' when fn has no
 docstring.

* lisp/progmodes/elisp-mode.el (elisp-eldoc-funcall-with-docstring):
Add "Undocumented" as docstring if the function as no docstring,
and limit docstring length to 1000 characters.  (bug#)
---
 lisp/progmodes/elisp-mode.el | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 748d2f11360..7b8f4af746b 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -1861,17 +1861,22 @@ elisp-eldoc-funcall-with-docstring
 Compared to `elisp-eldoc-funcall', this also includes the
 current function doc string, doc string length depends on
 `elisp-eldoc-funcall-with-docstring-length'."
-  (let* ((sym-info (elisp--fnsym-in-current-sexp))
-         (fn-sym (car sym-info))
-         (doc (when (fboundp fn-sym)
-                (propertize
-                 (cdr (help-split-fundoc
-                       (condition-case nil (documentation fn-sym t)
-                         (invalid-function nil))
-                       fn-sym))
-                 'face 'font-lock-doc-face))))
-    (when fn-sym
-      (funcall callback
+  (when-let* ((sym-info (elisp--fnsym-in-current-sexp))
+              (fn-sym (car sym-info))
+              (fn-doc (or (cdr (help-split-fundoc
+                                (condition-case nil (documentation fn-sym t)
+                                  (invalid-function nil))
+                                fn-sym))
+                          "Undocumented."))
+              (more (- (length fn-doc) 1000))
+              (doc (when (fboundp fn-sym)
+                     (concat
+                      (propertize
+                       (string-limit fn-doc 1000)
+                       'face 'font-lock-doc-face)
+                      (when (> more 0)
+                        (format "[%sc more]" more))))))
+    (funcall callback
                (concat (apply #'elisp-get-fnsym-args-string sym-info)
                        ;; Ensure not display the docstring in the
                        ;; mode-line.
@@ -1887,7 +1892,7 @@ elisp-eldoc-funcall-with-docstring
                :thing fn-sym
                :face (if (functionp fn-sym)
                          'font-lock-function-name-face
-                       'font-lock-keyword-face)))))
+                       'font-lock-keyword-face))))
 
 (defun elisp-eldoc-var-docstring (callback &rest _ignored)
   "Document variable at point by calling CALLBACK.
-- 
2.49.0

-- 
                                          - E.G via GNU Emacs and Org.