diff options
| author | Stefan Monnier | 2021-02-14 23:56:42 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2021-02-14 23:56:42 -0500 |
| commit | 54e577fbc1fb2e1189388ac290fe70d0f87b6c76 (patch) | |
| tree | e0e5916c708826242ad8ebeede449b675d39d9a4 | |
| parent | 623e534e49ad0a360d1291b917ce97515742a3e9 (diff) | |
| download | emacs-54e577fbc1fb2e1189388ac290fe70d0f87b6c76.tar.gz emacs-54e577fbc1fb2e1189388ac290fe70d0f87b6c76.zip | |
* lisp/emacs-lisp/edebug.el (edebug-&optional, edebug-&rest): Remove vars
According to my tests, `edebug-&optional` never has any effect.
And `edebug-&rest` can be replaced with a closure.
(edebug-&rest-wrapper): Remove function.
(edebug--match-&-spec-op): Use a closure to remember the `specs`.
| -rw-r--r-- | lisp/emacs-lisp/edebug.el | 59 |
1 files changed, 24 insertions, 35 deletions
diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index efca7305fea..7fae4d21d50 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el | |||
| @@ -1091,8 +1091,6 @@ circular objects. Let `read' read everything else." | |||
| 1091 | ;; This data is shared by all embedded definitions. | 1091 | ;; This data is shared by all embedded definitions. |
| 1092 | (defvar edebug-top-window-data) | 1092 | (defvar edebug-top-window-data) |
| 1093 | 1093 | ||
| 1094 | (defvar edebug-&optional) | ||
| 1095 | (defvar edebug-&rest) | ||
| 1096 | (defvar edebug-gate nil) ;; whether no-match forces an error. | 1094 | (defvar edebug-gate nil) ;; whether no-match forces an error. |
| 1097 | 1095 | ||
| 1098 | (defvar edebug-def-name nil) ; name of definition, used by interactive-form | 1096 | (defvar edebug-def-name nil) ; name of definition, used by interactive-form |
| @@ -1143,8 +1141,6 @@ purpose by adding an entry to this alist, and setting | |||
| 1143 | edebug-top-window-data | 1141 | edebug-top-window-data |
| 1144 | edebug-def-name;; make sure it is locally nil | 1142 | edebug-def-name;; make sure it is locally nil |
| 1145 | ;; I don't like these here!! | 1143 | ;; I don't like these here!! |
| 1146 | edebug-&optional | ||
| 1147 | edebug-&rest | ||
| 1148 | edebug-gate | 1144 | edebug-gate |
| 1149 | edebug-best-error | 1145 | edebug-best-error |
| 1150 | edebug-error-point | 1146 | edebug-error-point |
| @@ -1512,6 +1508,9 @@ contains a circular object." | |||
| 1512 | ((consp form) | 1508 | ((consp form) |
| 1513 | ;; The first offset for a list form is for the list form itself. | 1509 | ;; The first offset for a list form is for the list form itself. |
| 1514 | (if (eq 'quote (car form)) | 1510 | (if (eq 'quote (car form)) |
| 1511 | ;; This makes sure we don't instrument 'foo | ||
| 1512 | ;; which would cause the debugger to single-step | ||
| 1513 | ;; the trivial evaluation of a constant. | ||
| 1515 | form | 1514 | form |
| 1516 | (let* ((head (car form)) | 1515 | (let* ((head (car form)) |
| 1517 | (spec (and (symbolp head) (edebug-get-spec head))) | 1516 | (spec (and (symbolp head) (edebug-get-spec head))) |
| @@ -1584,10 +1583,7 @@ contains a circular object." | |||
| 1584 | ;; The after offset will be left in the cursor after processing the form. | 1583 | ;; The after offset will be left in the cursor after processing the form. |
| 1585 | (let ((head (edebug-top-element-required cursor "Expected elements")) | 1584 | (let ((head (edebug-top-element-required cursor "Expected elements")) |
| 1586 | ;; Prevent backtracking whenever instrumenting. | 1585 | ;; Prevent backtracking whenever instrumenting. |
| 1587 | (edebug-gate t) | 1586 | (edebug-gate t)) |
| 1588 | ;; A list form is never optional because it matches anything. | ||
| 1589 | (edebug-&optional nil) | ||
| 1590 | (edebug-&rest nil)) | ||
| 1591 | ;; Skip the first offset. | 1587 | ;; Skip the first offset. |
| 1592 | (edebug-set-cursor cursor (edebug-cursor-expressions cursor) | 1588 | (edebug-set-cursor cursor (edebug-cursor-expressions cursor) |
| 1593 | (cdr (edebug-cursor-offsets cursor))) | 1589 | (cdr (edebug-cursor-offsets cursor))) |
| @@ -1632,7 +1628,7 @@ contains a circular object." | |||
| 1632 | (setq edebug-error-point (or edebug-error-point | 1628 | (setq edebug-error-point (or edebug-error-point |
| 1633 | (edebug-before-offset cursor)) | 1629 | (edebug-before-offset cursor)) |
| 1634 | edebug-best-error (or edebug-best-error args)) | 1630 | edebug-best-error (or edebug-best-error args)) |
| 1635 | (if (and edebug-gate (not edebug-&optional)) | 1631 | (if edebug-gate |
| 1636 | (progn | 1632 | (progn |
| 1637 | (if edebug-error-point | 1633 | (if edebug-error-point |
| 1638 | (goto-char edebug-error-point)) | 1634 | (goto-char edebug-error-point)) |
| @@ -1643,9 +1639,7 @@ contains a circular object." | |||
| 1643 | (defun edebug-match (cursor specs) | 1639 | (defun edebug-match (cursor specs) |
| 1644 | ;; Top level spec matching function. | 1640 | ;; Top level spec matching function. |
| 1645 | ;; Used also at each lower level of specs. | 1641 | ;; Used also at each lower level of specs. |
| 1646 | (let (edebug-&optional | 1642 | (let (edebug-best-error |
| 1647 | edebug-&rest | ||
| 1648 | edebug-best-error | ||
| 1649 | edebug-error-point | 1643 | edebug-error-point |
| 1650 | (edebug-gate edebug-gate) ;; locally bound to limit effect | 1644 | (edebug-gate edebug-gate) ;; locally bound to limit effect |
| 1651 | ) | 1645 | ) |
| @@ -1782,11 +1776,10 @@ contains a circular object." | |||
| 1782 | 1776 | ||
| 1783 | (cl-defmethod edebug--match-&-spec-op ((_ (eql &optional)) cursor specs) | 1777 | (cl-defmethod edebug--match-&-spec-op ((_ (eql &optional)) cursor specs) |
| 1784 | ;; Keep matching until one spec fails. | 1778 | ;; Keep matching until one spec fails. |
| 1785 | (edebug-&optional-wrapper cursor specs 'edebug-&optional-wrapper)) | 1779 | (edebug-&optional-wrapper cursor specs #'edebug-&optional-wrapper)) |
| 1786 | 1780 | ||
| 1787 | (defun edebug-&optional-wrapper (cursor specs remainder-handler) | 1781 | (defun edebug-&optional-wrapper (cursor specs remainder-handler) |
| 1788 | (let (result | 1782 | (let (result |
| 1789 | (edebug-&optional specs) | ||
| 1790 | (edebug-gate nil) | 1783 | (edebug-gate nil) |
| 1791 | (this-form (edebug-cursor-expressions cursor)) | 1784 | (this-form (edebug-cursor-expressions cursor)) |
| 1792 | (this-offset (edebug-cursor-offsets cursor))) | 1785 | (this-offset (edebug-cursor-offsets cursor))) |
| @@ -1801,21 +1794,21 @@ contains a circular object." | |||
| 1801 | nil))) | 1794 | nil))) |
| 1802 | 1795 | ||
| 1803 | 1796 | ||
| 1804 | (defun edebug-&rest-wrapper (cursor specs remainder-handler) | ||
| 1805 | (if (null specs) (setq specs edebug-&rest)) | ||
| 1806 | ;; Reuse the &optional handler with this as the remainder handler. | ||
| 1807 | (edebug-&optional-wrapper cursor specs remainder-handler)) | ||
| 1808 | |||
| 1809 | (cl-defgeneric edebug--match-&-spec-op (op cursor specs) | 1797 | (cl-defgeneric edebug--match-&-spec-op (op cursor specs) |
| 1810 | "Handle &foo spec operators. | 1798 | "Handle &foo spec operators. |
| 1811 | &foo spec operators operate on all the subsequent SPECS.") | 1799 | &foo spec operators operate on all the subsequent SPECS.") |
| 1812 | 1800 | ||
| 1813 | (cl-defmethod edebug--match-&-spec-op ((_ (eql &rest)) cursor specs) | 1801 | (cl-defmethod edebug--match-&-spec-op ((_ (eql &rest)) cursor specs) |
| 1814 | ;; Repeatedly use specs until failure. | 1802 | ;; Repeatedly use specs until failure. |
| 1815 | (let ((edebug-&rest specs) ;; remember these | 1803 | (let (edebug-best-error |
| 1816 | edebug-best-error | ||
| 1817 | edebug-error-point) | 1804 | edebug-error-point) |
| 1818 | (edebug-&rest-wrapper cursor specs 'edebug-&rest-wrapper))) | 1805 | ;; Reuse the &optional handler with this as the remainder handler. |
| 1806 | (edebug-&optional-wrapper | ||
| 1807 | cursor specs | ||
| 1808 | (lambda (c s rh) | ||
| 1809 | ;; `s' is the remaining spec to match. | ||
| 1810 | ;; When it's nil, start over matching `specs'. | ||
| 1811 | (edebug-&optional-wrapper c (or s specs) rh))))) | ||
| 1819 | 1812 | ||
| 1820 | 1813 | ||
| 1821 | (cl-defmethod edebug--match-&-spec-op ((_ (eql &or)) cursor specs) | 1814 | (cl-defmethod edebug--match-&-spec-op ((_ (eql &or)) cursor specs) |
| @@ -1961,19 +1954,15 @@ a sequence of elements." | |||
| 1961 | 1954 | ||
| 1962 | (defun edebug-match-sublist (cursor specs) | 1955 | (defun edebug-match-sublist (cursor specs) |
| 1963 | ;; Match a sublist of specs. | 1956 | ;; Match a sublist of specs. |
| 1964 | (let (edebug-&optional | 1957 | (prog1 |
| 1965 | ;;edebug-best-error | 1958 | ;; match with edebug-match-specs so edebug-best-error is not bound. |
| 1966 | ;;edebug-error-point | 1959 | (edebug-match-specs cursor specs 'edebug-match-specs) |
| 1967 | ) | 1960 | (if (not (edebug-empty-cursor cursor)) |
| 1968 | (prog1 | 1961 | (if edebug-best-error |
| 1969 | ;; match with edebug-match-specs so edebug-best-error is not bound. | 1962 | (apply #'edebug-no-match cursor edebug-best-error) |
| 1970 | (edebug-match-specs cursor specs 'edebug-match-specs) | 1963 | ;; A failed &rest or &optional spec may leave some args. |
| 1971 | (if (not (edebug-empty-cursor cursor)) | 1964 | (edebug-no-match cursor "Failed matching" specs) |
| 1972 | (if edebug-best-error | 1965 | )))) |
| 1973 | (apply #'edebug-no-match cursor edebug-best-error) | ||
| 1974 | ;; A failed &rest or &optional spec may leave some args. | ||
| 1975 | (edebug-no-match cursor "Failed matching" specs) | ||
| 1976 | ))))) | ||
| 1977 | 1966 | ||
| 1978 | 1967 | ||
| 1979 | (defun edebug-match-string (cursor spec) | 1968 | (defun edebug-match-string (cursor spec) |