GNU bug report logs - #57179
29.0.50: 'wrong-number-of-arguments' for function of two arguments called from 'window-scroll-functions'

Previous Next

Package: emacs;

Reported by: Andrea Greselin <greselin.andrea <at> gmail.com>

Date: Sat, 13 Aug 2022 16:19:01 UTC

Severity: normal

Found in version 29.0.50

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Alan Mackenzie <acm <at> muc.de>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: acm <at> muc.de, Eli Zaretskii <eliz <at> gnu.org>, 57179 <at> debbugs.gnu.org, Andrea Greselin <greselin.andrea <at> gmail.com>
Subject: bug#57179: 29.0.50: 'wrong-number-of-arguments' for function of two arguments called from 'window-scroll-functions'
Date: Sun, 14 Aug 2022 13:22:36 +0000
Hello, Michael and Andrea.

On Sun, Aug 14, 2022 at 02:19:31 +0200, Michael Heerdegen wrote:
> Michael Heerdegen <michael_heerdegen <at> web.de> writes:

> > Please tell whether this information suffices and you already have some
> > idea or if I should try to create a recipe.  I guess this must be
> > related to a recent change from within the last few days.

> Reverting a part of

> 48215c41d1 New debugging facility: backtraces from errors in Lisp called
> from redisplay (Alan Mackenzie <acm <at> muc.de> 2022-08-11)

> like this:


> From ffb7c3d558b599bcc84f1bf4fb4388569892d927 Mon Sep 17 00:00:00 2001
> From: Michael Heerdegen <michael_heerdegen <at> web.de>
> Date: Sun, 14 Aug 2022 02:14:58 +0200
> Subject: [PATCH] Test for #57179
> 
> ---
>  src/xdisp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/xdisp.c b/src/xdisp.c
> index 719b131baa..47eaddabce 100644
> --- a/src/xdisp.c
> +++ b/src/xdisp.c
> @@ -18221,8 +18221,8 @@ run_window_scroll_functions (Lisp_Object window, struct text_pos startp)
>      {
>        specpdl_ref count = SPECPDL_INDEX ();
>        specbind (Qinhibit_quit, Qt);
> -      safe_run_hooks_2
> -	(Qwindow_scroll_functions, window, make_fixnum (CHARPOS (startp)));
> +      run_hook_with_args_2 (Qwindow_scroll_functions, window,
> +			    make_fixnum (CHARPOS (startp)));
>        unbind_to (count, Qnil);
>        SET_TEXT_POS_FROM_MARKER (startp, w->start);
>        /* In case the hook functions switch buffers.  */
> --
> 2.30.2
> 


> seems to fix my incarnation of this problem.  Can it be that?  CC'ing
> Alan (the author).

Yes, this was indeed the problem.  Can I ask you please, instead of
applying your patch (above) to try out the following patch, which works
for me.

Thanks!



diff --git a/src/keyboard.c b/src/keyboard.c
index 8a2b7d58c4..1d7125a0a3 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1832,8 +1832,16 @@ adjust_point_for_property (ptrdiff_t last_pt, bool modified)
 static Lisp_Object
 safe_run_hooks_1 (ptrdiff_t nargs, Lisp_Object *args)
 {
-  eassert (nargs == 2);
-  return call0 (args[1]);
+  eassert (nargs >= 2 && nargs <= 4);
+  switch (nargs)
+    {
+    case 2:
+      return call0 (args[1]);
+    case 3:
+      return call1 (args[1], args[2]);
+    default:
+      return call2 (args[1], args[2], args[3]);
+    }
 }
 
 /* Subroutine for safe_run_hooks: handle an error by clearing out the function
@@ -1878,11 +1886,27 @@ safe_run_hooks_error (Lisp_Object error, ptrdiff_t nargs, Lisp_Object *args)
 static Lisp_Object
 safe_run_hook_funcall (ptrdiff_t nargs, Lisp_Object *args)
 {
-  eassert (nargs == 2);
+  eassert (nargs >= 2 && nargs <= 4);
   /* Yes, run_hook_with_args works with args in the other order.  */
-  internal_condition_case_n (safe_run_hooks_1,
-			     2, ((Lisp_Object []) {args[1], args[0]}),
-			     Qt, safe_run_hooks_error);
+  switch (nargs)
+    {
+    case 2:
+      internal_condition_case_n (safe_run_hooks_1,
+				 2, ((Lisp_Object []) {args[1], args[0]}),
+				 Qt, safe_run_hooks_error);
+      break;
+    case 3:
+      internal_condition_case_n (safe_run_hooks_1,
+				 3, ((Lisp_Object []) {args[1], args[0], args[2]}),
+				 Qt, safe_run_hooks_error);
+      break;
+    default:
+      internal_condition_case_n (safe_run_hooks_1,
+				 4, ((Lisp_Object [])
+				     {args[1], args[0], args[2], args[3]}),
+				 Qt, safe_run_hooks_error);
+      break;
+    }
   return Qnil;
 }
 


> TIA,

> Michael.

-- 
Alan Mackenzie (Nuremberg, Germany).




This bug report was last modified 2 years and 336 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.