diff options
| -rw-r--r-- | NEWS.org | 1 | ||||
| -rw-r--r-- | compat-29.el | 6 | ||||
| -rw-r--r-- | compat-tests.el | 5 | ||||
| -rw-r--r-- | compat.texi | 11 |
4 files changed, 23 insertions, 0 deletions
@@ -8,6 +8,7 @@ - compat-28: Add ~color-dark-p~. - compat-28: Add ~with-window-non-dedicated~. - compat-29: Add ~plist-get~ generalized variable. +- compat-29: Add ~compiled-function-p~. * Release of "Compat" Version 29.1.2.0 diff --git a/compat-29.el b/compat-29.el index 27edaaa..bae8f07 100644 --- a/compat-29.el +++ b/compat-29.el @@ -185,6 +185,12 @@ and return the value found in PLACE instead." (compat-defalias string-split split-string) ;; <compat-tests:string-split> +(compat-defun compiled-function-p (object) ;; <compat-tests:compiled-function-p> + "Return non-nil if OBJECT is a function that has been compiled. +Does not distinguish between functions implemented in machine code +or byte-code." + (or (subrp object) (byte-code-function-p object))) + (compat-defun function-alias-p (func &optional noerror) ;; <compat-tests:function-alias-p> "Return nil if FUNC is not a function alias. If FUNC is a function alias, return the function alias chain. diff --git a/compat-tests.el b/compat-tests.el index e315e2c..4f75887 100644 --- a/compat-tests.el +++ b/compat-tests.el @@ -1157,6 +1157,11 @@ (should-equal 'l (cddadr xxxx)) (should-equal 'h (cdddar xxxx)))) +(ert-deftest compiled-function-p () + (should-not (compiled-function-p '(lambda (x) x))) + (should (compiled-function-p (symbol-function 'assq))) + (should (compiled-function-p (symbol-function 'identity)))) + (ert-deftest subr-native-elisp-p () (should-not (subr-native-elisp-p (symbol-function 'identity)))) diff --git a/compat.texi b/compat.texi index 1280fe6..5471851 100644 --- a/compat.texi +++ b/compat.texi @@ -2121,6 +2121,17 @@ positive. @end defun @c copied from lispref/functions.texi +@defun compiled-function-p object +This function returns @code{t} if @var{object} is a function object +that is not in the form of ELisp source code but something like +machine code or byte code instead. More specifically it returns +@code{t} if the function is built-in (a.k.a.@: ``primitive'', +@pxref{What Is a Function}), or byte-compiled (@pxref{Byte +Compilation}), or natively-compiled (@pxref{Native Compilation}), or +a function loaded from a dynamic module (@pxref{Dynamic Modules}). +@end defun + +@c copied from lispref/functions.texi @defun function-alias-p object &optional noerror Checks whether @var{object} is a function alias. If it is, it returns a list of symbols representing the function alias chain, else |
