From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#67196: M-: uses a wrong value of debug-on-error when it is nil. Date: Sat, 16 Dec 2023 23:23:31 -0500 Message-ID: References: <83a5rfq6i2.fsf@gnu.org> <83ttpbdm2f.fsf@gnu.org> <83il5qe00e.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25340"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 67196@debbugs.gnu.org, Eli Zaretskii To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 17 05:24:24 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rEihU-0006Ng-6y for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 17 Dec 2023 05:24:24 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rEih9-0005bD-Gl; Sat, 16 Dec 2023 23:24:03 -0500 Original-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 ) id 1rEih7-0005al-BJ for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2023 23:24:01 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rEih7-0008Uj-2d for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2023 23:24:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rEih8-0000q4-0j for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2023 23:24:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 17 Dec 2023 04:24:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67196 X-GNU-PR-Package: emacs Original-Received: via spool by 67196-submit@debbugs.gnu.org id=B67196.17027870243189 (code B ref 67196); Sun, 17 Dec 2023 04:24:01 +0000 Original-Received: (at 67196) by debbugs.gnu.org; 17 Dec 2023 04:23:44 +0000 Original-Received: from localhost ([127.0.0.1]:56444 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rEigp-0000pN-TO for submit@debbugs.gnu.org; Sat, 16 Dec 2023 23:23:44 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:60513) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rEigm-0000p1-EZ for 67196@debbugs.gnu.org; Sat, 16 Dec 2023 23:23:42 -0500 Original-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== Original-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) Original-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) In-Reply-To: (Stefan Monnier's message of "Sat, 25 Nov 2023 09:23:42 -0500") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:276403 Archived-At: --=-=-= 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)) --=-=-=--