From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#37540: [PATCH] Wishlist: Allow edebug-specs to signal arbitrary error strings on syntax errors in macros. Date: Sat, 28 Sep 2019 12:30:34 +0000 Message-ID: <20190928123034.GA9181@ACM> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="248502"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) To: 37540@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Sep 28 14:31:35 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iEBss-0012X9-4z for geb-bug-gnu-emacs@m.gmane.org; Sat, 28 Sep 2019 14:31:34 +0200 Original-Received: from localhost ([::1]:60888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iEBsr-0000cK-17 for geb-bug-gnu-emacs@m.gmane.org; Sat, 28 Sep 2019 08:31:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36608) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iEBsO-0000cC-HZ for bug-gnu-emacs@gnu.org; Sat, 28 Sep 2019 08:31:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iEBsN-0001t1-4o for bug-gnu-emacs@gnu.org; Sat, 28 Sep 2019 08:31:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40627) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iEBsN-0001sm-1V for bug-gnu-emacs@gnu.org; Sat, 28 Sep 2019 08:31:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iEBsM-0005PX-Ey for bug-gnu-emacs@gnu.org; Sat, 28 Sep 2019 08:31:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 28 Sep 2019 12:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 37540 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.156967385020778 (code B ref -1); Sat, 28 Sep 2019 12:31:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 28 Sep 2019 12:30:50 +0000 Original-Received: from localhost ([127.0.0.1]:49448 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iEBsA-0005P3-A5 for submit@debbugs.gnu.org; Sat, 28 Sep 2019 08:30:50 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:42958) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iEBs8-0005Ow-9n for submit@debbugs.gnu.org; Sat, 28 Sep 2019 08:30:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36578) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iEBs4-0000by-BG for bug-gnu-emacs@gnu.org; Sat, 28 Sep 2019 08:30:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iEBs2-0001dL-73 for bug-gnu-emacs@gnu.org; Sat, 28 Sep 2019 08:30:44 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:59798 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1iEBs1-0001XZ-HF for bug-gnu-emacs@gnu.org; Sat, 28 Sep 2019 08:30:42 -0400 Original-Received: (qmail 83972 invoked by uid 3782); 28 Sep 2019 12:30:35 -0000 Original-Received: from acm.muc.de (p2E5D5A4C.dip0.t-ipconnect.de [46.93.90.76]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 28 Sep 2019 14:30:34 +0200 Original-Received: (qmail 9195 invoked by uid 1000); 28 Sep 2019 12:30:34 -0000 Content-Disposition: inline X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:167475 Archived-At: Hello, Emacs. I think it would be a good idea to allow edebug-specs to signal syntax errors with arbitrary strings, like: ("`" &error "Too deeply nested backquotes") . The motivation is to complete the correction in bug #31090, which fixed edebug's handling of nested backquotes in macros. The problem with that fix is it doesn't handle triply nested backquotes (without , or ,@ between them) at all well. There is a fundamental structure clash between backquote's nesting and Lisp's nesting of parentheses. The pragmatic solution is simply to ban triply nested backquotes (i.e. three `s without ,s or ,@s between them) from edebug instrumentation. However, this really needs a mechanism to output an error message string. There is currently no such mecahanism in edebug. The following patch implements an &error mechanism in edebug.el, and illustrates its use in the case which motivated it. Any objections to committing this patch (together with the needed amendments to documentation and NEWS)? diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index 717026995a..73257f1568 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el @@ -1683,6 +1683,7 @@ edebug-match-specs (cl-macrolet-body . edebug-match-cl-macrolet-body) (¬ . edebug-match-¬) (&key . edebug-match-&key) + (&error . edebug-match-&error) (place . edebug-match-place) (gate . edebug-match-gate) ;; (nil . edebug-match-nil) not this one - special case it. @@ -1816,6 +1817,14 @@ edebug-match-&key (car (cdr pair)))) specs)))) +(defun edebug-match-&error (cursor specs) + ;; Signal an error, using the following string in the spec as argument. + (setq edebug-gate t) + (let* ((error-string (car specs))) + (if (stringp error-string) + (edebug-no-match cursor error-string) + (error "String expected after &error in edebug-spec")))) + (defun edebug-match-gate (_cursor) ;; Simply set the gate to prevent backtracking at this level. @@ -2185,6 +2194,8 @@ backquote-form (def-edebug-spec nested-backquote-form (&or + ("`" &error "Triply nested backquotes (without commas \"between\" them) \ +are too difficult to instrument") ;; Allow instrumentation of any , or ,@ contained within the (\, ...) or ;; (\,@ ...) matched on the next line. ([&or "," ",@"] backquote-form) -- Alan Mackenzie (Nuremberg, Germany).