GNU bug report logs - #67196
M-: uses a wrong value of debug-on-error when it is nil.

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Alan Mackenzie <acm@HIDDEN>; dated Wed, 15 Nov 2023 17:03:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 27 Dec 2023 04:54:17 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Dec 26 23:54:17 2023
Received: from localhost ([127.0.0.1]:35225 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rILvt-0003zH-9H
	for submit <at> debbugs.gnu.org; Tue, 26 Dec 2023 23:54:17 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:41612)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rms@HIDDEN>) id 1rILvr-0003z1-1q
 for 67196 <at> debbugs.gnu.org; Tue, 26 Dec 2023 23:54:16 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <rms@HIDDEN>)
 id 1rILvk-00044D-Eh; Tue, 26 Dec 2023 23:54:08 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=Date:References:Subject:In-Reply-To:To:From:
 mime-version; bh=2+vvn56xrkOU/4h/HJD3iHZP2ZTBYMV1yjS96lJ8Dmo=; b=cgYUpwxljo9W
 LR2DlBPlRNg+gSs4A/1yaDioT9wgWQLO7AVpLqA5TZXWttFdbU2dtOwY0o3czphFzzChV8LvZfu9o
 TSdOoJxHPUQmGBuZj8pbqo+tcnbCfpFD7hmCzPeQY6jwO8EUAYAfMiS8/WsW4qY9jh75jbbkFkXLE
 MBjD1ntqla4URDW/SVOLrh4vkf4dEEpHoZ5enZjn2aMhTJ8BqMPcgl9NWtOJaGx7R91mzBxhaHDUu
 FtvB5yEHN4HGklQ+CFxkpVdjiWPxyN1IeN7tQedqdHYC1Fl/em6lc4xGvWwb4pthCIjAyuwl16WZ6
 1aBj6GKTJIy9KqGV9YehDw==;
Received: from rms by fencepost.gnu.org with local (Exim 4.90_1)
 (envelope-from <rms@HIDDEN>)
 id 1rILvj-0006Nv-F4; Tue, 26 Dec 2023 23:54:07 -0500
Content-Type: text/plain; charset=Utf-8
From: Richard Stallman <rms@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <jwvzfxxit7b.fsf-monnier+emacs@HIDDEN> (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
References: <ZVTMOH229jaiw86s@ACM> <83a5rfq6i2.fsf@HIDDEN>
 <ZVUGBolDKfgLNEy8@ACM> <jwvjzqdekij.fsf-monnier+emacs@HIDDEN>
 <ZWDZF17mTpJp48ly@ACM> <83ttpbdm2f.fsf@HIDDEN> <ZWENlc6fj9odIdt6@ACM>
 <jwvleam6e7v.fsf-monnier+emacs@HIDDEN> <ZWEh52qxu8CfNKlC@ACM>
 <83il5qe00e.fsf@HIDDEN> <ZWHNN3LTX-QNDd51@ACM>
 <jwv34wu2ag2.fsf-monnier+emacs@HIDDEN>
 <jwvr0jlxxzi.fsf-monnier+emacs@HIDDEN>
 <E1rFRBn-0003Hp-T7@HIDDEN>
 <jwvv88urdex.fsf-monnier+emacs@HIDDEN>
 <E1rHbqa-0007Sw-VO@HIDDEN> <jwvzfxxit7b.fsf-monnier+emacs@HIDDEN>
Message-Id: <E1rILvj-0006Nv-F4@HIDDEN>
Date: Tue, 26 Dec 2023 23:54:07 -0500
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, acm@HIDDEN, eliz@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: rms@HIDDEN
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

When I first implemented Emacs Lisp -- before there was an editor to
fit it into -- I was desperately trying to keep it small.
Thus, when implementing error handling, I did not try to represent
error daat in such a way that a handler could analyze the situation
or continue.  So I implemented condition-case and that's all.

handler-bind is a natural step forward, but it might be desirable to make
a way to handle an error and continue from where the error happened.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)






Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 26 Dec 2023 02:39:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Dec 25 21:39:58 2023
Received: from localhost ([127.0.0.1]:55659 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rHxMA-0003sa-Gl
	for submit <at> debbugs.gnu.org; Mon, 25 Dec 2023 21:39:58 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:19923)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1rHxM7-0003sJ-HA
 for 67196 <at> debbugs.gnu.org; Mon, 25 Dec 2023 21:39:44 -0500
Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 32EA982FEA;
 Mon, 25 Dec 2023 21:39:31 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1703558369;
 bh=hZulPFtqXigfBD5gzWd6K/IPSla0oH4EqhSmG4Ex8t8=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=RT6hEYP8Pyz9/A3WCFsStow6lHY8y1rw/NXJJ82O1c1mufVBge3bIZ81x7Hz5qmKQ
 SqYEMW403iS5DB3A+lAF9xqgyNmm1Zaa5AxwvH9nflTka3WDVl8r62r2W67qrnaVo+
 2XneSLy3LiayXCFme/kDVs3goA/FAbSGcf4ViFXBx/WrI/1fQ3BE/RihYI3cWHX4gB
 gPqhQFtbxaX8MIp53JNGfhhE+fiuEGnULZiapxxYFqJ40eIk1LlsnF7h6EMO1x7Gm/
 Qm3fXI78H+yY0W4AMlMSX1ApcG3qNQ6WYsEudN114/JjIVoUnRSgw22Hy5YN7LGQRP
 40Jgh5Cr5Obuw==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 2CA0F808AD;
 Mon, 25 Dec 2023 21:39:29 -0500 (EST)
Received: from pastel (65-110-221-238.cpe.pppoe.ca [65.110.221.238])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id E7F4A12110E;
 Mon, 25 Dec 2023 21:39:28 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Richard Stallman <rms@HIDDEN>
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
In-Reply-To: <E1rHbqa-0007Sw-VO@HIDDEN> (Richard Stallman's message
 of "Sun, 24 Dec 2023 22:41:44 -0500")
Message-ID: <jwvzfxxit7b.fsf-monnier+emacs@HIDDEN>
References: <ZVTMOH229jaiw86s@ACM> <83a5rfq6i2.fsf@HIDDEN>
 <ZVUGBolDKfgLNEy8@ACM> <jwvjzqdekij.fsf-monnier+emacs@HIDDEN>
 <ZWDZF17mTpJp48ly@ACM> <83ttpbdm2f.fsf@HIDDEN> <ZWENlc6fj9odIdt6@ACM>
 <jwvleam6e7v.fsf-monnier+emacs@HIDDEN> <ZWEh52qxu8CfNKlC@ACM>
 <83il5qe00e.fsf@HIDDEN> <ZWHNN3LTX-QNDd51@ACM>
 <jwv34wu2ag2.fsf-monnier+emacs@HIDDEN>
 <jwvr0jlxxzi.fsf-monnier+emacs@HIDDEN>
 <E1rFRBn-0003Hp-T7@HIDDEN>
 <jwvv88urdex.fsf-monnier+emacs@HIDDEN>
 <E1rHbqa-0007Sw-VO@HIDDEN>
Date: Mon, 25 Dec 2023 21:39:26 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL 0.110 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain T_SCC_BODY_TEXT_LINE    -0.01 -
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, acm@HIDDEN, eliz@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain

>   > Here's my current handler-bind patch, which includes some doc.
> Thanks, but I don't see any documentation of handler-bind in that patch.

Hmm... indeed it wasn't the right patch.  Don't know how that happened.
Hopefully, this one is better,


        Stefan

--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline; filename=handler-bind.patch

commit 034f453c17683bfc4e55e8a9bf9402556c4cb1ae
Author: Stefan Monnier <monnier@HIDDEN>
Date:   Mon Dec 18 23:45:05 2023 -0500

    New special form `handler-bind`
    
    AFAIK, this provides the same semantics as Common Lisp's `handler-bind`.
    
    * lisp/subr.el (handler-bind): New macro.
    
    * src/eval.c (pop_handler): New function.
    (Fhandler_Bind_1): New function.
    (signal_or_quit): Handle new handlertypes `HANDLER` and `SKIP_CONDITIONS`.
    (find_handler_clause): Simplify.
    (syms_of_eval): Defsubr `Fhandler_bind_1`.
    
    * doc/lispref/control.texi (Handling Errors): Add `handler-bind`.
    
    * test/src/eval-tests.el (eval-tests--handler-bind): New test.

diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi
index d4bd8c14ae3..4107963eed5 100644
--- a/doc/lispref/control.texi
+++ b/doc/lispref/control.texi
@@ -2293,6 +2293,44 @@ Handling Errors
 @code{condition-case-unless-debug} rather than @code{condition-case}.
 @end defmac
 
+Occasionally, we want to catch some errors and record some information
+about the conditions in which they occurred, such as the full
+backtrace, or the current buffer.  This kinds of information is sadly
+not available in the handlers of a @code{condition-case} because the
+stack is unwound before running that handler, so the handler is run in
+the dynamic context of the @code{condition-case} rather than that of
+the place where the error was signaled.  For those circumstances, you
+can use the following form:
+
+@defmac handler-bind handlers body@dots{}
+This special form runs @var{body} and if it executes without error,
+the value it returns becomes the value of the @code{handler-bind}
+form.  In this case, the @code{handler-bind} has no effect.
+
+@var{handlers} should be a list of elements of the form
+@code{(@var{conditions} @var{handler})} where @var{conditions} is an
+error condition name to be handled, or a list of condition names, and
+@var{handler} should be a form whose evaluation should return a function.
+
+Before running @var{body}, @code{handler-bind} evaluates all the
+@var{handler} forms and installs those handlers to be active during
+the evaluation of @var{body}.  These handlers are searched together
+with those installed by @code{condition-case}.  When the innermost
+matching handler is one installed by @code{handler-bind}, the
+@var{handler} function is called with a single argument holding the
+error description.
+
+@var{handler} is called in the dynamic context where the error
+happened, without first unwinding the stack, meaning that all the
+dynamic bindings are still in effect, except that all the error
+handlers between the code that signaled the error and the
+@code{handler-bind} are temporarily suspended.  Like any normal
+function, @var{handler} can exit non-locally, typically via
+@code{throw}, or it can return normally.  If @var{handler} returns
+normally, it means the handler @emph{declined} to handle the error and
+the search for an error handler is continued where it left off.
+@end defmac
+
 @node Error Symbols
 @subsubsection Error Symbols and Condition Names
 @cindex error symbol
diff --git a/etc/NEWS b/etc/NEWS
index 90ff23b7937..8e71b0a903d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1326,6 +1326,11 @@ values.
 
 * Lisp Changes in Emacs 30.1
 
+** New special form 'handler-bind'.
+Provides a functionality similar to `condition-case` except it runs the
+handler code without unwinding the stack, such that we can record the
+backtrace and other dynamic state at the point of the error.
+
 ** New 'pop-up-frames' action alist entry for 'display-buffer'.
 This has the same effect as the variable of the same name and takes
 precedence over the variable when present.
diff --git a/lisp/subr.el b/lisp/subr.el
index 93428c4a518..c53dd333303 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -7497,6 +7497,36 @@ match-buffers
         (push buf bufs)))
     bufs))
 
+(defmacro handler-bind (handlers &rest body)
+  "Setup error HANDLERS around execution of BODY.
+HANDLERS is a list of (CONDITIONS HANDLER) where
+CONDITIONS should be a list of condition names (symbols) or
+a single condition name and HANDLER is a form whose evaluation
+returns a function.
+When an error is signaled during execution of BODY, if that
+error matches CONDITIONS, then the associated HANDLER
+function is called with the error as argument.
+HANDLERs can either transfer the control via a non-local exit,
+or return normally.  If they return normally the search for an
+error handler continues from where it left off."
+  ;; FIXME: Completion support as in `condition-case'?
+  (declare (indent 1) (debug ((&rest (sexp form)) body)))
+  (let ((args '())
+        (bindings '()))
+    (dolist (cond+handler (reverse handlers))
+      (let ((handler (car (cdr cond+handler)))
+            (conds (car cond+handler))
+            (handlersym (gensym "handler")))
+        (push (list handlersym handler) bindings)
+        (if (not (listp conds))
+            (progn
+              (push handlersym args)
+              (push `',conds args))
+          (dolist (cond conds)
+            (push handlersym args)
+            (push `',cond args)))))
+    `(let ,bindings (handler-bind-1 (lambda () ,@body) ,@args))))
+
 (defmacro with-memoization (place &rest code)
   "Return the value of CODE and stash it in PLACE.
 If PLACE's value is non-nil, then don't bother evaluating CODE
diff --git a/src/eval.c b/src/eval.c
index 419285eb694..e00886afbc8 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1192,6 +1192,12 @@ DEFUN ("catch", Fcatch, Scatch, 1, UNEVALLED, 0,
 
 #define clobbered_eassert(E) verify (sizeof (E) != 0)
 
+static void
+pop_handler (void)
+{
+  handlerlist = handlerlist->next;
+}
+
 /* Set up a catch, then call C function FUNC on argument ARG.
    FUNC should return a Lisp_Object.
    This is how catches are done from within C code.  */
@@ -1355,6 +1361,37 @@ or (:success BODY...), where the BODY is made of Lisp expressions.
   return internal_lisp_condition_case (var, bodyform, handlers);
 }
 
+DEFUN ("handler-bind-1", Fhandler_bind_1, Shandler_bind_1, 1, MANY, 0,
+       doc: /* Setup error handlers around execution of BODYFUN.
+BODYFUN be a function and it is called with no arguments.
+CONDITION should be a condition name (symbol).
+When an error is signaled during executon of BODYFUN, if that
+error matches CONDITION, then the associated HANDLER is
+called with the error as argument.
+HANDLER should either transfer the control via a non-local exit,
+or return normally.
+If it returns normally, the search for an error handler continues
+from where it left off.
+
+usage: (handler-bind BODYFUN [CONDITION HANDLER]...)  */)
+  (ptrdiff_t nargs, Lisp_Object *args)
+{
+  eassert (nargs >= 1);
+  Lisp_Object bodyfun = args[0];
+  Lisp_Object map = Qnil;
+  ptrdiff_t i = 2;
+  while (i < nargs)
+    {
+      Lisp_Object condition = args[i - 1], handler = args[i];
+      map = Fcons (Fcons (condition, handler), map);
+      i += 2;
+    }
+  push_handler (Fnreverse (map), HANDLER);
+  Lisp_Object ret = call0 (bodyfun);
+  pop_handler ();
+  return ret;
+}
+
 /* Like Fcondition_case, but the args are separate
    rather than passed in a list.  Used by Fbyte_code.  */
 
@@ -1731,6 +1768,7 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool keyboard_quit)
     = (NILP (error_symbol) ? Fcar (data) : error_symbol);
   Lisp_Object clause = Qnil;
   struct handler *h;
+  int skip;
 
   if (gc_in_progress || waiting_for_input)
     emacs_abort ();
@@ -1753,6 +1791,7 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool keyboard_quit)
       /* Edebug takes care of restoring these variables when it exits.  */
       max_ensure_room (&max_lisp_eval_depth, lisp_eval_depth, 20);
 
+      /* FIXME: 'handler-bind' makes `signal-hook-function' obsolete?  */
       call2 (Vsignal_hook_function, error_symbol, data);
     }
 
@@ -1772,16 +1811,53 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool keyboard_quit)
 	Vsignaling_function = backtrace_function (pdl);
     }
 
-  for (h = handlerlist; h; h = h->next)
+  for (skip = 0, h = handlerlist; h; skip++, h = h->next)
     {
-      if (h->type == CATCHER_ALL)
+      switch (h->type)
         {
+        case CATCHER_ALL:
           clause = Qt;
           break;
-        }
-      if (h->type != CONDITION_CASE)
-	continue;
-      clause = find_handler_clause (h->tag_or_ch, conditions);
+	case CATCHER:
+	  continue;
+        case CONDITION_CASE:
+          clause = find_handler_clause (h->tag_or_ch, conditions);
+	  break;
+	case HANDLER:
+	  {
+	    Lisp_Object handlers = h->tag_or_ch;
+	    for (; CONSP (handlers); handlers = XCDR (handlers))
+	      {
+	        Lisp_Object handler = XCAR (handlers);
+	        if (CONSP (handler)
+	            && !NILP (Fmemq (XCAR (handler), conditions)))
+	          {
+	            Lisp_Object error_data
+	              = (NILP (error_symbol)
+	                 ? data : Fcons (error_symbol, data));
+	            push_handler (make_fixnum (skip), SKIP_CONDITIONS);
+	            Lisp_Object retval = call1 (XCDR (handler), error_data);
+	            pop_handler ();
+	            if (CONSP (retval))
+	              {
+	                error_symbol = XCAR (retval);
+	                data = XCDR (retval);
+	                conditions = Fget (error_symbol, Qerror_conditions);
+	              }
+	          }
+	      }
+	    continue;
+	  }
+	case SKIP_CONDITIONS:
+	  {
+	    int toskip = XFIXNUM (h->tag_or_ch);
+	    while (toskip-- >= 0)
+	      h = h->next;
+	    continue;
+	  }
+	default:
+	  abort ();
+	}
       if (!NILP (clause))
 	break;
     }
@@ -1798,7 +1874,7 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool keyboard_quit)
 	  || (CONSP (clause) && !NILP (Fmemq (Qdebug, clause)))
 	  /* Special handler that means "print a message and run debugger
 	     if requested".  */
-	  || EQ (h->tag_or_ch, Qerror)))
+	  || EQ (clause, Qerror)))
     {
       debugger_called
 	= maybe_call_debugger (conditions, error_symbol, data);
@@ -1812,8 +1888,9 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool keyboard_quit)
      with debugging.  Make sure to use `debug-early' unconditionally
      to not interfere with ERT or other packages that install custom
      debuggers.  */
+  /* FIXME: This could be turned into a `handler-bind` at toplevel?  */
   if (!debugger_called && !NILP (error_symbol)
-      && (NILP (clause) || EQ (h->tag_or_ch, Qerror))
+      && (NILP (clause) || EQ (clause, Qerror))
       && noninteractive && backtrace_on_error_noninteractive
       && NILP (Vinhibit_debugger)
       && !NILP (Ffboundp (Qdebug_early)))
@@ -1827,6 +1904,7 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object data, bool keyboard_quit)
 
   /* If an error is signaled during a Lisp hook in redisplay, write a
      backtrace into the buffer *Redisplay-trace*.  */
+  /* FIXME: Turn this into a `handler-bind` installed during redisplay?  */
   if (!debugger_called && !NILP (error_symbol)
       && backtrace_on_redisplay_error
       && (NILP (clause) || h == redisplay_deep_handler)
@@ -2052,13 +2130,10 @@ find_handler_clause (Lisp_Object handlers, Lisp_Object conditions)
   register Lisp_Object h;
 
   /* t is used by handlers for all conditions, set up by C code.  */
-  if (EQ (handlers, Qt))
-    return Qt;
-
   /* error is used similarly, but means print an error message
      and run the debugger if that is enabled.  */
-  if (EQ (handlers, Qerror))
-    return Qt;
+  if (!CONSP (handlers))
+    return handlers;
 
   for (h = handlers; CONSP (h); h = XCDR (h))
     {
@@ -4461,6 +4536,7 @@ syms_of_eval (void)
   defsubr (&Sthrow);
   defsubr (&Sunwind_protect);
   defsubr (&Scondition_case);
+  defsubr (&Shandler_bind_1);
   DEFSYM (QCsuccess, ":success");
   defsubr (&Ssignal);
   defsubr (&Scommandp);
diff --git a/src/lisp.h b/src/lisp.h
index df6cf1df544..ee7ceb8e250 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3595,7 +3595,8 @@ record_in_backtrace (Lisp_Object function, Lisp_Object *args, ptrdiff_t nargs)
 }
 
 /* This structure helps implement the `catch/throw' and `condition-case/signal'
-   control structures.  A struct handler contains all the information needed to
+   control structures as well as 'handler-bind'.
+   A struct handler contains all the information needed to
    restore the state of the interpreter after a non-local jump.
 
    Handler structures are chained together in a doubly linked list; the `next'
@@ -3616,9 +3617,23 @@ record_in_backtrace (Lisp_Object function, Lisp_Object *args, ptrdiff_t nargs)
    state.
 
    Members are volatile if their values need to survive _longjmp when
-   a 'struct handler' is a local variable.  */
-
-enum handlertype { CATCHER, CONDITION_CASE, CATCHER_ALL };
+   a 'struct handler' is a local variable.
+
+   For the HANDLER and SKIP_CONDITIONS cases, we only make use of the
+   `tag_or_ch` field and none of the rest, because there's no longjmp
+   to jump to.
+   [ Maybe we should split the handler-list into a list of restart point
+     (for CATCHERs and CONDITION_CASEs) and a list of conditions handlers
+     (for HANDLERs and CONDITION_CASEs)?  ]
+
+   When running the HANDLER of a 'handler-bind', we need to
+   temporarily "mute" the CONDITION_CASEs and HANDLERs that are "below"
+   the current handler, but without hiding any CATCHERs.  We do that by
+   installing a SKIP_CONDITIONS which tells the search to skip the
+   N next conditions.  */
+
+enum handlertype { CATCHER, CONDITION_CASE, CATCHER_ALL,
+                   HANDLER, SKIP_CONDITIONS };
 
 enum nonlocal_exit
 {
diff --git a/test/src/eval-tests.el b/test/src/eval-tests.el
index 4589763b2f5..71049d927a9 100644
--- a/test/src/eval-tests.el
+++ b/test/src/eval-tests.el
@@ -282,4 +282,41 @@ eval-tests-defvaralias
   (should-error (defvaralias 'eval-tests--my-c 'eval-tests--my-d)
                 :type 'cyclic-variable-indirection))
 
+(ert-deftest eval-tests--handler-bind ()
+  ;; A `handler-bind' has no effect if no error is signaled.
+  (should (equal (catch 'tag
+                   (handler-bind ((error (lambda (err) (throw 'tag 'wow))))
+                     'noerror))
+                 'noerror))
+  ;; The handler is called from within the dynamic extent where the
+  ;; error is signaled, unlike `condition-case'.
+  (should (equal (catch 'tag
+                   (handler-bind ((error (lambda (_err) (throw 'tag 'err))))
+                     (list 'inner-catch
+                           (catch 'tag
+                             (user-error "hello")))))
+                 '(inner-catch err)))
+  ;; But inner condition handlers are temporarily muted.
+  (should (equal (condition-case nil
+                     (handler-bind
+                         ((error (lambda (_err)
+                                   (signal 'wrong-type-argument nil))))
+                       (list 'result
+                             (condition-case nil
+                                 (user-error "hello")
+                               (wrong-type-argument 'inner-handler))))
+                   (wrong-type-argument 'wrong-type-argument))
+                 'wrong-type-argument))
+  ;; Handlers do not apply to the code run within the handlers.
+  (should (equal (condition-case nil
+                     (handler-bind
+                         ((error (lambda (_err)
+                                   (signal 'wrong-type-argument nil)))
+                          (wrong-type-argument
+                           (lambda (_err) (user-error "wrong-type-argument"))))
+                       (user-error "hello"))
+                   (wrong-type-argument 'wrong-type-argument)
+                   (error 'plain-error))
+                 'wrong-type-argument)))
+
 ;;; eval-tests.el ends here

--=-=-=--





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 25 Dec 2023 03:42:00 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 24 22:41:59 2023
Received: from localhost ([127.0.0.1]:53784 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rHbqp-0004ar-Ge
	for submit <at> debbugs.gnu.org; Sun, 24 Dec 2023 22:41:59 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:56318)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rms@HIDDEN>) id 1rHbqn-0004ad-HM
 for 67196 <at> debbugs.gnu.org; Sun, 24 Dec 2023 22:41:58 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <rms@HIDDEN>)
 id 1rHbqb-0006hf-8C; Sun, 24 Dec 2023 22:41:45 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=Date:References:Subject:In-Reply-To:To:From:
 mime-version; bh=xQGbCFu8PJPBW1LG/VH/wC21IlD+3KM8gBjnhJpoFNo=; b=FN0ju/E6/gGh
 70JF3tN/qpgbzrKzUOF800L+YdBzUK8YGbTwAYEMEhpvGWHDGMYz5TEBUgYf7UaPLp7Wct+AKDUCK
 63tTvF+Y5rGctHz+BdAa/Xo62rJAdGLVAI4KLAbWHsUKHdxGGjAnJOY6Jk+E8bNYn4IkDhd9mgLL8
 rjCkINYseLPoTRwxDxTukfXBo7yFKBZvqiD0+U3H0zGRFXfs8jhbYoURUfKE7PtRrmFYjzHOFmFW6
 CuewjFzfTtD23C8LmQMgwQB5ys/HHioAcdKx+IZ8AEXBWt12oTDEaia1hH0J0PFe/U5x1+SZ6zJ9L
 282ec8ivaOKsC/ERemWU5w==;
Received: from rms by fencepost.gnu.org with local (Exim 4.90_1)
 (envelope-from <rms@HIDDEN>)
 id 1rHbqa-0007Sw-VO; Sun, 24 Dec 2023 22:41:44 -0500
Content-Type: text/plain; charset=Utf-8
From: Richard Stallman <rms@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <jwvv88urdex.fsf-monnier+emacs@HIDDEN> (message from Stefan
 Monnier on Tue, 19 Dec 2023 00:05:02 -0500)
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
References: <ZVTMOH229jaiw86s@ACM> <83a5rfq6i2.fsf@HIDDEN>
 <ZVUGBolDKfgLNEy8@ACM> <jwvjzqdekij.fsf-monnier+emacs@HIDDEN>
 <ZWDZF17mTpJp48ly@ACM> <83ttpbdm2f.fsf@HIDDEN> <ZWENlc6fj9odIdt6@ACM>
 <jwvleam6e7v.fsf-monnier+emacs@HIDDEN> <ZWEh52qxu8CfNKlC@ACM>
 <83il5qe00e.fsf@HIDDEN> <ZWHNN3LTX-QNDd51@ACM>
 <jwv34wu2ag2.fsf-monnier+emacs@HIDDEN>
 <jwvr0jlxxzi.fsf-monnier+emacs@HIDDEN>
 <E1rFRBn-0003Hp-T7@HIDDEN> <jwvv88urdex.fsf-monnier+emacs@HIDDEN>
Message-Id: <E1rHbqa-0007Sw-VO@HIDDEN>
Date: Sun, 24 Dec 2023 22:41:44 -0500
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, acm@HIDDEN, eliz@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: rms@HIDDEN
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > Here's my current handler-bind patch, which includes some doc.

Thanks, but I don't see any documentation of handler-bind in that patch.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)






Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 19 Dec 2023 05:05:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Dec 19 00:05:16 2023
Received: from localhost ([127.0.0.1]:33943 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rFSI7-0008Tg-GI
	for submit <at> debbugs.gnu.org; Tue, 19 Dec 2023 00:05:16 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:56595)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1rFSI5-0008TL-Kp
 for 67196 <at> debbugs.gnu.org; Tue, 19 Dec 2023 00:05:14 -0500
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id CD364440055;
 Tue, 19 Dec 2023 00:05:05 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1702962303;
 bh=EkHSyXVofF0UW32HA/BcaTOb+ttbv+pEdQ0SelNzYAk=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=mmhyU6PG3uasyKsJVI6oH8eqK+zLBewBYIxJo2/ivKan9JjZJ4GGzn+KfX+iyhRZf
 x4J9pKJxokzf7RTm7h0oVWV/BBqCPwx/PoGjHCqaQluGPnt2yMaepXnAGc3jFzcKwi
 QUY3a2W4Fu4hoAWqW0lJ6IhOsEwrtj2YhK17U5w3wDnjBDXcOLnFQr5cQRoEQgyptz
 G3Q4PQ+WTMsCkU/bWv5h36X83UkkLxI/oSX2pzfD5Gn69XUOJVYnk0xYpjPJJyDoxV
 4oK9S7AG8xAZXSQ4X3MUj41yES9dkUh92mHpI8Sj3LNA5VP/off2nStXKhryz57beo
 eUIYaw9tNlTwA==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 61A7A44420F;
 Tue, 19 Dec 2023 00:05:03 -0500 (EST)
Received: from pastel (65-110-221-238.cpe.pppoe.ca [65.110.221.238])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 2C0611204D6;
 Tue, 19 Dec 2023 00:05:03 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Richard Stallman <rms@HIDDEN>
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
In-Reply-To: <E1rFRBn-0003Hp-T7@HIDDEN> (Richard Stallman's message
 of "Mon, 18 Dec 2023 22:54:39 -0500")
Message-ID: <jwvv88urdex.fsf-monnier+emacs@HIDDEN>
References: <ZVTMOH229jaiw86s@ACM> <83a5rfq6i2.fsf@HIDDEN>
 <ZVUGBolDKfgLNEy8@ACM> <jwvjzqdekij.fsf-monnier+emacs@HIDDEN>
 <ZWDZF17mTpJp48ly@ACM> <83ttpbdm2f.fsf@HIDDEN> <ZWENlc6fj9odIdt6@ACM>
 <jwvleam6e7v.fsf-monnier+emacs@HIDDEN> <ZWEh52qxu8CfNKlC@ACM>
 <83il5qe00e.fsf@HIDDEN> <ZWHNN3LTX-QNDd51@ACM>
 <jwv34wu2ag2.fsf-monnier+emacs@HIDDEN>
 <jwvr0jlxxzi.fsf-monnier+emacs@HIDDEN>
 <E1rFRBn-0003Hp-T7@HIDDEN>
Date: Tue, 19 Dec 2023 00:05:02 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.004 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain T_SCC_BODY_TEXT_LINE    -0.01 -
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, acm@HIDDEN, eliz@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

--=-=-=
Content-Type: text/plain

>   > > Side note: there's recently been several things pointing to the need to
>   > > add something like Common Lisp's `handler-bind`.
>
> Could someone explain the `handler-bind' construct and show its
> documentation?  It might be a good idea, but it could be that we can
> do better,

Here's my current handler-bind patch, which includes some doc.


        Stefan

--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline; filename=handler-bind.patch

commit 7252f6b48944e22980f4030c98a6c7b05243e19e
Author: Stefan Monnier <monnier@HIDDEN>
Date:   Tue Dec 19 00:03:25 2023 -0500

    tramp.el: Use `handler-bind` instead of `signal-hook-function`
    
    * lisp/net/tramp.el (tramp--trace-errors): Rename from
    `tramp-signal-hook-function` and change calling convention for
    `handler-bind`.
    (tramp-unknown-id-string, tramp-unknown-id-integer):
    Don't use `defconst` for vars which we let-bind (in tramp-tests.el).
    (tramp-file-name-handler): Use `handler-bind` instead of let-binding
    `signal-hook-function`.
    (tramp-handle-lock-file, tramp-handle-load, tramp-add-hops)
    (tramp-run-real-handler):
    * lisp/net/tramp-sshfs.el (tramp-sshfs-handle-insert-file-contents):
    * lisp/net/tramp-sh.el (tramp-sh-get-signal-strings):
    (tramp-send-command-and-read):
    * lisp/net/tramp-message.el (tramp-debug-message, tramp-error):
    * lisp/net/tramp-adb.el (tramp-do-parse-file-attributes-with-ls): Don't
    let-bind `signal-hook-function`.

diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index e4d3ba8c74b..0b68e7384b2 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -297,9 +297,7 @@ tramp-do-parse-file-attributes-with-ls
 		 (cons uid tramp-unknown-id-integer)
 		 (cons gid tramp-unknown-id-integer)
 		 tramp-time-dont-know   ; atime
-		 ;; `date-to-time' checks `iso8601-parse', which might fail.
-		 (let (signal-hook-function)
-		   (date-to-time date))	; mtime
+		 (date-to-time date)	; mtime
 		 tramp-time-dont-know   ; ctime
 		 size
 		 mod-string
diff --git a/lisp/net/tramp-message.el b/lisp/net/tramp-message.el
index e05357f1f4f..924f4d15ad2 100644
--- a/lisp/net/tramp-message.el
+++ b/lisp/net/tramp-message.el
@@ -207,8 +207,7 @@ tramp-debug-message
 ARGUMENTS to actually emit the message (if applicable)."
   (declare (tramp-suppress-trace t))
   (let ((inhibit-message t)
-	create-lockfiles file-name-handler-alist message-log-max
-	signal-hook-function)
+	create-lockfiles file-name-handler-alist message-log-max)
     (with-current-buffer (tramp-get-debug-buffer vec)
       (goto-char (point-max))
       (let ((point (point)))
@@ -364,7 +363,7 @@ tramp-error
 signal identifier to be raised, remaining arguments passed to
 `tramp-message'.  Finally, signal SIGNAL is raised with
 FMT-STRING and ARGUMENTS."
-  (let (signal-hook-function)
+  (let ()
     (tramp-backtrace vec-or-proc)
     (unless arguments
       ;; FMT-STRING could be just a file name, as in
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index a7ead1f2997..77ab5b0a399 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -3168,12 +3168,11 @@ tramp-sh-get-signal-strings
 	(setcdr signals (cddr signals)))
       ;; Sanity check.  "kill -l" shall have returned just the signal
       ;; names.  Some shells don't, like the one in "docker alpine".
-      (let (signal-hook-function)
-	(condition-case nil
-	    (dolist (sig (cdr signals))
-	      (unless (string-match-p (rx bol (+ (any "+-" alnum)) eol) sig)
-		(error nil)))
-	  (error (setq signals '(0)))))
+      (condition-case nil
+	  (dolist (sig (cdr signals))
+	    (unless (string-match-p (rx bol (+ (any "+-" alnum)) eol) sig)
+	      (error nil)))
+	(error (setq signals '(0))))
       (dotimes (i 128)
 	(push
 	 (cond
@@ -5536,9 +5535,7 @@ tramp-send-command-and-read
       ;; Read the expression.
       (condition-case nil
 	  (prog1
-	      (let ((signal-hook-function
-		     (unless noerror signal-hook-function)))
-		(read (current-buffer)))
+	      (read (current-buffer))
 	    ;; Error handling.
 	    (when (search-forward-regexp (rx (not space)) (line-end-position) t)
 	      (error nil)))
diff --git a/lisp/net/tramp-sshfs.el b/lisp/net/tramp-sshfs.el
index 102ba637f55..afc2033ee6e 100644
--- a/lisp/net/tramp-sshfs.el
+++ b/lisp/net/tramp-sshfs.el
@@ -242,7 +242,7 @@ tramp-sshfs-handle-insert-file-contents
   (filename &optional visit beg end replace)
   "Like `insert-file-contents' for Tramp files."
   (setq filename (expand-file-name filename))
-  (let (signal-hook-function result)
+  (let (result)
     (unwind-protect
         (setq result
 	      (insert-file-contents
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 88cbfa2d88c..ebdc8bf97ef 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -1085,10 +1085,10 @@ tramp-postfix-host-regexp
 (defconst tramp-localname-regexp (rx (* (not (any "\r\n"))) eos)
   "Regexp matching localnames.")
 
-(defconst tramp-unknown-id-string "UNKNOWN"
+(defvar tramp-unknown-id-string "UNKNOWN"
   "String used to denote an unknown user or group.")
 
-(defconst tramp-unknown-id-integer -1
+(defvar tramp-unknown-id-integer -1
   "Integer used to denote an unknown user or group.")
 
 ;;;###tramp-autoload
@@ -1994,16 +1994,16 @@ tramp-barf-if-file-missing
 
 ;; This function provides traces in case of errors not triggered by
 ;; Tramp functions.
-(defun tramp-signal-hook-function (error-symbol data)
-  "Function to be called via `signal-hook-function'."
+(defun tramp--trace-errors (err)
+  "Function to be called via `handler-bind'."
   ;; `custom-initialize-*' functions provoke `void-variable' errors.
   ;; We don't want to see them in the backtrace.
   (declare (tramp-suppress-trace t))
-  (unless (eq error-symbol 'void-variable)
+  (unless (eq (car err) 'void-variable)
     (let ((inhibit-message t))
       (tramp-error
-       (car tramp-current-connection) error-symbol
-       (mapconcat (lambda (x) (format "%s" x)) data " ")))))
+       (car tramp-current-connection) (car err)
+       (mapconcat (lambda (x) (format "%s" x)) (cdr err) " ")))))
 
 (defmacro with-parsed-tramp-file-name (filename var &rest body)
   "Parse a Tramp filename and make components available in the body.
@@ -2081,7 +2081,7 @@ with-tramp-progress-reporter
 (defmacro with-tramp-timeout (list &rest body)
   "Like `with-timeout', but allow SECONDS to be nil.
 
-(fn (SECONDS TIMEOUT-FORMS...) BODY)"
+\(fn (SECONDS TIMEOUT-FORMS...) BODY)"
   (declare (indent 1) (debug ((form body) body)))
   (let ((seconds (car list))
 	(timeout-forms (cdr list)))
@@ -2248,8 +2248,7 @@ tramp-run-real-handler
 	    ,(and (eq inhibit-file-name-operation operation)
 		  inhibit-file-name-handlers)))
 	 (inhibit-file-name-operation operation)
-	 (args (if (tramp-file-name-p (car args)) (cons nil (cdr args)) args))
-	 signal-hook-function)
+	 (args (if (tramp-file-name-p (car args)) (cons nil (cdr args)) args)))
     (apply operation args)))
 
 ;; We handle here all file primitives.  Most of them have the file
@@ -2386,8 +2385,8 @@ tramp-file-name-handler
             (let ((current-connection tramp-current-connection)
 		  (foreign
 		   (tramp-find-foreign-file-name-handler v operation))
-		  (signal-hook-function #'tramp-signal-hook-function)
 		  result)
+	      (handler-bind ((error #'tramp--trace-errors))
 	      ;; Set `tramp-current-connection'.
 	      (unless
 		  (tramp-file-name-equal-p v (car tramp-current-connection))
@@ -2453,7 +2452,7 @@ tramp-file-name-handler
 		(unless
 		    (tramp-file-name-equal-p
 		     (car current-connection) (car tramp-current-connection))
-		  (setq tramp-current-connection current-connection))))))
+		  (setq tramp-current-connection current-connection)))))))
 
       ;; When `tramp-mode' is not enabled, or the file name is quoted,
       ;; we don't do anything.
@@ -4584,7 +4583,7 @@ tramp-handle-lock-file
 
 	;; Do the lock.
         (let ((tramp-verbose 0)
-              create-lockfiles signal-hook-function)
+              create-lockfiles)
 	  (condition-case nil
 	      (make-symbolic-link info lockname 'ok-if-already-exists)
 	    (error
@@ -4632,8 +4631,7 @@ tramp-handle-load
       (tramp-error v 'file-missing file))
     (if (not (file-exists-p file))
 	nil
-      (let ((signal-hook-function (unless noerror signal-hook-function))
-	    (inhibit-message (or inhibit-message nomessage)))
+      (let ((inhibit-message (or inhibit-message nomessage)))
 	(with-tramp-progress-reporter v 0 (format "Loading %s" file)
 	  (let ((local-copy (file-local-copy file)))
 	    (unwind-protect
@@ -4651,7 +4649,7 @@ tramp-add-hops
   "Add ad-hoc proxy definitions to `tramp-default-proxies-alist'."
   (when-let ((hops (tramp-file-name-hop vec))
 	     (item vec))
-    (let (signal-hook-function changed)
+    (let (changed)
       (dolist
 	  (proxy (reverse (split-string hops tramp-postfix-hop-regexp 'omit)))
 	(let* ((host-port (tramp-file-name-host-port item))

--=-=-=--





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 19 Dec 2023 03:54:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Dec 18 22:54:54 2023
Received: from localhost ([127.0.0.1]:33916 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rFRC1-0000oF-Op
	for submit <at> debbugs.gnu.org; Mon, 18 Dec 2023 22:54:54 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:53754)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rms@HIDDEN>) id 1rFRBy-0000nk-K1
 for 67196 <at> debbugs.gnu.org; Mon, 18 Dec 2023 22:54:52 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <rms@HIDDEN>)
 id 1rFRBq-00035d-Si; Mon, 18 Dec 2023 22:54:42 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=Date:References:Subject:In-Reply-To:To:From:
 mime-version; bh=im2UZhNBw7WPKrgf4PKF+ENh8EUB2QGoFzUgGarEn+Y=; b=ahZAiS4V8zyy
 MhWvYTQJD/7Mh4pMgF75PXjIoNp5midyhzs0sdYoMgpXqxpvgDu3wbFdE/osrv/X3rIEUR7pYCp/9
 trRUY/acAs+foG3grLiJrphEU6nIxadQ9+BAAvVaXtGaSnD8buNLJchPYTTee+AQW2hSoEHUocRRB
 zokEe9Liu7Vrj1i5cgb2MvYNELTvRsw4CkQfRyEnYSy2utuyD2NIDHUszkqxKBpyhqHX/lLrKtH8X
 QRVZtPsfOs39t2uTivusEKX2ynH5f+q5R3Ijs6L/t8vjAsdHTdUWba513rxn0fiCIbq2ZufC2lP4z
 eosHSSH0eEPiP6XykFGx0w==;
Received: from rms by fencepost.gnu.org with local (Exim 4.90_1)
 (envelope-from <rms@HIDDEN>)
 id 1rFRBn-0003Hp-T7; Mon, 18 Dec 2023 22:54:40 -0500
Content-Type: text/plain; charset=Utf-8
From: Richard Stallman <rms@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <jwvr0jlxxzi.fsf-monnier+emacs@HIDDEN> (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
References: <ZVTMOH229jaiw86s@ACM> <83a5rfq6i2.fsf@HIDDEN>
 <ZVUGBolDKfgLNEy8@ACM> <jwvjzqdekij.fsf-monnier+emacs@HIDDEN>
 <ZWDZF17mTpJp48ly@ACM> <83ttpbdm2f.fsf@HIDDEN> <ZWENlc6fj9odIdt6@ACM>
 <jwvleam6e7v.fsf-monnier+emacs@HIDDEN> <ZWEh52qxu8CfNKlC@ACM>
 <83il5qe00e.fsf@HIDDEN> <ZWHNN3LTX-QNDd51@ACM>
 <jwv34wu2ag2.fsf-monnier+emacs@HIDDEN>
 <jwvr0jlxxzi.fsf-monnier+emacs@HIDDEN>
Message-Id: <E1rFRBn-0003Hp-T7@HIDDEN>
Date: Mon, 18 Dec 2023 22:54:39 -0500
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, acm@HIDDEN, eliz@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: rms@HIDDEN
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > > Side note: there's recently been several things pointing to the need to
  > > add something like Common Lisp's `handler-bind`.

Could someone explain the `handler-bind' construct and show its
documentation?  It might be a good idea, but it could be that we can
do better,

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)






Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 17 Dec 2023 04:23:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 16 23:23:44 2023
Received: from localhost ([127.0.0.1]:56444 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rEigp-0000pN-TO
	for submit <at> debbugs.gnu.org; Sat, 16 Dec 2023 23:23:44 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:60513)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1rEigm-0000p1-EZ
 for 67196 <at> debbugs.gnu.org; Sat, 16 Dec 2023 23:23:42 -0500
Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id D9CD180C20;
 Sat, 16 Dec 2023 23:23:33 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1702787012;
 bh=uSIeYY8ESAw57XLW7X4vIEC7lZ5vrBqGmBPTbartRu4=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=i7tm8d4nzIMY4BMvgxlLeDv2pEWiieEKo+oeXi7cs3pVqgFGqLZOrlAYs2ykcBAjp
 oakFMaKG96fkLacIZSeKUFYZ9qkHEzxrA12AXq9VtIEE3vcZ/e6E+KdBOGadC5fV27
 V12QnnVacQos2jqC1WTkFl3vz+rMCqONpWwRK/fq7HPWTTDee8/5sVUxGcx2l/iuN7
 MKI/eAxVYiBJ75Ze029kAhbJqJ66HkdA4mOekx7fTYDf0e04sAjiuALwt3N9bRuix2
 EJit0z6Di442F40kc0mwwF/hGqDPCTbeTRyjGcTzLigHst6n65tSwa3s+BcHjMOsP1
 v4m+jnn8MJ1Fw==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id A662080C0A;
 Sat, 16 Dec 2023 23:23:32 -0500 (EST)
Received: from pastel (65-110-221-238.cpe.pppoe.ca [65.110.221.238])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 4E925120DDE;
 Sat, 16 Dec 2023 23:23:32 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
In-Reply-To: <jwv34wu2ag2.fsf-monnier+emacs@HIDDEN> (Stefan Monnier's message
 of "Sat, 25 Nov 2023 09:23:42 -0500")
Message-ID: <jwvr0jlxxzi.fsf-monnier+emacs@HIDDEN>
References: <ZVTMOH229jaiw86s@ACM> <83a5rfq6i2.fsf@HIDDEN>
 <ZVUGBolDKfgLNEy8@ACM> <jwvjzqdekij.fsf-monnier+emacs@HIDDEN>
 <ZWDZF17mTpJp48ly@ACM> <83ttpbdm2f.fsf@HIDDEN> <ZWENlc6fj9odIdt6@ACM>
 <jwvleam6e7v.fsf-monnier+emacs@HIDDEN> <ZWEh52qxu8CfNKlC@ACM>
 <83il5qe00e.fsf@HIDDEN> <ZWHNN3LTX-QNDd51@ACM>
 <jwv34wu2ag2.fsf-monnier+emacs@HIDDEN>
Date: Sat, 16 Dec 2023 23:23:31 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL 0.054 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain T_SCC_BODY_TEXT_LINE    -0.01 -
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

--=-=-=
Content-Type: text/plain

> Side note: there's recently been several things pointing to the need to
> add something like Common Lisp's `handler-bind`.

BTW, I now have working code implementing `handler-bind` (see bug#67862
for a preview of the code).  With it I can fix this bug with the
patch below (well, plus a tweak in `debug.el` plus some docstring
adjustements).


        Stefan



--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline; filename=eval-expression.patch

diff --git a/lisp/simple.el b/lisp/simple.el
index cee1ddac52f..da07a249081 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2120,23 +2120,17 @@ eval-expression
    (cons (read--expression "Eval: ")
          (eval-expression-get-print-arguments current-prefix-arg)))
 
-  (let (result)
+  (let* (result
+         (runfun
+          (lambda ()
+            (setq result
+                  (values--store-value
+                   (eval (let ((lexical-binding t)) (macroexpand-all exp))
+                         t))))))
     (if (null eval-expression-debug-on-error)
-        (setq result
-              (values--store-value
-               (eval (let ((lexical-binding t)) (macroexpand-all exp)) t)))
-      (let ((old-value (make-symbol "t")) new-value)
-        ;; Bind debug-on-error to something unique so that we can
-        ;; detect when evalled code changes it.
-        (let ((debug-on-error old-value))
-          (setq result
-	        (values--store-value
-                 (eval (let ((lexical-binding t)) (macroexpand-all exp)) t)))
-	  (setq new-value debug-on-error))
-        ;; If evalled code has changed the value of debug-on-error,
-        ;; propagate that change to the global binding.
-        (unless (eq old-value new-value)
-	  (setq debug-on-error new-value))))
+        (funcall runfun)
+      (handler-bind ((error debugger))
+        (funcall runfun)))
 
     (let ((print-length (unless no-truncate eval-expression-print-length))
           (print-level  (unless no-truncate eval-expression-print-level))

--=-=-=--





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 25 Nov 2023 18:13:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 25 13:13:11 2023
Received: from localhost ([127.0.0.1]:40173 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6x9T-0002A0-HR
	for submit <at> debbugs.gnu.org; Sat, 25 Nov 2023 13:13:11 -0500
Received: from mail-out.m-online.net ([212.18.0.9]:44960)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <whitebox@HIDDEN>) id 1r6x9Q-00029p-Ns
 for 67196 <at> debbugs.gnu.org; Sat, 25 Nov 2023 13:13:10 -0500
Received: from frontend01.mail.m-online.net (unknown [192.168.8.182])
 by mail-out.m-online.net (Postfix) with ESMTP id 4Sd0MJ1kR9z1qsPc;
 Sat, 25 Nov 2023 19:12:59 +0100 (CET)
Received: from localhost (dynscan1.mnet-online.de [192.168.6.68])
 by mail.m-online.net (Postfix) with ESMTP id 4Sd0MH66v1z1qqlS;
 Sat, 25 Nov 2023 19:12:59 +0100 (CET)
X-Virus-Scanned: amavis at mnet-online.de
Received: from mail.mnet-online.de ([192.168.8.182])
 by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavis, port 10024)
 with ESMTP id pruvH22Y0Lpl; Sat, 25 Nov 2023 19:12:59 +0100 (CET)
X-Auth-Info: Z+ZwkckVaJcxfzL4eOQx7ceMoCHFw9OpSlCcQxT6ngUok9mKKtAAcQ4ipULcJXT6
Received: from igel.home (aftr-62-216-205-193.dynamic.mnet-online.de
 [62.216.205.193])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
 (No client certificate requested)
 by mail.mnet-online.de (Postfix) with ESMTPSA;
 Sat, 25 Nov 2023 19:12:59 +0100 (CET)
Received: by igel.home (Postfix, from userid 1000)
 id 921582C1C07; Sat, 25 Nov 2023 19:12:58 +0100 (CET)
From: Andreas Schwab <schwab@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
In-Reply-To: <ZWIncbvgpPxb2WPq@ACM> (Alan Mackenzie's message of "Sat, 25 Nov
 2023 16:57:21 +0000")
References: <ZWEh52qxu8CfNKlC@ACM> <83il5qe00e.fsf@HIDDEN>
 <ZWHNN3LTX-QNDd51@ACM> <83edgecce4.fsf@HIDDEN> <ZWHrIwPr5aW0IXvr@ACM>
 <8334wuc7cn.fsf@HIDDEN> <ZWIBY6B_7s8qbZzD@ACM>
 <83y1elbzny.fsf@HIDDEN> <ZWIjiObn_fBCzpwO@ACM>
 <83sf4tbx2q.fsf@HIDDEN> <ZWIncbvgpPxb2WPq@ACM>
X-Yow: Hello?  Enema Bondage?  I'm calling because I want to be happy, I
 guess..
Date: Sat, 25 Nov 2023 19:12:58 +0100
Message-ID: <87plzxwvkl.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 3.1 (+++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  On Nov 25 2023,
 Alan Mackenzie wrote: > My guess is that debug-on-error
 was originally a DEFVAR_BOOL, and at some > stage it was extended to handle
 a list of conditions. But for some > reason eval-expression-debug-on-error
 was not extende [...] 
 Content analysis details:   (3.1 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 3.6 RCVD_IN_SBL_CSS        RBL: Received via a relay in Spamhaus SBL-CSS
 [62.216.205.193 listed in zen.spamhaus.org]
 -0.7 RCVD_IN_DNSWL_LOW      RBL: Sender listed at https://www.dnswl.org/,
 low trust [212.18.0.9 listed in list.dnswl.org]
 0.0 RCVD_IN_MSPIKE_H3      RBL: Good reputation (+3)
 [212.18.0.9 listed in wl.mailspike.net]
 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.0 SPF_PASS               SPF: sender matches SPF record
 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level
 mail domains are different
 0.0 RCVD_IN_MSPIKE_WL      Mailspike good senders
 -0.0 T_SCC_BODY_TEXT_LINE   No description available.
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>,
 monnier@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 2.1 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  On Nov 25 2023, Alan Mackenzie wrote: > My guess is that debug-on-error
    was originally a DEFVAR_BOOL, and at some > stage it was extended to handle
    a list of conditions. But for some > reason eval-expression-debug-on-error
    was not extende [...] 
 
 Content analysis details:   (2.1 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.7 RCVD_IN_DNSWL_LOW      RBL: Sender listed at https://www.dnswl.org/,
                             low trust
                             [212.18.0.9 listed in list.dnswl.org]
  3.6 RCVD_IN_SBL_CSS        RBL: Received via a relay in Spamhaus SBL-CSS
                             [62.216.205.193 listed in zen.spamhaus.org]
  0.0 RCVD_IN_MSPIKE_H3      RBL: Good reputation (+3)
                             [212.18.0.9 listed in wl.mailspike.net]
  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.0 SPF_PASS               SPF: sender matches SPF record
  0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level
                             mail domains are different
  0.0 RCVD_IN_MSPIKE_WL      Mailspike good senders
 -0.0 T_SCC_BODY_TEXT_LINE   No description available.
 -1.0 MAILING_LIST_MULTI     Multiple indicators imply a widely-seen list
                             manager

On Nov 25 2023, Alan Mackenzie wrote:

> My guess is that debug-on-error was originally a DEFVAR_BOOL, and at some
> stage it was extended to handle a list of conditions.  But for some
> reason eval-expression-debug-on-error was not extended in the same way.

There is no need to extend eval-expression-debug-on-error.  Just set it
to nil to let eval-expression use the value of debug-on-error as usual.

-- 
Andreas Schwab, schwab@HIDDEN
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 25 Nov 2023 17:36:52 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 25 12:36:52 2023
Received: from localhost ([127.0.0.1]:40159 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6waJ-00019Y-P4
	for submit <at> debbugs.gnu.org; Sat, 25 Nov 2023 12:36:52 -0500
Received: from mail.muc.de ([193.149.48.3]:37210)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1r6waH-00019H-IM
 for 67196 <at> debbugs.gnu.org; Sat, 25 Nov 2023 12:36:50 -0500
Received: (qmail 5615 invoked by uid 3782); 25 Nov 2023 18:36:38 +0100
Received: from acm.muc.de (pd953a2e3.dip0.t-ipconnect.de [217.83.162.227])
 (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP;
 Sat, 25 Nov 2023 18:36:38 +0100
Received: (qmail 19863 invoked by uid 1000); 25 Nov 2023 17:36:37 -0000
Date: Sat, 25 Nov 2023 17:36:37 +0000
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
Message-ID: <ZWIwpSo950ZrEqo_@ACM>
References: <83il5qe00e.fsf@HIDDEN> <ZWHNN3LTX-QNDd51@ACM>
 <83edgecce4.fsf@HIDDEN> <ZWHrIwPr5aW0IXvr@ACM>
 <8334wuc7cn.fsf@HIDDEN> <ZWIBY6B_7s8qbZzD@ACM>
 <83y1elbzny.fsf@HIDDEN> <ZWIjiObn_fBCzpwO@ACM>
 <83sf4tbx2q.fsf@HIDDEN> <ZWIncbvgpPxb2WPq@ACM>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <ZWIncbvgpPxb2WPq@ACM>
X-Submission-Agent: TMDA/1.3.x (Ph3nix)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, acm@HIDDEN, monnier@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello again, Eli.

On Sat, Nov 25, 2023 at 16:57:21 +0000, Alan Mackenzie wrote:
> On Sat, Nov 25, 2023 at 18:46:05 +0200, Eli Zaretskii wrote:
> > > Date: Sat, 25 Nov 2023 16:40:40 +0000
> > > Cc: monnier@HIDDEN, 67196 <at> debbugs.gnu.org, acm@HIDDEN
> > > From: Alan Mackenzie <acm@HIDDEN>

> > > > > Instead, the new internal variable
> > > > > debug-from--eval-expression gets set to e-e-debug-on-error.

> > > > Exactly.  And that value can be non-nil, but also not t.  That is the
> > > > change I see, and your doc string suggests that it is intentional.
> > > > Thus, we have a behavior change wrt to the value that the body of
> > > > eval-expression will see.  And non-nil, non-t values have special
> > > > meaning there.

> > > OK, I'm with you, now.  The non-nil, non-t value in the internal variable
> > > debug-from--e-e won't be seen by any Lisp code.  It can be seen by Lisp
> > > code in eval-expression-debug-on-error.

> > > This is an extension of e-e-debug-on-error to match what debug-on-error
> > > does.  I wouldn't think that d-o-e gets set to a list of conditions very
> > > often, but when it does, it's likely very useful.  It seemed logical to
> > > extend the same facility to e-e-debug-on-error.  Do you think this is a
> > > bad idea?  [Clearly, some entries in NEWS will be needed, as well as
> > > amendments to the Elisp manual.]

> > I don't know yet if it is a good idea, I just wanted to point out that
> > your change is not just a bugfix: it actually changes the behavior of
> > eval-expression.

> OK.  It's a change that would be trivially easy to reverse.

> My guess is that debug-on-error was originally a DEFVAR_BOOL, and at some
> stage it was extended to handle a list of conditions.  But for some
> reason eval-expression-debug-on-error was not extended in the same way.
> Perhaps this was an oversight.  If so, now would be a good time to fix
> this.

> Maybe there is some evidence of what happened in the repository.  I'll
> have a look.

eval-expression-debug-on-error came into existence with this commit:

commit b49df39ddcfc578234530208eba8e288f604db1b
Author: Richard M. Stallman <rms@HIDDEN>
Date:   Tue Sep 14 07:00:04 1999 +0000

    (eval-expression-print-level): New variable.
    (eval-expression-print-length): New variable.
    (eval-expression-debug-on-error): New variable.
    (eval-expression): Bind print-level, print-length and
    debug-on-error from those vars.

..  debug-on-error got its list value with this commit:

commit 128c0f667926dd4296411b9189125ee8c5b78b79
Author: Roland McGrath <roland@HIDDEN>
Date:   Thu Jun 4 04:33:43 1992 +0000

    *** empty log message ***

..  So debug-on-error had its list of conditions value 7 years before
eval-expression-debug-on-error existed.  It's not clear why this new
variable didn't take over the enhanced semantics from debug-on-error.

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 25 Nov 2023 16:57:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 25 11:57:35 2023
Received: from localhost ([127.0.0.1]:40131 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6vyJ-0008VL-Fh
	for submit <at> debbugs.gnu.org; Sat, 25 Nov 2023 11:57:35 -0500
Received: from mail.muc.de ([193.149.48.3]:56655)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1r6vyH-0008V7-AF
 for 67196 <at> debbugs.gnu.org; Sat, 25 Nov 2023 11:57:34 -0500
Received: (qmail 60121 invoked by uid 3782); 25 Nov 2023 17:57:21 +0100
Received: from acm.muc.de (pd953a2e3.dip0.t-ipconnect.de [217.83.162.227])
 (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP;
 Sat, 25 Nov 2023 17:57:21 +0100
Received: (qmail 19638 invoked by uid 1000); 25 Nov 2023 16:57:21 -0000
Date: Sat, 25 Nov 2023 16:57:21 +0000
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
Message-ID: <ZWIncbvgpPxb2WPq@ACM>
References: <ZWEh52qxu8CfNKlC@ACM> <83il5qe00e.fsf@HIDDEN>
 <ZWHNN3LTX-QNDd51@ACM> <83edgecce4.fsf@HIDDEN>
 <ZWHrIwPr5aW0IXvr@ACM> <8334wuc7cn.fsf@HIDDEN>
 <ZWIBY6B_7s8qbZzD@ACM> <83y1elbzny.fsf@HIDDEN>
 <ZWIjiObn_fBCzpwO@ACM> <83sf4tbx2q.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <83sf4tbx2q.fsf@HIDDEN>
X-Submission-Agent: TMDA/1.3.x (Ph3nix)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, acm@HIDDEN, monnier@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Eli.

On Sat, Nov 25, 2023 at 18:46:05 +0200, Eli Zaretskii wrote:
> > Date: Sat, 25 Nov 2023 16:40:40 +0000
> > Cc: monnier@HIDDEN, 67196 <at> debbugs.gnu.org, acm@HIDDEN
> > From: Alan Mackenzie <acm@HIDDEN>

> > > > Instead, the new internal variable
> > > > debug-from--eval-expression gets set to e-e-debug-on-error.

> > > Exactly.  And that value can be non-nil, but also not t.  That is the
> > > change I see, and your doc string suggests that it is intentional.
> > > Thus, we have a behavior change wrt to the value that the body of
> > > eval-expression will see.  And non-nil, non-t values have special
> > > meaning there.

> > OK, I'm with you, now.  The non-nil, non-t value in the internal variable
> > debug-from--e-e won't be seen by any Lisp code.  It can be seen by Lisp
> > code in eval-expression-debug-on-error.

> > This is an extension of e-e-debug-on-error to match what debug-on-error
> > does.  I wouldn't think that d-o-e gets set to a list of conditions very
> > often, but when it does, it's likely very useful.  It seemed logical to
> > extend the same facility to e-e-debug-on-error.  Do you think this is a
> > bad idea?  [Clearly, some entries in NEWS will be needed, as well as
> > amendments to the Elisp manual.]

> I don't know yet if it is a good idea, I just wanted to point out that
> your change is not just a bugfix: it actually changes the behavior of
> eval-expression.

OK.  It's a change that would be trivially easy to reverse.

My guess is that debug-on-error was originally a DEFVAR_BOOL, and at some
stage it was extended to handle a list of conditions.  But for some
reason eval-expression-debug-on-error was not extended in the same way.
Perhaps this was an oversight.  If so, now would be a good time to fix
this.

Maybe there is some evidence of what happened in the repository.  I'll
have a look.

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 25 Nov 2023 16:46:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 25 11:46:30 2023
Received: from localhost ([127.0.0.1]:40107 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6vnZ-00085Z-SO
	for submit <at> debbugs.gnu.org; Sat, 25 Nov 2023 11:46:30 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:37262)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1r6vnX-00085I-NO
 for 67196 <at> debbugs.gnu.org; Sat, 25 Nov 2023 11:46:29 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1r6vnM-0005Kr-Mn; Sat, 25 Nov 2023 11:46:16 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=N4IYuBHv7Ql3Bd+tsBE7qI7BqMI8obGhU9LliQBdWVo=; b=VcIaurKW6yb7
 AO5BD+LRyv+41Yh6IkHDIOWSShJj4G1dWwo7NaKr75CKawtvn7ADPYUVN3Ds8pMdjzzCNBGg1t2zA
 kS4/bCAuHueV9/KGwbXG4D3r5z35HXbbht7ZwETrrPe7w0UFCGG6SFJFbApmSqn3qrMrF1KpnefDy
 L99oFkNlsiI61EBBM1P8g+AT9RKDDqBeJ0AKtBvpQLQVnmEdk4ArnHo+ZM0XUn3fDlZX/KHgFJGni
 Ip/6K0eK/u2XMI9vnN+mZwBcDBVKrpane2ecRXlWsSxkr4PLUzw6m1Jd/+c4eXnE7rTAl/a+fqnUq
 p0dgZ+rq98kD6YFv4Ib4ig==;
Date: Sat, 25 Nov 2023 18:46:05 +0200
Message-Id: <83sf4tbx2q.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
In-Reply-To: <ZWIjiObn_fBCzpwO@ACM> (message from Alan Mackenzie on Sat, 25
 Nov 2023 16:40:40 +0000)
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
References: <ZWENlc6fj9odIdt6@ACM> <jwvleam6e7v.fsf-monnier+emacs@HIDDEN>
 <ZWEh52qxu8CfNKlC@ACM> <83il5qe00e.fsf@HIDDEN>
 <ZWHNN3LTX-QNDd51@ACM> <83edgecce4.fsf@HIDDEN>
 <ZWHrIwPr5aW0IXvr@ACM> <8334wuc7cn.fsf@HIDDEN>
 <ZWIBY6B_7s8qbZzD@ACM>
 <83y1elbzny.fsf@HIDDEN> <ZWIjiObn_fBCzpwO@ACM>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, monnier@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Sat, 25 Nov 2023 16:40:40 +0000
> Cc: monnier@HIDDEN, 67196 <at> debbugs.gnu.org, acm@HIDDEN
> From: Alan Mackenzie <acm@HIDDEN>
> 
> > > Instead, the new internal variable
> > > debug-from--eval-expression gets set to e-e-debug-on-error.
> 
> > Exactly.  And that value can be non-nil, but also not t.  That is the
> > change I see, and your doc string suggests that it is intentional.
> > Thus, we have a behavior change wrt to the value that the body of
> > eval-expression will see.  And non-nil, non-t values have special
> > meaning there.
> 
> OK, I'm with you, now.  The non-nil, non-t value in the internal variable
> debug-from--e-e won't be seen by any Lisp code.  It can be seen by Lisp
> code in eval-expression-debug-on-error.
> 
> This is an extension of e-e-debug-on-error to match what debug-on-error
> does.  I wouldn't think that d-o-e gets set to a list of conditions very
> often, but when it does, it's likely very useful.  It seemed logical to
> extend the same facility to e-e-debug-on-error.  Do you think this is a
> bad idea?  [Clearly, some entries in NEWS will be needed, as well as
> amendments to the Elisp manual.]

I don't know yet if it is a good idea, I just wanted to point out that
your change is not just a bugfix: it actually changes the behavior of
eval-expression.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 25 Nov 2023 16:40:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 25 11:40:54 2023
Received: from localhost ([127.0.0.1]:40102 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6viA-0005Kh-1o
	for submit <at> debbugs.gnu.org; Sat, 25 Nov 2023 11:40:54 -0500
Received: from mail.muc.de ([193.149.48.3]:56148)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1r6vi8-0005KP-5L
 for 67196 <at> debbugs.gnu.org; Sat, 25 Nov 2023 11:40:53 -0500
Received: (qmail 41293 invoked by uid 3782); 25 Nov 2023 17:40:40 +0100
Received: from acm.muc.de (pd953a2e3.dip0.t-ipconnect.de [217.83.162.227])
 (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP;
 Sat, 25 Nov 2023 17:40:40 +0100
Received: (qmail 19548 invoked by uid 1000); 25 Nov 2023 16:40:40 -0000
Date: Sat, 25 Nov 2023 16:40:40 +0000
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
Message-ID: <ZWIjiObn_fBCzpwO@ACM>
References: <ZWENlc6fj9odIdt6@ACM> <jwvleam6e7v.fsf-monnier+emacs@HIDDEN>
 <ZWEh52qxu8CfNKlC@ACM> <83il5qe00e.fsf@HIDDEN>
 <ZWHNN3LTX-QNDd51@ACM> <83edgecce4.fsf@HIDDEN>
 <ZWHrIwPr5aW0IXvr@ACM> <8334wuc7cn.fsf@HIDDEN>
 <ZWIBY6B_7s8qbZzD@ACM> <83y1elbzny.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <83y1elbzny.fsf@HIDDEN>
X-Submission-Agent: TMDA/1.3.x (Ph3nix)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, acm@HIDDEN, monnier@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Eli.

On Sat, Nov 25, 2023 at 17:50:09 +0200, Eli Zaretskii wrote:
> > Date: Sat, 25 Nov 2023 14:14:59 +0000
> > Cc: monnier@HIDDEN, 67196 <at> debbugs.gnu.org, acm@HIDDEN
> > From: Alan Mackenzie <acm@HIDDEN>

> > > No, I meant with the current code debug-on-error is set to t whenever
> > > eval-expression-debug-on-error is non-nil, ....

> > Yes.

> > > .... and your change sets it to the same value as
> > > eval-expression-debug-on-error instead.

> > That is not what is meant to happen.

> We are miscommunicating.

> > Instead, the new internal variable
> > debug-from--eval-expression gets set to e-e-debug-on-error.

> Exactly.  And that value can be non-nil, but also not t.  That is the
> change I see, and your doc string suggests that it is intentional.
> Thus, we have a behavior change wrt to the value that the body of
> eval-expression will see.  And non-nil, non-t values have special
> meaning there.

OK, I'm with you, now.  The non-nil, non-t value in the internal variable
debug-from--e-e won't be seen by any Lisp code.  It can be seen by Lisp
code in eval-expression-debug-on-error.

This is an extension of e-e-debug-on-error to match what debug-on-error
does.  I wouldn't think that d-o-e gets set to a list of conditions very
often, but when it does, it's likely very useful.  It seemed logical to
extend the same facility to e-e-debug-on-error.  Do you think this is a
bad idea?  [Clearly, some entries in NEWS will be needed, as well as
amendments to the Elisp manual.]

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 25 Nov 2023 15:50:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 25 10:50:53 2023
Received: from localhost ([127.0.0.1]:40052 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6uvl-0003tD-6w
	for submit <at> debbugs.gnu.org; Sat, 25 Nov 2023 10:50:53 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:41194)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1r6uvh-0003sv-GT
 for 67196 <at> debbugs.gnu.org; Sat, 25 Nov 2023 10:50:52 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1r6uvT-0004Wc-Tm; Sat, 25 Nov 2023 10:50:37 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=f5aWEIsZ1S63+Mw8H2Eh5k6tSt2iUHarr2Ev48uzCL8=; b=CkYZc/ljyeqm
 2D61aWSrF591X+ozKtHGr1U8HQkNqXbvn2vUkhPm9NyyETe/eNRYBmymSQMBAs2WERvF7fJ5ryHPK
 CH4lDaSKVne75TJ1ikegPPTSNcNzgnN6Ww4rejo/yp6+B+4OIQ7XGQhClh/U2eG/ILrvr+adO66/E
 J9otD3r36SVjU44TzfwyYxt5ySiXl2D1f6I31a1sYuu5C1oCMwvWrXg0T7FniKnPwlgvBvftIJq/m
 doVK2MVa44NOHrfKWi9s1CqVQ1TROPCaw4uc2VRe18TbPING8lwwtDsIukBhdeV29mFd/hm3cip+v
 v4syTm8ghFzQ46Zk1Qpf3A==;
Date: Sat, 25 Nov 2023 17:50:09 +0200
Message-Id: <83y1elbzny.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
In-Reply-To: <ZWIBY6B_7s8qbZzD@ACM> (message from Alan Mackenzie on Sat, 25
 Nov 2023 14:14:59 +0000)
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
References: <ZWDZF17mTpJp48ly@ACM> <83ttpbdm2f.fsf@HIDDEN>
 <ZWENlc6fj9odIdt6@ACM> <jwvleam6e7v.fsf-monnier+emacs@HIDDEN>
 <ZWEh52qxu8CfNKlC@ACM> <83il5qe00e.fsf@HIDDEN>
 <ZWHNN3LTX-QNDd51@ACM> <83edgecce4.fsf@HIDDEN>
 <ZWHrIwPr5aW0IXvr@ACM>
 <8334wuc7cn.fsf@HIDDEN> <ZWIBY6B_7s8qbZzD@ACM>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, monnier@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Sat, 25 Nov 2023 14:14:59 +0000
> Cc: monnier@HIDDEN, 67196 <at> debbugs.gnu.org, acm@HIDDEN
> From: Alan Mackenzie <acm@HIDDEN>
> 
> > No, I meant with the current code debug-on-error is set to t whenever
> > eval-expression-debug-on-error is non-nil, ....
> 
> Yes.
> 
> > .... and your change sets it to the same value as
> > eval-expression-debug-on-error instead.
> 
> That is not what is meant to happen.

We are miscommunicating.

> Instead, the new internal variable
> debug-from--eval-expression gets set to e-e-debug-on-error.

Exactly.  And that value can be non-nil, but also not t.  That is the
change I see, and your doc string suggests that it is intentional.
Thus, we have a behavior change wrt to the value that the body of
eval-expression will see.  And non-nil, non-t values have special
meaning there.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 25 Nov 2023 14:23:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 25 09:23:57 2023
Received: from localhost ([127.0.0.1]:38228 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6tZc-0000z1-Tk
	for submit <at> debbugs.gnu.org; Sat, 25 Nov 2023 09:23:57 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:44244)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1r6tZa-0000yo-N4
 for 67196 <at> debbugs.gnu.org; Sat, 25 Nov 2023 09:23:55 -0500
Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 3407F1000AD;
 Sat, 25 Nov 2023 09:23:44 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1700922223;
 bh=OymoA2LiHiwmnHH/WWbvDJXCKKqXWHeEMs6EPCCbdA8=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=phpsUCRROmvjjX7HaQF1HDMxqw3j10x0/DOVvgBBb0OvUzbLNGY4+3ea19rqwXb7D
 wVIhK8Eub4px1mCSKNGdh8ibGhtXXbK7TxgreYdRnqJD4wpGxFS6Z+df4wfnCTpZ4E
 wgG6ox1egCLwQdCunN/AgedREWiUMhBXI/VNM5CWy0CH+LBChEuT03lVEoQiESZJur
 GjWccUwK/8Z2otOrNK+2QEkdpDZ0uYb4TKVr1yO76GXAcCfuHB6V4l0L8SlT1aURN6
 nO3BSkrZVBMbHWL2XZfP+SIkMSKKAhAmP8K7Oj9aUHsPZsV+cWahYRjQxOEZYNZKQN
 nvv0tWrvQ712Q==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 80F41100043;
 Sat, 25 Nov 2023 09:23:43 -0500 (EST)
Received: from pastel (unknown [45.72.227.120])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 574841202E5;
 Sat, 25 Nov 2023 09:23:43 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
In-Reply-To: <ZWHNN3LTX-QNDd51@ACM> (Alan Mackenzie's message of "Sat, 25 Nov
 2023 10:32:23 +0000")
Message-ID: <jwv34wu2ag2.fsf-monnier+emacs@HIDDEN>
References: <ZVTMOH229jaiw86s@ACM> <83a5rfq6i2.fsf@HIDDEN>
 <ZVUGBolDKfgLNEy8@ACM> <jwvjzqdekij.fsf-monnier+emacs@HIDDEN>
 <ZWDZF17mTpJp48ly@ACM> <83ttpbdm2f.fsf@HIDDEN> <ZWENlc6fj9odIdt6@ACM>
 <jwvleam6e7v.fsf-monnier+emacs@HIDDEN> <ZWEh52qxu8CfNKlC@ACM>
 <83il5qe00e.fsf@HIDDEN> <ZWHNN3LTX-QNDd51@ACM>
Date: Sat, 25 Nov 2023 09:23:42 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.122 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain T_SCC_BODY_TEXT_LINE    -0.01 -
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> That's a very good idea.  It would need little more than a new C function
> which would bind that variable then call eval.  Maybe move
> eval-expression-debug-on-error into eval.c, too.

Side note: there's recently been several things pointing to the need to
add something like Common Lisp's `handler-bind`.

`handler-bind` would provide a superset of the features that your
new C function would provide.  E.g. we could do something like:

    (defmacro with-debug-on-error (&rest body)
      `(handler-bind ((error #'debugger))
         ,@body))

which would mean that any error signal not caught within BODY itself
would call the debugger (and contrary to `condition-case`, that call is
performed before unwinding the stack, so we'd get the behavior we
expect from the debugger).

> Sorry, I wasn't clear enough.  During those 10 hours, I was under the
> impression that debug-on-error was t, because M-: debug-on-error said so.
> It actually was nil.  That's why I submitted this bug report.

I feel for you.  Personally I had a similar experience at some point but
instead of looking at the value of the var, I actually signaled
an error.

Seeing how I was getting into the debugger, I assumed that
`debug-on-error` was properly set (I had set it manually, so I (thought
I) knew that it was set, which is why I didn't even look at the var, but
apparently that was within a recursive edit that had it let-bound or
something, which is why it was actually unset).

The change you propose wouldn't have helped me directly in that case,
tho I think it probably would have circumvented the problem because the
var presumably wouldn't have been let-bound in the first place :-)

It took me less than 10 hours to figure out one of my many unjustified
assumptions, luckily.


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 25 Nov 2023 14:15:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 25 09:15:13 2023
Received: from localhost ([127.0.0.1]:38218 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6tRB-0000lK-A8
	for submit <at> debbugs.gnu.org; Sat, 25 Nov 2023 09:15:13 -0500
Received: from mail.muc.de ([193.149.48.3]:16899)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1r6tR9-0000l8-21
 for 67196 <at> debbugs.gnu.org; Sat, 25 Nov 2023 09:15:11 -0500
Received: (qmail 74162 invoked by uid 3782); 25 Nov 2023 15:14:59 +0100
Received: from acm.muc.de (pd953a2e3.dip0.t-ipconnect.de [217.83.162.227])
 (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP;
 Sat, 25 Nov 2023 15:14:59 +0100
Received: (qmail 18445 invoked by uid 1000); 25 Nov 2023 14:14:59 -0000
Date: Sat, 25 Nov 2023 14:14:59 +0000
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
Message-ID: <ZWIBY6B_7s8qbZzD@ACM>
References: <ZWDZF17mTpJp48ly@ACM> <83ttpbdm2f.fsf@HIDDEN>
 <ZWENlc6fj9odIdt6@ACM> <jwvleam6e7v.fsf-monnier+emacs@HIDDEN>
 <ZWEh52qxu8CfNKlC@ACM> <83il5qe00e.fsf@HIDDEN>
 <ZWHNN3LTX-QNDd51@ACM> <83edgecce4.fsf@HIDDEN>
 <ZWHrIwPr5aW0IXvr@ACM> <8334wuc7cn.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <8334wuc7cn.fsf@HIDDEN>
X-Submission-Agent: TMDA/1.3.x (Ph3nix)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, acm@HIDDEN, monnier@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Eli.

On Sat, Nov 25, 2023 at 15:04:08 +0200, Eli Zaretskii wrote:
> > Date: Sat, 25 Nov 2023 12:40:03 +0000
> > Cc: monnier@HIDDEN, 67196 <at> debbugs.gnu.org, acm@HIDDEN
> > From: Alan Mackenzie <acm@HIDDEN>

[ .... ]

> > > Note that (AFAIU) your change doesn't just solve the problem you
> > > bumped into, it also changes the value of debug-on-error inside
> > > eval-expression etc., when eval-expression-debug-on-error's value is
> > > non-nil, but not t.  I wonder what is the reason for that?

> > I don't see that in my current version of the patch (below).  To test
> > this, I used the following:

> > (defun foo ()
> >   (interactive)
> >   (message "debug-on-error is %s" debug-on-error)
> >   (message "eval-expression-debug-on-error is %s" eval-expression-debug-on-error)
> >   (car 'foo))

> > , and called it with various settings of debug-on-error and
> > eval-expression-debug-on-error.  In particular, with

> >   (setq eval-expression-debug-on-error '(wrong-type-argument))

> > , I still see debug-on-error reported as nil.

> No, I meant with the current code debug-on-error is set to t whenever
> eval-expression-debug-on-error is non-nil, ....

Yes.

> .... and your change sets it to the same value as
> eval-expression-debug-on-error instead.

That is not what is meant to happen.  Instead, the new internal variable
debug-from--eval-expression gets set to e-e-debug-on-error.
debug-on-error should remain unchanged throughout a M-: call, leaving it
free for use by user code.  The subroutines of signal_or_quit test
debug-from--eval-expression in addition to testing debug-on-error.

Are you sure that isn't what you're seeing?

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 25 Nov 2023 13:04:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 25 08:04:26 2023
Received: from localhost ([127.0.0.1]:38113 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6sKg-0007AO-0k
	for submit <at> debbugs.gnu.org; Sat, 25 Nov 2023 08:04:26 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:46072)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1r6sKe-0007A8-Lx
 for 67196 <at> debbugs.gnu.org; Sat, 25 Nov 2023 08:04:25 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1r6sKU-0004sS-5w; Sat, 25 Nov 2023 08:04:14 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=FwpYI+3KMWdz0YgLn1M/SHToQAuts/gI19BsBtBOluM=; b=FUuzU/wl6QpA
 v6pBaoZ9A0ehQoSdlSqcQF62cPoale0I3wn7y5jdAuRwvQTjI89EbdhEcUSDMh8Mgh6r3qjNQlhsM
 K4YX+iYdGilpFA47QhGR6iJM+jCC2/3KnujmSQnuzZHXmbrsDqM7yAgkRoFmAiUpDjLVZJGzCOFsq
 EOQ4YLcIbxvqKqiJA1x8LN4EUJCWMZIn28obOqG3LHmxY35ldZqeJ6Hn1zupovNLrfYJZky99E52U
 chgrO72+yzP9cedZF8Ot0bOXuwSNL1WR6r1ki/FmHIy3jG7KMo8F7Lw2XwClphz8Tiq+Zyt4jWTzb
 ptxs8DY+E09XNt85miWv1w==;
Date: Sat, 25 Nov 2023 15:04:08 +0200
Message-Id: <8334wuc7cn.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
In-Reply-To: <ZWHrIwPr5aW0IXvr@ACM> (message from Alan Mackenzie on Sat, 25
 Nov 2023 12:40:03 +0000)
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
References: <ZVUGBolDKfgLNEy8@ACM> <jwvjzqdekij.fsf-monnier+emacs@HIDDEN>
 <ZWDZF17mTpJp48ly@ACM> <83ttpbdm2f.fsf@HIDDEN>
 <ZWENlc6fj9odIdt6@ACM> <jwvleam6e7v.fsf-monnier+emacs@HIDDEN>
 <ZWEh52qxu8CfNKlC@ACM> <83il5qe00e.fsf@HIDDEN>
 <ZWHNN3LTX-QNDd51@ACM>
 <83edgecce4.fsf@HIDDEN> <ZWHrIwPr5aW0IXvr@ACM>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, monnier@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Sat, 25 Nov 2023 12:40:03 +0000
> Cc: monnier@HIDDEN, 67196 <at> debbugs.gnu.org, acm@HIDDEN
> From: Alan Mackenzie <acm@HIDDEN>
> 
> > What I had in mind was a function exposed to Lisp that would set an
> > internal variable not exposed to Lisp.
> 
> The would still require an unwind-protect somewhere.

We can unwind-protect in C as well.

> > > Sorry, I wasn't clear enough.  During those 10 hours, I was under the
> > > impression that debug-on-error was t, because M-: debug-on-error said so.
> > > It actually was nil.  That's why I submitted this bug report.
> 
> > So maybe instead of changing how this stuff works we should improve
> > how debug-on-error's value is reported by M-: and other eval commands?
> 
> Yes, but that might be complicated, and won't help the user trying to
> debug something which depends on debug-on-error, who is using M-: to try
> to test it.

I don't see how that could happen.

> > Note that (AFAIU) your change doesn't just solve the problem you
> > bumped into, it also changes the value of debug-on-error inside
> > eval-expression etc., when eval-expression-debug-on-error's value is
> > non-nil, but not t.  I wonder what is the reason for that?
> 
> I don't see that in my current version of the patch (below).  To test
> this, I used the following:
> 
> (defun foo ()
>   (interactive)
>   (message "debug-on-error is %s" debug-on-error)
>   (message "eval-expression-debug-on-error is %s" eval-expression-debug-on-error)
>   (car 'foo))
> 
> , and called it with various settings of debug-on-error and
> eval-expression-debug-on-error.  In particular, with
> 
>   (setq eval-expression-debug-on-error '(wrong-type-argument))
> 
> , I still see debug-on-error reported as nil.

No, I meant with the current code debug-on-error is set to t whenever
eval-expression-debug-on-error is non-nil, and your change sets it to
the same value as eval-expression-debug-on-error instead.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 25 Nov 2023 12:40:22 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 25 07:40:22 2023
Received: from localhost ([127.0.0.1]:38090 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6rxN-0006OB-Gn
	for submit <at> debbugs.gnu.org; Sat, 25 Nov 2023 07:40:22 -0500
Received: from mail.muc.de ([193.149.48.3]:22151)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1r6rxH-0006Ns-Qj
 for 67196 <at> debbugs.gnu.org; Sat, 25 Nov 2023 07:40:20 -0500
Received: (qmail 63277 invoked by uid 3782); 25 Nov 2023 13:40:04 +0100
Received: from acm.muc.de (pd953a2e3.dip0.t-ipconnect.de [217.83.162.227])
 (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP;
 Sat, 25 Nov 2023 13:40:04 +0100
Received: (qmail 16230 invoked by uid 1000); 25 Nov 2023 12:40:03 -0000
Date: Sat, 25 Nov 2023 12:40:03 +0000
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
Message-ID: <ZWHrIwPr5aW0IXvr@ACM>
References: <ZVUGBolDKfgLNEy8@ACM> <jwvjzqdekij.fsf-monnier+emacs@HIDDEN>
 <ZWDZF17mTpJp48ly@ACM> <83ttpbdm2f.fsf@HIDDEN>
 <ZWENlc6fj9odIdt6@ACM> <jwvleam6e7v.fsf-monnier+emacs@HIDDEN>
 <ZWEh52qxu8CfNKlC@ACM> <83il5qe00e.fsf@HIDDEN>
 <ZWHNN3LTX-QNDd51@ACM> <83edgecce4.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <83edgecce4.fsf@HIDDEN>
X-Submission-Agent: TMDA/1.3.x (Ph3nix)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, acm@HIDDEN, monnier@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Eli.

On Sat, Nov 25, 2023 at 13:15:15 +0200, Eli Zaretskii wrote:
> > Date: Sat, 25 Nov 2023 10:32:23 +0000
> > Cc: monnier@HIDDEN, 67196 <at> debbugs.gnu.org
> > From: Alan Mackenzie <acm@HIDDEN>

> > > How about not exposing the internal variable to Lisp at all?

> > That's a very good idea.  It would need little more than a new C function
> > which would bind that variable then call eval.  Maybe move
> > eval-expression-debug-on-error into eval.c, too.

> What I had in mind was a function exposed to Lisp that would set an
> internal variable not exposed to Lisp.

The would still require an unwind-protect somewhere.  I've implemented
sub-eval-expression in eval.c.  debug-from--eval-expression is no longer
visible from Lisp.  Perhaps this is good enough.  

> > > > For what it's worth, I lost about 10 hours of time trying to debug
> > > > a situation where I wasn't getting a backtrace, despite debug-on-error
> > > > being t.  The problem was that d-o-e wasn't t at all, it was nil.  M-:
> > > > had been lying.  

> > > You never described that situation, AFAICT.  I think you should, so
> > > that we could assess how grave the problem is, which is an important
> > > part of deciding whether the solution you propose is useful.  I don't
> > > understand how could you NOT get a backtrace when debug-on-error is
> > > non-nil.

> > Sorry, I wasn't clear enough.  During those 10 hours, I was under the
> > impression that debug-on-error was t, because M-: debug-on-error said so.
> > It actually was nil.  That's why I submitted this bug report.

> So maybe instead of changing how this stuff works we should improve
> how debug-on-error's value is reported by M-: and other eval commands?

Yes, but that might be complicated, and won't help the user trying to
debug something which depends on debug-on-error, who is using M-: to try
to test it.  I still say the bug is trying to make debug-on-error do too
much, more than it's capable of.

> Note that (AFAIU) your change doesn't just solve the problem you
> bumped into, it also changes the value of debug-on-error inside
> eval-expression etc., when eval-expression-debug-on-error's value is
> non-nil, but not t.  I wonder what is the reason for that?

I don't see that in my current version of the patch (below).  To test
this, I used the following:

(defun foo ()
  (interactive)
  (message "debug-on-error is %s" debug-on-error)
  (message "eval-expression-debug-on-error is %s" eval-expression-debug-on-error)
  (car 'foo))

, and called it with various settings of debug-on-error and
eval-expression-debug-on-error.  In particular, with

  (setq eval-expression-debug-on-error '(wrong-type-argument))

, I still see debug-on-error reported as nil.



diff --git a/lisp/cus-start.el b/lisp/cus-start.el
index 6d83aaf4d14..9d176c6c599 100644
--- a/lisp/cus-start.el
+++ b/lisp/cus-start.el
@@ -262,6 +262,13 @@ minibuffer-prompt-properties--setter
 					     :value (nil)
 					     (symbol :format "%v"))
 				     (const :tag "always" t)))
+             (eval-expression-debug-on-error debug
+                                             (choice (const :tag "off")
+                                                     (repeat :menu-tag "When"
+                                                             :value (nil)
+                                                             (symbol :format "%v"))
+                                                     (const :tag "always" t))
+                                             "30.1")
 	     (debug-ignored-errors debug (repeat (choice symbol regexp)))
 	     (debug-on-quit debug boolean)
 	     (debug-on-signal debug boolean)
diff --git a/lisp/simple.el b/lisp/simple.el
index 02c68912dba..f4c9873ceed 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1980,13 +1980,6 @@ eval-expression-print-length
   :type '(choice (const :tag "No Limit" nil) integer)
   :version "21.1")
 
-(defcustom eval-expression-debug-on-error t
-  "If non-nil set `debug-on-error' to t in `eval-expression'.
-If nil, don't change the value of `debug-on-error'."
-  :group 'lisp
-  :type 'boolean
-  :version "21.1")
-
 (defcustom eval-expression-print-maximum-character 127
   "The largest integer that will be displayed as a character.
 This affects printing by `eval-expression' (via
@@ -2120,34 +2113,18 @@ eval-expression
    (cons (read--expression "Eval: ")
          (eval-expression-get-print-arguments current-prefix-arg)))
 
-  (let (result)
-    (if (null eval-expression-debug-on-error)
-        (setq result
-              (values--store-value
-               (eval (let ((lexical-binding t)) (macroexpand-all exp)) t)))
-      (let ((old-value (make-symbol "t")) new-value)
-        ;; Bind debug-on-error to something unique so that we can
-        ;; detect when evalled code changes it.
-        (let ((debug-on-error old-value))
-          (setq result
-	        (values--store-value
-                 (eval (let ((lexical-binding t)) (macroexpand-all exp)) t)))
-	  (setq new-value debug-on-error))
-        ;; If evalled code has changed the value of debug-on-error,
-        ;; propagate that change to the global binding.
-        (unless (eq old-value new-value)
-	  (setq debug-on-error new-value))))
-
-    (let ((print-length (unless no-truncate eval-expression-print-length))
-          (print-level  (unless no-truncate eval-expression-print-level))
-          (eval-expression-print-maximum-character char-print-limit)
-          (deactivate-mark))
-      (let ((out (if insert-value (current-buffer) t)))
-        (prog1
-            (prin1 result out)
-          (let ((str (and char-print-limit
-                          (eval-expression-print-format result))))
-            (when str (princ str out))))))))
+  (let* ((result (values--store-value
+                  (sub-eval-expression (macroexpand-all exp))))
+         (print-length (unless no-truncate eval-expression-print-length))
+         (print-level  (unless no-truncate eval-expression-print-level))
+         (eval-expression-print-maximum-character char-print-limit)
+         (deactivate-mark)
+         (out (if insert-value (current-buffer) t)))
+    (prog1
+        (prin1 result out)
+      (let ((str (and char-print-limit
+                      (eval-expression-print-format result))))
+        (when str (princ str out))))))
 
 (defun edit-and-eval-command (prompt command)
   "Prompting with PROMPT, let user edit COMMAND and eval result.
diff --git a/src/eval.c b/src/eval.c
index 12e811ce264..eccabf3a091 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2033,7 +2033,8 @@ maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Lisp_Object data)
       /* Does user want to enter debugger for this kind of error?  */
       && (signal_quit_p (sig)
 	  ? debug_on_quit
-	  : wants_debugger (Vdebug_on_error, conditions))
+	  : (wants_debugger (Vdebug_from__eval_expression, conditions)
+	     || wants_debugger (Vdebug_on_error, conditions)))
       && ! skip_debugger (conditions, combined_data)
       /* See commentary on definition of
          `internal-when-entered-debugger'.  */
@@ -2383,6 +2384,19 @@ DEFUN ("eval", Feval, Seval, 1, 2, 0,
   return unbind_to (count, eval_sub (form));
 }
 
+DEFUN ("sub-eval-expression", Fsub_eval_expression, Ssub_eval_expression,
+       1, 1, 0,
+       doc: /* Evaluate FORM and return its value.
+This function should be called only from `eval-expression'.
+It evaluates with `lexical-binding' non-nil, and handles
+`eval-expression-debug-on-error'.  */)
+  (Lisp_Object form)
+{
+  specpdl_ref count = SPECPDL_INDEX ();
+  specbind (Qdebug_from__eval_expression, Veval_expression_debug_on_error);
+  return unbind_to (count, Feval (form, Qt));
+}
+
 void
 grow_specpdl_allocation (void)
 {
@@ -4299,6 +4313,29 @@ syms_of_eval (void)
 See also the variable `debug-on-quit' and `inhibit-debugger'.  */);
   Vdebug_on_error = Qnil;
 
+  DEFSYM (Qeval_expression_debug_on_error, "eval-expression-debug-on-error");
+  DEFVAR_LISP ("eval-expression-debug-on-error",
+	       Veval_expression_debug_on_error,
+	       doc: /* Non-nil means enter debugger on error on a call from `eval-expression'.
+Does not apply to errors handled by `condition-case' or those
+matched by `debug-ignored-errors'.
+Like `debug-on-error', this variable's value can also be a list,
+with the same meaning as for `debug-on-error'.
+
+A nil value for this variable will not prevent an entry to
+the debugger caused by other variables such as `debug-on-error'.  */);
+  Veval_expression_debug_on_error = Qt;
+
+  DEFSYM (Qdebug_from__eval_expression, "debug-from--eval-expression");
+  DEFVAR_LISP ("debug-from--eval-expression", Vdebug_from__eval_expression,
+	       doc: /* Non-nil means enter debugger if an error is signaled.
+This only applies in forms called by `eval-expression'.  This variable
+has the same semantics as `debug-on-error'.  It is an internal variable
+only.  */);
+  Vdebug_from__eval_expression = Qnil;
+  /* debug-from--eval-expression should not be visible from Lisp.  */
+  Funintern (Qdebug_from__eval_expression, Qnil);
+
   DEFVAR_LISP ("debug-ignored-errors", Vdebug_ignored_errors,
     doc: /* List of errors for which the debugger should not be called.
 Each element may be a condition-name or a regexp that matches error messages.
@@ -4455,6 +4492,7 @@ syms_of_eval (void)
   defsubr (&Sautoload);
   defsubr (&Sautoload_do_load);
   defsubr (&Seval);
+  defsubr (&Ssub_eval_expression);
   defsubr (&Sapply);
   defsubr (&Sfuncall);
   defsubr (&Sfunc_arity);


-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 25 Nov 2023 11:15:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 25 06:15:50 2023
Received: from localhost ([127.0.0.1]:37999 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6qda-0000ho-0y
	for submit <at> debbugs.gnu.org; Sat, 25 Nov 2023 06:15:50 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:50830)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1r6qdY-0000TH-FS
 for 67196 <at> debbugs.gnu.org; Sat, 25 Nov 2023 06:15:49 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1r6qdM-0000nE-92; Sat, 25 Nov 2023 06:15:36 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=zWdbb7DqkhuITMfSG2iKNh0jCcoaACOakEecJUOvoK0=; b=f52wZ2AIm87p
 ywSEkAWJvquqPIthbpDE7khsFDcMm6oocfMNfFPSw/hDX9BU5XlYyqQRDWKVJ+zf7dTNMCm6P1cSG
 EaJbRVMNuoOn0sJkucNNaPT3QRJ9jImgPYdX3nWb7IxaR09Nv7tvK1BVSKbuTeICPpNDNeYmAc/V3
 hPbPHDdt2end4mHXdf9YDRgWAmrnHIblE6O6u78W7O5o14SAb/B2S64GyyqosZFE9Ny3v43+2X/wm
 vsiOMIuHHyErV0LOh45HElKNlHYdFc8BzQO1ZSJoT9MRaKUoCeKP4JYZcvy13hnV9yHDetDmsUfpM
 HcJpPpaVGsduHj4EZShP7w==;
Date: Sat, 25 Nov 2023 13:15:15 +0200
Message-Id: <83edgecce4.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
In-Reply-To: <ZWHNN3LTX-QNDd51@ACM> (message from Alan Mackenzie on Sat, 25
 Nov 2023 10:32:23 +0000)
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
References: <ZVTMOH229jaiw86s@ACM> <83a5rfq6i2.fsf@HIDDEN>
 <ZVUGBolDKfgLNEy8@ACM> <jwvjzqdekij.fsf-monnier+emacs@HIDDEN>
 <ZWDZF17mTpJp48ly@ACM> <83ttpbdm2f.fsf@HIDDEN>
 <ZWENlc6fj9odIdt6@ACM> <jwvleam6e7v.fsf-monnier+emacs@HIDDEN>
 <ZWEh52qxu8CfNKlC@ACM>
 <83il5qe00e.fsf@HIDDEN> <ZWHNN3LTX-QNDd51@ACM>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, monnier@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Sat, 25 Nov 2023 10:32:23 +0000
> Cc: monnier@HIDDEN, 67196 <at> debbugs.gnu.org
> From: Alan Mackenzie <acm@HIDDEN>
> 
> > How about not exposing the internal variable to Lisp at all?
> 
> That's a very good idea.  It would need little more than a new C function
> which would bind that variable then call eval.  Maybe move
> eval-expression-debug-on-error into eval.c, too.

What I had in mind was a function exposed to Lisp that would set an
internal variable not exposed to Lisp.

> > > For what it's worth, I lost about 10 hours of time trying to debug
> > > a situation where I wasn't getting a backtrace, despite debug-on-error
> > > being t.  The problem was that d-o-e wasn't t at all, it was nil.  M-:
> > > had been lying.  
> 
> > You never described that situation, AFAICT.  I think you should, so
> > that we could assess how grave the problem is, which is an important
> > part of deciding whether the solution you propose is useful.  I don't
> > understand how could you NOT get a backtrace when debug-on-error is
> > non-nil.
> 
> Sorry, I wasn't clear enough.  During those 10 hours, I was under the
> impression that debug-on-error was t, because M-: debug-on-error said so.
> It actually was nil.  That's why I submitted this bug report.

So maybe instead of changing how this stuff works we should improve
how debug-on-error's value is reported by M-: and other eval commands?

Note that (AFAIU) your change doesn't just solve the problem you
bumped into, it also changes the value of debug-on-error inside
eval-expression etc., when eval-expression-debug-on-error's value is
non-nil, but not t.  I wonder what is the reason for that?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 25 Nov 2023 10:32:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 25 05:32:39 2023
Received: from localhost ([127.0.0.1]:37929 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6pxm-0005eU-Iz
	for submit <at> debbugs.gnu.org; Sat, 25 Nov 2023 05:32:39 -0500
Received: from mail.muc.de ([193.149.48.3]:27068)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1r6pxj-0005eD-5w
 for 67196 <at> debbugs.gnu.org; Sat, 25 Nov 2023 05:32:38 -0500
Received: (qmail 10756 invoked by uid 3782); 25 Nov 2023 11:32:24 +0100
Received: from acm.muc.de (pd953a2e3.dip0.t-ipconnect.de [217.83.162.227])
 (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP;
 Sat, 25 Nov 2023 11:32:24 +0100
Received: (qmail 13401 invoked by uid 1000); 25 Nov 2023 10:32:23 -0000
Date: Sat, 25 Nov 2023 10:32:23 +0000
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
Message-ID: <ZWHNN3LTX-QNDd51@ACM>
References: <ZVTMOH229jaiw86s@ACM> <83a5rfq6i2.fsf@HIDDEN>
 <ZVUGBolDKfgLNEy8@ACM> <jwvjzqdekij.fsf-monnier+emacs@HIDDEN>
 <ZWDZF17mTpJp48ly@ACM> <83ttpbdm2f.fsf@HIDDEN>
 <ZWENlc6fj9odIdt6@ACM> <jwvleam6e7v.fsf-monnier+emacs@HIDDEN>
 <ZWEh52qxu8CfNKlC@ACM> <83il5qe00e.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <83il5qe00e.fsf@HIDDEN>
X-Submission-Agent: TMDA/1.3.x (Ph3nix)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, monnier@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Eli.

On Sat, Nov 25, 2023 at 09:59:45 +0200, Eli Zaretskii wrote:
> > Date: Fri, 24 Nov 2023 22:21:27 +0000
> > Cc: Eli Zaretskii <eliz@HIDDEN>, 67196 <at> debbugs.gnu.org, acm@HIDDEN
> > From: Alan Mackenzie <acm@HIDDEN>

> > > So you kicked the can a bit further down the road.
> > > The next bug report will be that `M-: debug-from--eval-expression` does
> > > not return the expected value.

> > Not at all.  debug-from--eval-expression is a purely internal variable,
> > unlike debug-on-error which is intended for user use.  It is bound in
> > exactly one place, and tested in exactly one place.

> > Anybody reporting such a "bug" would legitimately get the reply "not a
> > bug".

> How about not exposing the internal variable to Lisp at all?

That's a very good idea.  It would need little more than a new C function
which would bind that variable then call eval.  Maybe move
eval-expression-debug-on-error into eval.c, too.

> > For what it's worth, I lost about 10 hours of time trying to debug
> > a situation where I wasn't getting a backtrace, despite debug-on-error
> > being t.  The problem was that d-o-e wasn't t at all, it was nil.  M-:
> > had been lying.  

> You never described that situation, AFAICT.  I think you should, so
> that we could assess how grave the problem is, which is an important
> part of deciding whether the solution you propose is useful.  I don't
> understand how could you NOT get a backtrace when debug-on-error is
> non-nil.

Sorry, I wasn't clear enough.  During those 10 hours, I was under the
impression that debug-on-error was t, because M-: debug-on-error said so.
It actually was nil.  That's why I submitted this bug report.

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 25 Nov 2023 08:00:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 25 03:00:04 2023
Received: from localhost ([127.0.0.1]:37699 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6na7-00077m-Jz
	for submit <at> debbugs.gnu.org; Sat, 25 Nov 2023 03:00:03 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:45024)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1r6na3-00076k-Gf
 for 67196 <at> debbugs.gnu.org; Sat, 25 Nov 2023 03:00:02 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1r6nZs-0007KK-BB; Sat, 25 Nov 2023 02:59:48 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=dw94QZ2FWezg7UyhbgJ1UjBJwsdMcyTR2jDEuYn/vwg=; b=FAlIFF94VID6
 01odFY5eTSJcn4gBWo6sAFNe9So5CJUNtWRp45IfTIQrPCv5u7XyAmjJXVRIN5a7fybazzeg6sA9v
 DzZByJvUPLGqKOUs9/kuVQfMQUNEMII7vmV2pQJfXz0sRmL1R75Zdr/WWeRp1np7PrElLMnMxpmVz
 oV2DvStxgQSYsEepwjWeaVenRNTQLhYnUvioCyPiEK3dC6vEU2cWzFgnRs9VjfSi1qauI23O+cMe1
 NNM52hgvJzAvV6gNesk4nT5ALo6aBiNKKhdvKi0XpeHQqhWk8o7TSehmvNcGSUF6bza0baQLFJCPY
 GU/vszHKe7G2y2Bl/7/ktw==;
Date: Sat, 25 Nov 2023 09:59:45 +0200
Message-Id: <83il5qe00e.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
In-Reply-To: <ZWEh52qxu8CfNKlC@ACM> (message from Alan Mackenzie on Fri, 24
 Nov 2023 22:21:27 +0000)
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
References: <ZVTMOH229jaiw86s@ACM> <83a5rfq6i2.fsf@HIDDEN>
 <ZVUGBolDKfgLNEy8@ACM> <jwvjzqdekij.fsf-monnier+emacs@HIDDEN>
 <ZWDZF17mTpJp48ly@ACM> <83ttpbdm2f.fsf@HIDDEN>
 <ZWENlc6fj9odIdt6@ACM>
 <jwvleam6e7v.fsf-monnier+emacs@HIDDEN> <ZWEh52qxu8CfNKlC@ACM>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, monnier@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Fri, 24 Nov 2023 22:21:27 +0000
> Cc: Eli Zaretskii <eliz@HIDDEN>, 67196 <at> debbugs.gnu.org, acm@HIDDEN
> From: Alan Mackenzie <acm@HIDDEN>
> 
> > So you kicked the can a bit further down the road.
> > The next bug report will be that `M-: debug-from--eval-expression` does
> > not return the expected value.
> 
> Not at all.  debug-from--eval-expression is a purely internal variable,
> unlike debug-on-error which is intended for user use.  It is bound in
> exactly one place, and tested in exactly one place.
> 
> Anybody reporting such a "bug" would legitimately get the reply "not a
> bug".

How about not exposing the internal variable to Lisp at all?

> For what it's worth, I lost about 10 hours of time trying to debug
> a situation where I wasn't getting a backtrace, despite debug-on-error
> being t.  The problem was that d-o-e wasn't t at all, it was nil.  M-:
> had been lying.  

You never described that situation, AFAICT.  I think you should, so
that we could assess how grave the problem is, which is an important
part of deciding whether the solution you propose is useful.  I don't
understand how could you NOT get a backtrace when debug-on-error is
non-nil.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 25 Nov 2023 07:30:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 25 02:30:55 2023
Received: from localhost ([127.0.0.1]:37688 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6n7v-0006I4-A3
	for submit <at> debbugs.gnu.org; Sat, 25 Nov 2023 02:30:55 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:51022)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1r6n7q-0006Ho-AT
 for 67196 <at> debbugs.gnu.org; Sat, 25 Nov 2023 02:30:53 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1r6n7e-0002Pw-Jo; Sat, 25 Nov 2023 02:30:38 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=ZqzHeFmx5ZxeBptui4mUbbAqG+yEc8iTuNFt3I8RLYA=; b=isabgfExPoo0
 eI6T2oZBFAY1xnPNWc+HrZrL32Uwm1doaZJN2XX/It/4xQ9vlcwVUGzRfhwI2yWcia3mM1/U47kJ8
 QTwen7F2vi6/oPjxiLxjCr32M3YKT7v+k7OggyCgBj6KZ1L97Ta6nDMNfOC0nx20OKzy6MSWHFtXR
 juEI/SL+b2xLurIjfzO6cXANAnIFl3w0ZF4L51cy2FKBM2LzjeLpVd4ASz14KVNisQ5sseHVjsAP6
 6TNdnK2P/Z2jUv4ZdpdH+E9NXzwKb0Lt6mhM5v6UgrgMgk7aWdBQqm0Oy+OnQWbyxF/d3bscRAekR
 VQf7fZwRd7B0rBm+cJ2zAg==;
Date: Sat, 25 Nov 2023 09:30:29 +0200
Message-Id: <83leame1d6.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
In-Reply-To: <ZWENlc6fj9odIdt6@ACM> (message from Alan Mackenzie on Fri, 24
 Nov 2023 20:54:45 +0000)
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
References: <ZVTMOH229jaiw86s@ACM> <83a5rfq6i2.fsf@HIDDEN>
 <ZVUGBolDKfgLNEy8@ACM> <jwvjzqdekij.fsf-monnier+emacs@HIDDEN>
 <ZWDZF17mTpJp48ly@ACM>
 <83ttpbdm2f.fsf@HIDDEN> <ZWENlc6fj9odIdt6@ACM>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, acm@HIDDEN, monnier@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Fri, 24 Nov 2023 20:54:45 +0000
> Cc: 67196 <at> debbugs.gnu.org, acm@HIDDEN
> From: Alan Mackenzie <acm@HIDDEN>
> 
> > >     Non-nil means enter debugger on an error in a call from `eval-expression'.
> > >     Does not apply to errors handled by `condition-case' or those
> > >     matched by `debug-ignored-errors'.
> > >     A nil value for this variable will not prevent an entry to
> > >     the debugger caused by other variables such as `debug-on-error'.
> 
> > First, the last two sentences above should be transposed, as the
> > second one is not related to the 1st one, but the 3rd one is.
> 
> Done.
> 
> > And second, please try to reword so that the text is less complicated
> > and easier to understand.
> 
> I'm perhaps a bit too close to it.  Apart from the first line (for which
> too much information needs squashing in), I can't really see much scope
> for improvement.

Here:

   (defcustom eval-expression-debug-on-error t
    "If non-nil, enter debugger if `eval-expression' signals an error.
  A non-nil value means set `debug-on-error' to that value when calling
  `eval-expression'; this will enter a debugger if `eval-expression'
  signals an error.  A nil value means don't change the value of
  `debug-on-error' when calling `eval-expression'.
  The value can also be a list, with the same meaning as for `debug-on-error'.
  Like  `debug-on-error', this variable does not apply to errors handled
  by `condition-case' or those matched by `debug-ignored-errors'."

> +  DEFVAR_LISP ("debug-from--eval-expression", Vdebug_from__eval_expression,
> +	       doc: /* Non-nil means enter debugger if an error is signaled.
> +This only applies in forms called by `eval-expression'.  This variable
> +has the same semantics as `debug-on-error'.  It is an internal variable
> +only.  */);

The doc string should be just

  /* Internal use only, used by `eval-expression'.  */




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 24 Nov 2023 22:21:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 24 17:21:42 2023
Received: from localhost ([127.0.0.1]:37416 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6eYQ-00083e-Dx
	for submit <at> debbugs.gnu.org; Fri, 24 Nov 2023 17:21:42 -0500
Received: from mail.muc.de ([193.149.48.3]:25348)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1r6eYM-00083H-D5
 for 67196 <at> debbugs.gnu.org; Fri, 24 Nov 2023 17:21:40 -0500
Received: (qmail 66504 invoked by uid 3782); 24 Nov 2023 23:21:27 +0100
Received: from acm.muc.de (pd953a757.dip0.t-ipconnect.de [217.83.167.87])
 (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP;
 Fri, 24 Nov 2023 23:21:26 +0100
Received: (qmail 1894 invoked by uid 1000); 24 Nov 2023 22:21:27 -0000
Date: Fri, 24 Nov 2023 22:21:27 +0000
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
Message-ID: <ZWEh52qxu8CfNKlC@ACM>
References: <ZVTMOH229jaiw86s@ACM> <83a5rfq6i2.fsf@HIDDEN>
 <ZVUGBolDKfgLNEy8@ACM> <jwvjzqdekij.fsf-monnier+emacs@HIDDEN>
 <ZWDZF17mTpJp48ly@ACM> <83ttpbdm2f.fsf@HIDDEN>
 <ZWENlc6fj9odIdt6@ACM> <jwvleam6e7v.fsf-monnier+emacs@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <jwvleam6e7v.fsf-monnier+emacs@HIDDEN>
X-Submission-Agent: TMDA/1.3.x (Ph3nix)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, acm@HIDDEN, Eli Zaretskii <eliz@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Stefan.

On Fri, Nov 24, 2023 at 16:25:11 -0500, Stefan Monnier wrote:
> > +  (let* ((debug-from--eval-expression eval-expression-debug-on-error)
> > +         (result (values--store-value
> > +                  (eval (let ((lexical-binding t)) (macroexpand-all exp)) t)))
> > +         (print-length (unless no-truncate eval-expression-print-length))
> > +         (print-level  (unless no-truncate eval-expression-print-level))
> > +         (eval-expression-print-maximum-character char-print-limit)
> > +         (deactivate-mark)
> > +         (out (if insert-value (current-buffer) t)))
> > +    (prog1
> > +        (prin1 result out)
> > +      (let ((str (and char-print-limit
> > +                      (eval-expression-print-format result))))
> > +        (when str (princ str out))))))

> So you kicked the can a bit further down the road.
> The next bug report will be that `M-: debug-from--eval-expression` does
> not return the expected value.

Not at all.  debug-from--eval-expression is a purely internal variable,
unlike debug-on-error which is intended for user use.  It is bound in
exactly one place, and tested in exactly one place.

Anybody reporting such a "bug" would legitimately get the reply "not a
bug".

> FWIW, the other way I came up to circumvent the problem is to test the
> shape of the expression to evaluate and only use
> `eval-expression-debug-on-error` when the expression is not a mere
> symbol (for which the backtrace would presumably not be interesting anyway).
> But then we get the weird situation where `M-x debug-on-error` can
> return nil but `M-x (list debug-on-error ...)` returns a list that
> starts with t.

[ By M-x, I assume you're meaning M-:.]

Yes.  Such a patch wouldn't fix the bug.  The root of the bug is trying
to make debug-on-error do two different contradictory jobs, as we've
already discussed.  To fix this, you've either got to decide not to do
one of these jobs at all, or introduce a new variable.  My patch does
the second of these.

> I think I'd rather keep the current code, whose semantics is
> actually simpler.

No.  My patch fixes the bug, by introducing a separate variable to do
one of the two jobs that debug-on-error is currently trying to do.  This
is a simplification.  As a side effect, eval-expression has been reduced
from 59 to 44 lines; not counting the doc string this is a reduction of
around 50%.

For what it's worth, I lost about 10 hours of time trying to debug
a situation where I wasn't getting a backtrace, despite debug-on-error
being t.  The problem was that d-o-e wasn't t at all, it was nil.  M-:
had been lying.  

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 24 Nov 2023 21:25:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 24 16:25:25 2023
Received: from localhost ([127.0.0.1]:37353 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6dfw-00060D-W3
	for submit <at> debbugs.gnu.org; Fri, 24 Nov 2023 16:25:25 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:18708)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1r6dfu-0005zx-LA
 for 67196 <at> debbugs.gnu.org; Fri, 24 Nov 2023 16:25:23 -0500
Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 8AD0A100068;
 Fri, 24 Nov 2023 16:25:12 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1700861111;
 bh=lz6waaW0AxTcFQrhUcv3yiCJ/KM31WPPIYUnXgl85aE=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=e9YqgxgHOrETSpSsyM70pCsEI5TDlbut2Eg3oZEbobfDCxpIRbArIhE0x+j4I/3OM
 mckpU3jvuHwkbAd1rntBYSnM8rybMo1evN1iRIaUhyb+mw0UU3LGOEtEj5F7j2+t6Q
 L0qv+e/TWinit4xTRu2TFFJkYOhLQwKXceU0/uHsyHPuvE0cshDfbhw6V9rpA7q+Ga
 MUjPnCgN3N+xhV64kIkSkc4EdeAtwzTfl8iNdQ5miLn6Xv4aujEEABY9y+5tRD0maF
 GsG/McgPxi72jj2oTq/YwudLP6g4nbNte1rK7I3tyLOkDlzg01Uoh29wp7iiu+oB2h
 AUDS8ZPZlN4+Q==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id D9CB1100033;
 Fri, 24 Nov 2023 16:25:11 -0500 (EST)
Received: from pastel (unknown [45.72.227.120])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B67BA120191;
 Fri, 24 Nov 2023 16:25:11 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
In-Reply-To: <ZWENlc6fj9odIdt6@ACM> (Alan Mackenzie's message of "Fri, 24 Nov
 2023 20:54:45 +0000")
Message-ID: <jwvleam6e7v.fsf-monnier+emacs@HIDDEN>
References: <ZVTMOH229jaiw86s@ACM> <83a5rfq6i2.fsf@HIDDEN>
 <ZVUGBolDKfgLNEy8@ACM> <jwvjzqdekij.fsf-monnier+emacs@HIDDEN>
 <ZWDZF17mTpJp48ly@ACM> <83ttpbdm2f.fsf@HIDDEN> <ZWENlc6fj9odIdt6@ACM>
Date: Fri, 24 Nov 2023 16:25:11 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.126 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain T_SCC_BODY_TEXT_LINE    -0.01 -
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> +  (let* ((debug-from--eval-expression eval-expression-debug-on-error)
> +         (result (values--store-value
> +                  (eval (let ((lexical-binding t)) (macroexpand-all exp)) t)))
> +         (print-length (unless no-truncate eval-expression-print-length))
> +         (print-level  (unless no-truncate eval-expression-print-level))
> +         (eval-expression-print-maximum-character char-print-limit)
> +         (deactivate-mark)
> +         (out (if insert-value (current-buffer) t)))
> +    (prog1
> +        (prin1 result out)
> +      (let ((str (and char-print-limit
> +                      (eval-expression-print-format result))))
> +        (when str (princ str out))))))

So you kicked the can a bit further down the road.
The next bug report will be that `M-: debug-from--eval-expression` does
not return the expected value.

FWIW, the other way I came up to circumvent the problem is to test the
shape of the expression to evaluate and only use
`eval-expression-debug-on-error` when the expression is not a mere
symbol (for which the backtrace would presumably not be interesting anyway).
But then we get the weird situation where `M-x debug-on-error` can
return nil but `M-x (list debug-on-error ...)` returns a list that
starts with t.

I think I'd rather keep the current code, whose semantics is
actually simpler.


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 24 Nov 2023 20:55:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 24 15:55:03 2023
Received: from localhost ([127.0.0.1]:37330 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6dCY-00056x-H3
	for submit <at> debbugs.gnu.org; Fri, 24 Nov 2023 15:55:03 -0500
Received: from mail.muc.de ([193.149.48.3]:52278)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1r6dCT-00056K-7Y
 for 67196 <at> debbugs.gnu.org; Fri, 24 Nov 2023 15:55:01 -0500
Received: (qmail 67704 invoked by uid 3782); 24 Nov 2023 21:54:45 +0100
Received: from acm.muc.de (pd953a757.dip0.t-ipconnect.de [217.83.167.87])
 (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP;
 Fri, 24 Nov 2023 21:54:45 +0100
Received: (qmail 1405 invoked by uid 1000); 24 Nov 2023 20:54:45 -0000
Date: Fri, 24 Nov 2023 20:54:45 +0000
To: Eli Zaretskii <eliz@HIDDEN>, Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
Message-ID: <ZWENlc6fj9odIdt6@ACM>
References: <ZVTMOH229jaiw86s@ACM> <83a5rfq6i2.fsf@HIDDEN>
 <ZVUGBolDKfgLNEy8@ACM> <jwvjzqdekij.fsf-monnier+emacs@HIDDEN>
 <ZWDZF17mTpJp48ly@ACM> <83ttpbdm2f.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <83ttpbdm2f.fsf@HIDDEN>
X-Submission-Agent: TMDA/1.3.x (Ph3nix)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, acm@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Eli and Stefan.

On Fri, Nov 24, 2023 at 20:48:40 +0200, Eli Zaretskii wrote:
> > Date: Fri, 24 Nov 2023 17:10:47 +0000
> > Cc: Eli Zaretskii <eliz@HIDDEN>, 67196 <at> debbugs.gnu.org
> > From: Alan Mackenzie <acm@HIDDEN>

> > Firstly, though, there is a bug in the doc string of
> > eval-expression-debug-on-error: rather than stating what the meaning of
> > the variable is, what it's for, it states the low level details of how
> > it achieves the desired effect.  This is needlessly restrictive.  I
> > propose changing that doc string from:

> >     If non-nil set `debug-on-error' to t in `eval-expression'.
> >     If nil, don't change the value of `debug-on-error'.

> > to something like:

> >     Non-nil means enter debugger on an error in a call from `eval-expression'.
> >     Does not apply to errors handled by `condition-case' or those
> >     matched by `debug-ignored-errors'.
> >     A nil value for this variable will not prevent an entry to
> >     the debugger caused by other variables such as `debug-on-error'.

> First, the last two sentences above should be transposed, as the
> second one is not related to the 1st one, but the 3rd one is.

Done.

> And second, please try to reword so that the text is less complicated
> and easier to understand.

I'm perhaps a bit too close to it.  Apart from the first line (for which
too much information needs squashing in), I can't really see much scope
for improvement.

> Thanks.

Anyway, here's the patch of the current state.  With it, M-:
debug-on-error RET shows nil, when that is the case.  M-: (foo) enters
the debugger when an error gets signalled, assuming
eval-expression-debug-on-error is t (or a suitable list), but doesn't
enter the debugger when e-e-d-o-error is nil.

There's a slight disadvantage to the approach, namely the introduction of
a new internal variable debug-from--eval-expression which is tested from
signal_or_quit.  On the other hand, eval-expression itself has been
noticeably simplified.



diff --git a/lisp/simple.el b/lisp/simple.el
index 02c68912dba..e8a9a795c0b 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1981,11 +1981,17 @@ eval-expression-print-length
   :version "21.1")
 
 (defcustom eval-expression-debug-on-error t
-  "If non-nil set `debug-on-error' to t in `eval-expression'.
-If nil, don't change the value of `debug-on-error'."
+  "Non-nil means enter debugger on error on a call from `eval-expression'.
+Does not apply to errors handled by `condition-case' or those
+matched by `debug-ignored-errors'.
+Like `debug-on-error', this variable's value can also be a list,
+with the same meaning as for `debug-on-error'.
+
+A nil value for this variable will not prevent an entry to
+the debugger caused by other variables such as `debug-on-error'."
   :group 'lisp
   :type 'boolean
-  :version "21.1")
+  :version "30.1")
 
 (defcustom eval-expression-print-maximum-character 127
   "The largest integer that will be displayed as a character.
@@ -2120,34 +2126,19 @@ eval-expression
    (cons (read--expression "Eval: ")
          (eval-expression-get-print-arguments current-prefix-arg)))
 
-  (let (result)
-    (if (null eval-expression-debug-on-error)
-        (setq result
-              (values--store-value
-               (eval (let ((lexical-binding t)) (macroexpand-all exp)) t)))
-      (let ((old-value (make-symbol "t")) new-value)
-        ;; Bind debug-on-error to something unique so that we can
-        ;; detect when evalled code changes it.
-        (let ((debug-on-error old-value))
-          (setq result
-	        (values--store-value
-                 (eval (let ((lexical-binding t)) (macroexpand-all exp)) t)))
-	  (setq new-value debug-on-error))
-        ;; If evalled code has changed the value of debug-on-error,
-        ;; propagate that change to the global binding.
-        (unless (eq old-value new-value)
-	  (setq debug-on-error new-value))))
-
-    (let ((print-length (unless no-truncate eval-expression-print-length))
-          (print-level  (unless no-truncate eval-expression-print-level))
-          (eval-expression-print-maximum-character char-print-limit)
-          (deactivate-mark))
-      (let ((out (if insert-value (current-buffer) t)))
-        (prog1
-            (prin1 result out)
-          (let ((str (and char-print-limit
-                          (eval-expression-print-format result))))
-            (when str (princ str out))))))))
+  (let* ((debug-from--eval-expression eval-expression-debug-on-error)
+         (result (values--store-value
+                  (eval (let ((lexical-binding t)) (macroexpand-all exp)) t)))
+         (print-length (unless no-truncate eval-expression-print-length))
+         (print-level  (unless no-truncate eval-expression-print-level))
+         (eval-expression-print-maximum-character char-print-limit)
+         (deactivate-mark)
+         (out (if insert-value (current-buffer) t)))
+    (prog1
+        (prin1 result out)
+      (let ((str (and char-print-limit
+                      (eval-expression-print-format result))))
+        (when str (princ str out))))))
 
 (defun edit-and-eval-command (prompt command)
   "Prompting with PROMPT, let user edit COMMAND and eval result.
diff --git a/src/eval.c b/src/eval.c
index 12e811ce264..6cadda01efb 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -2033,7 +2033,8 @@ maybe_call_debugger (Lisp_Object conditions, Lisp_Object sig, Lisp_Object data)
       /* Does user want to enter debugger for this kind of error?  */
       && (signal_quit_p (sig)
 	  ? debug_on_quit
-	  : wants_debugger (Vdebug_on_error, conditions))
+	  : (wants_debugger (Vdebug_from__eval_expression, conditions)
+	     || wants_debugger (Vdebug_on_error, conditions)))
       && ! skip_debugger (conditions, combined_data)
       /* See commentary on definition of
          `internal-when-entered-debugger'.  */
@@ -4299,6 +4300,13 @@ syms_of_eval (void)
 See also the variable `debug-on-quit' and `inhibit-debugger'.  */);
   Vdebug_on_error = Qnil;
 
+  DEFVAR_LISP ("debug-from--eval-expression", Vdebug_from__eval_expression,
+	       doc: /* Non-nil means enter debugger if an error is signaled.
+This only applies in forms called by `eval-expression'.  This variable
+has the same semantics as `debug-on-error'.  It is an internal variable
+only.  */);
+  Vdebug_from__eval_expression = Qnil;
+
   DEFVAR_LISP ("debug-ignored-errors", Vdebug_ignored_errors,
     doc: /* List of errors for which the debugger should not be called.
 Each element may be a condition-name or a regexp that matches error messages.


-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 24 Nov 2023 20:22:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 24 15:22:25 2023
Received: from localhost ([127.0.0.1]:37324 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6cgz-00048Y-JY
	for submit <at> debbugs.gnu.org; Fri, 24 Nov 2023 15:22:25 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:6075)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1r6cgx-00048E-GX
 for 67196 <at> debbugs.gnu.org; Fri, 24 Nov 2023 15:22:24 -0500
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 4D92644264A;
 Fri, 24 Nov 2023 15:22:13 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1700857332;
 bh=EqY13nW2gY87ME43djIayR5dftYe7yaiOJrFObEGAAA=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=GNCi6PqgEhns0/JFz5u5j1rc1RGaX/Vp0BDTCFjT99Fy9IZ7Q9mXIW4ZlcpdZXxRj
 JoH9ZYQEyIcZ8oE6oFikKnYxRAu3K9XGSk/wxGZWdxcYhuqknGQ/FqYGXvc8tlyKtj
 rJyO66Ug6/j135/B27CctrxCPZM/W57Ln52NtGI34k+x73Y2JFLVrZ8wwHeJi/FwRV
 tDmMOZYG/oBbDyc7zPpEp9x+40oPDQEjxp1m4yC0OYm55zv8tCvodeJfGN2wW56iFw
 6NP8qx7eUvuVJ9ImkHN59Vg4PVY51b/Jhzigc6HvIppffiXuWsTZaE6juh21wKp+cP
 O7hd/kVLSnIEw==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 5BC36442636;
 Fri, 24 Nov 2023 15:22:12 -0500 (EST)
Received: from pastel (unknown [45.72.227.120])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 32AC2120351;
 Fri, 24 Nov 2023 15:22:12 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
In-Reply-To: <ZWDZF17mTpJp48ly@ACM> (Alan Mackenzie's message of "Fri, 24 Nov
 2023 17:10:47 +0000")
Message-ID: <jwvwmu66gwy.fsf-monnier+emacs@HIDDEN>
References: <ZVTMOH229jaiw86s@ACM> <83a5rfq6i2.fsf@HIDDEN>
 <ZVUGBolDKfgLNEy8@ACM> <jwvjzqdekij.fsf-monnier+emacs@HIDDEN>
 <ZWDZF17mTpJp48ly@ACM>
Date: Fri, 24 Nov 2023 15:22:10 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL 0.033 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain T_SCC_BODY_TEXT_LINE    -0.01 -
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> I can think of a way to do this (indeed, I've got a trial implementation
> here which works).

Eager to see it,


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 24 Nov 2023 18:48:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 24 13:48:57 2023
Received: from localhost ([127.0.0.1]:37261 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6bEX-0007Rq-0G
	for submit <at> debbugs.gnu.org; Fri, 24 Nov 2023 13:48:57 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:40628)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1r6bEV-0007RM-6w
 for 67196 <at> debbugs.gnu.org; Fri, 24 Nov 2023 13:48:55 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1r6bEJ-00078A-U8; Fri, 24 Nov 2023 13:48:44 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=GYfqObDH7EPhSFpkVjuBEb4QMRaw31OPJPeTi4sla/0=; b=DBLU/pfrxPlf
 kg2H7NPYuIKHD7Zoo/K5b7nGsYq4Mn2f5oxuWfnRFraZmXgUZLCi/X9YRS16I9OaqeXgwvBRryOPR
 fZQ0wBCURwuLKHbwPjHImM+xS4nsV9ZxiKLvg61zP0vhZRyospyuAuf1SgjLz+/l82HdS7d1wgB4/
 1VpW/e/TPyD9ivyCNV3lRdqeAMsJ/wHA79MWS5S7vg/3n39r30Jd09VyCGABlMLPs47EoHp6DXUkZ
 9PGNjAjAwLwrc/1s9Mj4N2pCD2BEcChwNt4FZ1ELqCHQgyoeKll7+oIkV+lXTnRo0wKuYwDQTqQFd
 FbElKlLKGipx1t6KxKgDew==;
Date: Fri, 24 Nov 2023 20:48:40 +0200
Message-Id: <83ttpbdm2f.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
In-Reply-To: <ZWDZF17mTpJp48ly@ACM> (message from Alan Mackenzie on Fri, 24
 Nov 2023 17:10:47 +0000)
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
References: <ZVTMOH229jaiw86s@ACM> <83a5rfq6i2.fsf@HIDDEN>
 <ZVUGBolDKfgLNEy8@ACM>
 <jwvjzqdekij.fsf-monnier+emacs@HIDDEN> <ZWDZF17mTpJp48ly@ACM>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, monnier@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Fri, 24 Nov 2023 17:10:47 +0000
> Cc: Eli Zaretskii <eliz@HIDDEN>, 67196 <at> debbugs.gnu.org
> From: Alan Mackenzie <acm@HIDDEN>
> 
> Firstly, though, there is a bug in the doc string of
> eval-expression-debug-on-error: rather than stating what the meaning of
> the variable is, what it's for, it states the low level details of how
> it achieves the desired effect.  This is needlessly restrictive.  I
> propose changing that doc string from:
> 
>     If non-nil set `debug-on-error' to t in `eval-expression'.
>     If nil, don't change the value of `debug-on-error'.
> 
> to something like:
> 
>     Non-nil means enter debugger on an error in a call from `eval-expression'.
>     Does not apply to errors handled by `condition-case' or those
>     matched by `debug-ignored-errors'.
>     A nil value for this variable will not prevent an entry to
>     the debugger caused by other variables such as `debug-on-error'.

First, the last two sentences above should be transposed, as the
second one is not related to the 1st one, but the 3rd one is.

And second, please try to reword so that the text is less complicated
and easier to understand.

Thanks.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 24 Nov 2023 17:11:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 24 12:11:03 2023
Received: from localhost ([127.0.0.1]:37150 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6Zhn-0004mf-Gv
	for submit <at> debbugs.gnu.org; Fri, 24 Nov 2023 12:11:03 -0500
Received: from mail.muc.de ([193.149.48.3]:41682)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1r6Zhi-0004m5-I8
 for 67196 <at> debbugs.gnu.org; Fri, 24 Nov 2023 12:11:01 -0500
Received: (qmail 10819 invoked by uid 3782); 24 Nov 2023 18:10:48 +0100
Received: from acm.muc.de (pd953a757.dip0.t-ipconnect.de [217.83.167.87])
 (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP;
 Fri, 24 Nov 2023 18:10:47 +0100
Received: (qmail 24659 invoked by uid 1000); 24 Nov 2023 17:10:47 -0000
Date: Fri, 24 Nov 2023 17:10:47 +0000
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
Message-ID: <ZWDZF17mTpJp48ly@ACM>
References: <ZVTMOH229jaiw86s@ACM> <83a5rfq6i2.fsf@HIDDEN>
 <ZVUGBolDKfgLNEy8@ACM> <jwvjzqdekij.fsf-monnier+emacs@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <jwvjzqdekij.fsf-monnier+emacs@HIDDEN>
X-Submission-Agent: TMDA/1.3.x (Ph3nix)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Stefan.

On Sun, Nov 19, 2023 at 12:19:49 -0500, Stefan Monnier wrote:
> > Thinking about it more clearly, we're using one variable, debug-on-error,
> > for two conflicting purposes:
> > (i) The calling mechanism of execute-extended-command, including the
> >   invocation of the debugger, should an error be signalled.
> > (ii) Use in the form to be evaluated, where the variable's value outside
> >   of execute-extended-command should endure.

> Yes, there's a conflicting need here: we want to control the way `eval`
> works "from the outside", i.e. we want the `debug-on-error` to apply to
> the evaluator but not to the code being evaluated.

> But `eval` doesn't distinguish between the context of the evaluator and
> the context of the code being evaluated because all ELisp code uses the
> same evaluator.  I can't think of any way to split the variable into two
> to solve the problem.  Instead it gives me the impression we're trying
> some impossible feat like watching oneself sleep.

I can think of a way to do this (indeed, I've got a trial implementation
here which works).

Firstly, though, there is a bug in the doc string of
eval-expression-debug-on-error: rather than stating what the meaning of
the variable is, what it's for, it states the low level details of how
it achieves the desired effect.  This is needlessly restrictive.  I
propose changing that doc string from:

    If non-nil set `debug-on-error' to t in `eval-expression'.
    If nil, don't change the value of `debug-on-error'.

to something like:

    Non-nil means enter debugger on an error in a call from `eval-expression'.
    Does not apply to errors handled by `condition-case' or those
    matched by `debug-ignored-errors'.
    A nil value for this variable will not prevent an entry to
    the debugger caused by other variables such as `debug-on-error'.
    Like `debug-on-error', this variable's value can also be a list,
    with the same meaning as for `debug-on-error'.    

..  With this change, the mechanism for eval-expression-debug-on-error
can be changed such that it doesn't become confused with debug-on-error.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 19 Nov 2023 19:30:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 19 14:30:53 2023
Received: from localhost ([127.0.0.1]:52110 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r4nVM-0001fl-Os
	for submit <at> debbugs.gnu.org; Sun, 19 Nov 2023 14:30:52 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:2434)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1r4nVI-0001fW-BX
 for 67196 <at> debbugs.gnu.org; Sun, 19 Nov 2023 14:30:51 -0500
Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 4399E1000BC;
 Sun, 19 Nov 2023 14:30:41 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1700422240;
 bh=A+wcE4j9hjUI67bDtJS5L1iyrBDI41+v3aH581P67bo=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=dq9ot/DkvBuwOhWUfESIe6dgGVoIXCHEgEgY8mm8H81Q+Z8Mk3zRGTN1uQDCuRa1Z
 mWcfNq3csMLllWEWqe7qqkE9rReqxiBM0jzDp2fSjSDmbZLuiEfOq+ES5R47bQSkHd
 5ISaIBI+SAFKXqREB4gKHkhO1bFbgAn+fWbdW50yGrC+3NEjvisGj6SO+FwDQ90q2P
 UqePXfx70mRQhOJZxGaVkiUp4eQ2LnVFJo3Rgt0CicZpHzdf2u+FS7esw/ifeKTmMv
 wFcA8odlnONwBfrq9iKyVF7iwrpjvCfFNSc82ZGeMKF+ND0JF4F1ieSnumOvgSC2tS
 9/+d/bKH3gglg==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 90150100061;
 Sun, 19 Nov 2023 14:30:40 -0500 (EST)
Received: from pastel (unknown [45.72.227.120])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 612161201B2;
 Sun, 19 Nov 2023 14:30:40 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: dick <dick.r.chiang@HIDDEN>
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
In-Reply-To: <87a5r9efj0.fsf@dick> (dick's message of "Sun, 19 Nov 2023
 13:58:43 -0500")
Message-ID: <jwvedglee6c.fsf-monnier+emacs@HIDDEN>
References: <ZVTMOH229jaiw86s@ACM> <83a5rfq6i2.fsf@HIDDEN>
 <ZVUGBolDKfgLNEy8@ACM> <jwvjzqdekij.fsf-monnier+emacs@HIDDEN>
 <83fs11k5qb.fsf@HIDDEN> <87a5r9efj0.fsf@dick>
Date: Sun, 19 Nov 2023 14:30:40 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.129 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain T_SCC_BODY_TEXT_LINE    -0.01 -
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, acm@HIDDEN, Eli Zaretskii <eliz@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Eli wrote:
> This is Emacs: the impossible we do today; miracles take
> a little longer.

To which dick wrote:
> I assure you your smug self-satisfaction is shared only by the
> unemployable programmers you compare yourself to.

Thank you Dick for the subtle comic relief.


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 19 Nov 2023 17:34:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 19 12:34:20 2023
Received: from localhost ([127.0.0.1]:52027 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r4lga-0004ZH-Cw
	for submit <at> debbugs.gnu.org; Sun, 19 Nov 2023 12:34:20 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:59050)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1r4lgV-0004Z1-Ih
 for 67196 <at> debbugs.gnu.org; Sun, 19 Nov 2023 12:34:19 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1r4lgN-00037j-TM; Sun, 19 Nov 2023 12:34:07 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=4XelMwY07oFU9rjCoQOCexyLaZLZpq3y4dK72ZAboVA=; b=IZ9G/VyWT5F7
 POKSQe4XtsMdE0PD8HEKyn+LjoDtf6mTdcgCT8hVxp2M5S5irIGxpK/DkJ+7dE4oCpISX976fKmOV
 fw0CymHgya7uvO9cwqOU2pzNFUV85Vy7DVDD/etCSFsEZn/Y7sVopfZHjKlFFadxeH0UXdxqMiDJa
 bAK914FeyuNwDa7/KwOlqk3mrBODzFU+51xI4ot1HryrEMo8X3pl4b4RqwzPacVEFzz5Pr11dFgMT
 Cru+lSrLO4sxn/61U80TDnccPujOqJj1MnMXIv+gEhflFOvrwzJGjZyQbpsfanWa07uV2MXv6AIkA
 e8egRXdAT+xXoThy5EXTEQ==;
Date: Sun, 19 Nov 2023 19:33:48 +0200
Message-Id: <83fs11k5qb.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <jwvjzqdekij.fsf-monnier+emacs@HIDDEN> (message from Stefan
 Monnier on Sun, 19 Nov 2023 12:19:49 -0500)
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
References: <ZVTMOH229jaiw86s@ACM> <83a5rfq6i2.fsf@HIDDEN>
 <ZVUGBolDKfgLNEy8@ACM> <jwvjzqdekij.fsf-monnier+emacs@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, acm@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Stefan Monnier <monnier@HIDDEN>
> Cc: Eli Zaretskii <eliz@HIDDEN>,  67196 <at> debbugs.gnu.org
> Date: Sun, 19 Nov 2023 12:19:49 -0500
> 
> it gives me the impression we're trying some impossible feat like
> watching oneself sleep.

This is Emacs: the impossible we do today; miracles take a little
longer.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 19 Nov 2023 17:20:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 19 12:20:03 2023
Received: from localhost ([127.0.0.1]:52019 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r4lSk-0004DG-SR
	for submit <at> debbugs.gnu.org; Sun, 19 Nov 2023 12:20:03 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:2726)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1r4lSg-0004Cf-JN
 for 67196 <at> debbugs.gnu.org; Sun, 19 Nov 2023 12:20:02 -0500
Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 98DE88076C;
 Sun, 19 Nov 2023 12:19:51 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1700414390;
 bh=ucPeXfSj5FEP+jnofUd43Gv82WpJ7KtXn+fDCZua4zQ=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=TY206xjC01/obu93B5erU56Q6CxfoNGBdfDXhRBfBmvUf4n1CgQl0LCDkRUJpognL
 EXF5R40e/KcCjDwImM0xYjICgOG5Dsy9pQn+rVv8PQievpmMIy0Fux88phgiF1VoQb
 +LocFBJkg6wO8yscee6km5Ukbr67WDuNTVCTrzs2A5rpTyTPUX78WbZ2UO5F6Fggm7
 fP/h0uXFCtHVPNmxv6LFy+siZ/7j+IYapAeh0+/NPxrkb97HyvCqoyzLDA9pYmI+XE
 rDBq5ox4T6cUBwMcIYOeAI6mTyBBVrkKjYsNlrwlTbSa82JLDBgX+D6PuofeDZjjBL
 M/+CVVN7z6IgA==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id C4D9D8024B;
 Sun, 19 Nov 2023 12:19:50 -0500 (EST)
Received: from pastel (unknown [45.72.227.120])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 9A1661203EF;
 Sun, 19 Nov 2023 12:19:50 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
In-Reply-To: <ZVUGBolDKfgLNEy8@ACM> (Alan Mackenzie's message of "Wed, 15 Nov
 2023 17:55:18 +0000")
Message-ID: <jwvjzqdekij.fsf-monnier+emacs@HIDDEN>
References: <ZVTMOH229jaiw86s@ACM> <83a5rfq6i2.fsf@HIDDEN>
 <ZVUGBolDKfgLNEy8@ACM>
Date: Sun, 19 Nov 2023 12:19:49 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL 0.022 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain T_SCC_BODY_TEXT_LINE    -0.01 -
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Thinking about it more clearly, we're using one variable, debug-on-error,
> for two conflicting purposes:
> (i) The calling mechanism of execute-extended-command, including the
>   invocation of the debugger, should an error be signalled.
> (ii) Use in the form to be evaluated, where the variable's value outside
>   of execute-extended-command should endure.

Yes, there's a conflicting need here: we want to control the way `eval`
works "from the outside", i.e. we want the `debug-on-error` to apply to
the evaluator but not to the code being evaluated.

But `eval` doesn't distinguish between the context of the evaluator and
the context of the code being evaluated because all ELisp code uses the
same evaluator.  I can't think of any way to split the variable into two
to solve the problem.  Instead it gives me the impression we're trying
some impossible feat like watching oneself sleep.


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 15 Nov 2023 17:55:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 15 12:55:27 2023
Received: from localhost ([127.0.0.1]:53730 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r3K6p-0001yA-0W
	for submit <at> debbugs.gnu.org; Wed, 15 Nov 2023 12:55:27 -0500
Received: from mail.muc.de ([193.149.48.3]:33689)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1r3K6m-0001xt-61
 for 67196 <at> debbugs.gnu.org; Wed, 15 Nov 2023 12:55:25 -0500
Received: (qmail 61466 invoked by uid 3782); 15 Nov 2023 18:55:19 +0100
Received: from acm.muc.de (p4fe15c08.dip0.t-ipconnect.de [79.225.92.8]) (using
 STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP;
 Wed, 15 Nov 2023 18:55:18 +0100
Received: (qmail 24204 invoked by uid 1000); 15 Nov 2023 17:55:18 -0000
Date: Wed, 15 Nov 2023 17:55:18 +0000
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
Message-ID: <ZVUGBolDKfgLNEy8@ACM>
References: <ZVTMOH229jaiw86s@ACM>
 <83a5rfq6i2.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <83a5rfq6i2.fsf@HIDDEN>
X-Submission-Agent: TMDA/1.3.x (Ph3nix)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org, Stefan Monnier <monnier@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Eli.

On Wed, Nov 15, 2023 at 19:19:17 +0200, Eli Zaretskii wrote:
> > Date: Wed, 15 Nov 2023 13:48:40 +0000
> > From: Alan Mackenzie <acm@HIDDEN>

> > Hello, Emacs.

> > On the master branch (and probably any recent Emacs):

> > (i) emacs -Q
> > (ii) C-h v debug-on-error RET
> > (iii) M-: debug-on-error RET

> > >From (ii) it will be seen that debug-on-error's value is nil.
> > (iii) wrongly reports that its value is t.  This is a bug.

> > #########################################################################

> > What is happening here is that eval-expression binds debug-on-error to
> > an uninterned symbol called "t", so that d-o-e will be set to non-nil
> > for the evaluation of the coming form.

> > This has the unwanted side effect of ignoring the actual value of d-o-e
> > in forms which use it.  For example, if the variable is set to a list of
> > error symbols, this value gets ignored on evaluating a form with M-:.

> Aren't we doing this on purpose, Stefan?

Thinking about it more clearly, we're using one variable, debug-on-error,
for two conflicting purposes:
(i) The calling mechanism of execute-extended-command, including the
  invocation of the debugger, should an error be signalled.
(ii) Use in the form to be evaluated, where the variable's value outside
  of execute-extended-command should endure.

It would seem to me we really need two distinct variables for these two
purposes.  I think it's clear that purpose (ii) would be the one to
retain use of debug-on-error.

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at 67196 <at> debbugs.gnu.org:


Received: (at 67196) by debbugs.gnu.org; 15 Nov 2023 17:19:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 15 12:19:34 2023
Received: from localhost ([127.0.0.1]:53502 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r3JY6-0006ZH-7B
	for submit <at> debbugs.gnu.org; Wed, 15 Nov 2023 12:19:34 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:58860)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1r3JY4-0006Z0-5H
 for 67196 <at> debbugs.gnu.org; Wed, 15 Nov 2023 12:19:32 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1r3JXy-0002m0-6d; Wed, 15 Nov 2023 12:19:26 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=7sEa6aX/LwDlxP66Y0ZK70lMx4pub+pJz8pR8tt5tss=; b=dswCjmtoIaYl
 UUFVzvi6N6aXtMm6cfTkWHeJxROYcWDDkoYcMy/OGqLKTnA8TKj1gZG/GGjNmP+wy6TQ0spac1/eK
 rSH+QlThK1RXW+lSuosZuYlINUj/2efMwTbkfqDpNmDXkxsRpt/C5zhjqMX4xUPinhovBak42px8/
 df14P6NY8E3+HuIi+BfdVZ/RU2Hu44y4hinhquc+Cuz/9lwVD6TzIBCvd3dE0FDna5+4K0HNU3Itz
 NdFCiK8o730/YwEmARajaMebTp2Ffo8zN2faAf5DaFG2EEff1VsEhvvZc1TtbaAn+IhCMIQWo1hlG
 Snxwa0ASt7IV7jWmCGYEkQ==;
Date: Wed, 15 Nov 2023 19:19:17 +0200
Message-Id: <83a5rfq6i2.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>,
 Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <ZVTMOH229jaiw86s@ACM> (message from Alan Mackenzie on Wed, 15
 Nov 2023 13:48:40 +0000)
Subject: Re: bug#67196: M-: uses a wrong value of debug-on-error when it is
 nil.
References: <ZVTMOH229jaiw86s@ACM>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67196
Cc: 67196 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Wed, 15 Nov 2023 13:48:40 +0000
> From: Alan Mackenzie <acm@HIDDEN>
> 
> Hello, Emacs.
> 
> On the master branch (and probably any recent Emacs):
> 
> (i) emacs -Q
> (ii) C-h v debug-on-error RET
> (iii) M-: debug-on-error RET
> 
> >From (ii) it will be seen that debug-on-error's value is nil.
> (iii) wrongly reports that its value is t.  This is a bug.
> 
> #########################################################################
> 
> What is happening here is that eval-expression binds debug-on-error to
> an uninterned symbol called "t", so that d-o-e will be set to non-nil
> for the evaluation of the coming form.
> 
> This has the unwanted side effect of ignoring the actual value of d-o-e
> in forms which use it.  For example, if the variable is set to a list of
> error symbols, this value gets ignored on evaluating a form with M-:.

Aren't we doing this on purpose, Stefan?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 15 Nov 2023 17:02:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 15 12:02:04 2023
Received: from localhost ([127.0.0.1]:53333 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r3JHA-0005z1-Je
	for submit <at> debbugs.gnu.org; Wed, 15 Nov 2023 12:02:04 -0500
Received: from lists.gnu.org ([2001:470:142::17]:49592)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1r3JH8-0005xa-1V
 for submit <at> debbugs.gnu.org; Wed, 15 Nov 2023 12:02:03 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <acm@HIDDEN>) id 1r3GGR-00007v-Ni
 for bug-gnu-emacs@HIDDEN; Wed, 15 Nov 2023 08:49:07 -0500
Received: from mail.muc.de ([193.149.48.3])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <acm@HIDDEN>) id 1r3GGP-000724-Nr
 for bug-gnu-emacs@HIDDEN; Wed, 15 Nov 2023 08:49:07 -0500
Received: (qmail 79097 invoked by uid 3782); 15 Nov 2023 14:48:41 +0100
Received: from acm.muc.de (p4fe15c08.dip0.t-ipconnect.de [79.225.92.8]) (using
 STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP;
 Wed, 15 Nov 2023 14:48:40 +0100
Received: (qmail 11906 invoked by uid 1000); 15 Nov 2023 13:48:40 -0000
Date: Wed, 15 Nov 2023 13:48:40 +0000
To: bug-gnu-emacs@HIDDEN
Subject: M-: uses a wrong value of debug-on-error when it is nil.
Message-ID: <ZVTMOH229jaiw86s@ACM>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
X-Submission-Agent: TMDA/1.3.x (Ph3nix)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
Received-SPF: pass client-ip=193.149.48.3; envelope-from=acm@HIDDEN;
 helo=mail.muc.de
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.9 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.1 (/)

Hello, Emacs.

On the master branch (and probably any recent Emacs):

(i) emacs -Q
(ii) C-h v debug-on-error RET
(iii) M-: debug-on-error RET

From (ii) it will be seen that debug-on-error's value is nil.
(iii) wrongly reports that its value is t.  This is a bug.

#########################################################################

What is happening here is that eval-expression binds debug-on-error to
an uninterned symbol called "t", so that d-o-e will be set to non-nil
for the evaluation of the coming form.

This has the unwanted side effect of ignoring the actual value of d-o-e
in forms which use it.  For example, if the variable is set to a list of
error symbols, this value gets ignored on evaluating a form with M-:.

-- 
Alan Mackenzie (Nuremberg, Germany).




Acknowledgement sent to Alan Mackenzie <acm@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#67196; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 20 Jan 2024 12:30:02 UTC

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