GNU bug report logs - #37540
[PATCH] Wishlist: Allow edebug-specs to signal arbitrary error strings on syntax errors in macros.

Previous Next

Package: emacs;

Reported by: Alan Mackenzie <acm <at> muc.de>

Date: Sat, 28 Sep 2019 12:31:02 UTC

Severity: wishlist

Tags: patch

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

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Alan Mackenzie <acm <at> muc.de>
Subject: bug#37540: closed (Re: Bug 37540: [PATCH] Wishlist: Allow
 edebug-specs to signal arbitrary error strings on syntax errors in
 macros.)
Date: Fri, 17 Jan 2020 22:02:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#37540: [PATCH] Wishlist: Allow edebug-specs to signal arbitrary error strings on syntax errors in macros.

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 37540 <at> debbugs.gnu.org.

-- 
37540: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=37540
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Alan Mackenzie <acm <at> muc.de>
To: 37540-done <at> debbugs.gnu.org
Cc: Eli Zaretskii <eliz <at> gnu.org>, Stefan Kangas <stefan <at> marxist.se>
Subject: Re: Bug 37540: [PATCH] Wishlist: Allow edebug-specs to signal
 arbitrary error strings on syntax errors in macros.
Date: Fri, 17 Jan 2020 22:01:43 +0000
Wishlist item committed to master.

-- 
Alan Mackenzie (Nuremberg, Germany).

[Message part 3 (message/rfc822, inline)]
From: Alan Mackenzie <acm <at> muc.de>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Wishlist: Allow edebug-specs to signal arbitrary error
 strings on syntax errors in macros.
Date: Sat, 28 Sep 2019 12:30:34 +0000
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)
 		(&not . edebug-match-&not)
 		(&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).



This bug report was last modified 5 years and 185 days ago.

Previous Next


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