emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scratch/func-type-decls acb51997524 5/6: Update C-h f


From: Andrea Corallo
Subject: scratch/func-type-decls acb51997524 5/6: Update C-h f
Date: Fri, 23 Feb 2024 10:12:13 -0500 (EST)

branch: scratch/func-type-decls
commit acb519975247ff2656737774fa3d7dcf98faccaa
Author: Andrea Corallo <acorallo@gnu.org>
Commit: Andrea Corallo <acorallo@gnu.org>

    Update C-h f
---
 lisp/emacs-lisp/comp-common.el | 29 +++++++++++++++--------------
 lisp/help-fns.el               |  2 +-
 2 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/lisp/emacs-lisp/comp-common.el b/lisp/emacs-lisp/comp-common.el
index 0fab976474f..3aa0da60440 100644
--- a/lisp/emacs-lisp/comp-common.el
+++ b/lisp/emacs-lisp/comp-common.el
@@ -197,32 +197,33 @@ Account for `native-comp-eln-load-path' and 
`comp-native-version-dir'."
                                (expand-file-name dir invocation-directory))))
           native-comp-eln-load-path))
 
+;; FIXME now that is possible we should move this to help-fns.el
 ;;;###autoload
 (defun comp-function-type-spec (function)
   "Return the type specifier of FUNCTION.
 
-This function returns a cons cell whose car is the function
-specifier, and cdr is a symbol, either `inferred' or `declared'.
-If the symbol is `inferred', the type specifier is automatically
-inferred from the code itself by the native compiler; if it is
-`know', the type specifier comes from `comp-primitive-type-specifiers'."
+This function returns a cons cell whose car is the function specifier,
+and cdr is a symbol, either `inferred' or `declared'.  If the symbol is
+`inferred', the type specifier is automatically inferred from the code
+itself by the native compiler; if it is `declared', the type specifier
+comes from the function declaration."
   (let ((kind 'declared)
         type-spec)
-    (when-let ((res (assoc function comp-primitive-type-specifiers)))
-      ;; Declared primitive
-      (setf type-spec (cadr res)))
-    (let ((f (and (symbolp function)
-                  (symbol-function function))))
-      (when (and f (null type-spec))
+    (when-let ((symp (symbolp function))
+               (f (symbol-function function)))
+      (if-let ((primitive (subr-primitive-p f))
+               (type (subr-type f)))
+          ;; Declared primitive
+          (setf type-spec type)
         (if-let ((delc-type (function-get function 'declared-type)))
             ;; Declared Lisp function
             (setf type-spec (cons 'function delc-type))
           (when (subr-native-elisp-p f)
             ;; Native compiled inferred
             (setf kind 'inferred
-                  type-spec (subr-type f))))))
-    (when type-spec
-        (cons type-spec kind))))
+                  type-spec (subr-type f)))))
+      (when type-spec
+        (cons type-spec kind)))))
 
 (provide 'comp-common)
 
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 15d87f9925c..00c3edb400a 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -734,7 +734,7 @@ the C sources, too."
               (insert (format
                        (if (eq kind 'inferred)
                            "\nInferred type: %s\n"
-                         "\nType: %s\n")
+                         "\nDeclared type: %s\n")
                        type-spec))))
           (fill-region fill-begin (point))
           high-doc)))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]