Update C-h f

This commit is contained in:
Andrea Corallo 2024-02-23 15:57:43 +01:00
parent 22da320285
commit acb5199752
2 changed files with 16 additions and 15 deletions

View file

@ -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)

View file

@ -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)))))