]> git.eshelyaron.com Git - emacs.git/commitdiff
* Add function type declarations for Lisp functions
authorAndrea Corallo <acorallo@gnu.org>
Fri, 23 Feb 2024 09:17:27 +0000 (10:17 +0100)
committerEshel Yaron <me@eshelyaron.com>
Mon, 6 May 2024 16:28:15 +0000 (18:28 +0200)
* lisp/emacs-lisp/byte-run.el (byte-run--set-declared-type): Add alias.
(defun-declarations-alist): Use it for 'type' declaration.

(cherry picked from commit 1c7b8099839f62ddfaa5a0f87c29bcd905095dee)

lisp/emacs-lisp/byte-run.el

index 76e0a4fe11b516a64a596417fd24a2ed6be83a20..87ee626342167f6ee6ea336e44c23999520f34ff 100644 (file)
@@ -217,6 +217,11 @@ So far, FUNCTION can only be a symbol, not a lambda expression."
                  (cadr elem)))
               val)))))
 
+(defalias 'byte-run--set-declared-type
+  #'(lambda (f _args &rest val)
+      (list 'function-put (list 'quote f)
+            ''declared-type (list 'quote val))))
+
 ;; Add any new entries to info node `(elisp)Declare Form'.
 (defvar defun-declarations-alist
   (list
@@ -239,7 +244,8 @@ If `error-free', drop calls even if `byte-compile-delete-errors' is nil.")
    (list 'speed #'byte-run--set-speed)
    (list 'completion #'byte-run--set-completion)
    (list 'modes #'byte-run--set-modes)
-   (list 'interactive-args #'byte-run--set-interactive-args))
+   (list 'interactive-args #'byte-run--set-interactive-args)
+   (list 'type #'byte-run--set-declared-type))
   "List associating function properties to their macro expansion.
 Each element of the list takes the form (PROP FUN) where FUN is
 a function.  For each (PROP . VALUES) in a function's declaration,