unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#54225: [PATCH] with-demoted-errors: Fix macroexp-warn-and-return call
@ 2022-03-03  3:00 Kyle Meyer
  2022-03-03 14:36 ` Lars Ingebrigtsen
  2022-03-03 15:14 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 2 replies; 4+ messages in thread
From: Kyle Meyer @ 2022-03-03  3:00 UTC (permalink / raw)
  To: 54225; +Cc: lomov.vl

The macroexp-warn-and-return call added to with-demoted-errors in
d52c929e31f (2022-02-04) is incorrect.  The with-demoted-errors format
string is passed as MSG, the actual message is passed as FORM, and the
form is passed as CATEGORY, leading to with-demoted-errors returning
"Missing format argument".

* lisp/subr.el (with-demoted-errors): Call macroexp-warn-and-return
with correct arguments.
---
 lisp/subr.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/subr.el b/lisp/subr.el
index eb9af0b36da..7dde7589dd9 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4560,7 +4560,7 @@ with-demoted-errors
     (if (eq orig-body body) exp
       ;; The use without `format' is obsolete, let's warn when we bump
       ;; into any such remaining uses.
-      (macroexp-warn-and-return format "Missing format argument" exp))))
+      (macroexp-warn-and-return "Missing format argument" exp))))
 
 (defmacro combine-after-change-calls (&rest body)
   "Execute BODY, but don't call the after-change functions till the end.

base-commit: 543640628607ec06e9698cc50c33497ca75155a4
-- 
2.34.0






^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#54225: [PATCH] with-demoted-errors: Fix macroexp-warn-and-return call
  2022-03-03  3:00 bug#54225: [PATCH] with-demoted-errors: Fix macroexp-warn-and-return call Kyle Meyer
@ 2022-03-03 14:36 ` Lars Ingebrigtsen
  2022-03-04  0:21   ` Michael Heerdegen
  2022-03-03 15:14 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-03-03 14:36 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: 54225, Stefan Monnier, lomov.vl

Kyle Meyer <kyle@kyleam.com> writes:

> The macroexp-warn-and-return call added to with-demoted-errors in
> d52c929e31f (2022-02-04) is incorrect.  The with-demoted-errors format
> string is passed as MSG, the actual message is passed as FORM, and the
> form is passed as CATEGORY, leading to with-demoted-errors returning
> "Missing format argument".
>
> * lisp/subr.el (with-demoted-errors): Call macroexp-warn-and-return
> with correct arguments.

[...]

> -      (macroexp-warn-and-return format "Missing format argument" exp))))
> +      (macroexp-warn-and-return "Missing format argument" exp))))

The code flow in with-demoted-errors is pretty confusing.  Can it be
improved upon instead of tweaked this way?  (`format' here will be
"Error: %S" at least in some cases, I guess?)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#54225: [PATCH] with-demoted-errors: Fix macroexp-warn-and-return call
  2022-03-03  3:00 bug#54225: [PATCH] with-demoted-errors: Fix macroexp-warn-and-return call Kyle Meyer
  2022-03-03 14:36 ` Lars Ingebrigtsen
@ 2022-03-03 15:14 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-03-03 15:14 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: lomov.vl, 54225-done

Kyle Meyer [2022-03-02 22:00:35] wrote:

> The macroexp-warn-and-return call added to with-demoted-errors in
> d52c929e31f (2022-02-04) is incorrect.  The with-demoted-errors format
> string is passed as MSG, the actual message is passed as FORM, and the
> form is passed as CATEGORY, leading to with-demoted-errors returning
> "Missing format argument".
>
> * lisp/subr.el (with-demoted-errors): Call macroexp-warn-and-return
> with correct arguments.
> ---
>  lisp/subr.el | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lisp/subr.el b/lisp/subr.el
> index eb9af0b36da..7dde7589dd9 100644
> --- a/lisp/subr.el
> +++ b/lisp/subr.el
> @@ -4560,7 +4560,7 @@ with-demoted-errors
>      (if (eq orig-body body) exp
>        ;; The use without `format' is obsolete, let's warn when we bump
>        ;; into any such remaining uses.
> -      (macroexp-warn-and-return format "Missing format argument" exp))))
> +      (macroexp-warn-and-return "Missing format argument" exp))))
>  
>  (defmacro combine-after-change-calls (&rest body)
>    "Execute BODY, but don't call the after-change functions till the end.
>
> base-commit: 543640628607ec06e9698cc50c33497ca75155a4

Thanks.  I used the patch below, instead.


        Stefan


diff --git a/lisp/subr.el b/lisp/subr.el
index eb9af0b36da..2321765f953 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4560,7 +4560,7 @@ with-demoted-errors
     (if (eq orig-body body) exp
       ;; The use without `format' is obsolete, let's warn when we bump
       ;; into any such remaining uses.
-      (macroexp-warn-and-return format "Missing format argument" exp))))
+      (macroexp-warn-and-return "Missing format argument" exp nil nil format))))
 
 (defmacro combine-after-change-calls (&rest body)
   "Execute BODY, but don't call the after-change functions till the end.






^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#54225: [PATCH] with-demoted-errors: Fix macroexp-warn-and-return call
  2022-03-03 14:36 ` Lars Ingebrigtsen
@ 2022-03-04  0:21   ` Michael Heerdegen
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Heerdegen @ 2022-03-04  0:21 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: Kyle Meyer, 54225, Stefan Monnier, lomov.vl

Lars Ingebrigtsen <larsi@gnus.org> writes:

> The code flow in with-demoted-errors is pretty confusing.  Can it be
> improved upon instead of tweaked this way?

Yesterday I dealt with that, and I think I understood most parts: the
code is a bit ugly but necessarily because the semantics are (also
necessarily due to backwards compatibility).  The cases to be supported
are:

- FORMAT is a string (and BODY not empty) - the expected use case

- FORMAT is nil: that's equivalent to FORMAT being "Error: %S"

- Anything else: also use the above default format string but
  additionally add that sexp to the BODY since it's expected to be code
  (backwards compatibility).  It works but you get a warning.

Once the third case will not be supported any more the code can be made
much simpler.

Michael.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-03-04  0:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-03  3:00 bug#54225: [PATCH] with-demoted-errors: Fix macroexp-warn-and-return call Kyle Meyer
2022-03-03 14:36 ` Lars Ingebrigtsen
2022-03-04  0:21   ` Michael Heerdegen
2022-03-03 15:14 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).