diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2023-01-14 20:40:54 +0100 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2023-01-14 20:40:54 +0100 |
| commit | 42df9609d53ee5be5bed0cebf8f4ea78ab4c5468 (patch) | |
| tree | 751b6b21c96d3bf150651475cc2bd06f1605d16b | |
| parent | 02fa6c9725cd5e6529877785ef25591721a32c5b (diff) | |
compat-28: Add macroexp-warn-and-return
| -rw-r--r-- | NEWS.org | 1 | ||||
| -rw-r--r-- | compat-28.el | 10 | ||||
| -rw-r--r-- | compat-tests.el | 3 | ||||
| -rw-r--r-- | compat.texi | 7 |
4 files changed, 19 insertions, 2 deletions
@@ -3,6 +3,7 @@ * Development - compat-27: Add generalized variables for ~decoded-time-*~. +- compat-28: Add ~macroexp-warn-and-return~. * Release of "Compat" Version 29.1.1.1 diff --git a/compat-28.el b/compat-28.el index db5a2c7..ebcb68a 100644 --- a/compat-28.el +++ b/compat-28.el @@ -738,6 +738,16 @@ where the mouse button is clicked to find a thing nearby." ;;;; Defined in macroexp.el +(compat-defun macroexp-warn-and-return (msg form &optional _category _compile-only _arg) ;; <OK> + "Return code equivalent to FORM labeled with warning MSG. +CATEGORY is the category of the warning, like the categories that +can appear in `byte-compile-warnings'. +COMPILE-ONLY non-nil means no warning should be emitted if the code +is executed without being compiled first. +ARG is a symbol (or a form) giving the source code position for the message. +It should normally be a symbol with position and it defaults to FORM." + (macroexp--warn-and-return msg form)) + (compat-defun macroexp-file-name () ;; <OK> "Return the name of the file from which the code comes. Returns nil when we do not know. diff --git a/compat-tests.el b/compat-tests.el index bc6386e..4e3edd2 100644 --- a/compat-tests.el +++ b/compat-tests.el @@ -2085,6 +2085,9 @@ (ert-deftest macroexp-file-name () (should-equal (file-name-nondirectory (compat-tests--filename)) "compat-tests.el")) +(ert-deftest macroexp-warn-and-return () + (should-equal (macroexp-warn-and-return "test warning" '(some form)) '(some form))) + (ert-deftest macroexpand-1 () (should-equal '(if a b c) (macroexpand-1 '(if a b c))) (should-equal '(if a (progn b)) (macroexpand-1 '(when a b))) diff --git a/compat.texi b/compat.texi index 4066114..8025fc1 100644 --- a/compat.texi +++ b/compat.texi @@ -1769,6 +1769,11 @@ Return the name of the file in which the code is currently being evaluated, or @code{nil} if it cannot be determined. @end defun +@c based on lisp/emacs-lisp/macroexp.el +@defun macroexp-warn-and-return msg form &optional category compile-only arg +Return code equivalent to @code{form} labeled with warning @code{msg}. +@end defun + @c copied from on lispref/os.texi @defmac with-environment-variables variables body@dots{} This macro sets the environment variables according to @var{variables} @@ -1983,8 +1988,6 @@ Support for the @code{natnum} defcustom type. @item The function @code{macroexp-compiling-p}. @item -The function @code{macroexp-warn-and-return}. -@item Additional Edebug keywords. @item Shorthand support. |
