diff options
| author | Alan Mackenzie | 2020-01-17 21:53:13 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2020-01-17 21:53:13 +0000 |
| commit | 8d2fecdf6c372b8ff064454558ae5843d0607f06 (patch) | |
| tree | 8af86a930597807ef9163502e939128d0a566b6a | |
| parent | d97a77c481ec913d8c3c24f2eecdc41a28243678 (diff) | |
| download | emacs-8d2fecdf6c372b8ff064454558ae5843d0607f06.tar.gz emacs-8d2fecdf6c372b8ff064454558ae5843d0607f06.zip | |
Introduce element &error into edebug specification lists for macros
This fixes bug #37540.
* lisp/emacs-lisp/edebug.el (top level): New entry for &error in alist used to
associate elements with their handling functions.
(edebug-match-&error): New function.
(nested-backquote-form): Use the new element &error to abort instrumentation
on encountering a three deep nesting of backquotes (without intervening
commas).
* doc/lispref/edebug.texi (Specification List): Add an entry for &error.
* etc/NEWS: Add an entry for &error.
| -rw-r--r-- | doc/lispref/edebug.texi | 5 | ||||
| -rw-r--r-- | etc/NEWS | 7 | ||||
| -rw-r--r-- | lisp/emacs-lisp/edebug.el | 12 |
3 files changed, 24 insertions, 0 deletions
diff --git a/doc/lispref/edebug.texi b/doc/lispref/edebug.texi index 8be8307c75f..cfef5c12d1e 100644 --- a/doc/lispref/edebug.texi +++ b/doc/lispref/edebug.texi | |||
| @@ -1362,6 +1362,11 @@ while matching the remainder of the specifications at this level. This | |||
| 1362 | is primarily used to generate more specific syntax error messages. See | 1362 | is primarily used to generate more specific syntax error messages. See |
| 1363 | @ref{Backtracking}, for more details. Also see the @code{let} example. | 1363 | @ref{Backtracking}, for more details. Also see the @code{let} example. |
| 1364 | 1364 | ||
| 1365 | @item &error | ||
| 1366 | @code{&error} should be followed by a string, an error message, in the | ||
| 1367 | edebug-spec; it aborts the instrumentation, displaying the message in | ||
| 1368 | the minibuffer. | ||
| 1369 | |||
| 1365 | @item @var{other-symbol} | 1370 | @item @var{other-symbol} |
| 1366 | @cindex indirect specifications | 1371 | @cindex indirect specifications |
| 1367 | Any other symbol in a specification list may be a predicate or an | 1372 | Any other symbol in a specification list may be a predicate or an |
| @@ -48,6 +48,13 @@ It was declared obsolete in Emacs 27.1. | |||
| 48 | ** The sb-image.el library is now marked obsolete. | 48 | ** The sb-image.el library is now marked obsolete. |
| 49 | This file was a compatibility kludge which is no longer needed. | 49 | This file was a compatibility kludge which is no longer needed. |
| 50 | 50 | ||
| 51 | ** Edebug | ||
| 52 | |||
| 53 | +++ | ||
| 54 | *** Edebug specification lists can use the new keyword '&error', which | ||
| 55 | unconditionally aborts the current edebug instrumentation with the | ||
| 56 | supplied error message. | ||
| 57 | |||
| 51 | 58 | ||
| 52 | * New Modes and Packages in Emacs 28.1 | 59 | * New Modes and Packages in Emacs 28.1 |
| 53 | 60 | ||
diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index 0aa6caa37e1..85cc8c8e7ad 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el | |||
| @@ -1714,6 +1714,7 @@ contains a circular object." | |||
| 1714 | (cl-macrolet-body . edebug-match-cl-macrolet-body) | 1714 | (cl-macrolet-body . edebug-match-cl-macrolet-body) |
| 1715 | (¬ . edebug-match-¬) | 1715 | (¬ . edebug-match-¬) |
| 1716 | (&key . edebug-match-&key) | 1716 | (&key . edebug-match-&key) |
| 1717 | (&error . edebug-match-&error) | ||
| 1717 | (place . edebug-match-place) | 1718 | (place . edebug-match-place) |
| 1718 | (gate . edebug-match-gate) | 1719 | (gate . edebug-match-gate) |
| 1719 | ;; (nil . edebug-match-nil) not this one - special case it. | 1720 | ;; (nil . edebug-match-nil) not this one - special case it. |
| @@ -1847,6 +1848,15 @@ contains a circular object." | |||
| 1847 | (car (cdr pair)))) | 1848 | (car (cdr pair)))) |
| 1848 | specs)))) | 1849 | specs)))) |
| 1849 | 1850 | ||
| 1851 | (defun edebug-match-&error (cursor specs) | ||
| 1852 | ;; Signal an error, using the following string in the spec as argument. | ||
| 1853 | (let ((error-string (car specs)) | ||
| 1854 | (edebug-error-point (edebug-before-offset cursor))) | ||
| 1855 | (goto-char edebug-error-point) | ||
| 1856 | (error "%s" | ||
| 1857 | (if (stringp error-string) | ||
| 1858 | error-string | ||
| 1859 | "String expected after &error in edebug-spec")))) | ||
| 1850 | 1860 | ||
| 1851 | (defun edebug-match-gate (_cursor) | 1861 | (defun edebug-match-gate (_cursor) |
| 1852 | ;; Simply set the gate to prevent backtracking at this level. | 1862 | ;; Simply set the gate to prevent backtracking at this level. |
| @@ -2216,6 +2226,8 @@ into `edebug--cl-macrolet-defs' which is checked in `edebug-list-form-args'." | |||
| 2216 | 2226 | ||
| 2217 | (def-edebug-spec nested-backquote-form | 2227 | (def-edebug-spec nested-backquote-form |
| 2218 | (&or | 2228 | (&or |
| 2229 | ("`" &error "Triply nested backquotes (without commas \"between\" them) \ | ||
| 2230 | are too difficult to instrument") | ||
| 2219 | ;; Allow instrumentation of any , or ,@ contained within the (\, ...) or | 2231 | ;; Allow instrumentation of any , or ,@ contained within the (\, ...) or |
| 2220 | ;; (\,@ ...) matched on the next line. | 2232 | ;; (\,@ ...) matched on the next line. |
| 2221 | ([&or "," ",@"] backquote-form) | 2233 | ([&or "," ",@"] backquote-form) |