Subject: Re: bug#79128: 31.0.50; shortdoc doesn't always display the correct arglist

From: Stefan Monnier <[email-masked]>
Date: Sat, 02 Aug 2025 15:35:44 -0400

>> Shortdoc:
>> 
>>     >> (seq-empty-p arg &rest args)

Hmm... I suggest the patch below.

        Stefan

diff --git a/lisp/help.el b/lisp/help.el
index 65950a2b3a8..d1522ee392d 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -2282,8 +2282,9 @@
   "Return a formal argument list for the function DEF.
 If PRESERVE-NAMES is non-nil, return a formal arglist that uses
 the same names as used in the original source code, when possible."
-  ;; Handle symbols aliased to other symbols.
-  (if (and (symbolp def) (fboundp def)) (setq def (indirect-function def)))
+  (let ((orig def)
+        ;; Follow symbols aliased to other symbols.
+        (def (indirect-function def)))
   ;; Advice wrappers have "catch all" args, so fetch the actual underlying
   ;; function to find the real arguments.
   (setq def (advice--cd*r def))
@@ -2299,7 +2300,10 @@
    ((or (and (byte-code-function-p def) (integerp (aref def 0)))
         (subrp def) (module-function-p def))
     (or (when preserve-names
-          (let* ((doc (condition-case nil (documentation def 'raw) (error nil)))
+            (let* ((doc (condition-case nil
+                            ;; Use `orig' to obey `function-documentation'.
+                           (documentation orig 'raw)
+                          (error nil)))
                  (docargs (if doc (car (help-split-fundoc doc nil))))
                  (arglist (if docargs
                               (cdar (read-from-string (downcase docargs)))))
@@ -2328,7 +2332,7 @@
           (nreverse arglist))))
    ((not (member (autoloadp def) '(nil keymap)))
     "[Arg list not available until function definition is loaded.]")
-   (t t)))
+     (t t))))
 
 (defun help--make-usage (function arglist)
   (cons (if (symbolp function) function 'anonymous)